In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
First, based on the disadvantages of ordinary master-slave replication, MHA can automatically complete the database failover operation within 10 to 30 seconds, and in the process of failover, MHA can ensure the consistency of data to the greatest extent to achieve high availability in the real sense.
II. Structure
III. Software introduction
MHA software consists of two parts, the Manager toolkit and the Node toolkit.
Manager toolkit
Masterha_check_ssh # check the ssh- key ^ of MHA
Masterha_check_repl # check master-slave replication
Masterha_manger # launch MHA
Masterha_check_status # detects the running status of MHA ^
Masterha_mast er_monitor # check whether master is down
Masterha_mast er_switch # Manual failover-
Masterha_conf_host # add server double interest one manually
Masterha_secondary_check # establish a TCP connection from a remote server v
Masterha_stop # stop MHA
The Node toolkit mainly includes the following tools:
Save_binary_1ogs # saves the binlog of the down master
Apply_diff_relay_logs # identifies differences in relay log
Filter_mysqlbinlog # prevent rollback event-MHA no longer uses this tool
Purge_relay_logs # clearing relay log one does not block SQL threads
Fourth, the advantages of MHA
1. Automatic failover
2. There is no data inconsistency when the main database crashes.
3. There is no need to make major changes to the current mysql environment
4. There is no need to add additional servers
5. Excellent performance, able to work with semi-synchronous and asynchronous replication frameworks
6. As long as the storage engine mha supported by replication supports it.
5. Environmental description
Db01 host (master)
[root@db01 ~] # cat / etc/redhat-release
CentOS release 6.9 (Final)
[root@db01 ~] # uname-r
2.6.32-696.el6.x86_64
[root@db01 ~] # / etc/init.d/iptables status
Iptables: Firewall is not running.
[root@db01 ~] # getenforce
Disabled
[root@db01] # hostname-I
10.0.0.51 172.16.1.51
Db02 host (slave1)
[root@db02 ~] # cat / etc/redhat-release
CentOS release 6.9 (Final)
[root@db02 ~] # uname-r
2.6.32-696.el6.x86_64
[root@db02 ~] # / etc/init.d/iptables status
Iptables: Firewall is not running.
[root@db02 ~] # getenforce
Disabled
[root@db02] # hostname-I
10.0.0.52 172.16.1.52
Db03 hosts (slave1,MHA Manages, Atlas nodes)
[root@db03 ~] # cat / etc/redhat-release
CentOS release 6.9 (Final)
[root@db03 ~] # uname-r
2.6.32-696.el6.x86_64
[root@db03 ~] # / etc/init.d/iptables status
Iptables: Firewall is not running.
[root@db03 ~] # getenforce
Disabled
[root@db03] # hostname-I
10.0.0.53 172.16.1.53
Mysql 5.6.38 is newly installed on all three servers:
[root@db01] # mysql-- version
Mysql Ver 14.14 Distrib 5.6.38, for Linux (x86 / 64) using EditLine wrapper
Master-slave replication configuration based on GTID
Binlog should be enabled for both the master library and the slave library
The master library and slave library server-id must be different
There must be a master-slave replication user.
5.1. Configure master-slave replication
Db01 my.cnf file
[mysqld]
Basedir=/application/mysql
Datadir=/application/mysql/data
Socket=/tmp/mysql.sock
Log-error=/var/log/mysql.log
Log-bin=/application/mysql/mysql-bin
Binlog_format=row
Secure-file-priv=/tmp
Server-id=51
Skip-name-resolve # skip domain name resolution
Gtid-mode=on # enables the gtid type, otherwise it is a normal replication schema
Enforce-gtid-consistency=true # enforces consistency in GTID
Whether log-slave-updates=1 # slave updates are logged (5.6 required)
Relay_log_purge = 0
[mysql]
Socket=/tmp/mysql.sock
Db02 my.cnf file
[root@db02 ~] # cat / etc/my.cnf
[mysqld]
Basedir=/application/mysql
Datadir=/application/mysql/data
Socket=/tmp/mysql.sock
Log-error=/var/log/mysql.log
Log-bin=/application/mysql/mysql-bin
Binlog_format=row
Secure-file-priv=/tmp
Server-id=52
Skip-name-resolve
Gtid-mode=on
Enforce-gtid-consistency=true
Log-slave-updates=1
Relay_log_purge = 0
[mysql]
Socket=/tmp/mysql.sock
Db03 my.cnf file
[root@db03 ~] # cat / etc/my.cnf
[mysqld]
Basedir=/application/mysql
Datadir=/application/mysql/data
Socket=/tmp/mysql.sock
Log-error=/var/log/mysql.log
Log-bin=/application/mysql/mysql-bin
Binlog_format=row
Secure-file-priv=/tmp
Server-id=53
Skip-name-resolve
Gtid-mode=on
Enforce-gtid-consistency=true
Log-slave-updates=1
Relay_log_purge = 0
Skip-name-resolve
[mysql]
Socket=/tmp/mysql.sock
Create replication users (51 as master nodes, 52 and 53 as slaves)
GRANT REPLICATION SLAVE ON *. * TO repl@'172.16.1.%' IDENTIFIED BY '123'
Enable replication from the library
Change master to
Master_host='172.16.1.51'
Master_user='repl'
Master_password='123'
MASTER_AUTO_POSITION=1
Start replication from the library
Start slave
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.