I. Deployment environment:
VIP: 192.168.3.30 (on the master)
VIP: 192.168.3.32 (on backup)
Interface
|
Master |
Backup |
Description |
Eth1 |
192.168.3.23
|
192.168.3.24 |
Intranet management IP Address |
Eth2 |
192.168.5.23 |
192.168.5.24 |
Heartbeat line |
Eth3 |
192.168.2.23 |
192.168.2.24 |
Internet (for temporary file download) |
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/39/8C/wKioL1O6ayfheYhIAABqcqGfbmo100.png "Title =" heartbeat-01.PNG "alt =" wkiol1o6ayfheyhiaabqcqgfbmo100.png "/>
Ii. Demand Analysis:
The high availability feature of Heartbeat ensures that the dual-master VIP address is online at the same time. Mysql01 is bound to VIP: 192.168.3.30 by default, and mysql02 is bound to 192.168.3.32 by default. Automatic switch after any host goes down.
Iii. Related Configuration:
1) End of mysql01:
Route add-host 192.168.5.24 Dev eth2echo "route add-host 192.168.5.24 Dev eth2">/etc/rc. Local # Add it to RC. Local boot, or modify the default Static Routing reality
2) MySQL 02:
route add -host 192.168.5.23 dev eth2echo "route add -host 192.168.5.23 dev eth2" >>/etc/rc.local
[[email protected] ~]# mkdir tools[[email protected] ~]# cd tools[[email protected] tools]# wget [[email protected] tools]# rpm -ivh epel-release-6-8.noarch.rpm [[email protected] tools]# yum install heartbeat -y
[[email protected] tools]# cd /usr/share/doc/heartbeat-3.0.4/[[email protected] heartbeat-3.0.4]# ls[[email protected] heartbeat-3.0.4]# cp ha.cf haresources authkeys /etc/ha.d/[[email protected] heartbeat-3.0.4]# ls -ls /etc/ha.d/[[email protected] heartbeat-3.0.4]# cd /etc/ha.d/
Note: because there is a DNS server in the Internet segment 192.168.2.0, the hosts file is not configured here:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/39/8E/wKiom1O6b33QF2tOAABGEn8PQFc084.jpg "Title =" 2014-07-07-01-heartbeat-01-hosts-dns.png "alt =" wkiom1o6b33qf2toaabgen8pqfc084.jpg "/>
If you do not have a DNS server, you need to manually add the Host record. You can view the host name as follows:
[[email protected] resource.d]# uname -nMySQL01.stephenzhou.net[[email protected] ha.d]# cat /etc/hosts127.0.0.1 localhost.localdomain localhost.localdomain localhost4 localhost4.localdomain4 localhost MySQL01::1 localhost.localdomain localhost.localdomain localhost6 localhost6.localdomain6 localhost MySQL01192.168.2.23 MySQL01.stpehenzhou.net192.168.2.24 MySQL02.stpehenzhou.net192.168.3.23 MySQL01.stpehenzhou.net192.168.3.24 MySQL02.stpehenzhou.net
[[email protected] resource.d]# rpm -qa|grep epelepel-release-6-8.noarch
1. Ha. cf
# Created by Stephen # 2014-07-07debugfile/var/log/ha-debuglogfile/var/log/ha-loglogfacilitylocal0keepalive 2 deadtime 30 warntime 10 initdead 60 serial/dev/ttys0 # linuxmcast eth2 225.0.0.1 694 1 0 # use group/multicast mode, the heartbeat line is transmitted through eth2. The port is UDP -- 694auto_failback onnodemysql01.steenzhou.net # the same name as 'uname-n' must be used here. netcrm No
2. haresources
# Stephen services #192.168.2.23 www.stephen enzhou.net # mysql01.stephenzhou.net ipaddr: 192.168.2.30/24/eth3 # mysql01.stephenzhou.net ipaddr: 192.168.2.30/24/eth3 httpd #192.168.2.24 bbs.stephen enzhou.net # mysql02.stephenzhou.net ipaddr :: 192.168.2.32/24/eth3 # MySQL master mysqlm.stephen enzhou.net # mysql01.stephen enzhou.net ipaddr: 192.168.3.30/24/eth1 mysqldmysql01.stephen enzhou.net ipaddr :: 192.168.3.30/24/eth1 # the same name as 'uname-n' must also be used here # MySQL slave mysqls.stephen enzhou.netmysql02.stephen enzhou.net ipaddr: 192.168.3.32/24/eth1
3. authkeys
auth 11 sha1 47e9336850f1db6fa58bc470bc9b7810eb397f04
[[Email protected] ha. d] # Cat/etc/sysconfig/iptables # firewall configuration written by system-config-firewall # manual customization of this file is not recommended. * filter: Input accept [0: 0]: Forward accept [0: 0]: output accept [0: 0]-A input-p udp -- dport 694-J accept # Allow UDP 694 traffic to enter-A input-M state -- State established, related-J ACCEPT-A input-p icmp-J ACCEPT-A input-I lo-J ACCEPT-A input-M state -- state new-M TCP-P TCP -- dport 22-J ACCEPT-A input-J reject -- reject-with ICMP-host-prohibited-a forward-J reject -- reject-with ICMP-host-prohibitedcommit
1) End of mysql01:
[[Email protected] ha. d] #/etc/init. d/heartbeat startstarting high-availability services: info: resource is stoppedinfo: resource is stoppeddone. [[email protected] ha. d] # IP add | grep 192.168.3 # It is found that the vip has been bound to Inet 192.168.3.23/24 BRD 192.168.3.255 scope global eth1 Inet 192.168.3.30/24 BRD 192.168.3.255 scope global secondary eth1 [[email protected] ha. d] # iptables-VL # check that the UDP port has heartbeat traffic in the chain input (Policy accept 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 48 12296 accept UDP -- any anywhere Anywhere udp dpt: Ha-cluster 36 2376 accept all -- any anywhere state related, established 0 0 accept ICMP -- any anywhere Anywhere 0 0 accept all -- lo any anywhere 0 0 accept TCP -- any anywhere state New tcp dpt: SSH 1 229 reject all -- any anywhere Anywhere reject-with ICMP-host-prohibited [[email protected] ha. d] # tcpdump-I eth2 UDP-s 1500 # capture packets from the UDP port of the NIC where the jumper is located. The heartbeat traffic tcpdump: verbose output suppressed is displayed, use-V or-VV for full protocol decodelistening on eth2, link-type en10mb (Ethernet), capture size 1500 bytes16: 55: 16.399325 IP 192.168.5.23.35912> 225.0.0.1.ha-cluster: UDP, length 22616: 55: 17.216819 IP 192.168.5.24.53014> 225.0.0.1.ha-cluster: UDP, length 22616: 55: 17.371805 IP 192.168.5.23.35912> 225.0.0.1.ha-cluster: UDP, length 23916: 55: 18.399199 IP 192.168.5.23.35912> 225.0.0.1.ha-cluster: UDP, length 22616: 55: 19.222381 IP 192.168.5.24.53014> 225.0.0.1.ha-cluster: UDP, length 226... ^ C16 packets captured16 packets received by filter0 packets dropped by Kernel
2) MySQL 02:
[[email protected] ha.d]# /etc/init.d/heartbeat startStarting High-Availability services: INFO: Resource is stoppedINFO: Resource is stoppedDone.[[email protected] ha.d]# ip add|grep 192.168.3 inet 192.168.3.24/24 brd 192.168.3.255 scope global eth1 inet 192.168.3.32/24 brd 192.168.3.255 scope global secondary eth1
4. Refer to the blog post:
Detailed implementation and workflow of centos 6.5 heartbeat high-availability clusters
Heartbeat MySQL NFS high-availability MySQL Cluster
This article is from the "little devil's territory" blog, please be sure to keep this source http://zhoufwind.blog.51cto.com/1029821/1435437