在 Cli 中发出 mongod 命令时无法连接 MongoDB

在 Cli 中发出 mongod 命令时无法连接 MongoDB

我正在尝试在 centos VM 上安装 mongoDb 并关注了一些网站,例如 https://linuxize.com/post/how-to-install-mongodb-on-centos-7/,https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-centos-7 ,但在Cli中发出mongod命令时无法连接/进入MongoDB。有人对此有什么想法吗?提前致谢。

输出mongod

-460f-4bb5-a5d7-0bbe48f3246a") }
2019-08-26T15:21:13.417+0530 I  INDEX    [initandlisten] index build: done building index _id_ on ns admin.system.version
2019-08-26T15:21:13.417+0530 I  SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
2019-08-26T15:21:13.417+0530 I  COMMAND  [initandlisten] setting featureCompatibilityVersion to 4.2
2019-08-26T15:21:13.421+0530 I  SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2019-08-26T15:21:13.421+0530 I  STORAGE  [initandlisten] Flow Control is enabled on this deployment.
2019-08-26T15:21:13.422+0530 I  SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
2019-08-26T15:21:13.422+0530 I  STORAGE  [initandlisten] createCollection: local.startup_log with generated UUID: 660f8f2a-c6d0-4a0c-a4bb-0f975d1f207e and options: { c485760 }

2019-08-26T15:21:13.426+0530 I  INDEX    [initandlisten] index build: done building index _id_ on ns local.startup_log
2019-08-26T15:21:13.427+0530 I  SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
2019-08-26T15:21:13.427+0530 I  FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2019-08-26T15:21:13.428+0530 I  SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
2019-08-26T15:21:13.428+0530 I  NETWORK  [initandlisten] Listening on /tmp/mongodb-27017.sock
2019-08-26T15:21:13.428+0530 I  NETWORK  [initandlisten] Listening on 127.0.0.1
2019-08-26T15:21:13.428+0530 I  NETWORK  [initandlisten] waiting for connections on port 27017
2019-08-26T15:21:13.428+0530 I  CONTROL  [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: config.system.sessions
2019-08-26T15:21:13.429+0530 I  STORAGE  [LogicalSessionCacheRefresh] createCollection: config.system.sessions with provided UUID: 45ed25cc-1dbb-4f38-8333-cf36ae8bd473 UUID("45ed25cc-1dbb-4f38-8333-cf36ae8bd473") }
2019-08-26T15:21:13.433+0530 I  INDEX    [LogicalSessionCacheRefresh] index build: done building index _id_ on ns config.system.sessions
2019-08-26T15:21:13.438+0530 I  INDEX    [LogicalSessionCacheRefresh] index build: starting on config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lnfig.system.sessions", expireAfterSeconds: 1800 } using method: Hybrid
2019-08-26T15:21:13.439+0530 I  INDEX    [LogicalSessionCacheRefresh] build may temporarily use up to 500 megabytes of RAM
2019-08-26T15:21:13.439+0530 I  INDEX    [LogicalSessionCacheRefresh] index build: collection scan done. scanned 0 total records in 0 seconds
2019-08-26T15:21:13.439+0530 I  INDEX    [LogicalSessionCacheRefresh] index build: inserted 0 keys from external sorter into index in 0 seconds
2019-08-26T15:21:13.440+0530 I  INDEX    [LogicalSessionCacheRefresh] index build: done building index lsidTTLIndex on ns config.system.sessions
2019-08-26T15:26:13.428+0530 I  SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>

在此输入图像描述

答案1

我不确定你实际上想做什么。运行mongod会启动一个mongo服务器在您当前的 shell 中。如果你想连接到 MongoDB 服务器,你应该使用mongo

答案2

目前还不清楚,但如果您Marking collection...通过mongod命令到达,MongoDB 已经启动。

要开始工作,请打开一个新的终端窗口,导航到您的 bin 文件夹并运行mongo.我的部分困惑是它似乎挂起(在 bash 中),但事实并非如此。输入help并且它应该可以工作。

答案3

我有同样的问题。我正在尝试安装 mongo db。我调用./mongod命令,安装无法完成。它挂在同一命令上:

2019-09-21T21:45:17.039+0600 I SHARDING [LogicalSessionCacheReap] 将集合 config.transactions 标记为集合版本:

Mac OS Mojave 10.14 我所有的痕迹:

MacBook-Pro-dns:mongo user$ ./mongod
2019-09-21T21:45:16.178+0600 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-09-21T21:45:16.187+0600 I  CONTROL  [initandlisten] MongoDB starting : pid=8310 port=27017 dbpath=/data/db 64-bit host=MacBook-Pro-dns.local
2019-09-21T21:45:16.187+0600 I  CONTROL  [initandlisten] db version v4.2.0
2019-09-21T21:45:16.187+0600 I  CONTROL  [initandlisten] git version: a4b751dcf51dd249c5865812b390cfd1c0129c30
2019-09-21T21:45:16.187+0600 I  CONTROL  [initandlisten] allocator: system
2019-09-21T21:45:16.187+0600 I  CONTROL  [initandlisten] modules: none
2019-09-21T21:45:16.187+0600 I  CONTROL  [initandlisten] build environment:
2019-09-21T21:45:16.187+0600 I  CONTROL  [initandlisten]     distarch: x86_64
2019-09-21T21:45:16.187+0600 I  CONTROL  [initandlisten]     target_arch: x86_64
2019-09-21T21:45:16.187+0600 I  CONTROL  [initandlisten] options: {}
2019-09-21T21:45:16.189+0600 W  STORAGE  [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
2019-09-21T21:45:16.189+0600 I  STORAGE  [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-09-21T21:45:16.189+0600 W  STORAGE  [initandlisten] Recovering data from the last clean checkpoint.
2019-09-21T21:45:16.189+0600 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),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2019-09-21T21:45:16.699+0600 I  STORAGE  [initandlisten] WiredTiger message [1569080716:699859][8310:0x10e6245c0], txn-recover: Recovering log 1 through 2
2019-09-21T21:45:16.762+0600 I  STORAGE  [initandlisten] WiredTiger message [1569080716:762524][8310:0x10e6245c0], txn-recover: Recovering log 2 through 2
2019-09-21T21:45:16.825+0600 I  STORAGE  [initandlisten] WiredTiger message [1569080716:825486][8310:0x10e6245c0], txn-recover: Main recovery loop: starting at 1/22912 to 2/256
2019-09-21T21:45:16.826+0600 I  STORAGE  [initandlisten] WiredTiger message [1569080716:826288][8310:0x10e6245c0], txn-recover: Recovering log 1 through 2
2019-09-21T21:45:16.884+0600 I  STORAGE  [initandlisten] WiredTiger message [1569080716:884735][8310:0x10e6245c0], txn-recover: Recovering log 2 through 2
2019-09-21T21:45:16.932+0600 I  STORAGE  [initandlisten] WiredTiger message [1569080716:932134][8310:0x10e6245c0], txn-recover: Set global recovery timestamp: (0,0)
2019-09-21T21:45:17.002+0600 I  RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-09-21T21:45:17.019+0600 I  STORAGE  [initandlisten] Timestamp monitor starting
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] 
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] 
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] 
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] 
2019-09-21T21:45:17.020+0600 I  CONTROL  [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2019-09-21T21:45:17.031+0600 I  SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2019-09-21T21:45:17.034+0600 I  STORAGE  [initandlisten] Flow Control is enabled on this deployment.
2019-09-21T21:45:17.034+0600 I  SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
2019-09-21T21:45:17.034+0600 I  SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
2019-09-21T21:45:17.035+0600 I  SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
2019-09-21T21:45:17.036+0600 I  FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2019-09-21T21:45:17.039+0600 I  SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
2019-09-21T21:45:17.039+0600 I  NETWORK  [initandlisten] Listening on /tmp/mongodb-27017.sock
2019-09-21T21:45:17.039+0600 I  NETWORK  [initandlisten] Listening on 127.0.0.1
2019-09-21T21:45:17.039+0600 I  NETWORK  [initandlisten] waiting for connections on port 27017
2019-09-21T21:45:17.039+0600 I  SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>```

相关内容