一、当用客户端登录到数据库时,会提示警告信息

mongodb启动警告

WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine

文件系统类型,安装系统时设置的。

df -h  #查看

WARNING: Access control is not enabled for the database.

         Read and write access to data and configuration is unrestricted.

数据库安全,权限,用户问题

WARNING: You are running this process as the root user, which is not recommended.

非root用户登录数据库

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'

启动参数优化1,禁止内存巨大页

WARNING: soft rlimits too low. rlimits set to 3895 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.

内核进程数设置


1、内核进程数限制放开

修改文件/etc/security/limits.conf,需要重新登录

* - nproc 65536

2、mongodb启动参数优化1,禁止内存巨大页

echo 'never' >/sys/kernel/mm/transparent_hugepage/enabled
echo 'never' >/sys/kernel/mm/transparent_hugepage/defrag

能够下次开机启动实现,加入启动文件/etc/rc.local。centos7的此文件没有执行权限。

把命令加入/etc/rc.local

chmod +x /etc/rc.d/rc.local #支持执行权限

3、使用普通用户启动mongodb

useradd mongodb -s /sbin/nologin
chown -R mongodb:mongodb /data/mongodb/ /usr/local/mongodb/
su - mongodb -s /bin/bash
/usr/local/mongodb/bin/mongod -f /data/mongodb/27017/mongodb.conf

4、centos7默认进程数限制

修改/etc/security/limits.d/20-nproc.conf   
65536