1、安装python3 采用安装anaconda的形式安装python
到官网下载最新版
https://www.anaconda.com/distribution/#download-section
cd /opt
wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh
chmod +x Anaconda3-2019.10-Linux-x86_64.sh
./Anaconda3-2019.10-Linux-x86_64.sh
然后一直点同意。回车,全部采用默认设置
如果安装不了试下用以下这个版本
wget https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh
2、yum安装mongodb
参考文章:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
因为cat 会对$
进行转义,所以$
前面得加反斜杠
cat > /etc/yum.repos.d/mongodb-org-4.2.repo <<EOF
[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
EOF
执行yum 命令安装
yum install -y mongodb-org
启动MongoDB
service mongod start
设置开机启动
chkconfig mongod on
停止mongodb
service mongod stop
重启mongodb
Restart MongoDB
3、开启防火墙端口
查看防火墙状态
firewall-cmd --state
停止firewall
systemctl stop firewalld.service
禁止firewall开机启动
systemctl disable firewalld.service
例子:开放27017端口
firewall-cmd --zone=public --add-port=27017/tcp --permanent
firewall-cmd --reload
4、安装并设置supervisor
安装命令
pip install supervisor
新建存放配置文件的目录
mkdir /etc/supervisord.d/
新建默认配置文件
echo_supervisord_conf > /etc/supervisord.conf
编辑默认配置文件,让其包含配置文件目录下的所有ini文件
vim /etc/supervisord.conf
最后两行去掉; 并将改成,并保存退出
[include]
files = /etc/supervisord.d/*.ini
启动supervisor
supervisord -c /etc/supervisord.conf
配置supervisor开机启动
vim /usr/lib/systemd/system/supervisord.service
添加如下内容,保存退出:
其中/root/anaconda3/bin/supervisord
可用在shell下执行which supervisord
查找到
[Unit]
Description=Supervisor daemon
[Service]
Type=forking
PIDFile=/var/run/supervisord.pid
ExecStart=/root/anaconda3/bin/supervisord -c /etc/supervisord.conf
ExecStop=/root/anaconda3/bin/supervisorctl shutdown
ExecReload=/root/anaconda3/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
设置开机启动
systemctl enable supervisord
查看是否设置成功
systemctl is-enabled supervisord
网友评论