https://www.runoob.com/mongodb/mongodb-linux-install.html
1、下载mongodb并解压缩
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.4.1.tgz
tar -zxvf mongodb-linux-x86_64-ubuntu1804-4.4.1.tgz
mv mongodb-linux-x86_64-ubuntu1804-4.4.1 mongodb
sudo mv mongodb /usr/local
2、设置环境变量
sudo gedit /etc/profile
export MONGODB_HOME=/usr/local/mongodb
export PATH=$MONGODB_HOME/bin:$PATH
source /etc/profile
3、创建目录及日志文件
mkdir -p /usr/local/mongodb/data
mkdir -p /usr/local/mongodb/log
touch /usr/local/mongodb/log/mongodb.log
sudo chown `whoami` /usr/local/mongodb/data # 设置权限
sudo chown `whoami` /usr/local/mongodb/log # 设置权限
4、安装依赖项
sudo apt-get install libcurl4 openssl liblzma5
5、修改配置文件,并按照配置文件启动
mongod --dbpath /usr/local/mongodb/data --logpath /usr/local/mongodb/log/mongodb.log –fork