Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3243947
  • 博文数量: 710
  • 博客积分: 14546
  • 博客等级: 上将
  • 技术积分: 6738
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-30 10:20
文章分类

全部博文(710)

文章存档

2016年(1)

2014年(7)

2013年(22)

2012年(227)

2011年(322)

2009年(119)

2008年(12)

分类: LINUX

2012-01-13 16:43:29

共享存储配置就不写了

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
  1. chkconfig heartbeat on

4.install watchdog
  1. yum install watchdog
  2. /etc/init.d/watchdog start
  3. chkconfig watchdog on
  4. echo "modprobe softdog" >> /etc/rc.local
  5. modprobe softdog
  6. lsmod | grep soft
  7. ll /dev/watchdog
  8. 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配置文件
主配置文件
  1. cat > /usr/local/etc/ha.d/ha.cf <
  2. logfile /var/log/ha_log/ha-log.log
  3. debugfile /var/log/ha_log/ha-debug.log
  4. bcast eth1
  5. keepalive 1
  6. warntime 3
  7. deadtime 10
  8. initdead 120
  9. hopfudge 1
  10. udpport 694
  11. auto_failback off
  12. watchdog /dev/watchdog
  13. node node1  #uname -n
  14. node node2  #uname -n
  15. ping 192.168.0.136
  16. deadping 5
  17. crm respawn
  18. EOF
资源管理配置文件
  1. cat > /usr/local/etc/ha.d/haresources <
  2. node1 192.168.0.1 mount httpd
  3. EOF
配置heartbeat的认证文件
  1. cat > /usr/local/etc/ha.d/authkeys <<EOF
  2. auth 1
  3. 1 crc
  4. EOF
  5. chmod 600 /usr/local/etc/ha.d/authkeys
7.增加mount脚本,安装apache
  1. cat > /etc/init.d/mount <
  2. #!/bin/bash
  3. logger $0 called with $1
  4. case "$1" in
  5. start)
  6. mount /dev/mapper/vgdrbd-lvh0 /var/www/html
  7. ;;
  8. stop)
  9. umount /var/www/html
  10. ;;
  11. status)
  12. df -hP|column -t| grep html
  13. ;;
  14. esac
  15. EOF
  1. cp /etc/init.d/mount  /etc/ha.d/resource.d
  2. yum install httpd
8.同步2台服务器配置文件(修改后同步上面3个文件)
/usr/local/lib/heartbeat/ha_propagate

  1. #!/usr/bin/python
  2. # /usr/local/lib/heartbeat/ha_propagate
  3. import os, sys
  4. from stat import *

  5. cfgdir = "/usr/local/etc/ha.d/"
  6. cfgfile = cfgdir + "ha.cf"
  7. authfile = cfgdir + "authkeys"
  8. harefile = cfgdir + "haresources"

  9. try:
  10.         os.stat(cfgfile)
  11.         os.stat(authfile)
  12. except:
  13.         print "HA Linux not configured on this node. Can not propagate."
  14.         sys.exit()

  15. nodes = []

  16. f=open(cfgfile)
  17. for line in f:
  18.     if line.startswith("node"):
  19.        toks = line.split()
  20.        if (len(toks) == 2):
  21.           nodeName = toks[1]
  22.           nodes.append(nodeName)
  23. f.close()

  24. thisnode = os.uname()[1]
  25. if nodes.count(thisnode) > 0:
  26.    nodes.remove(thisnode)

  27. for i, v in enumerate(nodes):
  28.     print "Propagating HA configuration files to node " + v + "."
  29.     res = os.system("scp " + cfgfile + " " + authfile + " " + harefile + " root@" + v + ":" + cfgdir)
  30.     print "Setting HA startup configuration on node " + v + "."
  31.     res = os.system("ssh " + " root@" + v + " chkconfig --add heartbeat")
9.拷贝认证文件,hb_gui才能通过pam登陆
  1. cp /usr/local/etc/pam.d/hbmgmtd /etc/pam.d/
10.图形界面设置了
  1. hb_gui &



















阅读(1215) | 评论(0) | 转发(0) |
0

上一篇:mysql同步出错

下一篇:oracle启动脚本

给主人留下些什么吧!~~