#0. env
server:PowerEdge-R620
os: ubuntu16.04
#1 https://docs.mongodb.com/v3.6/tutorial/install-mongodb-on-ubuntu/
1) wget -qO - https://www.mongodb.org/static/pgp/server-3.6.asc | sudo apt-key add -
2) cd /etc/apt/sources.list.d/
sudo touch mongodb-org-3.6.list
3) echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
4) sudo apt-get update
5) sudo apt-get install -y mongodb-org
6) echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
7) ps --no-headers -o comm 1
8) start mongod
sudo systemctl start mongod
sudo systemctl status mongod
sudo systemctl enable mongod
You can follow the state of the process for errors or important messages by watching the output in the /var/log/mongodb/mongod.log file.
mongo --host 127.0.0.1:27017
#2 错误
Failed to unlink socket file /tmp/mongodb-27017.sock Operation not permitted
解决办法:
sudo rm /tmp/mongodb-27017.sock