参考官网,下载tar.gz包
安装参考如下:
https://docs.mongodb.com/manual/core/security-mongodb-configuration/
多种安装方式,我下载的是tgz,按照如下说明来写shell
#!/bin/bash sudo apt-get install libcurl4 openssl cd /software/mongodb/ tar -zxvf mongodb-linux-x86_64-ubuntu1804-4.2.8.tgz export PATH=/software/mongodb/mongodb-linux-x86_64-ubuntu1804-4.2.8/bin:$PATH echo "mongodb install finished!"
创建两个对应文件夹及日志文件
mkdir
/software/mongodb/data/db
touch
/software/mongodb/data/logs/mongod.log
用如下命令启动不再需要修改/etc/mongodb.conf就可以远程访问,如果修改下面命令不需要带参数
#!/bin/bash mongod --dbpath /software/mongodb/data/db --logpath /software/mongodb/data/logs/mongod.log --bind_ip 0.0.0.0 --fork
stop
#! /bin/bash # process-monitor.sh process=mongodb pid=$(ps x | grep $process | grep -v grep | awk ‘{print $1}‘) echo $pid kill -9 $pid echo pid=$pid mongodb is stopped!