MySQL master-slave plus keepalive in production system applications (Zabbix)

Source: Internet
Author: User

Our production platform used Zabbix,zabbix database is MySQL, and the data volume is relatively large, each month produced data files more than 10G, after the "MySQL master and slave data plus keepalive" drill, with the production system to apply the conditions, The Zabbix (open source monitoring platform) practiced hand is suitable for the production system.

The original system is a stand-alone system, Zabbix uses the linux+apache+mysql+php environment, the typical lamp, now we need to do is to turn MySQL into a master-slave dual machine, and in the master-slave dual-machine installation configuration keepalived, and finally The PHP program to connect the MySQL IP address to the master-slave dual-machine VIP.

Current network Zabbix Environment (stand-alone):

Zabbix Server: 10.0.0.111

MySQL server: 10.0.0.111

First, refer to "MySQL Master-Slave synchronization (unidirectional synchronization and Bidirectional synchronization)" this blog. Select an intranet a more idle server 10.0.0.10 as another MySQL server, install MySQL on this server, and then install the configuration keepalived on these 2 servers. Select an intranet free IP address as the VIP.

The modified system environment is as follows (master-slave Dual-machine):

Zabbix server: 10.0.0.111 (PHP +apache)

mysql-01:10.0.0.111 (Deployment Keepalived+mysql)

mysql-02:10.0.0.10 (Deployment Keepalived+mysql)

vip:10.0.0.15 (point PHP to VIP)

Installation detailed procedure is the reference "MySQL master-Slave synchronization (one-way synchronization and Bidirectional synchronization)" and "MySQL master and slave data plus keepalive" operation, here is not detailed, the process encountered the following problems, record down memo:

1, configure the master-slave synchronization of MySQL, configuration is bidirectional synchronization;

2, in the configuration file/etc/keepalived/keepalived.conf,

..........

Vrrp_instance Vi_1 {
State Master
Interface Em1

...............

The network interface needs to be modified according to the actual network card used.

3. Modify the/usr/share/zabbix/conf/zabbix.conf.php file $db[' server ' parameter on the Zabbix server:

$DB [' SERVER '] = ' 10.0.0.15 ';

This parameter does not need to restart the application after the modification, the direct effect.


Test process:

1, in MySql-01 will mysqld service stop:

Service Mysqld Stop

Use IP addr to view IP address in MySql-01, MySql-02, VIP address 10.0.0.15 switch from MySql-01 to MySql-02. Access to the Zabbix app via the Web interface is unaffected, indicating a smooth switchover success. At this point, the keepalived service for viewing MySql-01 is turned off:

#service keepalived Status
Keepalived is stopped

2, Recovery services. To turn mysqld on in the MYSQL-01 server:

Service mysqld Start

To open the Keepalived service:

Service keepalived Start

At this time the VIP or on the MySql-02, if you want to cut the VIP back to MySql-01, then perform service keepalived restart on MySql-02, because the process of restarting the Keepalived service is to first shut down and then start, The keepalived of another host will take over the VIP when it is closed, thus achieving the purpose of switching.

This article is from the "Yuweibing Technology blog" blog, make sure to keep this source http://yuweibing.blog.51cto.com/3879355/1745234

MySQL master-slave plus keepalive in production system applications (Zabbix)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.