群集-ldirector-055

 Heartbeat-lddirectord自动探测

不需要ipvsadm规则了

Heartbeatharesource配置文件在两台director服务器上必须是同步的

使用ldirecrot软件实现管理directoripvs的连接,不需要再写ipvsadm规则


55-1

Director1的配置

[root@director1 ~]# uname -r

2.6.18 -128.el5

[root@director1 ~]# uname -n

director1.test.com

[root@director1 ~]# hostname

director1.test.com

[root@director1 ~]# cat /etc/hosts

127.0.0.1               localhost.localdomain localhost

::1             localhost6.localdomain6 localhost

192.168.2.10      director1.test.com node1

192.168.2.11      director2.test.com node2

192.168.10.1      director1.test.com node1

192.168.10.2      director2.test.com node2

[root@director1 ~]# cat /etc/sysconfig/network

HOSTNAME=director1.test.com

[root@director1 ~]# ifconfig eth0     192.168.2.10

[root@director1 ~]# ifconfig eth1 192.168.10.1

[root@director1 ~]#

需要安装的heartbeat

[root@director1 ~]# ll soft/

heartbeat- 2.1.4 -11.el5.i386.rpm

heartbeat-devel- 2.1.4 -9.el5.i386.rpm

heartbeat-gui- 2.1.4 -9.el5.i386.rpm

heartbeat-ldirectord- 2.1.4 -9.el5.i386.rpm

heartbeat-pils- 2.1.4 -10.el5.i386.rpm

heartbeat-stonith- 2.1.4 -10.el5.i386.rpm

libnet- 1.1.4 -3.el5.i386.rpm

perl-MailTools-1.77-1.el5.noarch.rpm

[root@director1 soft]# yum install  heartbeat- 2.1.4 -11.el5.i386.rpm heartbeat-ldirectord-2.1.4-9.el5.i386.rpm heartbeat-pils-2.1.4-10.el5.i386.rpm heartbeat-stonith-2.1.4-10.el5.i386.rpm libnet-1.1.4-3.el5.i386.rpm perl-MailTools-1.77-1.el5.noarch.rpm -y –nogpgcheck

--生成配置文件

[root@director1 ha.d]# cp /usr/share/doc/heartbeat- 2.1.4 /ha.cf .

[root@director1 ha.d]# cp /usr/share/doc/heartbeat- 2.1.4 /haresources .

[root@director1 ha.d]# cp /usr/share/doc/heartbeat- 2.1.4 /authkeys .

[root@director1 ha.d]# cp /usr/share/doc/heartbeat-ldirectord- 2.1.4 /ldirectord.cf .

[root@director1 ha.d]# vim ha.cf

91 bcast   eth1            # Linux

213 node director1.test.com

214 node director2.test.com

--Heartbeat udp协议单播组播广播

--添加验证

[root@director1 ha.d]# dd if=/dev/urandom bs=512 count=1 |openssl md5>>authkeys 

[root@director1 ha.d]# vim authkeys

auth 1

1 md5 371779a32d9961694ad6b73e7d1799ab

[root@director1 ha.d]# vim haresources

--设置主director

 45 director1.test.com 192.168.2.100 ldirectord::ldirectord.cf

[root@director1 ha.d]# vim ldirectord.cf

checktimeout=3

checkinterval=1

#fallback=127.0.0.1:80      ---最好自身的web改为其他端口。避免冲突

autoreload=yes

#logfile="/var/log/ldirectord.log"

#logfile="local0"

#emailalert="[email protected]"

#emailalertfreq=3600

#emailalertstatus=all

quiescent=yes      --如果是no,自动删除失效的ipvsadm规则

 

# Sample for an http virtual service

virtual=192.168.2.100:80

        real=192.168.2.20:80 gate

        real=192.168.2.30:80 gate

        #fallback=127.0.0.1:80 gate

        service=http

        request=".test.html"

        receive="ok"

        #virtualhost=some.domain.com.au

        scheduler=rr

        #persistent=600

        #netmask=255.255.255.255

        protocol=tcp

        checktype=negotiate

        checkport=80

[root@director1 ha.d]# yum install ipvsadm –y

[root@director1 ha.d]# stonith –L –stonith的机制

 --linux本身自带的是fens机制

director2 的配置

[root@director2 ~]# uname -n

director2.test.com

[root@director2 ~]# cat /etc/hosts

127.0.0.1               localhost.localdomain localhost

::1             localhost6.localdomain6 localhost

192.168.2.10      director1.test.com node1

192.168.2.11      director2.test.com node2

192.168.10.1      director1.test.com node1

192.168.10.2      director2.test.com node2

 

[root@director2 ~]# cat /etc/sysconfig/network

HOSTNAME=director2.test.com

 

[root@director1 lwy]# scp /root/soft/* node2:/root/lwy/

[root@director1 ha.d]# cd /root/lwy/      

[root@director2 lwy]# yum localinstall heartbeat- 2.1.4 -11.el5.i386.rpm heartbeat-ldirectord-2.1.4-9.el5.i386.rpm heartbeat-stonith-2.1.4-10.el5.i386.rpm heartbeat-pils-2.1.4-10.el5.i386.rpm libnet-1.1.4-3.el5.i386.rpm perl-MailTools-1.77-1.el5.noarch.rpm -y –-nogpgcheck

 

[root@director1 ha.d]# scp ha.cf haresources authkeys ldirectord.cf node2:/etc/ha.d

root@node2's password:

ha.cf                                         100%   10KB  10.3KB/s   00:00   

haresources                                   100% 5964     5.8KB/s   00:00   

authkeys                                      100%  691     0.7KB/s   00:00   

ldirectord.cf                                 100% 7657     7.5KB/s   00:00   

开启heartbeat服务:

Ipvsadmheartbeat调用启动的,需要检查是否关闭

[root@director2 ha.d]# service ipvsadm stop

Clearing the current IPVS table:                           [  OK  ]

[root@director2 ha.d]#

[root@director1 ha.d]# service ipvsadm stop

Clearing the current IPVS table:                           [  OK  ]

[root@director1 ha.d]#

 

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

Starting High-Availability services:

2011/10/14 _01:03:36 INFO:  Resource is stopped

                                                           [  OK  ]

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

[root@director1 ha.d]# ipvsadm -Ln

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

TCP  192.168.2.100:80 rr

  -> 192.168.2.20:80              Route   0      0          0        

  -> 192.168.2.30:80              Route   0      0          0    

 

Server的配置

[root@server ~]# ifconfig eth0 192.168.2.20

[root@server ~]# ifconfig lo:0 192.168.2.100 netmask 255.255.255.255

[root@server ~]# route add -host 192.168.2.100 dev lo:0

[root@server ~]# route -n

[root@server ~]# sysctl -a |grep anno |head -3 >>/etc/sysctl.conf

[root@server ~]# sysctl -a |grep ignore|tail -2 >>/etc/sysctl.conf

[root@server ~]# vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

net.ipv4.conf.all.arp_announce = 2

net.ipv4.conf.lo.arp_announce = 2

net.ipv4.conf.all.arp_ignore = 1

net.ipv4.conf.lo.arp_ignore = 1                      

[root@server ~]# sysctl -p

 

[root@server ~]# yum install httpd

[root@server ~]# vim /var/www/html/index.html

server1 web.        

[root@server ~]# vim /var/www/html/.test.html

ok          

--测试连接的页面

[root@server ~]# service httpd start

 

 

Server2的配置

[root@server2 ~]# ifconfig eth0 192.168.2.30

[root@server2 ~]# ifconfig lo:0 192.168.2.100 netmask 255.255.255.255

[root@server2 ~]# route add -host 192.168.2.100 dev lo:0

[root@server ~]# scp /etc/sysctl.conf 192.168.2.30:/etc/sysctl.conf  

[root@server2 ~]# sysctl –p

[root@server2 ~]# vim /var/www/html/index.html

server2 web!

[root@server2 ~]# vim /var/www/html/.test.html

 

ok


55-2


55-3

你可能感兴趣的:(职场,休闲,群集,ldirector)