共享存储配置就不写了
1.add user on node1/2
[root@node1 ~]# groupadd -g 666 haclient
[root@node1 ~]# useradd -u 666 -g haclient hacluster
[root@node1 ~]# echo "hacluster" | passwd hacluster --stdin
2.install libnet.tar.gz on node1/2
3.install heartbeat.tar.gz on node1/2
4.install watchdog
- yum install watchdog
-
/etc/init.d/watchdog start
-
chkconfig watchdog on
- echo "modprobe softdog" >> /etc/rc.local
- modprobe softdog
- lsmod | grep soft
- ll /dev/watchdog
- echo "kernel.panic = 60" >> /etc/sysctl.conf
5.mkdir log dir on node1/2
mkdir /var/log/ha_log
chmod -R 777 /var/log/ha_log/
6.修改heartbeat配置文件
主配置文件
- cat > /usr/local/etc/ha.d/ha.cf <
- logfile /var/log/ha_log/ha-log.log
-
debugfile /var/log/ha_log/ha-debug.log
-
bcast eth1
-
keepalive 1
-
warntime 3
-
deadtime 10
-
initdead 120
-
hopfudge 1
-
udpport 694
-
auto_failback off
-
watchdog /dev/watchdog
-
node node1 #uname -n
-
node node2 #uname -n
-
ping 192.168.0.136
-
deadping 5
-
crm respawn
- EOF
资源管理配置文件
- cat > /usr/local/etc/ha.d/haresources <
- node1 192.168.0.1 mount httpd
- EOF
配置heartbeat的认证文件
- cat > /usr/local/etc/ha.d/authkeys <<EOF
-
auth 1
-
1 crc
-
EOF
- chmod 600 /usr/local/etc/ha.d/authkeys
7.增加mount脚本,安装apache
- cat > /etc/init.d/mount <
- #!/bin/bash
-
logger $0 called with $1
-
case "$1" in
-
start)
-
mount /dev/mapper/vgdrbd-lvh0 /var/www/html
-
;;
-
stop)
-
umount /var/www/html
-
;;
-
status)
-
df -hP|column -t| grep html
-
;;
-
esac
- EOF
- cp /etc/init.d/mount /etc/ha.d/resource.d
- yum install httpd
8.同步2台服务器配置文件(修改后同步上面3个文件)
/usr/local/lib/heartbeat/ha_propagate
-
#!/usr/bin/python
-
# /usr/local/lib/heartbeat/ha_propagate
-
import os, sys
-
from stat import *
-
-
cfgdir = "/usr/local/etc/ha.d/"
-
cfgfile = cfgdir + "ha.cf"
-
authfile = cfgdir + "authkeys"
-
harefile = cfgdir + "haresources"
-
-
try:
-
os.stat(cfgfile)
-
os.stat(authfile)
-
except:
-
print "HA Linux not configured on this node. Can not propagate."
-
sys.exit()
-
-
nodes = []
-
-
f=open(cfgfile)
-
for line in f:
-
if line.startswith("node"):
-
toks = line.split()
-
if (len(toks) == 2):
-
nodeName = toks[1]
-
nodes.append(nodeName)
-
f.close()
-
-
thisnode = os.uname()[1]
-
if nodes.count(thisnode) > 0:
-
nodes.remove(thisnode)
-
-
for i, v in enumerate(nodes):
-
print "Propagating HA configuration files to node " + v + "."
-
res = os.system("scp " + cfgfile + " " + authfile + " " + harefile + " root@" + v + ":" + cfgdir)
-
print "Setting HA startup configuration on node " + v + "."
-
res = os.system("ssh " + " root@" + v + " chkconfig --add heartbeat")
9.拷贝认证文件,hb_gui才能通过pam登陆
- cp /usr/local/etc/pam.d/hbmgmtd /etc/pam.d/
10.图形界面设置了
阅读(1208) | 评论(0) | 转发(0) |