Linux實現Ftp服務雙機熱備

來源:互聯網
上載者:User

Linux實現Ftp服務雙機熱備 系統:opensuse 11.3 32位熱備服務軟體:LVS:ipvsadm-1.26-3.1.i586.rpmKeepAlived:keepalived-1.2.2.tar.gz  www.2cto.com  安裝步驟:一,lvs採用rpm包安裝比較方便#rpm -ivh ipvsadm-1.26-3.1.i586.rpm二,keepalived使用源碼安裝#tar -zxvf keepalived-1.1.15.tar.gz#cd keepalived-1.1.15#./configure --prefix=/usr/local/keepalived#make && make install 配置編輯/etc/keepalived/keepalived.conf#===================================配置開始====================================! Configuration File for keepalived #全域配置global_defs {   notification_email {     hbyc@163.com   }   notification_email_from root@localhost   smtp_server 127.0.0.1   smtp_connect_timeout 30   router_id LVS_DEVEL}  #VRRP配置vrrp_instance VI_1 {    state MASTER    interface eth1    virtual_router_id 51    priority 100     advert_int 1    authentication {        auth_type PASS        auth_pass 1111    }       virtual_ipaddress {        192.168.1.80    }   }  virtual_server 192.168.1.80 80 {    delay_loop 6    lb_algo rr    lb_kind DR      nat_mask 255.255.255.0    persistence_timeout 50    protocol TCP       real_server 192.168.1.81 80 {        weight 1        TCP_CHECK {        connect_timeout 10        nb_get_retry 3        delay_before_retry 3        connect_port 80        }       }         real_server 192.168.1.82 80 {        weight 1        TCP_CHECK {        connect_timeout 10        nb_get_retry 3        delay_before_retry 3        connect_port 80        }    }  }#===================================配置結束==================================== 1,啟動lvs#ipvsadm查看是否啟動成功,#lsmod |grep ip_vip_vs_rr                1122  1 ip_vs                 106759  3 ip_vs_rrlibcrc32c                971  1 ip_vs 2,啟動keepalive#keepalived start查看是否啟動成功,#ps -ef|grep keepalivedroot      3242     1  0 23:35 ?        00:00:00 keepalived startroot      3243  3242  0 23:35 ?        00:00:00 keepalived startroot      3244  3242  0 23:35 ?        00:00:00 keepalived startroot      3280  3107  0 23:41 pts/0    00:00:00 grep keepalived 3,查看熱備情況,#ipvsadmIP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port Scheduler Flags  -> RemoteAddress:Port           Forward Weight ActiveConn InActConnTCP  192.168.1.80:http rr persistent 50 #查看熱備作業記錄#tail -f /var/log/messageMar 12 23:35:24 linux-e1j0 avahi-daemon[2016]: Registering new address record for 192.168.1.80 on eth1.IPv4.Mar 12 23:35:26 linux-e1j0 Keepalived_healthcheckers: TCP connection to [192.168.1.81]:80 failed !!!Mar 12 23:35:26 linux-e1j0 Keepalived_healthcheckers: Removing service [192.168.1.81]:80 from VS [192.168.1.80]:80Mar 12 23:35:26 linux-e1j0 Keepalived_healthcheckers: Remote SMTP server [127.0.0.1:25] connected. 4,查看虛擬位址是否正常載入到網卡上。#ip a2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000    link/ether 00:0c:29:cb:c8:7d brd ff:ff:ff:ff:ff:ff    inet 192.168.1.71/24 brd 192.168.1.255 scope global eth1    inet 192.168.1.80/32 scope global eth1    inet6 fe80::20c:29ff:fecb:c87d/64 scope link        valid_lft forever preferred_lft forever可以看到 192.168.1.80/32 虛擬位址正常載入。 測試熱備服務:開啟日誌監控#tail -f /var/log/message關掉主服務#killall -9 keepalived可以看到備用服務日誌輸出:Mar 13 23:00:27 linux-backup Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATEMar 13 23:00:28 linux-backup Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATEMar 13 23:00:28 linux-backup avahi-daemon[2053]: Registering new address record for 192.168.1.80 on eth2.IPv4.Mar 13 23:00:28 linux-backup avahi-daemon[2053]: Withdrawing address record for fe80::20c:29ff:fec4:da16 on eth2.Mar 13 23:00:28 linux-backup avahi-daemon[2053]: Withdrawing address record for 192.168.1.72 on eth2. 開啟主伺服器服務#keepalived start可以看到備用服務日誌輸出:Mar 13 23:01:00 linux-backup Keepalived_vrrp: VRRP_Instance(VI_1) Received higher prio advertMar 13 23:01:00 linux-backup Keepalived_vrrp: VRRP_Instance(VI_1) Entering BACKUP STATEMar 13 23:01:00 linux-backup avahi-daemon[2053]: Server startup complete. Host name is linux-backup-89.local. Local service cookie is 2700730627.Mar 13 23:01:00 linux-backup avahi-daemon[2053]: Withdrawing address record for 192.168.1.80 on eth2. 這隻是能看到服務正常切換了。真正測試雙備服務的方法是,在主備服務上同時開啟ftp服務。#service vsftpd start然後用第三方電腦訪問虛擬位址 ftp 192.168.1.80,可以看到當主備服務切換時,ftp用戶端會分別登入到不同的伺服器上(71或72),證明ftp服務雙機熱備正常搭建。 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.