20190807181540.jpg

1.环境说明

角色 主机名 IP 系统版本
sa管理机 sy-gmh-sa-vm3.shaoyan.pro 192.168.168.3 CentOS Linux release 7.6.1810 (Core)

这里先徒手安装,方便介绍,后面会整理到初始化系统脚本里面,一键安装配置好。

2.安装supervisor

使用pip工具安装:

  1. [root@sy-gmh-sa-vm3:~]# pip install supervisor
  2. DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
  3. Looking in indexes: https://pypi.doubanio.com/simple
  4. Collecting supervisor
  5. Downloading https://pypi.doubanio.com/packages/3f/1c/78026a80b8ff35e7c14adb331efb28e6ff2964dbae7e8bd9c52ef7c377a0/supervisor-4.0.3-py2.py3-none-any.whl (296kB)
  6. |████████████████████████████████| 296kB 47kB/s
  7. Collecting meld3>=1.0.0 (from supervisor)
  8. Downloading https://pypi.doubanio.com/packages/b6/ae/e6d731e4b9661642c1b20591d8054855bb5b8281cbfa18f561c2edd783f7/meld3-1.0.2-py2.py3-none-any.whl
  9. Installing collected packages: meld3, supervisor
  10. Successfully installed meld3-1.0.2 supervisor-4.0.3

如果 pip 工具没有安装上,那就安装一下:

  1. [root@sy-gmh-sa-vm3:~]# pip --version
  2. pip 19.1.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)
  3. # 方法一:通过yum 安装:
  4. rpm -ivh http://mirrors.163.com/centos/7/extras/x86_64/Packages/epel-release-7-11.noarch.rpm
  5. yum install python-pip
  6. # 方法二:通过脚本安装:
  7. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  8. python get-pip.py

如果你有内部pypi源,可以指定通过它安装噢。用法:

  1. pip install -i http://pypi.shaoyan.pro/simple --trusted-host pypi.shaoyan.pro

3.配置supervisor

  1. [root@sy-gmh-sa-vm3:~]# mkdir /etc/supervisor.d/ # 创建目录用来存放:自定义的配置
  2. [root@sy-gmh-sa-vm3:~]# vim /etc/supervisord.conf
  3. [root@sy-gmh-sa-vm3:~]# egrep -v ";|^$" /etc/supervisord.conf
  4. [unix_http_server]
  5. [supervisord]
  6. [rpcinterface:supervisor]
  7. supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
  8. [supervisorctl]
  9. [include]
  10. files = /etc/supervisor.d/*.ini
  11. [root@sy-gmh-sa-vm3:~]# supervisord
  12. /usr/lib/python2.7/site-packages/supervisor/options.py:471: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
  13. 'Supervisord is running as root and it is searching '
  14. [root@sy-gmh-sa-vm3:~]# ps -ef |grep supervisord |grep -v grep
  15. root 11317 1 0 09:20 ? 00:00:00 /bin/python /usr/bin/supervisord

4.使用supervisor

  1. [root@sy-gmh-sa-vm3:~]# supervisorctl
  2. supervisor>