Deepin [Linux] Mongodb安装与自启动
程序员文章站
2022-03-03 14:47:24
...
导入秘钥:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
添加源:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
更新源:
sudo apt-get update
安装MongoDB:
sudo apt-get install -y mongodb-org
其实到现在已经简单安装成功了下面我们需要配置一下自启动
[注意:Deepin中默认没有rc.local文件,Ubantu中默认有吧貌似,没用过]
sudo gedit /etc/rc.local
# 使用gedit创建并打开文件之后输入一下模板
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
systemctl start mongod
systemctl status mongod
exit 0
# 下面这两个就是我们系统启动之后执行的代码,启动MONGODB服务,如果有其他的命令都可以添加到exit 0这一行前面
systemctl start mongod
systemctl status mongod
开机试试看看是不是已经能够自动启动了