echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag; echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled; echo never > /sys/kernel/mm/transparent_hugepage/enabled; echo never > /sys/kernel/mm/transparent_hugepage/defrag; #建议写到 /etc/rc.local 中,重启后也可生效 vim /etc/rc.local echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled echo never > /sys/kernel/mm/transparent_hugepage/enabled echo never > /sys/kernel/mm/transparent_hugepage/defrag
启动mongodb
mongod –config /etc/mongod.conf
初始化认证脚本
percona-server-mongodb-enable-auth.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14
We have detected authentication is not enabled. Would you like help creating your first user? Please note that mongodb service could be restarted during this action Would you like to proceed?(Y/n)y Percona Server for MongoDB shell version v3.4.6-1.7 connecting to: mongodb://localhost/admin Percona Server for MongoDB server version: v3.4.6-1.7 Successfully added user: { "user" : "dba", "roles" : [ "root" ] } bye User has been created successfully! User:dba Password:tLjMotpKbLbZVTafOkiGuybV9YXXQRA9 It is needed to restart mongod service. Once service is restarted authentication will be enabled
重启后就需要认证登录了
1 2 3 4 5 6 7 8 9
> use admin switched to db admin > db.auth("dba","tLjMotpKbLbZVTafOkiGuybV9YXXQRA9") 1 > > > show dbs admin 0.000GB local 0.000GB