CentOS 4.6 Heartbeat+openvpn配置文档
一.操作系统
CentOS 4.6全完安装
二.文档说明
本文 档只是对服务器做了一个ha,并没有指出openvpn client的,至于请参考网上资料。(非常多)
三.IP及主机名规化
node1 eth0 192.168.1.116 eth1 192.168.1.117
node2 eth0 192.168.1.118 eht1 192.168.1.119
vip 192.168.1.120
四.Heartbeat 安装
# yum install heartbeat
五.Openvpn安装配置(node1配置)
# rpm -ihv lzo-1.08-4.2.el4.rf.i386.rpm
# rpm -ihv openvpn-2.0.9-1.el4.rf.i386.rpm
# mkdir /etc/openvpn/ -p
# cp /usr/share/doc/openvpn-2.0.9/sample-config-files/server.conf /etc/openvpn/
# cp -r /usr/share/doc/openvpn-2.0.9/easy-rsa/ /etc/openvpn/
# cd /etc/openvpn/easy-rsa/
# chmod 777 *
# source vars
# ./clean-all
# ./build-ca
出现 “Common Name (eg, your name or your server's hostname) []:”时输 入server,别的默认直接回车就可以
# ./build-key-server server
出现 “Common Name (eg, your name or your server's hostname) []:”时输 入server
出 现:“Certificate is to be certified until Aug 17 08:30:49 2017 GMT (3650 days)
Sign the certificate? [y/n]:“ 时选 y(一共有两次,别的不用管回车就可以)
# ./build-key client
出 现:“Common Name (eg, your name or your server's hostname) []:”输入 “client”
出现:“Certificate is to be certified until Aug 17 08:33:36 2017 GMT (3650 days)
Sign the certificate? [y/n]:“时先y
# ./build-dh
# cd keys/
# cp ca.crt server.key server.crt dh1024.pem /etc/openvpn/
六.Heartbeat的配置(node1配置)
# cd /usr/share/doc/heartbeat-2.1.3/
# cp ha.cf haresources authkeys /etc/ha.d/
# vi /etc/ha.d/ha.cf
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
bcast eth1
auto_failback on
node node1
node node2
crm yes
# vi /etc/ha.d/authkeys
auth 1
1 crc
# chmod 600 /etc/ha.d/authkeys
# vi /etc/ha.d/haresources
node1 192.168.1.120 openvpn
# python /usr/lib/heartbeat/haresources2cib.py /etc/ha.d/haresources
chkconfig openvpn off
chkconfig heartbeat on
七.克隆node1到node2并修改主机名和ip
这里 我是用的是Acronis True Image Echo Enterprise Server软件,为了省事没有从另一台安装相关软件采用了克隆的方式。
八.测试
1. down掉node1,VIP和openvpn服务会自动转换到node2服务器上
2. down掉node1服务器的openvpn服务,node1首先会自动重启openvpn服务,如果openvpn服务器重启失败,VIP和openvpn服务会乍动转换到node2服务器上(这里我让openvpn服务器重启失败的方法是把openvpn服务端口上别的服务用了,openvpn启动时发现端口已经使用无法启动)
- 最新评论
