CentOS7源码安装mongodb
1、下载源码包
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.0.18.tgz
2、解压缩包
tar -xzvf mongodb-linux-x86_64-rhel70-4.0.18.tgz
3、配置mongodb
mkdir -p /usr/local/mongodb/{conf,data,log}
vim config/mongodb.conf
输入下面的配置项
systemLog: destination: file path: "/usr/local/mongodb/log/mongodb.log" logAppend: true storage: dbPath: "/usr/local/mongodb/data/" journal: enabled: true processManagement: fork: true pidFilePath: "/usr/local/mongodb/mongodb.pid" net: port: 27017 setParameter: enableLocalhostAuthBypass: false
4、启动mongodb
/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/mongodb.conf
5、配置开机启动
vim /etc/init.d/mongo
#!/bin/sh # #chkconfig: 2345 80 90 #description: mongodb if test -f /sys/kernel/mm/transparent_hugepage/enabled; then echo never > /sys/kernel/mm/transparent_hugepage/enabled fi if test -f /sys/kernel/mm/transparent_hugepage/defrag; then echo never > /sys/kernel/mm/transparent_hugepage/defrag fi start() { /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/mongodb.conf } stop() { /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/mongodb.conf --shutdown } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 esac
chmod a+x mongodb
chkconfig --add mongodb
chkconfig mongodb on