问题描述
我在使用 mongoDB 时遇到问题 - 我会按照官方教程一步一步来:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
I have problem with mongoDB - I going step by step with official tutorial:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
我也是通过这个答案安装的(当然我改变了一些命令来下载 4.2 而不是 4.0 就像在这个答案中一样):https://askubuntu.com/questions/842592/apt-get-fails-on-16-04-or-18-04-installing-mongodb/842599#842599
Also I installed through this answer( of course I changed some commands to download 4.2 not 4.0 like it is in this answer): https://askubuntu.com/questions/842592/apt-get-fails-on-16-04-or-18-04-installing-mongodb/842599#842599
但终究还是不行:
adrian@ubuntu:~$ sudo service mongod start
adrian@ubuntu:~$ sudo service mongod status
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2019-09-26 09:37:53 CEST; 2s ago
Docs: https://docs.mongodb.org/manual
Process: 5220 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=62)
Main PID: 5220 (code=exited, status=62)
Sep 26 09:37:51 ubuntu systemd[1]: Started MongoDB Database Server.
Sep 26 09:37:53 ubuntu systemd[1]: mongod.service: Main process exited, code=exited, status=62/n/a
Sep 26 09:37:53 ubuntu systemd[1]: mongod.service: Failed with result 'exit-code'.
即使我尝试调查 mongo 日志,它仍然没有告诉我太多:
Even when I try to investigate mongo logs it still doesnt tell me much:
adrian@ubuntu:~$ sudo tail -n 100 /var/log/mongodb/mongod.log
2019-09-26T09:37:51.893+0200 I CONTROL [main] ***** SERVER RESTARTED *****
2019-09-26T09:37:51.895+0200 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] MongoDB starting : pid=5220 port=27017 dbpath=/var/lib/mongodb 64-bit host=ubuntu
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] db version v4.2.0
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] git version: a4b751dcf51dd249c5865812b390cfd1c0129c30
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] allocator: tcmalloc
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] modules: none
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] build environment:
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] distmod: ubuntu1804
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] distarch: x86_64
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] target_arch: x86_64
2019-09-26T09:37:51.901+0200 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-09-26T09:37:51.901+0200 I STORAGE [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-09-26T09:37:51.901+0200 I STORAGE [initandlisten]
2019-09-26T09:37:51.901+0200 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-09-26T09:37:51.901+0200 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-09-26T09:37:51.901+0200 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=11527M,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-26T09:37:52.400+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:400536][5220:0x7fc6c8d05b00], txn-recover: Recovering log 20 through 21
2019-09-26T09:37:52.460+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:460670][5220:0x7fc6c8d05b00], txn-recover: Recovering log 21 through 21
2019-09-26T09:37:52.544+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:544472][5220:0x7fc6c8d05b00], txn-recover: Main recovery loop: starting at 20/896 to 21/256
2019-09-26T09:37:52.607+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:607556][5220:0x7fc6c8d05b00], txn-recover: Recovering log 20 through 21
2019-09-26T09:37:52.643+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:643077][5220:0x7fc6c8d05b00], txn-recover: Recovering log 21 through 21
2019-09-26T09:37:52.669+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:669301][5220:0x7fc6c8d05b00], txn-recover: Set global recovery timestamp: (0,0)
2019-09-26T09:37:52.677+0200 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-09-26T09:37:52.682+0200 I STORAGE [initandlisten] Timestamp monitor starting
2019-09-26T09:37:52.683+0200 I CONTROL [initandlisten]
2019-09-26T09:37:52.683+0200 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-09-26T09:37:52.684+0200 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-09-26T09:37:52.684+0200 I CONTROL [initandlisten]
2019-09-26T09:37:52.698+0200 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2019-09-26T09:37:52.698+0200 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for version, 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-09-26T09:37:52.698+0200 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-09-26T09:37:52.698+0200 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-09-26T09:37:52.698+0200 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-09-26T09:37:52.698+0200 I STORAGE [initandlisten] Deregistering all the collections
2019-09-26T09:37:52.698+0200 I STORAGE [initandlisten] Timestamp monitor shutting down
2019-09-26T09:37:52.698+0200 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2019-09-26T09:37:52.699+0200 I STORAGE [initandlisten] Shutting down session sweeper thread
2019-09-26T09:37:52.699+0200 I STORAGE [initandlisten] Finished shutting down session sweeper thread
2019-09-26T09:37:52.699+0200 I STORAGE [initandlisten] Shutting down journal flusher thread
2019-09-26T09:37:52.779+0200 I STORAGE [initandlisten] Finished shutting down journal flusher thread
2019-09-26T09:37:52.779+0200 I STORAGE [initandlisten] Shutting down checkpoint thread
2019-09-26T09:37:52.779+0200 I STORAGE [initandlisten] Finished shutting down checkpoint thread
2019-09-26T09:37:52.779+0200 I STORAGE [initandlisten] Downgrading WiredTiger datafiles.
2019-09-26T09:37:52.808+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:808033][5220:0x7fc6c8d05b00], txn-recover: Recovering log 21 through 22
2019-09-26T09:37:52.848+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:848763][5220:0x7fc6c8d05b00], txn-recover: Recovering log 22 through 22
2019-09-26T09:37:52.891+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:891333][5220:0x7fc6c8d05b00], txn-recover: Main recovery loop: starting at 21/3328 to 22/256
2019-09-26T09:37:52.944+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:944712][5220:0x7fc6c8d05b00], txn-recover: Recovering log 21 through 22
2019-09-26T09:37:52.977+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:977288][5220:0x7fc6c8d05b00], txn-recover: Recovering log 22 through 22
2019-09-26T09:37:53.003+0200 I STORAGE [initandlisten] WiredTiger message [1569483473:3143][5220:0x7fc6c8d05b00], txn-recover: Set global recovery timestamp: (0,0)
2019-09-26T09:37:53.023+0200 I STORAGE [initandlisten] shutdown: removing fs lock...
2019-09-26T09:37:53.023+0200 I CONTROL [initandlisten] now exiting
2019-09-26T09:37:53.023+0200 I CONTROL [initandlisten] shutting down with code:62
我将非常感谢您的任何建议
I will be very grateful for any advice
推荐答案
从你的 ubuntu 中删除完整的 mongodb
Remove complete mongodb from your ubuntu
sudo apt-get purge mongo* // or sudo apt remove mongo*
sudo apt-get purge mongodb-org*
备份您的数据库并使用文件夹删除日志和数据
Backup your database and remove log and data using folder
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
现在用这个重新安装
$ wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc \
sudo apt-key add -
添加来源
$ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse" \
sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
然后再次安装mongodb包
Then install mongodb package again
sudo apt-get install -y mongodb-org=4.2.0 \
mongodb-org-server=4.2.0 \
mongodb-org-shell=4.2.0 \
mongodb-org-mongos=4.2.0 \
mongodb-org-tools=4.2.0
使用mongodb启动服务
Start service using mongodb
$ systemctl enable mongod.service
$ sudo service mongod start
或者按照这个文档安装过程
这篇关于重新安装后,MongoDB 4.2 无法在 ubuntu 18.04 上启动 - 进程立即停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!