Ubuntu16.04 install Mongodb tutorial

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

Related commands##

Configuration startup file

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, restart and shutdown commands
# Start the database
sudo service mongod start
# Restart the database
sudo service mongod restart
# Close the database
sudo service mongod stop
Check whether the database is installed successfully
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

Add php's mongodb extension
pecl install mongodb
echo "extension=mongodb.so">>`php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`

Complete uninstallation of mongodb##

**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

Ubuntu16.04 install Mongodb tutorial
ubuntu14.04 install jdk1.8 tutorial
How to install MongoDB on Ubuntu 16.04
Install MySQL under Ubuntu 18.04 (graphic tutorial)
ubuntu18.04 install docker
ubuntu12.04 install python3
Ubuntu install guide
ubuntu install nodejs
ubuntu 16 install asp.net
ubuntu install leanote
ubuntu install Jenkins
docker install ubuntu
ubuntu install elasticsearch
ubuntu16.0.1 install pagoda
ubuntu18.04 install python
ubuntu 18.04 install teamviewer
ubuntu install sendmail
Ubuntu20.04 steps to install cuda10.1 (graphic tutorial)
Ubuntu18.04 install Nvidia graphics driver tutorial (graphic)
Ubuntu 18.04 install Odoo14 tutorial through source code
Install apache+PHP under Ubuntu
Ubuntu20.04 install Python3 virtual environment tutorial detailed explanation
install vscode on ubuntu18
Install node.js under Ubuntu
Windows10 install ubuntu20.04 dual system detailed graphic tutorial
ubuntu install zsh terminal
Install nvtop on Ubuntu 18.04
Install postgresql-10 on Ubuntu 18.04
Install python3.6 under Ubuntu 16.04
Install docker on Ubuntu
Install mysql under Ubuntu 16.04
Install Thrift under ubuntu 14.10
Centos install elasticsearch tutorial
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Install nodejs10 on Ubuntu16
ubuntu install harbor warehouse
Install mysql on Ubuntu 14.04
Install Django on ubuntu
Install Pytorch+CUDA on Ubuntu 16.04
2018-09-11 Install arduino under Ubuntu
Centos7 install kubernetes tutorial
Centos7 install Mysql8 tutorial
Install Python3 on Ubuntu 14.04
Ubuntu18.04 install Asterisk16.10 + FreePBX15.0
Ubuntu19 install MySQL pit
Install MongoDB on CentOS 7
ubuntu16.04 install node.js, npm
Install rJava on Ubuntu18
Centos7 install mongodb 4.x
Install JDK10+ on Ubuntu
pcduino ubuntu install os
Install python in Ubuntu
Install JDK in Ubuntu19.10
Install Python3 on Ubuntu 16.04
Install ROS under ROS Ubuntu 18.04[2]
Install MySQL under Ubuntu
Install KDE on Ubuntu16.04.2
ubuntu install nginx server
Install Yarm-PM2 under Ubuntu
Install Docker on Ubuntu18