MongoDB shell
MongoDB shell
MongoDB & macOS
mongod
➜ ~ mongod --dbpath /System/Volumes/Data/data/db
2020-07-16T02:06:11.856+0800 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-07-16T02:06:11.857+0800 W ASIO [main] No TransportLayer configured during NetworkInterface startup
2020-07-16T02:06:11.858+0800 I CONTROL [initandlisten] MongoDB starting : pid=79552 port=27017 dbpath=/System/Volumes/Data/data/db 64-bit host=xgqfrms-mbp.local
2020-07-16T02:06:11.858+0800 I CONTROL [initandlisten] db version v4.2.8
2020-07-16T02:06:11.858+0800 I CONTROL [initandlisten] git version: 43d25964249164d76d5e04dd6cf38f6111e21f5f
2020-07-16T02:06:11.858+0800 I CONTROL [initandlisten] allocator: system
2020-07-16T02:06:11.858+0800 I CONTROL [initandlisten] modules: none
2020-07-16T02:06:11.858+0800 I CONTROL [initandlisten] build environment:
2020-07-16T02:06:11.858+0800 I CONTROL [initandlisten] distarch: x86_64
2020-07-16T02:06:11.858+0800 I CONTROL [initandlisten] target_arch: x86_64
2020-07-16T02:06:11.858+0800 I CONTROL [initandlisten] options: { storage: { dbPath: "/System/Volumes/Data/data/db" } }
2020-07-16T02:06:11.859+0800 I STORAGE [initandlisten] Detected data files in /System/Volumes/Data/data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-07-16T02:06:11.859+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7680M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2020-07-16T02:06:12.294+0800 I STORAGE [initandlisten] WiredTiger message [1594836372:294341][79552:0x10fdc9dc0], txn-recover: Recovering log 1 through 2
2020-07-16T02:06:12.351+0800 I STORAGE [initandlisten] WiredTiger message [1594836372:351584][79552:0x10fdc9dc0], txn-recover: Recovering log 2 through 2
2020-07-16T02:06:12.406+0800 I STORAGE [initandlisten] WiredTiger message [1594836372:406604][79552:0x10fdc9dc0], txn-recover: Main recovery loop: starting at 1/25088 to 2/256
2020-07-16T02:06:12.483+0800 I STORAGE [initandlisten] WiredTiger message [1594836372:483003][79552:0x10fdc9dc0], txn-recover: Recovering log 1 through 2
2020-07-16T02:06:12.534+0800 I STORAGE [initandlisten] WiredTiger message [1594836372:534293][79552:0x10fdc9dc0], txn-recover: Recovering log 2 through 2
2020-07-16T02:06:12.573+0800 I STORAGE [initandlisten] WiredTiger message [1594836372:573226][79552:0x10fdc9dc0], txn-recover: Set global recovery timestamp: (0, 0)
2020-07-16T02:06:12.658+0800 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-07-16T02:06:12.667+0800 I STORAGE [initandlisten] Timestamp monitor starting
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten]
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten]
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2020-07-16T02:06:12.668+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2020-07-16T02:06:12.668+0800 I CONTROL [initandlisten]
2020-07-16T02:06:12.670+0800 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2020-07-16T02:06:12.672+0800 I STORAGE [initandlisten] Flow Control is enabled on this deployment.
2020-07-16T02:06:12.672+0800 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
2020-07-16T02:06:12.672+0800 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
2020-07-16T02:06:12.676+0800 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
2020-07-16T02:06:12.676+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/System/Volumes/Data/data/db/diagnostic.data'
2020-07-16T02:06:12.677+0800 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
2020-07-16T02:06:12.677+0800 I NETWORK [listener] Listening on /tmp/mongodb-27017.sock
2020-07-16T02:06:12.677+0800 I NETWORK [listener] Listening on 127.0.0.1
2020-07-16T02:06:12.677+0800 I NETWORK [listener] waiting for connections on port 27017
2020-07-16T02:06:12.679+0800 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
2020-07-16T02:06:13.001+0800 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>
2020-07-16T02:06:43.467+0800 I NETWORK [listener] connection accepted from 127.0.0.1:55122 #1 (1 connection now open)
2020-07-16T02:06:43.467+0800 I NETWORK [conn1] received client metadata from 127.0.0.1:55122 conn1: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.2.8" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "19.5.0" } }
2020-07-16T02:07:47.013+0800 I NETWORK [listener] connection accepted from 127.0.0.1:55398 #2 (2 connections now open)
2020-07-16T02:07:47.013+0800 I NETWORK [conn2] received client metadata from 127.0.0.1:55398 conn2: { application: { name: "robo3t" }, driver: { name: "MongoDB Internal Client", version: "3.4.3-10-g865d2fb" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "19.5.0" } }
2020-07-16T02:07:47.013+0800 E - [conn2] Assertion: Location34348: cannot translate opcode 2010 src/mongo/rpc/message.h 120
2020-07-16T02:07:47.014+0800 I NETWORK [conn2] DBException handling request, closing client connection: Location34348: cannot translate opcode 2010
2020-07-16T02:07:47.014+0800 I NETWORK [conn2] end connection 127.0.0.1:55398 (1 connection now open)
2020-07-16T02:08:26.460+0800 I NETWORK [listener] connection accepted from 127.0.0.1:55565 #3 (2 connections now open)
2020-07-16T02:08:26.460+0800 I NETWORK [conn3] received client metadata from 127.0.0.1:55565 conn3: { application: { name: "robo3t" }, driver: { name: "MongoDB Internal Client", version: "3.4.3-10-g865d2fb" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "19.5.0" } }
2020-07-16T02:08:26.460+0800 E - [conn3] Assertion: Location34348: cannot translate opcode 2010 src/mongo/rpc/message.h 120
2020-07-16T02:08:26.460+0800 I NETWORK [conn3] DBException handling request, closing client connection: Location34348: cannot translate opcode 2010
2020-07-16T02:08:26.460+0800 I NETWORK [conn3] end connection 127.0.0.1:55565 (1 connection now open)
2020-07-16T02:17:18.240+0800 I NETWORK [listener] connection accepted from 127.0.0.1:58287 #4 (2 connections now open)
2020-07-16T02:17:18.240+0800 I NETWORK [conn4] received client metadata from 127.0.0.1:58287 conn4: { application: { name: "robo3t" }, driver: { name: "MongoDB Internal Client", version: "4.0.5-18-g7e327a9" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "19.5.0" } }
2020-07-16T02:17:18.281+0800 I NETWORK [listener] connection accepted from 127.0.0.1:58288 #5 (3 connections now open)
2020-07-16T02:17:18.282+0800 I NETWORK [conn5] received client metadata from 127.0.0.1:58288 conn5: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.5-18-g7e327a9" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "19.5.0" } }
# SSL, TLS 1.0
--sslDisabledProtocols 'none'
MongoDB starting : pid=79552 port=27017 dbpath=/System/Volumes/Data/data/db 64-bit host=xgqfrms-mbp.local
# config & --dbpath
options: { storage: { dbPath: "/System/Volumes/Data/data/db" } }
# storage engine
'wiredTiger' storage engine
'/System/Volumes/Data/data/db/diagnostic.data'
mongo
➜ ~ mongo
MongoDB shell version v4.2.8
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("61945adb-5cad-442f-856e-d2e31011056a") }
MongoDB server version: 4.2.8
Server has startup warnings:
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten]
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten]
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2020-07-16T02:06:12.667+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2020-07-16T02:06:12.668+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2020-07-16T02:06:12.668+0800 I CONTROL [initandlisten]
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
> show dbs
> show databases
> show dbs
> use local
Access Control
Remote IP Bind
--bind_ip <address>
--bind_ip_all
--bind_ip 127.0.0.1
cloud-based monitoring service
db.enableFreeMonitoring()
db.disableFreeMonitoring()
linux & bash shell
# 找出该端口号下的 PID
$ lsof -i :27017
# 关闭进程 PID
$ kill -9 61316
➜ ~ lsof -i :27017
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mongod 79552 xgqfrms-mbp 9u IPv4 0x5ae8addc25d4ab5d 0t0 TCP localhost:27017 (LISTEN)
mongod 79552 xgqfrms-mbp 26u IPv4 0x5ae8addc2609079d 0t0 TCP localhost:27017->localhost:55122 (ESTABLISHED)
mongod 79552 xgqfrms-mbp 30u IPv4 0x5ae8addc1b80101d 0t0 TCP localhost:27017->localhost:58287 (ESTABLISHED)
mongod 79552 xgqfrms-mbp 31u IPv4 0x5ae8addc2128279d 0t0 TCP localhost:27017->localhost:58288 (ESTABLISHED)
mongo 79987 xgqfrms-mbp 8u IPv4 0x5ae8addc26091b5d 0t0 TCP localhost:55122->localhost:27017 (ESTABLISHED)
Robo\x203 80177 xgqfrms-mbp 36u IPv4 0x5ae8addc29b8417d 0t0 TCP localhost:58287->localhost:27017 (ESTABLISHED)
Robo\x203 80177 xgqfrms-mbp 37u IPv4 0x5ae8addc2d2c079d 0t0 TCP localhost:58288->localhost:27017 (ESTABLISHED)
refs
MongoDB & macOS (install manually)
https://www.cnblogs.com/xgqfrms/p/9770091.html
MongoDB Manually config
https://www.cnblogs.com/xgqfrms/p/13313153.html
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/13320793.html
未经授权禁止转载,违者必究!