解决一些启动mongo之后出现的一些警告问题
如何安装mongodb请参考前一篇文章《mongodb在Linux下的安装》
mongod服务启动之后,我们该启动客户端,./bin/mongo
这个时候其实已经启动成功了,但是会出现一些警告性的错误:
MongoDB shell version: 3.0.6
connecting to: test
Server has startup warnings:
2015-08-28T15:29:38.513+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2015-08-28T15:29:38.513+0800 I CONTROL [initandlisten]
2015-08-28T15:29:38.541+0800 I CONTROL [initandlisten]
2015-08-28T15:29:38.541+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-08-28T15:29:38.541+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-08-28T15:29:38.541+0800 I CONTROL [initandlisten]
2015-08-28T15:29:38.541+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-08-28T15:29:38.541+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-08-28T15:29:38.541+0800 I CONTROL [initandlisten]
2015-08-28T15:29:38.541+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 1024 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files
我们在此先不管第一个root用户的警告问题。
解决办法:
echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
Mongodb建议ulimit设置:
-f (file size): unlimited
-t (cpu time): unlimited
-v (virtual memory): unlimited
-n (open files): 64000
-m (memory size): unlimited
-u (processes/threads): 64000
所以:
uimit -f unlimited
uimit -t unlimited
uimit -v unlimited
uimit -m unlimited
uimit -n 64000
uimit -u 64000