upgrade CentOS6 default mongodb from 2.4 to 3.6

upgrade CentOS6 default mongodb from 2.4 to 3.6

Vultr CentOS6 default mongodb version is 2.4.14.

Backup database

Assuming you have running database on mongodb. so always backup you database before doing any harzard action.

mongodump

Clone a new server

For safety consideration, it’s better do experienment on cloned new server. please refer to

Clone a new server

on Cloning new server, make sure all data are there, and follow instructions below

remove default mongodb

shutdown mongodb server

service mongod stop

remove packges

yum erase $(rpm -qa|grep mongodb)

during this operation, you are expectd to see package mongodb and mongodb-server are removed.
and also remove their related log folders

rm -rf /var/log/mongodb/
rm -rf /var/lib/mongodb/

Download Mongodb 3.6 from mongodb.org

vim /etc/yum.repos.d/mongodb-org-3.6.repo

fill in with repo configuration

[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/
gpgcheck=0
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc

starting to download

sudo yum install -y mongodb-org

restore database

start new mongodb server

service mongod start

remember you have backup database to folder dump/.

due to compatbility between mongodb 2.4 and 3.6, it is recommened to remove roles management data in 2.4

rm -rf dump/admin/

and remove all incompatible data of .json

find dump/ -name "*.json" -exec rm {} \; -print

let’s restore database to 3.6

mongorestore
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值