1. 程式人生 > >supervisor-monitor程序集中管理部署

supervisor-monitor程序集中管理部署

寫在前面:在網易蜂巢裡面儲存了一個docker映象檔案,可以直接使用,需要調整一些內容!

 

https://github.com/mlazarov/supervisord-monitor?spm=a2c4e.11153940.blogcont556762.23.2ea563274Uwu6E

一: 在以上連線中下載最新的supervisord-monitor 的程式碼檔案(PHP)

二:先安裝nginx和php-fpm環境(可以使用yum和原始碼安裝方式進行安裝,以下事列有原始碼方式展示)

2.1:原始碼檔案在[email protected] 中的百度雲盤中儲存(可根據情況下載最新版本)

2.2:安裝nginx

[[email protected] ~]# tar zxvf nginx-1.6.0.tar.gz
[[email protected] ~]# cd nginx-1.6.0
[[email protected] ~]# ./configure --prefix=/usr/local/nginx \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_dav_module \
--with-http_flv_module \ --with-http_realip_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-mail \ --with-mail_ssl_module \ --with-debug \ --http-client-body-temp-path=/var/tmp/nginx/client \ --http-proxy-temp-path=/var/tmp/nginx/proxy \ --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ --http-scgi-temp-path=/var/tmp/nginx/scgi \ --with-http_flv_module \ --with-http_mp4_module \ --with-ipv6 \ --with-openssl=/opt/cpnginx/openssl/ [[email protected] ~]# make && make install  
nginx 預設安裝即可

2.3 安裝php-fpm (直接安裝php-fpm 會提示需要安裝common,直接安裝即可)

[[email protected] ~]# rpm -ivh php-fpm-5.3.3-49.el6.x86_64.rpm 
[[email protected] ~]# rpm -ivh php-common-5.3.3-49.el6.x86_64.rpm

檢視php-fpm的預設檔案

[[email protected] ~]# vim /etc/php-fpm.d/www.conf
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
[[email protected] ~]# services php-fpm start

檢視是否正常啟動

[[email protected] ~]# ss -tanlp | grep 9000

2.4,nginx配置

啟動nginx看是否可以正常訪問nginx的預設網站

(Welcome to nginx on Fedora ! )

配置nginx的配置檔案可以在nginx.conf 中直接新增,或者在conf資料夾中寫一個自定義的配置檔案,

新增內容如下所示(未註釋的內容如下):

[[email protected] ~]# vim nginx.conf
#設定使用的使用者
user nginx;
worker_processes 1;
#開啟日誌記錄
error_log logs/error.log info;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;

sendfile on;
keepalive_timeout 65;

server {
listen 80;
server_name super.izejin.com;
root /usr/share/nginx/html/public_html;
index index.php index.html;

location /control/ {
index index.php;
rewrite /(.*)$ /index.php?$1 last;
}
location ~ \.php$ {
root /usr/share/nginx/html/public_html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#新增nginx驗證使用者名稱密碼
location / {
index index.php index.html;
auth_basic "Basic Auth";
auth_basic_user_file "/usr/local/nginx/conf/.htpasswd";
}
}
}

[[email protected] ~]# /usr/local/nginx/sbin/nginx -s reload

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

2.5 安裝 supervisor-monitor

[[email protected] ~]# unzip -q supervisord-monitor-master-new.zip -d /usr/share/nginx/html/
[[email protected] ~]# cd /usr/share/nginx/html 
[[email protected] ~]# cp /application/config/supervisor.php.example /application/config/supervisor.php

[[email protected] ~]# vim supervisor.php
$config['supervisor_servers'] = array(
'192.168.1.90' => array(
'url' => 'http://192.168.1.2/RPC2',
'port' => '9001',
'username' => 'user',
'password' => '123'
),
);

直接訪問部署supervisor-monitor所部署的伺服器

 

添加了nginx的驗證之後

 

問題記錄:

1,新增nginx驗證之後,在訪問網頁的時候可能會提示輸入使用者名稱密碼之後網頁報錯不能訪問,

則需要nginx日誌中開啟記錄日誌,檢視具體原因,

設定nginx配置檔案中user 使用者為nginx。

 

2,如遇 UNKNOWN_METHOD 故障報錯 則需要在被控端的supervisor 的配置檔案中新增 一下內容

[rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

3,如遇報錯內容為:

Did not receive a '200 OK' response from remote server. (HTTP/1.0 401 Unauthorized)

處理方法:檢查防火牆和網路連線性

可以參照網上阿里雲的一個文件:

https://yq.aliyun.com/articles/556762?spm=a2c4e.11154873.tagmain.79.279d27fd3QP6M4