1、wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.5.tgz
2、tar xf mongodb-linux-x86_64-2.6.5.tgz -C /usr/local/
3、cd /usr/local
4、ln -sv mongodb-linux-x86_64-2.6.5 mongo
5、vim /etc/profile.d/mongo.sh
export MONGOD_HOME=/usr/local/mongo
export PATH=$MONGOD_HOME/bin:$PATH
6、. /etc/profile.d/mongo.sh
vim /etc/mongod.conf
dbpath=/mongodb/data/
logpath=/var/log/mongodb/mongodb.log
pidfilepath=/var/run/mongo.pid
fork=true
logappend=true
directoryperdb=true
httpinterface=true
replSet=testSet
replIndexPrefetch=_id_only
vim /etc/init.d/mongod
#!/bin/sh
# chkconfig: - 64 36
# description:mongod
case $1 in
start)
/usr/local/mongo/bin/mongod --maxConns 20000 --config /etc/mongod.conf
;;
stop)
/usr/local/mongo/bin/mongo 127.0.0.1:27017/admin --eval "db.shutdownServer()"
#/usr/local/mongo/bin/mongo 127.0.0.1:27017/admin --eval "db.auth('system', '123456');db.shutdownServer()"
;;
restart)
/usr/local/mongo/bin/mongo 127.0.0.1:27017/admin --eval "db.shutdownServer()"
/usr/local/mongo/bin/mongod --maxConns 20000 --config /etc/mongod.conf
#/usr/local/mongo/bin/mongo 127.0.0.1:27017/admin --eval "db.auth('system', '123456');db.shutdownServer()"
;;
status)
/usr/local/mongo/bin/mongo 127.0.0.1:27017/admin --eval "db.stats()"
#/usr/local/mongo/bin/mongo 127.0.0.1:27017/admin --eval "db.auth('system', '123456');db.stats()"
;;
esac
chmod +x /etc/init.d/mongod
mkdir /mongdb/data -pv
mkdir /var/log/mongodb
groupadd mongod
useradd -g mongod mongod
chown -R mongod:mongod /mongodb/data
chown -R mongod:mongod /var/log/mongodb
欢迎光临 黑帽联盟 (https://bbs.cnblackhat.com/) | Powered by Discuz! X2.5 |