1.1. MongoDB 安装
cd /opt
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.4.tgz
tar zxvf mongodb-linux-x86_64-rhel70-3.6.4.tgz
mv mongodb-linux-x86_64-rhel70-3.6.4/ mongodb
mkdir -p /opt/mongodb/db
mkdir -p /opt/mongodb/log
chmod +x /etc/init.d/mongod
chkconfig mongod on
1.1.1. /etc/mongod.conf
# Where and how to store data.
storage:
dbPath: /opt/mongodb/db
journal:
enabled: true
wiredTiger:
engineConfig:
configString : cache_size=6144M
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /opt/mongodb/log/mongodb.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
# how the process runs
processManagement:
# fork: true
# pidFilePath: /var/run/mongodb/mongod.pid
timeZoneInfo: /usr/share/zoneinfo
security:
authorization: enabled
1.1.2. /etc/init.d/mongod
#!/bin/bash
#chkconfig: 2345 80 90
#description: mongodb
start() {
/opt/mongodb/bin/mongod --config /etc/mongod.conf --fork
}
stop() {
/opt/mongodb/bin/mongod --config /etc/mongod.conf --shutdown
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
1.1.3. set auth
/opt/mongo
>> use admin
db.createUser({user: 'admin', pwd: 'xxxxxx', roles: ['root']})