Linux Heartbeat 2.1.3 installation manual

Source: Internet
Author: User

1 Preface
HeartBeat is used to build a dual-host Hot Standby environment. It can be connected through a dedicated HeartBeat line or through a common network cable.
Of course, in addition to heartbeat, there are many other linux systems, such as the redhat cluster software. The following describes how to install and configure heartbeat.
2 Installation
2.1 preparation
There are two vmware virtual hosts in this test environment, of which the fixed IP addresses are:
Dingwy-as4-vmware-nod1 192.168.0.128
Dingwy-as4-vmware-nod2 192.168.0.130
Floating ip Address: 192.168.0.129
If the/etc/hosts file is not configured, configure the/etc/hosts file first.
Disable iptables
2.2 create users and user groups
Heartbeat requires the haclient user group and the hacluster user.
The two nodes perform the same operation and ensure that the IDs of haclient and hacluster are the same.
Groupadd haclient
Useradd-g haclient hacluster
2.3 Installation
You can directly download the rpm package or download the source code package to compile the package. Here, I compile the source code by myself. Install the libnet package before installing heartbeat.
Tar zxvf heartbeat-2.1.3.tar.gz
Rpm-ivh libnet-1.1.2.1-2.2.el4.rf.x86_64.rpm
Cd heartbeat-2.1.3
./Configure
Make
Make install
Similarly, it is installed on another host.
The libnet package can be searched in html/search. php "> http://rpmfind.net/linux/rpm2html/search.php.
3 Configuration
Heartbeat has three configuration files:
Ha. cf
Authkyes
Haresources
These files must be consistent on each machine. We will introduce them one by one.
Cp/usr/local/share/doc/heartbeat-2.1.3/ha. cf/usr/local/etc/ha. d
Cp/usr/local/share/doc/heartbeat-2.1.3/haresources/usr/local/etc/ha. d
Cp/usr/local/share/doc/heartbeat-2.1.3/authkeys/usr/local/etc/ha. d
Ha. cf, authkyes, and haresources of the master and slave servers are exactly the same.
3.1 Edit the master configuration file ha. cf of hertbeat. The content on the two hosts is the same.
The configuration to be enabled is as follows. Detailed descriptions are provided in ha. cf.
Vi/usr/local/etc/ha. d/ha. cf
# Location of the ha log file. If the directory does not exist, manually add
Logfile/var/log/ha-log # File to write other messages
Logfacility local0 # This is the log for setting heartbeat. Here the system log is used.
# Set the heartbeat (Monitoring) Time to 2 seconds
Keepalive 2 # How long does it take to detect
Warntime 5 # How long does it take to get in touch and start warning
Deadtime 20 # How long can the contact fail and the other party is considered to have crashed (the unit is wonderful)
Initdead 120 # Here is a period of ignore time reserved for the restart (for example, starting the network after the restart). If the network is not connected, the keepalive detection will fail, but it cannot be switched at this time)
# Send heartbeat information using bond0 udp Broadcast
Bcast bond0
# Use the udp unicast of the network card bond0 to notify the heartbeat. The ip address should be the IP address of the other party. We recommend that you use unicast. If a CIDR block has multiple such clusters, you must use single-play. Otherwise, each group of clusters will see the other node and report an error.
# Ucast bond0 192.168.0.128
# Use udp port 694 for heartbeat monitoring
Udpport 694
Auto_failback off # Whether to automatically switch back after it returns to normal, usually set to off.
# Node 1, which must be consistent with the result obtained by the uname-n command.
Node dingwy-as4-vmware-nod1
# Node 2
Node dingwy-as4-vmware-nod2
# Ping the gateway to check whether the heartbeat is normal
Ping 192.168.0.2
Hopfudge 1
Deadping 5
# Specify the process to be started and closed together with heartbeat # respawn hacluster/usr/local/lib64/heartbeat/ipfail # apiauth ipfail gid = haclient uid = hacluster
# Whether the v2 style mode is used. It must be enabled when there are more than three Nodes
# Crm on
According to the official heartbeat documents, the current ping node has no practical use, but it is only used to detect node connectivity and does not serve as a real basis for node switching. This may be done in future new versions.
3.2 edit the file authkeys
Vi/usr/local/etc/ha. d/authkeys
Auth 1
1 crc
Chmod 600/usr/local/etc/ha. d/authkeys
Note that authkeys must have 600 permissions.
3.3 edit the cluster resource file: haresources
After the ha. cf file is configured, It is the haresources file. This file lists the services provided by the cluster and the default owners of the services. Note: The files on the two cluster nodes must be the same. The cluster IP address is required for this option and cannot be configured outside the haresources file, the haresources file is used to specify the master node, cluster IP address, subnet mask, broadcast address, and started service of the dual-machine system. The statement format is as follows:
Node-name network-config <resource-group>

Vi/usr/local/etc/ha. d/haresources
Dingwy-as4-vmware-nod1 192.168.0.129 oracle10g
Node-name indicates the master node of the dual-machine system. The value must match one of the host names set by the node option in the ha. cf file, and the other host names set by the node option are slave nodes. Network-config is used for network settings, including specifying the cluster IP address, subnet mask, and broadcast address. Resource-group is used to set the service started by heartbeat. The service is finally provided by the dual-host system through the cluster IP address. In this article, we assume that the HA service to be configured is Apache and Samba.
The following content is required in the haresources file:
Primary.mydomain.com 192.168.85.3 httpd smb
/Usr/local/lib/heartbeat/haresources2cib. py-c/usr/local/etc/ha. d/haresources
This row is specified at startup, the node linuxha1 gets the IP address 192.168.85.3, and starts Apache and Samba. When it is stopped, Heartbeat will stop smb first, then stop Apache, and finally release the IP address 192.168.85.3. Assume that the output of the command "uname-n" is "primary.mydomain.com"-If the output is "primary", "primary" should be used ".
After the haresources file is correctly configured, copy ha. cf and haresource to the/etc/ha. d directory.
For details about how to configure it, see haresources.
There are several considerations:
1). the first column of the Resource Group is one of the nodes in the ha. cf configuration file, and should be the node currently prepared as the primary node.
2). Each row represents a resource group. If a row cannot be written, use "" line feed.
3) The Starting sequence of the resource group is from left to right, and the closing sequence is from right to left.
4). The script parameters are separated and passed through:
5). Different resources in a resource group are separated by spaces.
6) There is no inevitable relationship between different resource groups.
7 ). each resource is an angular, which can be in/etc/init. under the d directory, it can also be/usr/local/etc/ha. d/resource. d directory. These corners must support the xxx start; xxx stop; mode.
8) for details about the service IP resource setting format, see the haresources file.
9) If mysql is compiled and installed, modify the parameters basedir and datadir in the/etc/init. d/mysql file.
3.4 Master/Slave server hosts
Host hosts file:
Vi/etc/hosts
192.168.0.128 dingwy-as4-vmware-nod1 localhost. localdomain localhost
192.168.0.130 dingwy-as4-vmware-nod2
Backup hosts file:
Vi/etc/hosts
192.168.0.130 dingwy-as4-vmware-nod2 localhost. localdomain localhost
192.168.0.128 dingwy-as4-vmware-nod1
4 switch Test
Test switching is similar to the following:
1) manually call the heartbeat Node switch script
2 ). unplug the network cable and test the network switchover after the primary node is disconnected. After the network is unplugged, when the master node finds that it cannot communicate with the standby node, the warn information will be recorded in the log, if the duration reaches ha. after the duration specified in cf, resources are released. The standby node cannot communicate with the master node for a period of time (ha. cf settings), start to start the resource and turn itself into a primary node. The switching period is also very short except for the period set in ha. cf. The split of cluster brain is prone to problems. If dual master is used, this problem does not exist.
3) shut down the primary host and test whether the switchover is normal.
4) Whether the master node can be switched normally when the power is down.
5 heartbeat Management
To enable or disable heartbeat:
/Etc/init. d/hearbeat start or service heartbeat start
/Etc/init. d/hearbeat stop or service heartbeat stop
Manual Switch:
/Usr/local/share/heartbeat/hb_standby
2009/06/03 _ 00:35:00 Going standby [all].
Service heartbeat status
Heartbeat OK [pid 13763 et al] is running on alsme_probe3 [alsme_probe3]...
View heartbeat status
Service heartbeat status
Heartbeat OK [pid 13763 et al] is running on alsme_probe3 [alsme_probe3]...
 

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.