生产环境部署Heartbeat
一、环境准备:
1.1、关闭防火墙
1.2、关闭Selinux
1.3、修改主机名(要求简单明了)
[root@master ~]# hostname master |
[root@slave ~]# hostname slave |
1.4、网络配置
在青云上创建自管网络,分别在两台服务器上配置网卡IP
[root@master ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE=eth1 TYPE=Ethernet IPADDR=192.168.1.41 BOOTPROTO=static NETMASK=255.255.255.0 ONBOOT=yes NM_CONTROLLED=yes HWADDR=52:54:C3:57:3D:6A |
[root@slave ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE=eth1 TYPE=Ethernet IPADDR=192.168.1.42 BOOTPROTO=static NETMASK=255.255.255.0 ONBOOT=yes NM_CONTROLLED=yes HWADDR=52:54:76:AC:B5:9A
|
查看一下两台服务器eth1网卡的路由是否通畅:
Master端 |
[root@master ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth1 172.20.28.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0 0.0.0.0 172.20.28.1 0.0.0.0 UG 0 0 0 eth0 |
Slave端 |
[root@slave ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth1 172.20.28.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0 0.0.0.0 172.20.28.1 0.0.0.0 UG 0 0 0 eth0 |
[root@master ha.d]# ifconfig eth0:1 10.1.6.41/24 up |
说明:此处指设置一个vip,且设置在master端。 |
小结:添加路由操作:
Master:[root@master ~]# route add -host 192.168.1.42 dev eth1
Slave”[root@slave ~]# route add -host 192.168.1.41 dev eth1
1.5、两边服务器Hosts
[root@master ha.d]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.41 master
192.168.1.42 slave
小结:这里配置的IP是心跳线IP。
二、安装heartbeat服务(版本:heartbeat-3.0.4)
2.1 安装heartbeat软件包
[root@master ~]# yum install heartbeat -y
2.2 拷贝heartbeat配置文件
[root@master ~]# cp /usr/share/doc/heartbeat-3.0.4/{ha.cf,authkeys,haresources} /etc/ha.d/
[root@master ~]# ll /etc/ha.d/
-rw-r--r-- 1 root root 645 Nov 30 11:36 authkeys
-rw-r--r-- 1 root root 10502 Nov 30 11:36 ha.cf
-rwxr-xr-x 1 root root 745 Dec 3 2013 harc
-rw-r--r-- 1 root root 5905 Nov 30 11:36 haresources
drwxr-xr-x 2 root root 4096 Nov 30 11:24 rc.d
-rw-r--r-- 1 root root 692 Dec 3 2013 README.config
drwxr-xr-x 2 root root 4096 Nov 30 11:24 resource.d
-rw-r--r-- 1 root root 2082 Mar 24 2017 shellfuncs
2.3 编辑heartbeat配置文件
[root@master ha.d]# egrep -Ev "^#|^$" ha.cf debugfile /var/log/ha-debug logfile /var/log/ha-log logfacility local1 keepalive 2 deadtime 30 warntime 10 initdead 60 mcast eth0 225.0.0.1 694 1 0 auto_failback on node master node slave crm no |
[root@master ha.d]# cat /etc/ha.d/authkeys auth 1 1 sha1 0832bedde820a9bcf6858c0ff6e5e82a #这个authkeys是可用的,验证过了。 [root@slave ha.d]# chmod 600 /etc/ha.d/authkeys |
[root@master ha.d]# egrep -Ev "^#|^$" haresources master IPaddr::10.1.6.41/24/eth0 |
[root@master ha.d]# egrep -Ev "^#|^$" haresources
master IPaddr::10.1.6.41/24/eth0
2.4 启动heartbeat服务
[root@slave ha.d]# /etc/init.d/heartbeat start
[root@slave ha.d]# cat /var/log/ha-log
Nov 30 13:35:17 slave heartbeat: [11068]: info: Pacemaker support: no
Nov 30 13:35:17 slave heartbeat: [11068]: WARN: Logging daemon is disabled --enabling logging daemon is recommended
Nov 30 13:35:17 slave heartbeat: [11068]: info: **************************
Nov 30 13:35:17 slave heartbeat: [11068]: info: Configuration validated. Starting heartbeat 3.0.4
Nov 30 13:35:17 slave heartbeat: [11069]: info: heartbeat: version 3.0.4
Nov 30 13:35:17 slave heartbeat: [11069]: info: Heartbeat generation: 1512018408
Nov 30 13:35:17 slave heartbeat: [11069]: info: glib: UDP multicast heartbeat started for group 225.0.0.1 port 694 interface eth0 (ttl=1 loop=0)
Nov 30 13:35:17 slave heartbeat: [11069]: info: G_main_add_TriggerHandler: Added signal manual handler
Nov 30 13:35:17 slave heartbeat: [11069]: info: G_main_add_TriggerHandler: Added signal manual handler
Nov 30 13:35:17 slave heartbeat: [11069]: info: G_main_add_SignalHandler: Added signal handler for signal 17
Nov 30 13:35:17 slave heartbeat: [11069]: info: Local status now set to: 'up'
Nov 30 13:35:58 slave heartbeat: [11069]: info: Link master:eth0 up.
Nov 30 13:35:58 slave heartbeat: [11069]: info: Status update for node master: status up
harc(default)[11106]: 2017/11/30_13:35:58 info: Running /etc/ha.d//rc.d/status status
Nov 30 13:35:59 slave heartbeat: [11069]: info: Comm_now_up(): updating status to active
Nov 30 13:35:59 slave heartbeat: [11069]: info: Local status now set to: 'active'
Nov 30 13:35:59 slave heartbeat: [11069]: info: Status update for node master: status active
harc(default)[11126]: 2017/11/30_13:35:59 info: Running /etc/ha.d//rc.d/status status
Nov 30 13:36:10 slave heartbeat: [11069]: info: remote resource transition completed.
Nov 30 13:36:10 slave heartbeat: [11069]: info: remote resource transition completed.
Nov 30 13:36:10 slave heartbeat: [11069]: info: Initial resource acquisition complete (T_RESOURCES(us))
Nov 30 13:36:10 slave heartbeat: [11150]: info: No local resources [/usr/share/heartbeat/ResourceManager listkeys slave] to acquire.
至此,heartbeat就配置完成了。