Deploy MySQL high-availability cluster (third-party software + master-slave synchronization)
Mysql-mmm
Clustering: Using multiple servers to provide the same service
Depending on how multiple servers are serviced, they are divided into:
Highly Available clusters: Master (keepalived)
Load Balancing cluster: The average corresponding user's connection request (LVS Haproxy
Nginx
Configuring the main main structure (9/10)
9:
mysql> grant replication Slave on * * to [email protected] "%"
Identified by "123456";
#vim/etc/my.cnf
Server_id=9
Log_bin=master9
binlog_format= "Mixed"
: Wq
#systemctl Stop Mysqld
#systemctl Start mysqld
10
mysql> grant replication Slave on * * to [email protected] "%"
Identified by "123456";
#vim/etc/my.cnf
server_id=10
Log_bin=master10
binlog_format= "Mixed"
Log_slave_updates
: Wq
#systemctl Stop Mysqld
#systemctl Start mysqld
#mysql-uroot-p123456
Mysql>mysql> Change Master to
Master_host= "192.168.4.9", master_user= "PLJ", master_p
Assword= "123456", master_log_file= "master9.000001",
master_log_pos=154;
mysql> start slave;
Mysql>show slave status\g;
9
#mysql-uroot-p123456
Mysql> Change Master to
Master_host= "192.168.4.10", master_user= "PLJ", Master_
Password= "123456", master_log_file= "master10.000001
", master_log_pos=154;
mysql> start slave;
Mysql>show slave status\g;
Configure databases 11 and 12 separately to 10 from the database server
11
Vim/etc/my.cnf
[Mysqld]
server_id=11
: Wq
#systemctl Stop Mysqld
#systemctl Start mysqld
#mysql-uroot-p12345
Mysql>change Master to
Master_host= "192.168.4.10", master_user= "PLJ", Master_
Password= "123456", master_log_file= "master10.000001
", master_log_pos=154;
mysql> start slave;
Mysql>show slave status\g;
12
Vim/etc/my.cnf
[Mysqld]
Server_id=12
: Wq
#systemctl Stop Mysqld
#systemctl Start mysqld
#mysql-uroot-p12345
Mysql>change Master to
Master_host= "192.168.4.10", master_user= "PLJ", Master_
Password= "123456", master_log_file= "master10.000001
", master_log_pos=154;
mysql> start slave;
Mysql>show slave status\g;
MySQL master replication Manager, monitoring, failover
Monitoring service Mmm-monitor run on the monitoring server, responsible for monitoring and
The process of disability transfer work
The agent service Mmm-agent runs on the database server and is responsible for obtaining this
The status information for the machine database server.
1 Installing the MYSQL-MMM software on all hosts
#yum-y Install perl-*
#tar-ZXVF mysql-mmm-2.2.1.tar.gz
#cd mysql-mmm-2.2.1
#make Install
# ls/etc/mysql-mmm/
mmm_agent.conf mmm_agent Service Master configuration file
mmm_common.conf Public File
mmm_mon.conf mmm_monitor Service Master configuration file
2 Modifying the configuration
2.1 Modifying the Mmm_agent service master configuration file on the database server
Vim/etc/mysql-mmm/mmm_agent.conf
Include mmm_common.conf
This host name
: Wq
2.1 Modifying the Mmm_monitor Service Master profile on the monitoring server
Vim/etc/mysql-mmm/mmm_mon.conf
[Email protected] ~]# cat/etc/mysql-
Mmm/mmm_mon.conf
Include mmm_common.conf
<monitor>
ip192.168.4.13
Pid_path/var/run/mmm_mond.pid
bin_path/usr/lib/mysql-mmm/
Status_path
/var/lib/misc/mmm_mond.status
ping_ips192.168.4.9, 192.168.4.10,
192.168.4.11, 192.168.4.12
</monitor>
Monitor_user Monitor
Monitor_password 123456
Debug 0
[Email protected] ~]#
2.3 Modifying public configuration files
[Email protected] ~]# cat/etc/mysql-
Mmm/mmm_common.conf
Active_master_rolewriter
Cluster_interface eth0
Pid_path
/var/run/mmm_agentd.pid
Bin_path
/usr/lib/mysql-mmm/
Replication_user PLJ
Replication_password 123456
Agent_user Agent
Agent_password 123456
ip192.168.4.9
Modemaster
Peermasterdb10
ip192.168.4.10
Modemaster
Peermasterdb9
IP 192.168.4.11
mode slave
IP 192.168.4.12
mode slave
<role writer>
HOSTSMASTERDB9, MASTERDB10
ips192.168.4.100
Modeexclusive
</role>
<role reader>
Hosts Slavedb11, SLAVEDB12
IPS192.168.4.101,
192.168.4.102
modebalanced
</role>
[Email protected] ~]#
2.4 Add the appropriate authorized user to the database server based on the settings on the configuration file
。
Mysql> Grant replication Client on *. * To
[email protected] "%" identified by "123456";
Mysql>grant replication Client,process,super on *.
[email protected] "%" identified by "123456";
Mysql> Select User,host from Mysql.user where user in
("Monitor", "agent");
3 Starting the Service
3.1 Packages that are dependent on all host installation Services running
TAR-ZXVF algorithm-diff-1.1902.tar.gz
CD algorithm-diff-1.1902/
Perl makefile.pl
Make
Make install
Cd..
TAR-ZXVF proc-daemon-0.03.tar.gz
CD proc-daemon-0.03/
Perl makefile.pl
Make
Make install
Cd..
RPM-IVH perl-log-log4perl-1.26-1.el6.rf.noarch.rpm
3.2 Start the proxy service on the data database server 9, 10, 11, 12
A install the program that gets the virtual IP address arp-net
#yum-y Install gcc gcc-c++
1 Gunzip net-arp-1.0.8.tgz
2 TAR-XVF Net-arp-1.0.8.tar
3 CD net-arp-1.0.8/
4 ls
5 Perl makefile.pl
6 Make
7 Make Install
b Start the agent service
#/etc/init.d/mysql-mmm-agent Start
[Email protected] ~]# Netstat-utnalp | grep:9989
TCP 0 0 192.168.4.9:9989 0.0.0.0:*
LISTEN 20723/mmm_agentd
[Email protected] ~]#
Error log file
Cat/var/log/mysql-mmm/mmm_agentd.log
3.3 Start the Monitoring service on the monitoring server
]#/etc/init.d/mysql-mmm-monitor Start
[Email protected] ~]# Netstat-utnalp | grep:9988
TCP 0 0 192.168.4.13:9988 0.0.0.0:*
LISTEN 27642/mmm_mond
[Email protected] ~]#
Log file
/var/log/mysql-mmm/mmm_mond.log
: Wq
Deploy MySQL high-availability cluster (third-party software + master-slave synchronization) mysql-mmm