mongodb3 设置用户名密码 ,linux
2015-05-29T09:08:19.328+0800 I CONTROL [initandlisten] ** WARNING: You are running on a NUMA machine. 2015-05-29T09:08:19.328+0800 I CONTROL [initandlisten] ** We suggest launching mongod like this to avoid performance problems: 2015-05-29T09:08:19.328+0800 I CONTROL [initandlisten] ** numactl --interleave=all mongod [other options] 2015-05-29T09:08:19.328+0800 I CONTROL [initandlisten] 2015-05-29T09:08:19.328+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2015-05-29T09:08:19.328+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2015-05-29T09:08:19.328+0800 I CONTROL [initandlisten] 2015-05-29T09:08:19.328+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2015-05-29T09:08:19.329+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2015-05-29T09:08:19.329+0800 I CONTROL [initandlisten]
===================消除警告====↓========================
yum install -y numactl echo 0 > /proc/sys/vm/zone_reclaim_mode # vi /proc/sys/vm/zone_reclaim_mode echo never > /sys/kernel/mm/transparent_hugepage/enabled echo never > /sys/kernel/mm/transparent_hugepage/defrag
如果是NUMA machine ,启动服务时bin下这样执行
numactl --interleave=all ./mongod --config /etc/mongodb.conf &
判读是不是MUMA
grep -i numa /var/log/dmesg
NUMA: Allocated memnodemap from 2f000 - 3f840
NUMA: Using 20 for the hash shift.
---------------------------------------------------------
1./etc/mongodb.conf
http://docs.mongodb.org/master/reference/configuration-options/
内容如下:
systemLog:
destination: file
path: "/app/mongodb/mongodb.log"
logAppend: true
storage:
journal:
enabled: true
dbPath: "/app/mongodb/data/db"
net:
port: 27017
processManagement:
fork: true
security:
authorization: disabled
2.请确保配置文件中的path和dbPath存在
3.
启动服务命:
./mongod --config /etc/mongodb.conf &
./mongo
use admin
// show users
// db.system.users.remove({user:"someuser"})
db.createUser(
{
user: "admin",
pwd: "qwerty",
roles:
[
{
role: "userAdminAnyDatabase",
db: "admin"
}
]
}
)
// db.system.version.find()
db.system.version.update({ "_id" : "authSchema"},{$set: {"currentVersion" : 3} })
db.shutdownServer()
4.修改配置文件中的authorization 为 enabled
5.启动服务
./mongod --config /etc/mongodb.conf &
./mongo --port 27017 -u admin -p 'qwerty' --authenticationDatabase admin
use logtest
db.createUser(
{
"user": "user001",
"pwd": "asdfgh",
"roles":[
{
"role": "dbOwner",
"db": "logtest"
}
]
}
)
备注:没有关闭服务的权限时,重启需要ps&kill