Chinaunix首页 | 论坛 | 博客
  • 博客访问: 222257
  • 博文数量: 22
  • 博客积分: 1676
  • 博客等级: 上尉
  • 技术积分: 420
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-31 10:48
文章分类

全部博文(22)

文章存档

2011年(8)

2010年(1)

2009年(1)

2008年(12)

我的朋友

分类: LINUX

2010-11-17 15:26:32

文件: ha+apache_test_result.tar.gz
大小: 3KB
下载: 下载
#######################################
# Environment                         #
#######################################

node1:
OS: CentOS-5.5 i386
eth0:192.168.50.101/24
eth1: 10.50.0.101/16
node2:
OS: CentOS-5.5 i386
eth0:192.168.50.102/24
eth1: 10.50.0.102/16
Virtual IP: 192.168.50.100/24

#######################################
# pkgs setup and config               #
#######################################

# rpm -qa|grep heartbeat
heartbeat-pils-2.1.4-11.el5
heartbeat-stonith-2.1.4-11.el5
heartbeat-2.1.4-11.el5

# chkconfig heartbeat on

# rpm -qa|grep httpd
httpd-2.2.3-43.el5.centos.3

# chkconfig httpd on

# vi /etc/sysctl.conf
net.ipv4.ip_forward = 1

# vi /etc/hosts
192.168.50.101 node1
192.168.50.102 node2
192.168.50.100 web

# vi /etc/sysconfig/network
HOSTNAME=node1 # node1
HOSTNAME=node2 # node2

# hostname node1 # node1
# hostname node2 # node2

#######################################
# HA config                           #
#######################################

For any Heartbeat cluster, the following configuration files must be available:
/etc/ha.d/ha.cf — the global cluster configuration file
/etc/ha.d/authkeys — a file containing keys for mutual node authentication.
haresources: resources file,包括heartbeat服务启动时使用的资源。

1)# cat /etc/ha.d/ha.cf
logfile /var/log/ha-log
logfacility     local0
keepalive 2
deadtime 5
warntime 3
initdead 10
udpport 694
bcast   eth1
auto_failback on
watchdog /dev/watchdog
node node1
node node2

# Notes:
a. use_logd on|off: to specify whether Heartbeat logs its messages through logging daemon or not;
When it is used, logfile/debugfile/logfacility in this file are not meaningful 
b. logfacility: to tell Heartbeat which syslog logging facility it should use for logging its messages;
c. autojoin: cluster node auto-discovery
none: disables automatic joining; and requires that cluster nodes be listed explicitly, using the node options
other: allows nodes other than ourself who are not listed in ha.cf to join automatically. In other words, our node has to be listed in ha.cf, but other nodes do not. 
any: allows any node to join automatically without being listed in ha.cf, even the current node
d. bcast: to configure which interfaces Heartbeat sends UDP broadcast traffic on;
  mcast: to configure a multicast communication path;
  ucast: to configure Heartbeat to communicate over a UDP unicast communications link;
e. udpport: to specify which port Heartbeat will use for its UDP intra-cluster communication;
f. node failure detection: (seconds)
warntime: the time after which Heartbeat issues a warning that a no longer available peer node may be dead; how quickly Heartbeat should issue a "late heartbeat" warning;
deadtime: the time after which Heartbeat considers a node confirmed dead; how quickly Heartbeat should decide that a node in a cluster is dead;
initdead: the maximum time it waits for other nodes to check in at cluster startup; the time that it takes to declare a cluster node dead when Heartbeat is first started;
keepalive: the interval between heartbeat packets; 
g. node: cluster members, the exact host names of cluster nodes as given by uname -n;
h. crm respawn enables the Pacemaker cluster manager, and ensures that Pacemaker is automatically restarted in case of a failure;
i. crm: to enable the Pacemaker Cluster Manager;  it should always be set to respawn
2)# cat /etc/ha.d/haresources
node1 IPaddr::192.168.50.100 httpd

3)# cat /etc/ha.d/authkeys
auth 1
1 crc
# chmod 0600 /etc/ha.d/authkeys
# Notes:
Format:
auth num
num algorithm secret

Note:
a. num: simple key index, starting with 1;
b. algorithm: the signature algorithm being used, (crc, md5 or sha1); 
c. secret: the actual authentication key;
( echo -ne "auth 1\n1 sha1 "; \
  dd if=/dev/urandom bs=512 count=1 | openssl md5 ) \
  > /etc/ha.d/authkeys

# To propagate the contents of the ha.cf and authkeys configuration files  
# /usr/lib/heartbeat/ha_propagate

This utility will copy the configuration files over to any node listed in /etc/ha.d/ha.cf using scp;
It also connect to the nodes using ssh and issue "chkconfig heartbeat on"; 

#######################################
# HA startup and verification         #
#######################################

node1: 
# service httpd start
# cat /var/www/html/test.html

test
# service heartbeat start
Starting High-Availability services:
2010/11/12_15:01:34 INFO:  Resource is stopped
                                                           [  OK  ]
# ps -ef|grep heartbeat
root      9164     1  0 15:01 ?        00:00:00 heartbeat: master control process
nobody    9167  9164  0 15:01 ?        00:00:00 heartbeat: FIFO reader
nobody    9168  9164  0 15:01 ?        00:00:00 heartbeat: write: bcast eth1
nobody    9169  9164  0 15:01 ?        00:00:00 heartbeat: read: bcast eth1

Note: heartbeat is still running although it reports "Resource is stopped";

# ifconfig eth0:0
eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:93:5F:52
          inet addr:192.168.50.100  Bcast:192.168.50.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:177 Base address:0x1400
 
Note: Virtual IP is running.

# netstat -anu|grep 694
udp        0      0 0.0.0.0:694                 0.0.0.0:*                       

Note: UDP port is opening.

node2: 
# service httpd stop
# cat /var/www/html/test.html

test
# service heartbeat start
# ps -ef|grep heartbeat
# netstat -anu|grep 694

# ping rhel5-1
# ping rhel5-2
# ping web

#######################################
# Failover test                       #
#######################################

Please refer to attached file.

References:

阅读(1081) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~