📝

mongoDBバージョンアップ(2.4→4.0)の手順

2023/10/21に公開

mongoDBバージョンアップ(2.4→4.0)の手順

概要

いきなり4.0をインストールしても互換性がなく動かないため、段階的にバージョンアップしていく。

  1. 2.4uninstall
  2. 2.6install
  3. 2.6uninstall
  4. 3.4install(Community Edition)
  5. 3.4uninstall
  6. 3.6install(Community Edition)
  7. 3.6uninstall
  8. 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 });

参考

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 } )

参考

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 } )

参考

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