installation steps
Install using apt-get installation method
Add mongodb signature to APT
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80--recv EA312927
Create /etc/apt/sources.list.d/mongodb-org-3.2.list file and write commands
$ echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse"| sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
Update software source list
sudo apt-get update
Install mongodb (default is to install the stable version)
sudo apt-get install -y mongodb-org
Or install the specified version:
sudo apt-get install -y mongodb-org=3.2.9 mongodb-org-server=3.2.9 mongodb-org-shell=3.2.9 mongodb-org-mongos=3.2.9 mongodb-org-tools=3.2.9
If it is the version of ubuntu16.04, you need to manually create a new /lib/systemd/system/mongod.service file and write the following:
sudo touch /lib/systemd/system/mongod.service
vim /lib/systemd/system/mongod.service
[ Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual
[ Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads(user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits forfor mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
[ Install]
WantedBy=multi-user.target
# Start the database
sudo service mongod start
# Restart the database
sudo service mongod restart
# Close the database
sudo service mongod stop
netstat -plntu
The appearance of the process with port number 27127 proves that the installation is successful.
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 00127.0.0.1:270170.0.0.0:* LISTEN -
tcp 00127.0.0.1:33060.0.0.0:* LISTEN -
tcp 000.0.0.0:800.0.0.0:* LISTEN -
tcp 000.0.0.0:220.0.0.0:* LISTEN -
udp 000.0.0.0:680.0.0.0:*-
udp 00172.21.0.3:1230.0.0.0:*-
udp 00127.0.0.1:1230.0.0.0:*-
**Before setting the username and password for MongoDB, you need to open the MongoDB shell on the server. Enter the following to log in: **mongo
pecl install mongodb
echo "extension=mongodb.so">>`php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
**Stop running mongodb first **
# Close the database
sudo service mongod stop
Uninstall the software again
sudo apt-get purge mongodb-org*
Delete database and log files
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
Link to this article: https://www.debuginn.cn/2311.html
This article is licensed under CC BY-NC-SA 3.0 Unported agreement, please keep the link to this article for reprinting
Recommended Posts