mongodb 升级mongodb没有效果,依然显示老版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29999360/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Upgrading mongodb has no effect and still shows the old version
提问by swapnesh
Following are the commands which I used to upgrade my mongodb version from 2.6.9 to latest, but its still showing me the previous version. Let me know what I am doing wrong with the upgrading process. The problem is that mongod -version
still shows the old version installed after upgrade.
以下是我用来将 mongodb 版本从 2.6.9 升级到最新版本的命令,但它仍然向我显示以前的版本。让我知道我在升级过程中做错了什么。问题是mongod -version
升级后仍然显示安装的旧版本。
Docs which I refer to - Mongodb Docs
我参考的文档- Mongodb Docs
Steps I followed -
我遵循的步骤 -
- sudo apt-key adv --keyserver 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/sources.list.d/mongodb-org-3.0.list
- sudo apt-get update
- sudo apt-get install -y mongodb-org
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
- echo "deb http://repo.mongodb.org/apt/ubuntu"$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | 须藤三通/etc/apt/sources.list.d/mongodb-org-3.0.list
- sudo apt-get 更新
- sudo apt-get install -y mongodb-org
Result -
结果 -
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) ...
After this I re started the service - sudo service mongod restart
在此之后,我重新启动了服务 - sudo service mongod restart
But still its showing me version 2.6.9
Let me know what I am doing wrong here..or missed any step ?
但它仍然向我展示版本2.6.9
让我知道我在这里做错了什么……或者错过了任何步骤?
回答by Lior
I'm in the exact same situation, followed the exact same steps, and had the same issue.
我处于完全相同的情况,遵循完全相同的步骤,并且遇到了相同的问题。
What worked for me was:
对我有用的是:
卸载:
sudo service mongod stop
sudo apt-get purge mongodb-org*
Do NOT remove data directories- all your data will be lost if doing so.
不要删除数据目录- 如果这样做,您的所有数据都将丢失。
Note: Calling sudo apt-get purge mongodb-org*
deletes the mongod.conf
file. In case you want to keep this file after the update, make sure you create a backup copyof it and use it after the new version has been installed.
注意:调用sudo apt-get purge mongodb-org*
会删除mongod.conf
文件。如果您想在更新后保留此文件,请确保创建它的备份副本并在安装新版本后使用它。
Then install mongodbwith:
然后安装mongodb:
sudo apt-get install -y mongodb-org
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.
这假设您已经按照您的说明执行了之前的安装步骤(导入公钥、创建列表文件、重新加载本地包数据库)。
回答by malcolm
[Disclaimer] Before going into upgrade consider that moving from 2.6 to 3.+ requires an update on storage files. Same if you are updating from 3.2 to 3.4 or 3.4 to 3.6. Important:You can't directlyupgrade from 3.2 to 3.6, for example. You must upgrade "step by step" 3.2-->3.4-->3.6. See this question/answerfor details.
[免责声明] 在升级之前,请考虑从 2.6 迁移到 3.+ 需要更新存储文件。如果您从 3.2 更新到 3.4 或 3.4 到 3.6,则相同。重要提示:例如,您不能直接从 3.2 升级到 3.6。您必须“逐步”升级 3.2-->3.4-->3.6。有关详细信息,请参阅此问题/答案。
This is necessary if you want to recover your old DBs
如果您想恢复旧的数据库,这是必要的
As of writing 3.6 is the latest version of MongoDB. Some details here
在撰写本文时,3.6 是 MongoDB 的最新版本。一些细节在这里
Beware that changing between versions also regards some syntax in .conf file.
请注意,版本之间的更改也会考虑 .conf 文件中的某些语法。
[Procedure] A more general framework for updating is to follow the typical procedure as shown here, but point to "Install a specific release of MongoDB" part of this guide as you already have MongoDB installed.
[过程] 更通用的更新框架是遵循此处所示的典型过程,但请指向本指南的“安装特定版本的 MongoDB”部分,因为您已经安装了 MongoDB。
An example on Ubuntu 14.04:
Ubuntu 14.04 上的示例:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org=3.2.18 mongodb-org-server=3.2.18 mongodb-org-shell=3.2.18 mongodb-org-mongos=3.2.18 mongodb-org-tools=3.2.18
回答by Denis Bakharev
Run this:
运行这个:
sudo apt-get update
sudo apt-get --only-upgrade install mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
回答by vashishatashu
You can replace binaries to upgrade to mongodb 3.0 as follows (works on Ubuntu/CentOs but commands are listed for Ubuntu) :
您可以替换二进制文件以升级到 mongodb 3.0,如下所示(适用于 Ubuntu/CentOs,但列出了适用于 Ubuntu 的命令):
- 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
- 根据您的分发从 mongodb 网站下载 tar:https: //www.mongodb.org/downloads
解压下载的文件。
tar -zxvf {mongo-tar-file}.tgz
停止 mongod 服务。
须藤服务 mongod 停止
将 tar/bin 中的二进制文件替换为 /usr/bin。
cd {您的提取文件夹}/bin
须藤 mv -f * /usr/bin/
启动 mongod 服务。
须藤服务 mongod 开始
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.
在此之后连接到 mongo 后,您可以看到版本已更新。我已经在我的生产服务器上以这种方式升级,没有任何问题。
You should backup your data before upgrading. Usually no backup/restore is necessary but sometimes things don't go as expected.
您应该在升级前备份您的数据。通常不需要备份/恢复,但有时事情不会按预期进行。
回答by Bogdan Guban
You should update each package manually. So try:
您应该手动更新每个包。所以尝试:
dpkg -l | grep mongo
dpkg -l | grep mongo
ii mongodb-org 3.2.10 amd64 MongoDB open source document-oriented database system (metapackage)
ii mongodb-org-mongos 3.2.10 amd64 MongoDB sharded cluster query router
hi mongodb-org-server 3.2.10 amd64 MongoDB database server
ii mongodb-org-shell 3.2.14 amd64 MongoDB shell client
ii mongodb-org-tools 3.2.14 amd64 MongoDB tools
and then update each pakage manually
然后手动更新每个包
sudo apt-get install mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
sudo apt-get install mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
回答by vikram eklare
Step 1: First you need to uninstall existing mongodb
第 1 步:首先您需要卸载现有的 mongodb
stop Mongodb service
sudo service mongod stop
Remove Packages.
sudo apt-get purge mongodb-org*
Remove Data Directories. (optional)
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
停止 Mongodb 服务
须藤服务 mongod 停止
删除包。
sudo apt-get purge mongodb-org*
删除数据目录。(可选的)
须藤 rm -r /var/log/mongodb
须藤 rm -r /var/lib/mongodb
Step 2: Then Install latest mongodb (i.e. 3.4)
第二步:然后安装最新的mongodb(即3.4)
1. Import the public key used by the package management system.
1、导入包管理系统使用的公钥。
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
2. Create a list file for MongoDB. (Ubuntu 16.04)
2. 为 MongoDB 创建一个列表文件。(Ubuntu 16.04)
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
3. Reload local package database.
3. 重新加载本地包数据库。
sudo apt-get update
sudo apt-get 更新
4. Install the latest stable version of MongoDB
4.安装最新的稳定版MongoDB
sudo apt-get install -y mongodb-org
sudo apt-get install -y mongodb-org
5. Start MongoDB.
5. 启动MongoDB。
sudo service mongod start
须藤服务 mongod 开始
6. Verify that MongoDB has started successfully
6.验证MongoDB是否启动成功
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.
通过检查 /var/log/mongodb/mongod.log 中的日志文件的内容来验证 mongod 进程是否已成功启动
[initandlisten] 等待端口连接
/etc/mongod.conf中配置的端口在哪里,默认是27017。
回答by PaVen Nguyen
Thank. I action step by step this is done on ubuntu 14.04 LTS
谢谢。我一步一步地行动,这是在 ubuntu 14.04 LTS 上完成的
Download tar from mongodb website as per your destribution from : https://www.mongodb.org/downloadsUntar downloaded file.
根据您的分布从 mongodb 网站下载 tar:https: //www.mongodb.org/downloads解压缩下载的文件。
tar -zxvf {mongo-tar-file}.tgz
tar -zxvf {mongo-tar-file}.tgz
Stop mongod service.
停止 mongod 服务。
sudo service mongod stop
须藤服务 mongod 停止
Replace binaries from your tar/bin to /usr/bin.
将 tar/bin 中的二进制文件替换为 /usr/bin。
cd {your-extracted-folder}/bin
cd {您的提取文件夹}/bin
sudo mv -f * /usr/bin/
须藤 mv -f * /usr/bin/
Start mongod service.
启动 mongod 服务。
sudo service mongod start
须藤服务 mongod 开始