Linux Heartbeat high-availability simple configuration

Source: Internet
Author: User

Heartbeat

System environment:

Firewall off,

Seliux status is disabled

Address resolution for groups between servers

node3:172.25.44.3

node4:172.25.44.4

Physical Real Machine: 172.25.44.250

vip:172.25.44.100

The following content is configured on both NODE3 and NOD4

Installing the Software

heartbeat-libs-3.0.4-2.el6.x86_64.rpm

heartbeat-3.0.4-2.el6.x86_64.rpm

ldirectord-3.9.5-3.1.x86_64.rpm

heartbeat-devel-3.0.4-2.el6.x86_64.rpm

Rpm-q heartbeat-d # #查看软件生成的配置文件

cd/usr/share/doc/heartbeat/

CP ha.cf Haresources AUTHKEYS/ETC/HA.D

1).

vim/etc/ha.d/ ha.cf # # # #需要添加或更改的内容, according to the specific circumstances and settings, parameters are not fixed

Logfile/var/log/ha-log

2 keepalive

30 Deadtime

10 Warntime

60 Initdead

738 Udpport

Bcast eth0

157 Auto_failback on

211 Node Server3.example.com

212 Node server4.example.com

Ping 172.25.44.250 #已存在的ip地址, non-node address,

253 respawn Hacluster/usr/lib64/heartbeat/ipfail

259 Apiauth Ipfail Gid=haclient uid=hacluster

#########################################

Master configuration file (/ETC/HA.D/HA.CF):

Debugfile/var/log/ha-debug

Debug Log file file, default value

Logfile/var/log/ha-log

system run log file , take default value

Logfacility local0

log level , default value

KeepAlive 2

heart rate , set yourself. 1:1 seconds; 200ms: 200 ms

Deadtime 30

node death time threshold, that is, from the node after 30 has not received the heartbeat that the master node died, set himself

Warntime 10

issue a warning time , set yourself

Initdead 120

after the daemon starts for the first time, it should wait 120 seconds before starting resources on the primary server

Udpport 694

heartbeat messaging UDP port, using port 694 for Bcast and Ucast communication, taking the default value

#baud 19200

serial baud rate , used in conjunction with serial.

#serial/DEV/TTYS0

Use serial port to transmit heartbeat information.

Bcast eth1

use UDP broadcast to notify Heartbeat

#ucast eth1 10.0.0.3 uses the UDP unicast of the NIC Eth1 to notify the heartbeat, eth1 IP

#mcast eth0 225.0.0.1 694 1 0

use UDP multicast to notify the heartbeat

Auto_failback on

when the primary node resumes , does it automatically cut back

#stonith Baytech/etc/ha.d/conf/stonith.baytech

Stonith to ensure data integrity in a shared storage environment

Watchdog/dev/watchdog

Watchdog can allow the system to restart the machine after 1 minutes of failure, this function can help the server really stop the heart

after jumping, you can recover your heartbeat again. If you use this feature , modify the/etc/modprobe.conf in the system to add the following

Options Softdog nowayout=0

This will load the "Softdog" kernel module in the kernel to generate the actual device files when the system is booted.

/dev/watchdog

Node station3.example.com

The primary node name , consistent with Uname–n. The first default is the primary node, so don't make the order

Node station4.example.com

Sub-node name , consistent with Uname–n

Ping 192.168.0.254

Respawn Hacluster/usr/lib/heartbeat/ipfail

Apiauth Ipfail gid=haclient Uid=hacluster

The default heartbeat does not detect any services other than itself, nor does it detect network conditions.

So when the network is interrupted , there is no switch between Load Balancer and Backup.

You can solve this problem by setting the ' ping nodes ' through the Ipfail plugin, but you cannot use a cluster node as the ping node.

###########################

2).

vim/etc/ha.d/ haresources

650) this.width=650; "title=" Picture 1.png "alt=" Wkiol1gmpfxizsb0aabfgyhk49o486.png "src=" http://s1.51cto.com/wyfs02/M01 /89/35/wkiol1gmpfxizsb0aabfgyhk49o486.png "/>

Server3.example.com Ipaddr::172.25.44.100/24/eth0 httpd

The virtual IP is 172.25.44.100, and the boot service is httpd

########################

resource File (/etc/ha.d/haresources):

station3.example.com Ipaddr::192.168.0.200/24/eth0 Ldirectord httpd

This file defines the startup scripts for each software required to implement the cluster , which must be placed in the/ETC/INIT.D or/ETC/HA.D/RESOURCE.D directory ipaddr the role of the Virutal IP, which is Heartbeart a script that comes with it; Ldirectord's role is to start the Ldirectord monitoring program, which will make the LVS defined in ldirectord.cf take effect.

and monitor its health ; HTTPD is the startup script for the Apache service.

3).

VIM/ETC/HA.D /authkeys

650) this.width=650; "title=" Picture 2.png "alt=" Wkiom1gmpgvbssgkaaael0odnei144.png "src=" http://s2.51cto.com/wyfs02/M02 /89/37/wkiom1gmpgvbssgkaaael0odnei144.png "/>

chmod 600/etc/ha.d/authkeys

transfer files to Node4 after configuration is complete

#scp ha.cf haresources Authkeys 172.25.44.4:/etc/ha.d/

######## #认证文件, this file permission must be 600#######

Test:

1.Writing test files (writing different content on Node3 and node4 for easy testing)

Vim/var/www/html/index.html

2.#/etc/init.d/heartbeat Start # # #l两边都开启hearbeat服务

Starting high-availability Services:INFO:Resource is stopped

Done.

#arp-an | grep 172.25.44.100 # #查看vip在哪个节点上运行 (executes this command on a physical real machine)

Viewing VIPs on the master node

#ip Addr Show

3. Browser access to vip:172.25.44.100, View Web content

4.NODE3 manually shut down the heartbeat service, to see if the VIP jumps to Node4, while httpd on the node4, Access 172.25.44.100, if the content and node Node4 test file content consistent, test success.

This article is from the "11897256" blog, please be sure to keep this source http://65147718.blog.51cto.com/11897256/1864791

Linux Heartbeat high-availability simple configuration

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.