Supervisor of ELK server program start and stop automatic management tool

说说痛点,elasticsearch,kafka,zookeeper,kibana,elasticsearch-head,logstash,logstash是需要经常重启的,你上了点过滤规则或者修改点啥的,每次都尼玛杀进程,再nohup ,还看不到日志,这太不符合人性了,人性的优点之一就是懒惰。打开web 界面,点一下鼠标解决问题岂不是棒棒哒,还能通过web 界面看看后台日志,perfect!子曰:“工欲善其事,必先利其器。” 开搞!

Introduction to Supervisor:
Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.
Supervisor is a c/s architecture system that allows users to manage and monitor certain processes on Unix-like systems Number of programs running;
do you have many programs installed from source? How do you start these programs? nohup is it? or screen? Or & Backstage? Or do you practice magic by yourself and write a bunch of startup scripts? Even so, is your program down due to bugs or other reasons? Or do you need to start it manually?
When you get to know the supervisor, you will know what it means to sharpen the knife without accidentally chopping wood! What niubility functions does supervisor have?
1. Unified management of program start, stop, and restart, providing web and command line methods;
2. Automatically pull up when the program is down;
3. You can specify the startup user, which is very safe in terms of security;
4. You can define group restart and start;
5 , The web interface management is very convenient, after all, who doesn't want to do things with a click of a mouse?

#supervisor is a program written in Python, so it can be installed through easy_install or pip, which is up to you;
#I am used to using pip to install things, so I use easy_install to install pip
easy_install pip #After
that, install supervisor through pip
pip install supervisor

#Create a working directory and a configuration file directory for supervisor and give the directory 755 permissions;
mkdir -m 755 -p /etc/supervisor/conf.d

#Generate the default configuration file through the echo_supervisord_conf command provided by supervisor,
echo_supervisord_conf > /etc/supervisor/supervisord.conf #Check
whether the configuration file is generated through the cat command;
cat /etc/supervisor/supervisord.conf |grep -v "^;" | grep -v "^$"
[unix_http_server]
file=/tmp/supervisor.sock ; the path to the socket file
[inet_http_server] ; inet (TCP) server disabled by default #Whether to open the web management interface
port=ip:9001 ; ip_address :port specifier, :port for all iface #web access port;
username=user ; default is no username (open server) #web interface access username;
password=password ; default is no password (open server) #web interface access password ;
[supervisord]
logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log #log storage path
logfile_maxbytes=50MB ; max main logfile bytes b4 rotation; default 50MB #log size
logfile_backups=10 ; # of main logfile backups; 0 means none, default 10 #how many times the log is rolled
loglevel=info ; log level; default info; others: debug ,warn,trace #log level
pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid #pid file
nodaemon=false ; start in foreground if true; default false #Whether to start in the foreground, the default is false, that is Start by daemon
minfds=1024 ; min. avail startup file descriptors; default 1024 #The minimum number of file descriptors that can be opened, the default is 1024
minprocs=200 ; min. avail process descriptors; default 200 #The minimum number of processes that can be opened value, default 200
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket #Connect supervisord through UNIX socket, the path is consistent with the file in the unix_http_server section
[include]
files =/etc/supervisor/conf. d/
.conf #Introduce additional configuration files

#The configuration file placed in conf
[program:logstash-pack] # is the configuration parameter of the managed process, xx is the name of the process, when the program is managed by supervisorctl and the web interface use
command = /usr/local/logstash/bin/ logstash -f /usr/local/logstash/config/logstashx.conf
[program:kafka]
command = /usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties
[program:kibana] command = /usr/local /
kibana/bin/kibana
[ program:elasticsearch] command = /usr/local/elasticsearch/bin/elasticsearch autostart = true # The managed program also automatically starts autorestart when supervisord starts = true #Automatic restart after program exit, optional value: [unexpected,true,false], the default is unexpected, which means that the process will restart after being killed accidentally startsecs = 5 #If there is no abnormal exit after 5 seconds of startup, it means that the process starts normally Now , the default is 1 second startretries = 3 #Startup failure and retry several times, the default is 3 times user = elk #Start the user This is for security reasons






redirect_stderr = true #Redirect stderr to stdout, default false
stdout_logfile=/data/logs/elk/logstash-shipper-std.log #stdout log file size, default 50MB Need to manually create a directory and give elk permission
stderr_logfile=/ data/logs/elk/logstash-shipper-err.log #stdout The number of log file backups, the default is 10. You need to manually create a directory and give elk permission

#The configuration file is done, you can start the supervisor
supervisord -c /etc/supervisor/supervisord.conf

#Supervisor management is managed through supervisorctl, which can be managed through commands with parameters, such as: suervervisorctl shutdown, or by entering interactive mode, such as supervisorctl Enter, and then execute the command; #Refer to the first line
of the started program
supervisor status
is a custom name; the second is the running status, the third is the pid, and the third line is the startup time
Supervisor of ELK server program start and stop automatic management tool
#close supervisor
supervisorctl shutdown
#Reload supervisor, reload supervisor, which is equivalent to restarting the supervisor service, inside The service will also be restarted with
supervisor reload
#Add/delete services to be managed, when you modify the configuration file, you can upgrade directly through the update method to
supervisor update

#Start all services or a single service by command
supervisorctl start all
supervisorctl start service_name #Close
the service
supervisorctl stop all
supervisorctl stop service_name #Restart
all services or a single service
supervisorctl restart all
supervistorctl restart service_name Look at the
picture and talk web management interface:
Supervisor of ELK server program start and stop automatic management tool

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324739191&siteId=291194637