CentOS安装mongodb

安装参考:https://www.cnblogs.com/pfnie/articles/6759105.html

mkdir /data1/mongo/log -p

tar -zxvf /data1/software/mongodb-linux-x86_64-3.4.2.tgz /usr/local/

mv /usr/local/mongodb-linux-x86_64-3.4.2 /usr/local/mongodb

mkdir /usr/local/mongodb/etc

vi /usr/local/mongodb/etc/mongodb.conf,内容如下:

dbpath=/data1/mongodb
logpath=/data1/mongodb/log/mongodb.log
logappend=true
port=27017
fork=true
auth=true
pidfilepath=/usr/local/mongodb/mongo.pid
replSet=dsj_dbtest01
#keyFile=/usr/local/mongodb/etc/mongo.pass

ln /usr/local/mongodb/bin/mongod /usr/bin/mongod

启动mongodb:mongod -f /usr/local/mongodb/etc/mongodb.conf

验证:访问 http://mongodb_ip:27017/ 可以打开则表示成功

 添加开机启动项:

vim /etc/init.d/mongod,内容如下:

ulimit -SHn 655350
#!/bin/sh
# chkconfig: - 64 36
# description:mongod
case $1 in
start)
/usr/local/mongodb/bin/mongod --maxConns 20000 --config /usr/local/mongodb/etc/mongodb.conf
;;

stop)
/usr/local/mongodb/bin/mongod  --config /usr/local/mongodb/etc/mongodb.conf  --shutdown
;;
status)
/usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin --eval "db.stats()"
;;
restart)

/usr/local/mongodb/bin/mongod  --config /usr/local/mongodb/etc/mongodb.conf  --shutdown


/usr/local/mongodb/bin/mongod --maxConns 20000  --config /usr/local/mongodb/etc/mongodb.conf

;;
esac

chmod +x /etc/init.d/mongod

chkconfig mongod on

service mongod start

 

上一篇:mongodb启动报错 ERROR: child process failed, exited with error number 14


下一篇:Mongo Python 增、删、改、查等操作