mongodb升级,必须要2.2升到2.4,2.4升到2.6,然后2.6升级到3.0。
我2.4想升级到3.0,怎么办?从2.4先到2.6最后到3.0呗。
2.4到2.6升级见:/blog/single/id/749.html
接下来开始 mongodb 2.6 - 3.0.2 升级
http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.2.tgz
1、关闭 均衡器Disable the Balancer
> sh.stopBalancer()
2、升级集群元数据,mongos 路由服务器Upgrade the cluster's meta data.
关闭2.6 mongos ,一个一个升级
./mongodb-3.0.2/bin/mongos -f ./mongodb-2.4.1/conf/route21000.conf --upgrade ./mongodb-3.0.2/bin/mongos -f ./mongodb-2.4.1/conf/route21000.conf
3、更新配置服务器Upgrade the config servers.
2.6导出数据
./mongo2.6.9/bin/mongodump --port 10000 -o /data/mongo3.0.2/cfgbak2.6
3.0使用新引擎启动cfg,注意配置文件,需要制定新的配置目录dbpath
./mongo3.0.2/bin/mongod -f /etc/mongo3.0.2/mongo_27017.conf --storageEngine wiredTiger
3.0导入数据
./mongodb-3.0.2/bin/mongorestore --port 10000 --dir /data/mongo3.0.2/cfgbak2.6
4、更新分片,复制集Upgrade the shards.
先升级secondry,注意使用新引擎开启mongo --storageEngine wiredTiger
./mongo3.0.2/bin/mongod -f /etc/mongo3.0.2/mongo_27017.conf --storageEngine wiredTiger // rep2:STARTUP2> 变成 rep2:SECONDARY>
其次升级primary,先切primary.stepDown
> rs.stepDown() > rs.status() //等到当前primary变成 SECONDARY ,其他有的 SECONDARY 变成primary,这时升级 > db.shutdownServer() ./mongo3.0.2/bin/mongod -f /etc/mongo3.0.2/mongo_27018.conf --storageEngine wiredTiger
最后升级arbiter仲裁服务
./mongo3.0.2/bin/mongod -f /etc/mongo3.0.2/mongo_27019.conf --storageEngine wiredTiger
5、开启 均衡器Re-enable the balancer.
sh.startBalancer() 或者 sh.setBalancerState(true)
可能遇到问题:
[initandlisten] exception in initAndListen: 28574 Cannot start server. Detected data files in /export/servers/mongodb-2.4.1/data/cfg10000 created by storage engine 'mmapv1'. The configured storage engine is 'wiredTiger'., terminating
配置文件的文档目录可能指向原来的cfg目录,需要新建一个3.0的配置目录,制定db-path为新目录
老目录:/export/servers/mongodb-2.6.9/data/cfg10000
新的空目录:/export/servers/mongodb-3.0.2/data/cfg10000
php mongo报错:’Failed to connect to: XXXXX: Remote server has closed the connection’的解决方法
升级mongo后,报错,查了半天,几近疯狂,网上说mongo重启后,php的mongo模块也需要重启,就重启了php-fpm,整个世界都好了