centos_6.7 High-Availability Service heartbeat_v3.0.4 installation and configuration
There are 2 main types of cluster systems:
Highly available (high availability) HA clusters: using hardware and software such as Heartbeat/keepalived, also known as "dual-machine hot standby", "dual-machine interoperability", "dual-machine".
Load Balancing cluster (load Balance Cluster): Using hardware and software such as Linuxvirtual Server (LVS)/haproxy/nginx;
The Heartbeat project is an integral part of the LINUX-HA project, which implements a highly available cluster system. Heartbeat service and cluster communication are two key components of a highly available cluster , and in the Heartbeat project, these two functions are implemented by the Heartbeat module.
Highly available clusters refers to a set of independent computers that are connected by hardware and software that behave as a single system in front of the user, where one or more nodes within such a set of computer systems stop working, and the service runs from the failed node to a functioning node without interruption of service. As you can see from this definition, the cluster must detect when nodes and services are invalidated and when they are available. This task is usually done by a set of code called "Heartbeat". In linux-ha This function is done by a program called Heartbeat.
Heartbeat (Linux-ha) Working principle: Heartbeat core consists of two parts, heartbeat monitoring part and the resource taking over part, heartbeat monitoring can be carried out through the network link and serial port, and support redundant links, they send each other a newspaper Greek tell each other their current state, If the message is not received by the other party within the specified time, then it is considered to be invalid, then a resource takeover module should be initiated to take over the resources or services running on the other host.
Message Communication model
The heartbeat includes several components:
heartbeat– Inter-node communication check module
CRM-Cluster resource management module
CCM-maintaining consistency of cluster members
LRM-Local Resource management module
Stonithdaemon-Provides node restart service
LOGD-Non-blocking logging
APPHBD-Provides application-level watchdog Timer
Recovery Manager-Application failure recovery
underlying structure – including Plugins interfaces, inter-process communication wait
cts– cluster test system, cluster stress test
The main analysis here is the heartbeat trunking communication mechanism, so the main concern here is the heartbeat module
The heartbeat module consists of several processes:
Master Process (masterprocess)
FIFO Sub-process (fifochild)
Read child process (Readchild)
Write child process (Writechild)
in Heartbeat, the master process sends its own data, or data sent by the client, through IPC sent to the write child process, the write subprocess sends the data to the network, while the read child process reads data from the network, sends it to the master process through the IPC, is processed by the master process, or forwarded by the master process to its client.
When Heartbeat starts, the master process starts the FIFO child process, the write subprocess, and the read subprocess, and finally starts the client process.
System: CentOS 6.7 x86_64 (two virtual machines)
Security: SElinux Disabled
Iptables disabled
Heartbeat version: v3.0.4
Cluster gule Version: v1.0.5
Resource agents version: v3.9.5
Package installation method: Yum Installation
HEARTBEAT3.0 is composed of three parts: Gule, Heartbeat and agents. Therefore, separate installation is required.
First, the preparatory work
1. Configure the Hosts file (vim/etc/hosts):
10.0.0.50 DB1
192.168.0.205 DB1
10.0.0.52 DB2
192.168.0.201 DB2
Note:
1) hostname the domain name with suffix (ha25pxdschool.org) will give an error.
2. Installation dependencies:
# yum INSTALLGCC gcc-c++ autoconfautomake libtool glib2-devel libxml2-devel bzip2-devel e2fsprogs-devellibxslt-devel Libtool-ltdl-devel make wget Docbook-dtds docbook-style-xsl #源码安装时必须安装的依赖
3. Add users and groups running heartbeat (source installation, simultaneous operation on the primary and standby server)
# Groupadd-r Haclient
# Useradd-r-G haclient-m-s/sbin/nologin Hacluster
4. Change the Yum source
# Mv/etc/yum.repos.d/centos-base.repo/etc/yum.repos.d/centos-base.repo.backup
# Wget-o/etc/yum.repos.d/centos-base.repo Http://mirrors.aliyun.com/repo/Centos-6.repo
5. Adjust the time zone and
# ntpdate 10.0.0.254 #db1与db2上分别对时
7 May 22:33:02 ntpdate[2729]: adjust Timeserver 10.0.0.254 offset-0.001976 sec
Second, installation
# yum-y installheartbeat* httpd #最小化安装的系统大约有26个左右的包要安装
Third, configure and start heartbeat
1. Configuration of the Lord (DB1):
cd/usr/share/doc/heartbeat-3.0.4/
CP Authkeys HA.CF haresources/etc/ha.d/
Cd/etc/ha.d
VI Authkeys #打开下面两项: A total of three authentication methods to choose from, the first is CRC cyclic redundancy check, the second is the SHA1 hash algorithm, the third is the MD3 hashing algorithm, where their password can be arbitrarily set, but both sides of the password must be consistent.
Auth 3
3 MD5 hello!
chmod Authkeys #给认证文件授权为600
VI haresources #编辑资源文件, add the following statement
DB1 10.0.0.210/24/eth0 httpd #设定虚拟IP和对应的接口, and specifies that the HTTPD service is started when the virtual IP is started, where the httpd service must be a service that can be started directly in the/etc/init.d/directory.
Note: The resource file haresources in the master node and the standby node are exactly the same.
# ha.cf File main parameter comment:
Debugfile/var/log/ha-debug #设定debug文件目录
Logfile/var/log/ha-log #设定日志文件目录
Logfacility local0 #利用系统日志打印日志
KeepAlive 1 #设定检查时间间隔为1s
Deadtime #设定在10s内没有心跳信号, switch service immediately
Warntime 5 #设定告警时间为5s (Alarm is not received in 5s)
Initdead #设定初始化时间为60s
Udpport 694 #设定集群节点间的通信协议及端口为udp694监听端口 (the port can be modified)
Ucast eth1 192.168.0.201 #设定心跳方式使用单播方式, and is unicast on the Eth1 interface, IP address is the IP of the other heartbeat port
Auto_failback on/Off #当主节点恢复后, whether automatically cut back, generally set to off
Node DB1 #指定两个节点
Node DB2
Ping 192.168.0.1 #指定一个第三方的仲裁节点
Respawn hacluster/usr/lib64/heartbeat/ipfail #使用这个脚本去侦听对方是否还活着 (using ICMP message detection)
# egrep-v "^#|^$" ha.cf //configuration file for this experiment
Debugfile/var/log/ha-debug
Logfile/var/log/ha-log
Logfacility local0
KeepAlive 2
Deadtime 30
Warntime 10
Initdead 120
Udpport 694
Ucast eth1 192.168.0.201
Auto_failback off
Node DB1
Node DB2
Ping 192.168.0.1
Respawn Hacluster/usr/lib64/heartbeat/ipfail
2. Copy the three configuration of the Lord to the Slave (DB2):
cd/etc/ha.d/
Scp–p52668-p authkeys ha.cf haresources [email protected]:/etc/ha.d/
3. To the top (DB2) Edit HA.CF
VI/ETC/HA.D/HA.CF #只需要更改一个地方, IP address modified to peer host (192.168.0.205)
Ucast eth1 192.168.0.201 changed to Ucast eth1 192.168.0.205
4. Start Heartbeat
Guthrie, after from
Service Heartbeat Start
5. Test High Availability
DB1:
[[Email protected] ha.d]# IP A
1:lo: <LOOPBACK,UP,LOWER_UP> mtu65536 qdisc noqueue State UNKNOWN
Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00
inet 127.0.0.1/8 Scope host Lo
INET6:: 1/128 Scope Host
Valid_lft Forever Preferred_lft Forever
2:eth0: <broadcast,multicast,up,lower_up>mtu qdisc pfifo_fast State up Qlen 1000
Link/ether 00:0C:29:DB:31:F7 BRD FF:FF:FF:FF:FF:FF
inet 10.0.0.50/24 BRD 10.0.0.255 Scope Global eth0
inet 10.0.0.210/24 brd 10.0.0.255 scopeglobal secondary eth0
Inet6 FE80::20C:29FF:FEDB:31F7/64 Scope link
Valid_lft Forever Preferred_lft Forever
3:eth1:<broadcast,multicast,up,lower_up> MTU Qdisc Pfifo_fast State Unknownqlen 1000
Link/ether 00:0c:29:db:31:01 BRD FF:FF:FF:FF:FF:FF
inet 191.168.0.205/24 BRD 191.168.0.255 Scope Global eth1
Inet6 FE80::20C:29FF:FEDB:3101/64 Scope link
Valid_lft Forever Preferred_lft Forever
DB2:
[[Email protected] ~]# IP A
1:lo: <LOOPBACK,UP,LOWER_UP> mtu65536 qdisc noqueue State UNKNOWN
Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00
inet 127.0.0.1/8 Scope host Lo
INET6:: 1/128 Scope Host
Valid_lft Forever Preferred_lft Forever
2:eth0:<broadcast,multicast,up,lower_up> MTU Qdisc Pfifo_fast State up qlen1000
Link/ether 00:0C:29:DB:31:F7 BRD FF:FF:FF:FF:FF:FF
inet 10.0.0.52/24 BRD 10.0.0.255 Scope Global eth0
Inet6 FE80::20C:29FF:FEDB:31F7/64 Scope link
Valid_lft Forever Preferred_lft Forever
3:eth1:<broadcast,multicast,up,lower_up> MTU Qdisc Pfifo_fast State Unknownqlen 1000
Link/ether 00:0c:29:db:31:01 BRD FF:FF:FF:FF:FF:FF
inet 191.168.0.201/24 BRD 191.168.0.255 Scope Global eth1
Inet6 FE80::20C:29FF:FEDB:3101/64 Scope link
Valid_lft Forever Preferred_lft Forever
[Email protected] ~]# Curl 10.0.0.210
Web1 page
# After you stop the network card service or shutdown on the DB1, see if the VIP and service are successfully switched on the DB2 again
[[Email protected] ~]# service heartbeat stop
Stopping high-availability Services:done.
DB2:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/D0/wKioL1cupi3j3AwxAABBCq0DpwE438.png "title=" 11111. PNG "alt=" Wkiol1cupi3j3awxaabbcq0dpwe438.png "/>
[Email protected] ~]# Curl 10.0.0.210
WEB2 page
This article is from the "Lanzhou Linux operation and Maintenance" blog, please be sure to keep this source http://linuxzkq.blog.51cto.com/9379412/1771152
centos_6.7 High-Availability Service heartbeat_v3.0.4 installation and configuration