一、MongoDB登录警告处理
1.警告内容
The server generated these startup warnings when booting:
2020-12-11T00:25:39.415+08:00: The configured WiredTiger cache size is more than 80% of available RAM. See http://dochub.mongodb.org/core/faq-memory-diagnostics-wt
2020-12-11T00:25:40.364+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
2020-12-11T00:25:40.364+08:00: You are running this process as the root user, which is not recommended
2020-12-11T00:25:40.364+08:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
2020-12-11T00:25:40.364+08:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never'
2.警告一:
#内存设置超过服务器内存的80%
2020-12-11T00:25:39.415+08:00: The configured WiredTiger cache size is more than 80% of available RAM. See http://dochub.mongodb.org/core/faq-memory-diagnostics-wt
#解决:
将服务器内存调大,或者经配置文件中配置的缓存调低
3.警告二:
#数据库未启用访问控制。对数据和配置的读写访问是不受限制的
2020-12-11T00:25:40.364+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
#开启用户认证:
security:
authorization: enabled
4.警告三:
#您以root用户身份运行此进程,不建议这样做
2020-12-11T00:25:40.364+08:00: You are running this process as the root user, which is not recommended
#解决方式:
1.关闭mongodb
[root@redis01 ~]# mongod -f /server/mongo_27017/conf/mongodb.conf --shutdown
killing process with pid: 8412
2.创建用户
[root@redis01 ~]# useradd mongo
[root@redis01 ~]# passwd mongo
3.授权目录
[root@redis01 ~]# chown -R mongo.mongo /server/mongo_27017/
4.重新启动服务
[root@redis01 ~]# su mongo
[mongo@redis01 /root]$ mongod -f /server/mongo_27017/conf/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 8599
child process started successfully, parent exiting
5.告警四和告警五
#/sys/kernel/mm/transparent_hugepage/enabled 和/sys/kernel/mm/transparent_hugepage/defrag 配置都为"always"。我们建议设置为"never"
2020-12-11T00:25:40.364+08:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
2020-12-11T00:25:40.364+08:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never'
#解决:
[root@redis01 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
[root@redis01 ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
[root@redis01 ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@redis01 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
[root@redis01 ~]# echo never > /sys/kernel/mm/transparent_hugepage/defrag
[root@redis01 ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]