我使用以下命令安装了MongoDB:
sudo apt update
sudo apt install mongodb
以及当我检查服务状态时:
mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-11-06 10:25:11 PST; 54min ago
Docs: man:mongod(1)
Process: 1030 ExecStart=/usr/bin/mongod --unixSocketPrefix=${SOCKETPATH} --config ${CONF} $DAEMON_OPTS (code=exited, status=100)
Main PID: 1030 (code=exited, status=100)
Nov 06 10:25:09 JDL systemd[1]: Started An object/document-oriented database.
Nov 06 10:25:11 JDL systemd[1]: mongodb.service: Main process exited, code=exited, status=100/n/a
Nov 06 10:25:11 JDL systemd[1]: mongodb.service: Failed with result 'exit-code'.
我尝试创建/data/db
并更改了其权限。
我还能够运行mongod
命令,甚至重新启动PC。我还尝试删除lock
文件,并在MongoDB中做了repair
,但结果仍然相同。
如何解决此问题?我试图寻找解决方案,但似乎没有一个适合我。
其他信息
运行sudo tail -n 20 /var/log/mongodb/mongod.log
向我展示了
2019-11-05T22:17:52.153+0800 I CONTROL [initandlisten] build environment:
2019-11-05T22:17:52.153+0800 I CONTROL [initandlisten] distarch: x86_64
2019-11-05T22:17:52.153+0800 I CONTROL [initandlisten] target_arch: x86_64
2019-11-05T22:17:52.153+0800 I CONTROL [initandlisten] options: { config: "./etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2019-11-05T22:17:52.154+0800 I - [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-11-05T22:17:52.154+0800 I STORAGE [initandlisten]
2019-11-05T22:17:52.154+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-11-05T22:17:52.154+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-11-05T22:17:52.154+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=5431M,session_max=20000,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),
2019-11-05T22:17:52.723+0800 E STORAGE [initandlisten] WiredTiger error (-31802) [1572963472:723937][2926:0x7f9a371b00c0], txn-recover: unsupported WiredTiger file version: this build only supports versions up to 2, and the file is version 3: WT_ERROR: non-specific WiredTiger error
2019-11-05T22:17:52.724+0800 E STORAGE [initandlisten] WiredTiger error (0) [1572963472:724065][2926:0x7f9a371b00c0], txn-recover: WiredTiger is unable to read the recovery log.
2019-11-05T22:17:52.724+0800 E STORAGE [initandlisten] WiredTiger error (0) [1572963472:724099][2926:0x7f9a371b00c0], txn-recover: This may be due to the log files being encrypted, being from an older version or due to corruption on disk
2019-11-05T22:17:52.724+0800 E STORAGE [initandlisten] WiredTiger error (0) [1572963472:724124][2926:0x7f9a371b00c0], txn-recover: You should confirm that you have opened the database with the correct options including all encryption and compression options
2019-11-05T22:17:52.724+0800 E STORAGE [initandlisten] WiredTiger error (-31802) [1572963472:724152][2926:0x7f9a371b00c0], txn-recover: Recovery failed: WT_ERROR: non-specific WiredTiger error
2019-11-05T22:17:52.759+0800 E - [initandlisten] Assertion: 28595:-31802: WT_ERROR: non-specific WiredTiger error src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 413
2019-11-05T22:17:52.759+0800 I STORAGE [initandlisten] exception in initAndListen: Location28595: -31802: WT_ERROR: non-specific WiredTiger error, terminating
2019-11-05T22:17:52.759+0800 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-11-05T22:17:52.759+0800 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-11-05T22:17:52.759+0800 I CONTROL [initandlisten] now exiting
2019-11-05T22:17:52.759+0800 I CONTROL [initandlisten] shutting down with code:100
答案 0 :(得分:0)
如果不需要数据库,请使用rm -rf /usr/lib/mongodb
删除数据库文件夹中的所有文件(在Ubuntu路径中为/ usr / lib / mongodb),如果需要数据库,请按照以下步骤操作:
当您将MongoDB Server升级时,可以说是从3.4升级到3.6。升级之前,还需要使用此命令设置数据库功能兼容版本。
此命令必须在MongoDB Server v3.4中运行
db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
,然后升级到下一个主要版本。 例如,您必须将MongoDB服务器从3.4升级到3.6,而不是直接升级到4.0 有关更多详细信息,请遵循MongoDB Docs