Yura YuLife

ITエンジニアの覚え書き。

MongoDBで WARNING: You are running on a NUMA machine. というワーニングが出る場合

環境

  • Ubuntu Server 14.04
  • MongoDB 2.4.9

MongoDBの起動時にワーニングが出る

apt-getでインストールしたMongoDBを起動すると、起動時に以下のようなワーニングが表示された。

MongoDB shell version: 2.4.9
connecting to: test
Server has startup warnings: 

** WARNING: You are running on a NUMA machine.
**          We suggest launching mongod like this to avoid performance problems:
**              numactl --interleave=all mongod [other options]

Running MongoDB on a system with Non-Uniform Access Memory (NUMA) can cause a number of operational problems, including slow performance for periods of time and high system process usage. Production Notes — MongoDB Manual 3.0

どうも、NUMAなアーキテクチャのマシンでMongoDBを使うと、パフォーマンスの低下やリソース使用量の増加をもたらすことがあるので、適切に設定を行う必要があるらしい。

対処法

numactlをインストール

$ sudo apt-get install numactl

/etc/sysctl.confへ追記

$ sudo vi /etc/sysctl.conf

# 一番最後に追記
vm.zone_reclaim_mode = 0

/etc/init/mongodb.confの修正

$ sudo vi /etc/init/mongodb.conf

    # 以下の4行をコメントアウト
    # if [ "x$ENABLE_MONGODB" = "xyes" ]; then
    #     exec start-stop-daemon --start --quiet --chuid mongodb \
    #         --exec /usr/bin/mongod -- --config /etc/mongodb.conf
    # fi
    # 以下の4行を追記
    if [ "x$ENABLE_MONGODB" = "xyes" ]; then
        exec start-stop-daemon --start --quiet --chuid mongodb \
            --exec  /usr/bin/numactl -- --interleave=all /usr/bin/mongod --config /etc/mongodb.conf
    fi

これでとりあえずワーニングは表示されなくなります。

参考URL