mongodb提供一个mongo客户端,类似于mysql提供的客户端命令
/usr/local/mongodb/bin/mongo 127.0.0.1:27017
/usr/local/mongodb/bin/mongo #默认连接到127.0.0.1:27017
mongodb启动优化说明
WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
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.
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 3895 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
内核进程数限制放开/etc/security/limits.conf,需要重新登录
# 最大文件打开数
* - nofile 1024300
# 最大进程数
* - nproc 65536
mongodb启动参数优化1,禁止内存巨大页
vim /etc/rc.local # 添加到这个文件,每次启动自动优化
echo 'never' >/sys/kernel/mm/transparent_hugepage/enabled
echo 'never' >/sys/kernel/mm/transparent_hugepage/defrag
把命令加入/etc/rc.local,注意需要有执行权限,然后启动mongodb
chmod +x /etc/rc.d/rc.local #centos7默认rc.local没有执行权限,需要支持执行权限
使用普通用户启动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
centos7默认还有进程数限制/etc/security/limits.d/20-nproc.conf
访问控制建议设置ip白名单访问