乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      LVS+keepalived學(xué)習(xí) --主備

       憂(yōu)郁_小剛 2011-04-25

      LVS+keepalived學(xué)習(xí) --主備

      ((2009-10-23 10:23:06)

      上次做了LVS+keepalived的負(fù)載均衡,效果還不錯(cuò),但是沒(méi)有做主備,這次補(bǔ)上:

      安裝環(huán)境:環(huán)境 centos4.4

      關(guān)閉avahi-daemon

      service avahi-daemon stop

      一共準(zhǔn)備四臺(tái)機(jī)器:

      負(fù)載均衡機(jī)器:

      主:192.168.2.158 #安裝lvs+keepalived

      備:192.168.2.159 #安裝lvs+keepalived

      VIP:192.168.2.188

      real-server1:192.168.2.187 #僅執(zhí)行腳本

      real-server2:192.168.2.189 #僅執(zhí)行腳本


      安裝過(guò)程:

      在192.168.2.159上安裝ipvsadm和keepalived,方法不再贅述,主要看keepalived的配置:

      ! Configuration File for keepalived

      global_defs {

      notification_email {
      admin@xx.com #郵件地址,需要本機(jī)開(kāi)啟SMTP服務(wù)
      }
      notification_email_from root@localhost
      smtp_server 127.0.0.1
      smtp_connect_timeout 30
      router_id LVS_DEVEL2 #負(fù)載均衡器標(biāo)示:同一局域網(wǎng)內(nèi),應(yīng)該是唯一的。
      }

      vrrp_sync_group VGM {
      group {
      VI_1
      }
      }
      vrrp_instance VI_1 {
      state BACKUP
      #設(shè)置為BACKUP,通過(guò)priority控制那臺(tái)提升為主。
      interface eth0
      virtual_router_id 51
      priority 70
      advert_int 5
      authentication {
      auth_type PASS
      auth_pass 1111
      }
      virtual_ipaddress {
      192.168.2.188
      }
      }
      virtual_server 192.168.2.188 80 {
      delay_loop 6
      lb_algo rr
      lb_kind DR
      persistence_timeout 50
      protocol TCP

      real_server 192.168.2.187 80 {
      weight 3
      TCP_CHECK {
      nb_get_retry 3
      delay_before_retry 3
      connect_port 80
      connect_timeout 3
      }
      }
      real_server 192.168.2.189 80 {
      weight 1
      TCP_CHECK {
      nb_get_retry 3
      delay_before_retry 3
      connect_port 80
      connect_timeout 3
      }
      }
      }
      紅色標(biāo)記為需要修改的地方。
      執(zhí)行/etc/init.d/keepalived start
      附上備機(jī)keepalived的啟動(dòng)日志:
      Oct 22 23:40:35 test1 Keepalived: Starting Keepalived v1.1.17 (10/22,2009)
      Oct 22 23:40:35 test1 Keepalived_healthcheckers: Using MII-BMSR NIC polling thread...
      Oct 22 23:40:35 test1 Keepalived_healthcheckers: Netlink reflector reports IP 192.168.2.187 added
      Oct 22 23:40:35 test1 Keepalived_healthcheckers: Registering Kernel netlink reflector
      Oct 22 23:40:35 test1 Keepalived_healthcheckers: Registering Kernel netlink command channel
      Oct 22 23:40:35 test1 keepalived: keepalived startup succeeded
      Oct 22 23:40:35 test1 Keepalived_healthcheckers: Opening file '/etc/keepalived/keepalived.conf'.
      Oct 22 23:40:35 test1 Keepalived_healthcheckers: Configuration is using : 10675 Bytes
      Oct 22 23:40:35 test1 Keepalived_healthcheckers: Activating healtchecker for service [192.168.2.187:80]
      Oct 22 23:40:35 test1 Keepalived_healthcheckers: Activating healtchecker for service [192.168.2.189:80]
      Oct 22 23:40:35 test1 Keepalived: Starting Healthcheck child process, pid=5387
      Oct 22 23:40:35 test1 Keepalived_vrrp: Using MII-BMSR NIC polling thread...
      Oct 22 23:40:35 test1 Keepalived_vrrp: Netlink reflector reports IP 192.168.2.187 added
      Oct 22 23:40:35 test1 Keepalived_vrrp: Registering Kernel netlink reflector
      Oct 22 23:40:35 test1 Keepalived: Starting VRRP child process, pid=5389
      Oct 22 23:40:35 test1 Keepalived_vrrp: Registering Kernel netlink command channel
      Oct 22 23:40:35 test1 Keepalived_vrrp: Registering gratutious ARP shared channel
      Oct 22 23:40:35 test1 Keepalived_vrrp: Opening file '/etc/keepalived/keepalived.conf'.
      Oct 22 23:40:35 test1 Keepalived_vrrp: Configuration is using : 37155 Bytes
      Oct 22 23:40:35 test1 Keepalived_vrrp: VRRP_Instance(VI_1) Entering BACKUP STATE
      Oct 22 23:40:35 test1 Keepalived_vrrp: VRRP sockpool: [ifindex(2), proto(112), fd(10,11)]
      當(dāng)停掉主負(fù)載均衡時(shí),備機(jī)負(fù)載均衡的接管日志:
      Oct 22 23:42:18 test1 Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
      Oct 22 23:42:18 test1 Keepalived_vrrp: VRRP_Group(VGB) Syncing instances to MASTER state
      Oct 22 23:42:23 test1 Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
      Oct 22 23:42:23 test1 Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.
      Oct 22 23:42:23 test1 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.2.188
      Oct 22 23:42:23 test1 Keepalived_vrrp: Netlink reflector reports IP 192.168.2.188 added
      Oct 22 23:42:23 test1 Keepalived_healthcheckers: Netlink reflector reports IP 192.168.2.188 added
      Oct 22 23:42:28 test1 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.2.188

      當(dāng)重啟主負(fù)載均衡時(shí),備機(jī)負(fù)載均衡的日志:

      Oct 22 23:43:18 test1 Keepalived_vrrp: VRRP_Instance(VI_1) Received higher prio advert
      Oct 22 23:43:18 test1 Keepalived_vrrp: VRRP_Instance(VI_1) Entering BACKUP STATE
      Oct 22 23:43:18 test1 Keepalived_vrrp: VRRP_Instance(VI_1) removing protocol VIPs.
      Oct 22 23:43:18 test1 Keepalived_vrrp: VRRP_Group(VGB) Syncing instances to BACKUP state
      Oct 22 23:43:18 test1 Keepalived_vrrp: Netlink reflector reports IP 192.168.2.188 removed
      Oct 22 23:43:18 test1 Keepalived_healthcheckers: Netlink reflector reports IP 192.168.2.188 removed

      以上就完成雙機(jī)熱備的Lvs+keepalived的負(fù)載均衡。

      relserver上需要執(zhí)行的腳本:

      [root@test1 ~]# more /usr/local/bin/lvs_real
      #!/bin/sh
      VIP=192.168.2.188 (直接路由模式的vip必須跟服務(wù)器對(duì)外提供服務(wù)的ip地址在同一個(gè)網(wǎng)段)
      /etc/rc.d/init.d/functions
      case "$1" in
      start)
      echo " start tunl port"
      ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $VIP up

      (如果有多VIP,依次往下寫(xiě))
      echo "2">/proc/sys/net/ipv4/conf/all/arp_announce
      echo "1">/proc/sys/net/ipv4/conf/all/arp_ignore
      echo "2">/proc/sys/net/ipv4/conf/lo/arp_announce
      echo "1">/proc/sys/net/ipv4/conf/lo/arp_ignore
      ;;
      stop)
      echo " stop tunl port"
      ifconfig lo:0 down
      echo "0">/proc/sys/net/ipv4/conf/all/arp_announce
      echo "0">/proc/sys/net/ipv4/conf/all/arp_ignore
      echo "0">/proc/sys/net/ipv4/conf/lo/arp_announce
      echo "0">/proc/sys/net/ipv4/conf/lo/arp_ignore
      ;;

      *)
      echo "Usage: $0 {start|stop}"
      exit 1
      esac

      總結(jié):只需在負(fù)載均衡機(jī)器上安裝ipvsadm和keepalived,并執(zhí)行keepalived啟動(dòng)。在real server機(jī)器上僅需開(kāi)啟本地回環(huán)地址(腳本)即可,不用安裝任何軟件。

      經(jīng)驗(yàn):千萬(wàn)不要將負(fù)載均衡機(jī)器和web服務(wù)器搭建在一起,雖然端口等都不沖突,但是會(huì)出現(xiàn)莫名其妙的問(wèn)題..

      1.real server上未執(zhí)行此腳本時(shí):
      [root@linux keepalived]# ifconfig lo:0
      lo:0 Link encap:Local Loopback
      UP LOOPBACK RUNNING MTU:16436 Metric:1

      2.real server上執(zhí)行此腳本后:
      [root@linux keepalived]# /usr/local/bin/lvs_real start
      start tunl port
      [root@YuHao-linux keepalived]# ifconfig lo:0
      lo:0 Link encap:Local Loopback
      inet addr:192.168.2.188 Mask:255.255.255.255
      UP LOOPBACK RUNNING MTU:16436 Metric:1
      所以:
      keepalive機(jī)器上不用執(zhí)行此腳本,因?yàn)樵趉eepalived.conf中已經(jīng)定義了vip地址,
      而real server機(jī)器上必須執(zhí)行此腳本。將虛擬IP綁定在本機(jī)回環(huán)網(wǎng)卡上。

      這里還需注意一下MAC地址的問(wèn)題(netseek):
      假如兩臺(tái)VS之間使用的互備關(guān)系,那么當(dāng)一臺(tái)VS接管LVS服務(wù)時(shí),可能會(huì)網(wǎng)絡(luò)不通,這時(shí)因?yàn)槁酚善鞯腗AC緩存表里無(wú)法及時(shí)刷新MAC.關(guān)于vip這個(gè)地址的MAC地址還是替換的VS的MAC,有兩種解決方法,一種是修改新VS的MAC地
      址,另一種是使用 send_arp /arpiing 命令.
      以arping 命令為例.
      /sbin/arping -I eth0 -c 3 -s ${vip}${gateway_ip} > /dev/null 2>&1
      Eg:
      /sbin/arping -I eth0 -c 3 -s 192.168.1.6192.168.1.1

      如果采用Piranha/keealived方案切換的時(shí)候會(huì)內(nèi)置自動(dòng)發(fā)送 send_arp命令.UltraMonkey方案經(jīng)測(cè)試也會(huì)自動(dòng)發(fā)送此命令.如用 heartbeat方案,需要寫(xiě)一個(gè)send_arp 或者arping 相關(guān)的腳本當(dāng)作heartbeat 一個(gè)資源切換服務(wù)的時(shí)候自動(dòng)發(fā)送相關(guān)命令腳本.

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶(hù) 評(píng)論公約

        類(lèi)似文章 更多