📝
mongoDBバージョンアップ(2.4→4.0)の手順
mongoDBバージョンアップ(2.4→4.0)の手順
概要
いきなり4.0をインストールしても互換性がなく動かないため、段階的にバージョンアップしていく。
- 2.4uninstall
- 2.6install
- 2.6uninstall
- 3.4install(Community Edition)
- 3.4uninstall
- 3.6install(Community Edition)
- 3.6uninstall
- 4.0install(Community Edition)
2.4uninstall
手順
sudo apt-get purge mongodb*
2.6install
手順
curl -O http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.12.tgz
tar -zxvf mongodb-linux-x86_64-2.6.12.tgz
mkdir -p mongodb
cp -R -n mongodb-linux-x86_64-2.6.12/ mongodb
sudo mongodb/mongodb-linux-x86_64-2.6.12/bin/mongod --auth --bind_ip 127.0.0.1 --dbpath=/var/lib/mongodb
sudo mongodb/mongodb-linux-x86_64-2.6.12/bin/mongo admin -u dbadmin -p plattown
db.adminCommand({authSchemaUpgrade: 1 });
参考
- Install MongoDB on Linux Systems — MongoDB Manual
- Upgrade User Authorization Data to 2.6 Format — MongoDB Manual
2.6uninstall
手順
rm mongodb-linux-x86_64-2.6.12.tgz
rm -r mongodb-linux-x86_64-2.6.12
rm -r mongodb
3.4install(Community Edition)
手順
wget -qO - https://www.mongodb.org/static/pgp/server-3.4.asc | sudo apt-key add -
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
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo mongod --auth --bind_ip 127.0.0.1 --dbpath=/var/lib/mongodb
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
参考
- Install MongoDB Community Edition on Ubuntu — MongoDB Manual
- Release Notes for MongoDB 3.6 — MongoDB Manual
3.4uninstall
手順
sudo apt-get purge mongodb-org*
3.6install(Community Edition)
手順
wget -qO - https://www.mongodb.org/static/pgp/server-3.6.asc | sudo apt-key add -
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt-get update
sudo apt-get install -y mongodb-org
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
sudo mongod --auth --bind_ip 127.0.0.1 --dbpath=/var/lib/mongodb
db.adminCommand({authSchemaUpgrade: 1});
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
参考
- Install MongoDB Community Edition on Ubuntu — MongoDB Manual
- Upgrade to SCRAM — MongoDB Manual
- Release Notes for MongoDB 4.0 — MongoDB Manual
3.6uninstall
手順
sudo apt-get purge mongodb-org*
4.0install(Community Edition)
手順
wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
sudo mongod --auth --bind_ip 127.0.0.1 --dbpath=/var/lib/mongodb
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
Discussion