heartbeat v1

heartbeat v1

I. Introduction to the experimental environment

Hardware: lenovo T410S

Software: VMWARE workstation

SO: Centos 6.6

< br>

Second, network topology

Network card type: NAT

RIP: 192.168.239.133 node1.hailang.com

192.168.239.134 node2.hailang.com

VIP: 192.168.239.200

3. Experiment Environmental preparation

1. Configure an NTP server to ensure time synchronization

[root@node2 ha.d]# vim /etc/ntp.conf

Add as follows< /p>

restrict 192.168.239.0 mask 255.255.255.0 nomodify #Which network segment hosts are allowed to come and synchronize

Annotate the following time server

#server 0.centos. pool.ntp.org iburst

#server 1.centos.pool.ntp.org iburst

#server 2.centos.pool.ntp.org iburst

#Server 3.centos.pool.ntp.org iburst

server server s1a.time.edu.cn #Sync time with the NTP server

[root@node2 ha.d ]# ntpdate s1a.time.edu.cn

[root@node2 ha.d]# servic e ntpd start

2, the names of nodes communicate with each other

[root@node2 ha.d]# vim /etc /hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.239.133 node1. hailang.com node1

192.168.239.134 node2.hailang.com node2

[root@node1 ha.d]# hostname node1.hailang.com

[ root@node1 ha.d]# uname -n

3. SSH mutual authentication

[root@node1 ha.d ]# ssh-keygen -t rsa

[root@node1 ha.d]# ssh-copy-id ~/.ssh/id_isa.pub 192.168.239.134

[root@ node1 ha.d]# ssh node2.hailang.com

4. Turn off the firewall and SELINUX

[root@node1 ha .d]# service iptables stop

[root@node1 ha.d]# setenforce 0

5. Configure yum source

[root@node1 ha.d]# vim /etc/yum.repos.d/epel.repo

[epel]

name=Extra Packages for Enterp rise Linux 6-$basearch

baseurl=http://mirrors.aliyun.com/epel/6/$basearch

http://mirrors.aliyuncs.com/epel/ 6/$basearch

#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch

failovermethod=priority

Enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

< p>

6. httpd (The content of the page provided by node1 is node1, and the content of the page provided by node2 is node2)

[root@node1 ha.d] # yum -y install httpd

[root@node1 ha.d]# vim /var/www/html/index.html

node1

Four. Install and configure herartbeat v1

1. Install

[root @node1 ~]# yum install perl-TimeDate net-snmp-libs libnet PyXML

[root@node1 ~]# rpm -ivh heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat -2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm

2, configuration (2 The configuration files of the nodes are the same)

[root@node1 ~]# cp /usr/share/doc/heartbeat- 2.1.4/{ha.cf,authkeys,haresources} /etc/ha.d/

1) ha.cf

root@node1 ~]# vim /etc/ha.d/ha.cf

logfile /var/log/ha-log

Keepalive 2

Deadtime 30

warntime 10

initdead 120

udpport 694

mcast eth0 225.0.0.1 694 1 0

auto_failback on

node node1.hailang.com

node node2.hailang.com

ping 192.168.239.1

< /p>

2)authkeys

[root@node1 ~]# vim /etc/ha.d/authkeys

auth 1

1 crc

3)haresources

node1.hailang.com IPaddr::192.168.239.200/24/eth0 httpd< /p>

3. Start

[root@node1 ha.d]# service heartbeat start

>

4. Verify

Start the heartbeat service on 2 servers

[root@node1 ha.d]# ss -tulnp|grep 80

[root@node1 ha.d]# ifconfig

Visit the homepage to display node1

http://192.168.239.200

3) Stop node1

[root@node1 ha.d]# service heartbeat stop


4) Visit the homepage again to display node2

http://192.168.239.200

Leave a Comment

Your email address will not be published.