以下是我用来将MongoDB版本从2.6.9升级到最新版本的命令,但它仍然显示了以前的版本。让我知道我在升级过程中做错了什么。问题是mongod -version
仍然显示升级后安装的旧版本。
我所指的文档-Mongodb Docs
我遵循的步骤是-
- sudo apt-key adv--key服务器HKP://keyserver.ubuntu.com:80--recv 7F0CEB10
- ECHO“Deb http://repo.mongodb.org/apt/ubuntu”$(lsb_Release-sc)“/mongodb-org/3.0 MultiVerse”|sudo tee/etc/apt/Soures.list.d/mongodb-org-3.0.list
- sudo apt-获取更新
- sudo apt-get Install-y MongoDB-org
结果-
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
mongodb-org
1 upgraded, 0 newly installed, 0 to remove and 139 not upgraded.
Need to get 3,608 B of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://repo.mongodb.org/apt/ubuntu/ trusty/mongodb-org/3.0/multiverse mongodb-org amd64 3.0.2 [3,608 B]
Fetched 3,608 B in 0s (18.3 kB/s)
(Reading database ... 298790 files and directories currently installed.)
Preparing to unpack .../mongodb-org_3.0.2_amd64.deb ...
arg: upgrade
Unpacking mongodb-org (3.0.2) over (2.6.9) ...
Setting up mongodb-org (3.0.2) ...
之后,我重新启动了服务-sudo service mongod restart
但它仍然向我显示版本2.6.9
让我知道我在这里做错了什么.或者错过了任何一步?
9条答案
按热度按时间pkln4tw61#
I'm in the exact same situation, followed the exact same steps, and had the same issue.
What worked for me was:
Uninstalling:
Do NOT remove data directories- all your data will be lost if you do.
Don't forget the quotes to prevent shell from interpreting.
Note: Calling
sudo apt-get purge "mongodb-org*"
deletes themongod.conf
file. In case you want to keep this file after the update, make sure youcreate a backup copyof it and use it after the new version has been installed.Then install mongodb with:
This assumes that you've already performed the previous installation steps (importing the public key, creating a list file, reloading local package database) as you've stated.
rryofs0p2#
[免责声明]在升级之前,请考虑从2.6升级到3.+需要更新存储文件。如果您要从3.2更新到3.4或从3.4更新到3.6,则情况相同。重要提示:例如,您不能直接*从3.2升级到3.6。您必须升级“Step by Step”3.2-->3.4-->3.6。详情见this question/answer。
如果您想要恢复旧的数据库,这是必要的
在撰写本文时,3.6是MongoDB的最新版本。某些详细信息here
请注意,在不同版本之间进行更改还会涉及.conf文件中的某些语法。
[PROCEDURE]更一般的更新框架是按照here所示的典型步骤进行,但请参考本指南中的“安装特定版本的MongoDB”部分,因为您已经安装了MongoDB。
Ubuntu 14.04上的一个示例:
kmynzznz3#
运行以下命令:
3vpjnl9f4#
您应该手动更新每个包。所以试一试吧:
dpkg -l | grep mongo
然后手动更新每个包
sudo apt-get install mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
dddzy1tm5#
You can replace binaries to upgrade to mongodb 3.0 as follows (works on Ubuntu/CentOs but commands are listed for Ubuntu) :
tar -zxvf {mongo-tar-file}.tgz
sudo service mongod stop
cd {your-extracted-folder}/bin
sudo mv -f * /usr/bin/
sudo service mongod start
After you connect to mongo after this, you can see version has been updated. I have upgraded in this way on my production servers without any issue.
You should backup your data before upgrading. Usually no backup/restore is necessary but sometimes things don't go as expected.
wtzytmuj6#
Step 1: First you need to uninstall existing mongodb
1.stop Mongodb service
sudo service mongod stop
1.Remove Packages.
sudo apt-get purge mongodb-org*
1.Remove Data Directories. (optional)
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
Step 2: Then Install latest mongodb (i.e. 3.4)
1. Import the public key used by the package management system.
2. Create a list file for MongoDB. (Ubuntu 16.04)
3. Reload local package database.
sudo apt-get update
4. Install the latest stable version of MongoDB
sudo apt-get install -y mongodb-org
5. Start MongoDB.
sudo service mongod start
6. Verify that MongoDB has started successfully
Verify that the mongod process has started successfully by checking the contents of the log file at /var/log/mongodb/mongod.log for a line reading
[initandlisten] waiting for connections on port
where is the port configured in /etc/mongod.conf, 27017 by default.
bq9c1y667#
Thank. I action step by step this is done on ubuntu 14.04 LTS
Download tar from mongodb website as per your destribution from : https://www.mongodb.org/downloads Untar downloaded file.
tar -zxvf {mongo-tar-file}.tgz
Stop mongod service.
sudo service mongod stop
Replace binaries from your tar/bin to /usr/bin.
cd {your-extracted-folder}/bin
sudo mv -f * /usr/bin/
Start mongod service.
sudo service mongod start
nc1teljy8#
In a situation we run into this issue because we still have in the
/etc/apt/sources.list.d
the.list
file for mongodb-org's repository v4.2.When we removed, and redone a
apt update
we are finally able to reeally update to 4.4 version.w9apscun9#
I'm getting an error each time use command
sudo apt-get update
. They still try to get the old version and ask pgp key for each version. The things u need to do is go to path/etc/apt/sources.list.d
and delete filemongodb-org-<version>.list
u need to delete after usingsudo apt-get purge mongodb-org*
command. Usesudo apt-get update
again, it worked for me.