MongoDB入门到进阶笔记:02-MongoDB启动登录和服务端优化

MongoDB的登录测试

mongo 命令

mongodb提供一个客户端,类似于mysql提供的客户端命令

#默认连接到127.0.0.1:27017

/usr/local/mongodb/bin/mongo

mongodb启动优化说明

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

建议使用 xfs 文件系统

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’

解决:mongodb启动参数优化1,禁止内存巨大页

echo ‘never’ >/sys/kernel/mm/transparent_hugepage/enabled

echo ‘never’ >/sys/kernel/mm/transparent_hugepage/defrag

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,需要重新登录

* – nproc 65536

使用普通用户启动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

[root@5e7b4039fa6f ~]# more /etc/security/limits.d/20-nproc.conf

# Default limit for number of user’s processes to prevent

# accidental fork bombs.

# See rhbz #432903 for reasoning.

* soft nproc unlimited

访问控制建议设置ip白名单访问


数据运维技术 » MongoDB入门到进阶笔记:02-MongoDB启动登录和服务端优化