MongoDB 启动问题解决

# mongo
MongoDB shell version: 3.2.16
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    http://docs.mongodb.org/
Questions? Try the support group
    http://groups.google.com/group/mongodb-user
Server has startup warnings: 
2017-08-17T17:27:31.443+0800 I CONTROL  [initandlisten] 
2017-08-17T17:27:31.443+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.
2017-08-17T17:27:31.443+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:
2017-08-17T17:27:31.443+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]
2017-08-17T17:27:31.443+0800 I CONTROL  [initandlisten] 
2017-08-17T17:27:31.443+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-08-17T17:27:31.443+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-08-17T17:27:31.443+0800 I CONTROL  [initandlisten] 
2017-08-17T17:27:31.443+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2017-08-17T17:27:31.443+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-08-17T17:27:31.443+0800 I CONTROL  [initandlisten] 
2017-08-17T17:27:31.444+0800 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.
2017-08-17T17:27:31.444+0800 I CONTROL  [initandlisten] 
> 

第一个问题: 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.

解决方法:
1.系统级别
# vi /etc/sysctl.conf
fs.file-max = 100000
# sysctl -p

查看方法:
# cat /proc/sys/fs/file-max
# sysctl fs.file-max

2.用户级别
设置方法:
# vi /etc/security/limits.conf
mongod soft nofile 65535
mongod hard nofile 65535
mongod soft nproc 32768
mongod hard nproc 32768

查看方法:
# su - user
$ ulimit -Hn
$ ulimit -Sn

注意:
root用户还需单独设置
# vi /etc/security/limits.conf
root soft nofile 65536
root hard nofile 65535

CentOS还需开启PAM模块
# vi /etc/pam.d/login
session required pam_limits.so

第二个问题:
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'

解决方法:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag

# vim /etc/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag

查看方法:
# cat /sys/kernel/mm/transparent_hugepage/enabled 
always madvise [never]
# cat /sys/kernel/mm/redhat_transparent_hugepage/defrag
always madvise [never]

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

解决方法:
echo 0 | sudo tee /proc/sys/vm/zone_reclaim_mode
sysctl -w vm.zone_reclaim_mode=0

你可能感兴趣的:(MongoDB 启动问题解决)