Linux环境下FTP实现双机热备
生产环境中要实现数据存储,本下昂木使用ftp+MFS实现数据存储,
为预防鸡群中ftp单点故障,采用ftp+keepalived实现高可用
两台FTP服务器已安装完毕,且能正常访问,IP地址分别为192.168.10.192和192.168.10.193
vip设置为192.168.10.190
第一步 安装
热备服务软件:
LVS:
ipvsadm-1.26-3.1.i586.rpm
KeepAlived:
keepalived-1.2.13.tar.gz
LVS采用的是yum安装
yum install ipvsadm
keepalived使用源码安装
#tar -zxvf keepalived-1.2.13.tar.gz
#cd keepalived-1.2.13
#./configure --prefix=/usr/local/keepalived
#make && make install
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
mkdir /etc/keepalived
cd /etc/keepalived/
配置MASTER 192.168.10.192
编辑/etc/keepalived/keepalived.conf
*************************************
global_defs {
router_id LVS_DEVEL
}
vrrp_sync_group VGM {
group {
VI_CACHE
}
}
vrrp_instance VI_CACHE {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.10.190
}
}
virtual_server 192.168.10.190 80 {
delay_loop 6
lb_algo wlc
lb_kind DR
# nat_mask 255.255.0.0
persistence_timeout 50
protocol TCP
real_server 192.168.10.192 80 {
weight 1
MISC_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 192.168.10.193 80 {
weight 1
MISC_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
*******************************************
注意:此时端口为keepalived使用的端口80,切记不要改成21,第一次我改掉之后,找了好长时间问题。
*******************************************
配置备份服务器BACKUP
vrrp_instance VI_CACHE {
state BACKUP
interface eth0
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.10.190
}
}
*******************************************
1,启动lvs
#ipvsadm
查看是否启动成功,
#lsmod |grep ip_v
2,启动keepalive
/etc/rc.d/init.d/keepalived start
查看是否启动成功,
#ps -ef|grep keepalived
3,查看热备情况,
#ipvsadm
#查看热备运行日志
#tail -f /var/log/message
4,查看虚拟地址是否正常加载到网卡上。
#ip a
#service vsftpd start
然后用第三方电脑访问虚拟地址 ftp 192.168.10.190,
可以看到当主备服务切换时,ftp客户端会分别登录到不同的服务器上(71或72),证明ftp服务双机热备正常搭建。