ubuntu 安装mongodb
程序员文章站
2024-01-23 10:28:22
...
.1.导入软件源的公钥
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
2.为mongodb创建软件源list文件
ubuntu12.04
echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
ubuntu14.04
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
ubuntu16.04
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
3.更新软件源并安装mongodb
sudo apt-get update
sudo apt-get install -y mongodb-org
4.配置启动文件
如果是ubuntu16.04的版本,需要手动新建/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
[Install]
WantedBy=multi-user.target
5.启动、重启和关闭命令
sudo service mongod start
sudo service mongod restart
sudo service mongod stop
启动客户端:
上一篇: Ubuntu 安装Mongodb
下一篇: MongoDB 学习笔记