Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Database \ Process monitoring tools Supervisor start MongoDB     - Linux cd command Detailed (Linux)

- Cacti installation deployment under CentOS 6.6 (Server)

- Linux Firewall Builder shorewall (Linux)

- How to install Ubuntu applications Device 7 (Linux)

- Qt signals and slots mechanism (Programming)

- Terminal multiplexing tool tmux use (Linux)

- Elaborate .NET Multithreading: Using Task (Programming)

- To compile and install Redis Linux and master-slave replication configuration (Database)

- CentOS installed JDK8 (Linux)

- Ubuntu will be written in a command file, executable file, source command (Linux)

- Apache Mina framework Practice (Programming)

- ORA-00020: No more process state objects available (Database)

- Parts of the partition is not recognized after Debian mount mobile hard disk (Linux)

- Mongo-connector integrated MongoD to achieve incremental Solr index (Server)

- GNU Linux use diff to generate a patch with the patch (Linux)

- Create the best introductory tutorial REST API (Linux)

- Java, extends and implements Usage (Programming)

- Use dump restore mode fast backup and recovery system FreeBSD (Linux)

- CentOS7 install and configure Nagios (Server)

- Yii PHP Framework Getting Started tutorial (Linux)

  Process monitoring tools Supervisor start MongoDB
  Add Date : 2018-11-21      
  A,what is a supervisor

Superviosr is the process on a UNIX-like system monitoring tools. Supervisor is a Python developer of client / server system that can manage and monitor * nix above process. However, like daemontools, it can not monitor the daemon process

Official website: http: //supervisord.org/

B,why use two supervisor

 Deployment is simple: Why simple? Because when we usually manage linux process, in general, we need to write your own script process to achieve a start / stop / restart / reload function, and then thrown into /etc/init.d/ below. There are many good places to do so, first we have to write the script, which is a very time-consuming. Second, when the process hang time, linux does not automatically restart it, you want to automatically restart, then we need to write a script to restart the monitor. And, supervisor can be the perfect solution to these problems. Well, how to solve it, in fact, supervisor management process, is through the fork / exec the way these processes are managed, as a supervisor of the child process to start. In this case, as long as we in the supervisor's configuration file, the path you want to manage the process executable file written opinions OK. This will save us as linux management process when the write control script trouble. Second, the management process as a subprocess supervisor when the child process hang when the parent can get the child to hang accurate information, so of course it can hang on the child process to automatically restart, of course, restart or not restart, it also depends on your configuration file there are wood have set autostart = true, this is something.

Centralized management: supervisor management process, process group information, all written in a ini file format was OK. And, when we manage supervisor can be managed locally or remotely manage and supervisor provides a web interface, we can be on the web interface to monitor, manage processes. Of course, local, remote, and when the web management interface to call the supervisor of xml_rpc, this is something.

supervisor management process, process group information, all written in a ini file format was OK. And, when we manage supervisor can be managed locally or remotely manage and supervisor provides a web interface, we can be on the web interface to monitor, manage processes. Of course, local, remote, and when the web management interface to call the supervisor of xml_rpc, this is something.


Why say it accurate? Because linux feedback on the state of the process, sometimes less accurate. Why is not accurate? The landlord does not know ah, official documents is to say, tell the landlord knows about it, appreciate it. The supervisor monitoring the child process, the child process state was undoubtedly accurate.

Process group

supervisor can set the unified management of the process, that is to say we need to manage the process can be written to a group inside, and then we have this group as a managed object, such as start, stop, restart, etc. operations. The linux system is no such function, we want to stop a process, only one by one to stop, or to write their own scripts to batch is stopped.


Everyone knows that linux process, especially the process of listening ports under 1024, under the general user in most cases, can not be controlled. Want to control it, you must have root privileges. The supervisor provides a function for supervisord or each child, set a non-root user, the user can manage it corresponds to the process.

But this function, do not see everyone with their environment a

C,supervisor Structure

Supervisord: main process responsible for managing the process server, it creates a configuration file to specify the number of child processes applications throughout the life cycle management of the child process, the process of crash restart, changes to the process to send event notification. While built-in web server and XML-RPC Interface, easy process management.

Supervisorctl: management client, through the command line to send a message to supervisord, you can view the process status, load profiles, start and stop the process, view the process standard output and error, remote operation.

Web server: superviosr provides web server functionality available through web control process.

XML-RPC interface: XML-RPC interface that provides XML-RPC services sub-processes management, monitoring

D, installation and deployment

In order to unify python and various versions of dependent libraries, instead of the system recommended python pyrun be deployed, and the need to install pip in pyrun, to download the installation package pkg directory, run the following command:

/ Data / pyrun / bin / pip install --no-index -f pkg meld3 == 1.0.0

/ Data / pyrun / bin / pip install --no-index -f pkg elementtree == 1.2.6-20050316

/ Data / pyrun / bin / pip install --no-index -f pkg supervisor == 3.2.0

If the machine can not be networked, you can install the source code:

1) dependent python, python version can be upgraded

2) require third-party packages meld3, setuptools, ElementTree

setuptools (latest) from http://pypi.python.org/pypi/setuptools.

meld3 (latest) from http://www.plope.com/software/meld3/.

elementtree (latest) from http://effbot.org/downloads#elementtree.

3) root extract the related packages, batch installation.

E, configuration

Supervisor configuration file named supervisord.conf, it supervisord (Supervisor main service command) and supervisorctl (Supervisor monitoring and management commands) to provide a configuration option. Supervisor does not require the storage location of the configuration file supervisord.conf, Supervisor service startup by default in:

$ CWD / supervisord.conf
$ CWD / etc / supervisord.conf
These directory locations to find the configuration file supervisord.conf.

Supervisor also provide parameters "-c" to specify the directory path to the configuration file.
Terminal input "echo_supervisord_conf" command to view the contents of the default configuration of the Supervisor.

Generates a default configuration file:

echo_supervisord_conf> /etc/supervisord.conf

supervisor relatively simple configuration, the following configuration items to meet basic needs, more configuration items, please refer to the official configuration instructions

nodeamon = false # deamon way to start the process

[Supervisorctl] # system default configuration items

Port and user password [inet_http_server] #web management page
port = 8080

username = user

password = pwd

[Rpcinterface: supervisor] # xml-rpc Interface configuration
supervisor.rpcinterface_factory = supervisor.rpcinterface: make_main_rpcinterface

[Program: mongodb]

command = / data1 / mongodb_2.4.7_build / mongod -config /data1/mongodbrs/config/mongodb.conf --directoryperdb --quiet --profile 1 --slowms 1000 --noprealloc --shardsvr

directory = / data1 / mongodb_2.4.7_build

autostart = false

user = root

Note that the default configuration file last few lines

You can add a directory within supervisord.d at supervisord.conf file in the same directory .ini configuration file separately


files = supervisord.d / *. ini

Note: The process being monitored to run in non-daemon mode to mongodb, for example, need to remove mongodb process startup command parameters in the --fork


# Start supervisor

  python / usr / bin / supervisord

# Boot process monitoring

    supervisorctl start all

# Shutdown process monitoring

      supervisorctl stop all

# Check status

      supervisorctl status

# Reload the configuration file:

supervisorctl reload

In fact, by supervisorctl supervisor can open a command line console, and then enter the watch can be viewed with the help of the command, and then help + command to view the specific features of each command

G, web control

Arranged in supervisord.conf in [inet_http_server],


port = #IP and bound port

username = admin # Name Administrator

password = 123456 # administrator password

Thus, the input configuration write address and port number in the browser, enter the configured username and password, you can see the web-based console interface. From this, you can look supervisor monitoring> information, you can view logs and other processes.

Browser to: http: // 8080 /, (where IP supervisor for the deployment of IP)

H, Monitoring Alarms

If demand is automatically pulled crash process, through the command line to manage the process, more than enough content. supervisor 3.0 version introduces event, we take advantage of this feature to achieve real-time monitoring process status and alarms.

First, look at the event supervisor provided, supervisor of the child process through application management, monitoring program also runs as a child process, stdin child process, stdout, stderr have been redirected. Event processing is as follows:

Listener as a child process of writing to stdout READY \ n
When an event occurs, supervisor in the Ready state will choose a child process stdin written to the event content
Write OK \ n or FAIL \ n after the event is completed child process to handle stdout, feedback results
Repeat the above operation
Various types of events supervisor provided, comprising: a process status event, supervisor state event, timed events, xmlrpc call the event, the process log events, and so on. We focus on the process of state-related events. supervisor of the process is defined as a state in each state switch will trigger the corresponding event.

Monitoring program can use any language, as long as supervisor of the agreement properly formatted event messages can be processed. Recommended use python as the monitoring program, supervisor module provides a childutils handler makes writing easier.
- MySQL 5.6 use GTIDs build the master database (Database)
- OpenSSL: implementation creates a private CA, certificate signing request Explanation (Server)
- CentOS 6.3 compile and install LNMP environment (Server)
- Zabbix monitoring different versions of RAID installation and monitoring and MySQL master-slave monitor (Server)
- MySQL EXPLAIN SQL output description (Database)
- Varnish configuration language VCL and its built-in variables (Server)
- A summary of Java multi-threaded programming - acquaintance multithreading (Programming)
- Linux Shell Scripting multithreading (Programming)
- Linux data recovery software efficiently practical application extundelete (Linux)
- Linux performance optimization features Tuned and ktune (Linux)
- Boost - Memory Management - smart pointers (Programming)
- Quickly locate the mistakes by gdb location (Programming)
- Resolve the host via KVM console can not connect clients (Linux)
- CentOS 6.x Basic System Optimization after installation (Linux)
- To remove those IP is prohibited Fail2ban on CentOS 6/7 (Server)
- Linux systems for entry-learning - Install Go language in Linux (Linux)
- Several Ceph performance optimization of new methods and ideas (2015 SH Ceph Day after flu reference) (Server)
- Use mdadm tool to create software RAID 0 (Linux)
- Oracle Database asynchronous IO cause slow query response (Database)
- Run two MySQL service on one server (Database)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.