Requirement scenario
Using the proxy server HAProxy to load balance Mysql is a common solution. To improve the availability, when there is a problem with Mysql, such as server failure, or data replication Interrupted, it is best to let HAProxy know immediately, and then stop forwarding requests to it
HAProxy How do I know if there is a problem with Mysql?
Solutions
(1) Write a shell script to check the state of mysql, and then output the result, for example, when the status is normal, return status code 200 and correct information, otherwise return status code 503 and Error message
(2) Implement an HTTP service. After the request is connected, call the above check script and return the check result.
(3) HAProxy accesses the HTTP service according to the returned result information. To determine if this mysql is available
How to quickly and easily implement an HTTP service that can call shell scripts?
The more general solution is xinetd
xinetd is a Linux daemon, fully called extended interent daemon, extended network daemon
xinetd can open a port and wait for connection You can tell xinetd which script to run. When a connection comes in, xinetd will execute the script and then directly return the contents of the script output
HAProxy -> xinetd -> mysql-check script, HAProxy will get MySQL status information
xinetd configuration case
The following implementation of a simple xinetd example, open 9200 port, return a test script Output content
If there is no xinetd on the machine, install it first. Under centos7, you can use the command yum install xinetd
(1) test script
#!/bin/bash
echo `uptime
First, temporarily enable the network card and configure the IP: # ifconfig -a /* View all network a
without splitting the hard disk Installing Linux is a bit scary for novices: partitions and some ma
A summaryIn order to manage all server accounts and passwords in the enterprise, you can use the Wi
for Windows 7 computers Microsoft will allow its computer OEMs and their system co-developers to d
Software-only dual-system hot standby solution in-depth analysis
Linux decompression command Daquan /linux package compression command Daquan
Linux server performance optimization process
How to implement DNS service under Linux
The service does not support the solution of chkconfig
Automotive industry dealing with the Linux operating system
Seven highly damaging Linux system commands
How to configure the wireless network card under Linux system
Let rogue software roll out your system completely
Win10 cancels the forced upgrade Win7/Win8.1 users can choose
Win7 system boot prompt LDrvPro64.sys can not verify the digital signature solution
How does win7 not show system disk partition? win7 hidden disk partition
Win8.1 app store can not download and update the app how to do
WinXP restarts to the desktop after a sudden black screen repair program
Win8 broadband connection error 720 can not establish a remote computer connection How to solve