LoginSignup
44
45

More than 3 years have passed since last update.

MongoDB 3.0インストール後のワーニングの消し方

Last updated at Posted at 2015-03-09

インストール自体は、2.6の時の手順と変わらなかった。
インストール後にいくつかワーニングがでたので、インストールとワーニングの消し方を纏める。

インストール

インストール自体はMongoDBのドキュメントを見ながら実施
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat/

インストール準備

console
$sudo vi /etc/yum.repos.d/mongodb-org-3.0.repo 
mongodb-org-3.0.repoの内容
[mongodb-org-3.0]
name=MongoDB Repository
baseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/
gpgcheck=0
enabled=1

インストール実行

console
$sudo yum install -y mongodb-org

サービス起動

console
$sudo service mongod start

と普通に起動し、mongoコマンドでアクセスすると、

console
$ mongo
MongoDB shell version: 3.0.0
connecting to: test
Server has startup warnings: 
2015-03-06T23:40:40.565+0900 I CONTROL  [initandlisten] 
2015-03-06T23:40:40.565+0900 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-03-06T23:40:40.565+0900 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-03-06T23:40:40.565+0900 I CONTROL  [initandlisten] 
2015-03-06T23:40:40.566+0900 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-03-06T23:40:40.566+0900 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-03-06T23:40:40.566+0900 I CONTROL  [initandlisten] 
2015-03-06T23:40:40.566+0900 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 1024 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
2015-03-06T23:40:40.566+0900 I CONTROL  [initandlisten] 
> 

こんな感じでワーニングメッセージが表示される。
以下の手順でワーニングを消す

インストール後の設定(1) ~「WARNING: soft rlimits too low. 」の消し方

console
$sudo vi /etc/security/limits.d/90-nproc.conf

上記はCentOSの場合なので、ディストリビューションによっては、
/etc/security/limits.conf
だったりすると思う。

90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited

*          soft    nofile    64000  # この行追加
*          hard    nofile    64000  # この行追加
console
$su -
# service mongod restart

これで「WARNING: soft rlimits too low. 」は消える。
rebootが必要だったかもしれない。

(2015/07/22追記)
「WARNING: soft rlimits too low. 」は、CentOSにインストールした場合に発生した。
AmazonLinux(Amazon Linux AMI 2015.03 (HVM), SSD Volume Type)では発生しなかった。
(2015/07/22追記 終)

インストール後の設定(2)~「WARNING: /sys/kernel/mm/transparent_hugepage/enabled(or defrag ) is 'always'.」の消し方

console
$ sudo vi  /etc/rc.local
rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

if test -f /sys/kernel/mm/transparent_hugepage/enabled; then  # ↑ここから追加
   echo never > /sys/kernel/mm/transparent_hugepage/enabled   # │
fi                                                            # │
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then   # │
   echo never > /sys/kernel/mm/transparent_hugepage/defrag    # │
fi                                                            # ↓ここまで追加

これで
「WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.」
「WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.」
が消える。
ここもrebootが必要だったかもしれない。

以上。記憶を元にメモ。
再度どこかで検証し、更新予定。

AmazonLinuxにて(2015/07/22追記)

CentOSでは、
「WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.」
「WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.」
どちらも発生したが、
AmazonLinux(Amazon Linux AMI 2015.03 (HVM), SSD Volume Type)では、
「WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.」
のみ発生した。
(2015/07/22追記 終)

TransparetHugePagesについて(2015/09/28追記)

今まで気づかなかったが、公式のチュートリアルにも、ベストパフォーマンスにするためTransparetHugePagesはDisableにすべき。と記載があった。

https://docs.mongodb.com/manual/tutorial/transparent-huge-pages/
Transparent Huge Pages (THP) is a Linux memory management system that reduces the overhead of Translation
 Lookaside Buffer (TLB) lookups on machines with large amounts of memory by using larger memory pages.

However, database workloads often perform poorly with THP, because they tend to have sparse rather than 
contiguous memory access patterns. You should disable THP on Linux machines to ensure best performance with 
MongoDB.

※TransparetHugePagesとは
カーネルのメモリマネジメントの仕組みの一つで性能改善を目的とした機能のようだ。
RedHatのドキュメント(パフォーマンスチューニングガイド「5.2. Huge pages および transparent huge pages」)を見ると
「huge Pagesの作成、管理、使用の多くを自動化する抽象レイヤー」とある。
普通のアプリケーションサーバーとして使った場合にはパフォーマンスが良くなるのかもしれない。
Transparet HugePages databaseでググるとMongoDB以外にも無効を推奨するデータベースが多い。

メモ:時間があるときに、Documentation/vm/transhuge.txtをじっくり読む
(2015/09/28追記 終)

44
45
1

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
44
45