如何解决MongoDB 3.6和4.2之间的featureCompatibilityVersion问题?

时间:2019-10-23 01:30:37

标签: mongodb

我最近卸载了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 }

我如何解决此featureCompatibilityVersion问题?

2 个答案:

答案 0 :(得分:4)

答案在于错误消息。

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 mongodb-community@4.0
brew install mongodb-community-shell
brew services start mongodb-community@4.0
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 mongodb-community@4.0
brew uninstall mongodb-community@4.0
brew uninstall mongodb-community-shell [you get a new one with the next step]
brew install mongodb-community
brew services start mongodb-community

哪一种语言并不会完全绊倒,但确实为我工作而没有太多麻烦。

答案 1 :(得分:0)

运行3.6时,我的数据库目录C:\ data \ db \仍然存在。即使在卸载3.6之后,该目录仍保持其状态,并且仍为3.6配置。

清除目录后,再次运行mongod不会产生任何错误。