系统环境
Distributor ID: CentOS
Description: CentOS release 6.7 (Final)
Release: 6.7
Codename: Final
问题描述
在系统上安装mongodb之后报错。
(安装教程地址: https://docs.mongodb.com/master/tutorial/install-mongodb-on-red-hat/)
错误信息:
WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.We suggest setting it to ‘never’
WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.We suggest setting it to ‘never’
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.
如图:
解决方案
前两个warning
sudo echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
sudo echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
第三个warning
vim /etc/security/limits.conf
添加一下几行
mongod soft nofile 64000
mongod hard nofile 64000
mongod soft nproc 32000
mongod hard nproc 32000
重启mongod
sudo service mongod restart
成功
重启成功之后,所有报错都没啦,如下
➜ ~ git:(master) mongo
MongoDB shell version: 3.2.6
connecting to: test
>