高可用集群——HA
Linux 十月 11th, 2009高可用集群——HA
2008年3月10日
当日小结:
掌握使用heartbeat对Director做高可用集群HA(High Availability)。
“数据源”和“单一故障点(SOPE)”需要做HA集群。
HA方式:(三种)
主从方式HA:
主从方式HA:从服务平时不运行。只有当主服务DOWN掉时,从服务才马上启用。
对称方式HA:
现在,一般的陈列柜都有双控制器,可以有来个服务同时进行读写。
集群方式HA:
安装heartbeat:
#rpm -ivh *.rpm –force –nodeps
#cp /usr/share/doc/heart-2.1.2/ha.cf /etc/ha.d/ #主配置文件。
#cp /usr/share/doc/heart-2.1.2/haresources /etc/ha.d/ #切换配置文件。
#cp /usr/share/doc/heart-2.1.2/authkeys /etc/ha.d/ #认证文件。
#cp /usr/share/doc/heartbeat-ldirectord2.1.2/ldirectord.cf /etc/ha.d/
#查看real server是否正常工作的文件。
Director的HA集群:
主Director:
/etc/ha.d/ha.cf #主配置文件
写:debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2 #一分钟内进行2秒心跳。
deadtime 10 #10秒没心跳为“死心跳”。
warntime 6 #6秒没心跳,就警告。
initdead 120 #开机120秒“死心跳”。
udpport 694 #网卡心跳。用UDP:694端口。
#band 19200 #波特率,串口心跳。
#serial /dev/ttyS0 #linux的串口设备。
#bcast eth0 #广播心跳。
#mcast eth0 225.0.0.1 694 1 0 #组播心跳。
#ucast eth0 192.168.0.68 #UDP 点到点通信。设对方IP。
auto_failback on #on:从从服务器再切换回主服务器。
#off:主服务器DOWN掉→从服务器启动,主服务器UP了,不自动切换回主服务器,还是由从服务器运行。
#stonith baytech /etc/ha.d/conf/stonith.baytech
#stonith_host * baytech 10.0.0.3 mylogin mysecretpassword
#设置可编程电源控制器
watchdog /dev/watchdog #软看门狗,要#modprobe softdog
node tq.com #必须用主机名。写在前为主Server,写在后为从Server。
node cz.com #要在/etc/hosts文件中对应IP。写:192.168.0.66 tq.com
192.168.0.168 cz.com
ping 192.168.0.68 #仲裁
respawn hacluster(或root) /usr/lib/heartbeat/ipfail
apiauth ipfail gid=haclient(或root) uid=hacluster(或root)
/etc/ha.d/authkeys 认证文件。
写:auth 1
1 crc
#chmod 600 /etc/ha.d/authkeys
/etc/ha.d/haresources 切换配置文件。
切换三要素:① VIP;
② server scripts 脚本
③ fs 文件系统。(当Director(无存储时)时,不用切换fs)
无存储时,写:tq.com IPaddr::VIP/24/eth0:1 ipvsadm ldirectord
当有存储时,写:node1 10.0.0.170 Filesystem::/dev/sda1::/data1::ext2
#ipvsadm配置并save。
#scp /etc/ha.d/ha.cf 到从服务
/etc/ha.d/haresoures
/etc/ha.d/suthkeys
/etc/hosts
/etc/sysconfig/ipvsadm
#service heartbeat start
#chkconfig ipvsadm off
#service ipvsadm stop
/etc/ha.d/ldirectord.cf 查看real server是否正常工作。
checktimeout=10 #10秒看不到,把real server的ipvsadm中-w权值清“0”。
checkinterval=5 #每隔5秒访问一下real server
fallback=127.0.0.1:80
autoreload=yes #再把/etc/sysconfig/ipvsadm中的-w权值设为“1”。
logfile=”/var/log/ldirectord.log”
#logfile=”local0”
##虚拟服务
virtual=VIP:80
real=RIP1:80 gate #DR(LVS)方式是gate。NAT(LVS)方式是masq。
隧道方式是ipip。
real=RIP2:80 gate
fallback=127.0.0.1:80 gate
service=http
request=”index.html” #apache的htdocs/目录下index.html文件中,要有“Test Page”这8个字符。
receive=”Test Page”
#virtualhost=some.domain.com.au
scheduler=rr
protocol=tcp
checktype=negotiate
checkport=80
#virtualhost=www.x.y.z
从Director:
① #vim /etc/ha.d/ha.cf
写对方IP:ucase eth0 192.168.0.66
② 看一下,hostname
③ #chkconfig ipvsadm off
#service ipvsadm stop
#chmod 600 /etc/ha.d/authkeys
查看:
#ipvsadm -L
#ifconfig eth0:1
Post Footer automatically generated by wp-posturl plugin for wordpress.
Recent Comments