溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

管理ELK進(jìn)程工具: Supervisor &&am

發(fā)布時(shí)間:2020-07-28 12:33:44 來源:網(wǎng)絡(luò) 閱讀:1356 作者:kindy520 欄目:系統(tǒng)運(yùn)維

一、Supervisor簡介

supervisor是一個(gè)Linux/Unix系統(tǒng)上的進(jìn)程監(jiān)控工具,supervisor是一個(gè)Python開發(fā)的通用的進(jìn)程管理程序,可以管理和監(jiān)控Linux上面的進(jìn)程,能將一個(gè)普通的命令行進(jìn)程變?yōu)楹笈_(tái)daemon,并監(jiān)控進(jìn)程狀態(tài),異常退出時(shí)能自動(dòng)重啟。不過同daemontools一樣,它不能監(jiān)控daemon進(jìn)程

1. yum安裝supervisor

    yum install -y epel-release supervisor 

2. 生成配置文件

    echo_supervisord_conf > /etc/supervisord.conf

3. 編輯配置文件
```
    [unix_http_server]
file=/var/run/supervisor/supervisor.sock   ; (the path to the socket file)
[inet_http_server]         ; inet (TCP) server disabled by default
port=*:9001        ; (ip_address:port specifier, *:port for all iface)
[supervisord]
logfile=/var/log/supervisor/supervisord.log  ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10          ; (num of main logfile rotation backups;default 10)
loglevel=info               ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false              ; (start in foreground if true;default false)
minfds=1024                 ; (min. avail startup file descriptors;default 1024)
minprocs=200                ; (min. avail process descriptors;default 200)
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL  for a unix socket
[include]
files = /etc/supervisord.d/*.conf                    ; 注意寫絕對路徑
```
4. 啟動(dòng)supervisord,設(shè)置開機(jī)啟動(dòng)

    supervisord -c /etc/supervisord.conf

    echo "supervisord -c /etc/supervisord.conf" >> /etc/rc.local
    chmod +x /etc/rc.d/rc.local

5. 訪問supervisor的web界面

    http://ip:9001

6. 添加管理進(jìn)程的配置文件,存放在/etc/supervisord.d/ 
```
    [program:elasticsearch]
command = /usr/local/elasticsearch/bin/elasticsearch            ; 程序的啟動(dòng)目錄
user=elk                               ; 使用什么用戶啟動(dòng)
priority=10                            ; 優(yōu)先級(jí),默認(rèn)999 數(shù)字越小優(yōu)先級(jí)越高
numprocs=1                             ; 啟動(dòng)幾個(gè)進(jìn)程
autostart=true                         ; 隨著supervisord的啟動(dòng)而啟動(dòng)
autorestart=true                       ; 異常退出后,自動(dòng)重啟
startrestries=3                        ; 啟動(dòng)失敗時(shí)的最多重試次數(shù)
redirect_stderr=true                   ; 重定向stderr到stdout
stdout_logfile_maxbytes = 20MB         ; stdout 日志文件大小,默認(rèn) 50MB
stdout_logfile_backups = 10            ; stdout 日志文件備份數(shù)
stdout_logfile = /home/logs/supervisor/elasticsearch_stdout.log   ; 日志文件
```
展示圖:

管理ELK進(jìn)程工具: Supervisor &&am

二、Cesi 簡介

CeSi 是 Supervisor 官方推薦的集中化管理 Supervisor 實(shí)例的 Web UI,該工具是用 Python 編寫,基于 Flask Web 框架 。

Superviosr 自帶的 Web UI 不支持跨機(jī)器管理 
Supervisor 進(jìn)程,功能比較簡單,通過 CeSi 可以集中管理各個(gè)服務(wù)器節(jié)點(diǎn)的進(jìn)程,在 Web 界面就可以輕松管理各個(gè)服務(wù)的啟動(dòng)、關(guān)閉、重啟等,很方便使用。

1. 安裝依賴

    yum install -y git wget epel-release python34 python34-pip npm bzip2

    npm install -g n (升級(jí)node到最新版)
    n latest
    curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
    yum install -y yarn (安裝yarn)

2. 安裝cesi (參考官網(wǎng)教程)
```
    export CESI_SETUP_PATH=/opt/cesi

mkdir ${CESI_SETUP_PATH}
cd ${CESI_SETUP_PATH}
wget https://github.com/gamegos/cesi/releases/download/v2.6.7/cesi-extended.tar.gz -O cesi.tar.gz
tar -xvf cesi.tar.gz
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
deactivate
cd ${CESI_SETUP_PATH}/cesi/ui
yarn install
yarn build

注意修改/etc/cesi.conf.toml 和 /etc/systemd/system/cesi.service

cp ${CESI_SETUP_PATH}/defaults/cesi.conf.toml /etc/cesi.conf.toml
vi /etc/cesi.conf.toml
[cesi]
database = "sqlite:///users.db" # Relative path
activity_log = "activity.log" # File path for CeSI logs
admin_username = "admin" # Username of admin user
admin_password = "admin" # Password of admin user
[[nodes]]
name = "node1"
environment = ""
username = ""
password = ""
host = "172.16.16.75"
port = "9001"
[[nodes]]
name = "node2"
environment = ""
username = "admin"
password = "btr2014"
host = "172.16.8.12"
port = "9001"
cp ${CESI_SETUP_PATH}/defaults/cesi.service /etc/systemd/system/cesi.service
vi /etc/systemd/system/cesi.service
[Unit]
Description=cesi
[Service]
Environment=
ExecStart=/root/cesi/venv/bin/python3 /root/cesi/cesi/run.py --config-file /etc/cesi.conf.toml
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=TERM
User=root
WorkingDirectory=/root/cesi
Restart=on-failure
[Install]
WantedBy=multi-user.target

systemctl daemon-reload
systemctl start cesi


    展示圖:
    ![](https://s1.51cto.com/images/blog/201903/05/398eda22207b54bd888ba09ebcfe03d3.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI