5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Upgrade MongoDB v2.4.9 => 2.6.6

Last updated at Posted at 2014-12-30

年末ですが MongoDB のバージョンを上げたので手順メモを残しておきます。

Summary

MongoDB のバージョンアップ手順です。
バージョンによって手順は異なりますので、必ず公式ドキュメントとChangeLogを確認してください :octocat:

MongoDB は Replica Set 構成です。

環境

  • MongoDB : v2.4.9
  • OS : Arch Linux
  • Package manager : pacman
  • Service manager : systemd v217

手順

  • SECONDARY -> PRIMARY の順で作業します

Backup INDEX

作業前に最新のバックアップをとっておきましょう!

Package update

pacman -Syu

Set ulimit

LimitNOFILE=64000 を追加する

vim /usr/lib/systemd/system/mongodb.service

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf
# Add this line
LimitNOFILE=64000

[Install]
WantedBy=multi-user.target

Check database (最初の1台だけ)

ref: http://docs.mongodb.org/manual/reference/method/db.upgradeCheckAllDBs/#db.upgradeCheckAllDBs

mongo admin
> db.auth('user', 'pass')
> 
> // slaveOkにしないとcheckできない!
> db.getMongo().setSlaveOk()
> db.upgradeCheckAllDBs()
...
true # true を確認する

Step down primary (PRIMARYのみ)

mongo
> rs.stepDown();

Daemon reload

systemctl daemon-reload

mongodb restart

systemctl restart mongodb

Upgrade User Authorization Data (PRIMARYのみ)

ref: http://docs.mongodb.org/manual/release-notes/2.6-upgrade-authorization/

db admin
db.auth('user', 'pass')
db.getSiblingDB("admin").runCommand({authSchemaUpgrade: 1 });

動作確認

実際にアプリケーションから接続して動作確認

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?