我最近卸载了 MongoDB 3.6,然后安装了 MongoDB 4.2。当我导航到 MongoDB/Server/4.2/bin 并执行 mongo 时,我收到以下错误消息:
$ mongod
2019-10-22T21:16:36.723-0400 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-10-22T21:16:37.217-0400 I CONTROL [initandlisten] MongoDB starting : pid=9376 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-LF34G1M
2019-10-22T21:16:37.217-0400 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2019-10-22T21:16:37.217-0400 I CONTROL [initandlisten] db version v4.2.1
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] git version: edf6d45851c0b9ee15548f0f847df141764a317e
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] allocator: tcmalloc
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] modules: none
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] build environment:
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] distmod: 2012plus
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] distarch: x86_64
2019-10-22T21:16:37.219-0400 I CONTROL [initandlisten] target_arch: x86_64
2019-10-22T21:16:37.219-0400 I CONTROL [initandlisten] options: {}
2019-10-22T21:16:37.230-0400 I STORAGE [initandlisten] Detected data files in C:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wire
dTiger'.
2019-10-22T21:16:37.231-0400 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1498M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threa
ds_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],
2019-10-22T21:16:37.295-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:294196][9376:140704250879568], txn-recover: Recovering log 22 through 23
2019-10-22T21:16:37.439-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:438812][9376:140704250879568], txn-recover: Recovering log 23 through 23
2019-10-22T21:16:37.561-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:560490][9376:140704250879568], txn-recover: Main recovery loop: starting at 22/896 to 23/256
2019-10-22T21:16:37.712-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:712086][9376:140704250879568], txn-recover: Recovering log 22 through 23
2019-10-22T21:16:37.807-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:806834][9376:140704250879568], txn-recover: Recovering log 23 through 23
2019-10-22T21:16:37.883-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:882664][9376:140704250879568], txn-recover: Set global recovery timestamp: (0,0)
2019-10-22T21:16:37.934-0400 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-10-22T21:16:37.943-0400 I STORAGE [initandlisten] Timestamp monitor starting
2019-10-22T21:16:37.947-0400 I CONTROL [initandlisten]
2019-10-22T21:16:37.947-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten]
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten]
2019-10-22T21:16:37.959-0400 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2019-10-22T21:16:37.965-0400 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for ver
sion, found 3.6, expected '4.2' or '4.0'. Contents of featureCompatibilityVersion document in admin.system.version: { _id: "featureCompatibilityVersion", version: "3.6" }. See http:
//dochub.mongodb.org/core/4.0-feature-compatibility.). If the current featureCompatibilityVersion is below 4.0, see the documentation on upgrading at http://dochub.mongodb.org/core/
4.0-upgrade-fcv.
2019-10-22T21:16:37.965-0400 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-10-22T21:16:37.966-0400 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-10-22T21:16:37.966-0400 I STORAGE [initandlisten] Deregistering all the collections
2019-10-22T21:16:37.966-0400 I STORAGE [initandlisten] Timestamp monitor shutting down
2019-10-22T21:16:37.967-0400 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2019-10-22T21:16:37.967-0400 I STORAGE [initandlisten] Shutting down session sweeper thread
2019-10-22T21:16:37.968-0400 I STORAGE [initandlisten] Finished shutting down session sweeper thread
2019-10-22T21:16:37.968-0400 I STORAGE [initandlisten] Shutting down journal flusher thread
2019-10-22T21:16:38.037-0400 I STORAGE [initandlisten] Finished shutting down journal flusher thread
2019-10-22T21:16:38.037-0400 I STORAGE [initandlisten] Shutting down checkpoint thread
2019-10-22T21:16:38.038-0400 I STORAGE [initandlisten] Finished shutting down checkpoint thread
2019-10-22T21:16:38.038-0400 I STORAGE [initandlisten] Downgrading WiredTiger datafiles.
2019-10-22T21:16:38.188-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:187822][9376:140704250879568], txn-recover: Recovering log 23 through 24
2019-10-22T21:16:38.273-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:272644][9376:140704250879568], txn-recover: Recovering log 24 through 24
2019-10-22T21:16:38.365-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:365403][9376:140704250879568], txn-recover: Main recovery loop: starting at 23/2048 to 24/256
2019-10-22T21:16:38.533-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:532944][9376:140704250879568], txn-recover: Recovering log 23 through 24
2019-10-22T21:16:38.642-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:642615][9376:140704250879568], txn-recover: Recovering log 24 through 24
2019-10-22T21:16:38.722-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:722405][9376:140704250879568], txn-recover: Set global recovery timestamp: (0,0)
2019-10-22T21:16:39.004-0400 I STORAGE [initandlisten] shutdown: removing fs lock...
2019-10-22T21:16:39.005-0400 I CONTROL [initandlisten] now exiting
2019-10-22T21:16:39.005-0400 I CONTROL [initandlisten] shutting down with code:62
令我困惑的错误是:
UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for version, found 3.6, expected '4.2' or '4.0'.
这似乎与我在下面看到的不一致:
> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
{ "featureCompatibilityVersion" : { "version" : "4.2" }, "ok" : 1 }
如何解决此功能兼容性版本问题?
答案就在错误消息中。
If the current featureCompatibilityVersion is below 4.0,
see the documentation on upgrading at
https://docs.mongodb.com/manual/release-notes/4.2/#upgrade-procedures
该页面指出,如果您安装的是版本 3,首先您必须升级到 4.0。在 Mac 上,homebrew 提供了不指定版本号的 mongodb-community 安装,这并没有帮助。目前,mongodb-community 是 4.2。
我所做的是:
brew services stop mongodb-community
brew uninstall mongodb-community
brew install [email protected]
brew install mongodb-community-shell
brew services start [email protected]
mongo
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
[ it gave: { "featureCompatibilityVersion" : { "version" : "3.6" }, "ok" : 1 } ]
db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
ctrl-c
brew services stop [email protected]
brew uninstall [email protected]
brew uninstall mongodb-community-shell [you get a new one with the next step]
brew install mongodb-community
brew services start mongodb-community
这并不完全是脱口而出,但对我来说确实有效,没有太多麻烦。
我的数据库目录 C:\data\db\ 从 3.6 运行时起仍然存在。即使卸载 3.6 后,该目录仍保持其状态,并且仍然配置为 3.6。
清空目录后,第二次重新运行mongod,没有产生任何错误。
2023 年快速更新:
您无法再通过 brew
安装 [电子邮件受保护]
bin/mongod
(您可能需要在操作系统中授予权限)。mongod
,它应该可以正常工作。希望这可以节省一些人的时间。
在 Debian 11 中... 我删除了 /lib/mongod 文件夹,重新启动服务,不再有问题。 我一定是从以前的安装中得到了一些东西