LINUX服務集羣系統 linux virtual server(LVS) ---章文嵩開發 實現LINUX平臺下的簡單負載均衡。 負載調度器 服務器池 後端存儲(backend storage) MFS---分佈式文件存儲系統 負載均衡的方式: 1.NAT 2.TUN 3.DR 利用大多數internet服務的非對稱特色,負載調度器中只負責調度請求,而服務器直接相應返回給客戶,能夠極大地提升整個集羣系統的吞吐量。 調度器和服務器組必須在物理上有一個網卡經過不分段的局域網相連。即經過交換機或者告訴的HUB相連,中間沒有隔有路由器。 負載調度算法: 1.輪叫調度 RR(round-robin scheduling) 平均對待每一臺real server而無論服務器上的實際負載均衡情況和連接狀態。 2.加權輪叫調度 WRR(Weighted Round-Robin Scheduling) 根據real server的不一樣處理能力來調度請求,能夠對每臺real server設置不一樣的調度權值 3.最小連接調度 LC(Least-Connection Scheduling) 動態地將網絡請求調度到已創建的連接數最少的服務器上。若是集羣系統的real server具備相近似的性能,能夠較好的均衡負載。 4.加權最小連接調度 WLC(Weighted Least-Connection Scheduling) 每一個服務器節點的能夠用相應的權值來表示其處理能力,而系統管理源能夠動態的設置相應的權值,默認值爲1,加權最小連接調度在分配新連接請求時儘量使服務節點的已創建鏈接數和其權值成正比。 5.基於局部性的最少連接(Locality-Based Least Connections Scheduling) 6.帶複製的基於局部性最少連接(Locality-Based Least Connections with Replication Scheduling) 7.目標地址散列調度(Destination Hashing Scheduling) 8.源地址散列調度(Source Hashing Scheduling)
安裝html
安裝ipvsadm,keepalived-1.2.9 (1)下載軟件 //本機內核版本: # uname -r 2.6.32-358.el6.x86_64 下載地址: --相應版本 http://www.linuxvirtualserver.org/software/ipvs.html#kernel-2.6 #wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz keepalived http://www.keepalived.org/download.html #wget http://www.keepalived.org/software/keepalived-1.2.19.tar.gz (2)編譯安裝ipvsadm //安裝依賴包 [root@nan85 ipvsadm-1.26]# yum list|grep kernel-dev [root@nan85 ipvsadm-1.26]# yum list|grep popt [root@nan85 lvs]# yum -y install popt-static.x86_64 popt-devel.x86_64 popt.x86_64 [root@nan85 lvs]# yum -y install wget libnl* popt* gcc.x86_64 gcc-c++.x86_64 gcc-objc++.x86_64 kernel-devel.x86_64 make popt-static.x86_64 //確認模塊 [root@nan85 lvs]# modprobe -l|grep ipvs kernel/net/netfilter/ipvs/ip_vs.ko kernel/net/netfilter/ipvs/ip_vs_rr.ko kernel/net/netfilter/ipvs/ip_vs_wrr.ko kernel/net/netfilter/ipvs/ip_vs_lc.ko kernel/net/netfilter/ipvs/ip_vs_wlc.ko kernel/net/netfilter/ipvs/ip_vs_lblc.ko kernel/net/netfilter/ipvs/ip_vs_lblcr.ko kernel/net/netfilter/ipvs/ip_vs_dh.ko kernel/net/netfilter/ipvs/ip_vs_sh.ko kernel/net/netfilter/ipvs/ip_vs_sed.ko kernel/net/netfilter/ipvs/ip_vs_nq.ko kernel/net/netfilter/ipvs/ip_vs_ftp.ko //編譯keepalived-1.2.9 [root@nan85 lvs]# tar xvf keepalived-1.2.19.tar.gz 須要安裝基礎軟件包openssl和popt yum install net-snmp.x86_64 net-snmp-devel.x86_64 ./configure --prefix=/usr/local/keepalived --enable-snmp --sysconfdir=/etc/ 出現錯誤: configure: error: unable to find net-snmp-config 解決方法: [root@nan85 keepalived-1.2.9]# yum install net-snmp.x86_64 net-snmp-devel.x86_64 Keepalived version : 1.2.9 Compiler : gcc Compiler flags : -g -O2 Extra Lib : -Wl,-z,relro -Wl,-z,now -L/usr/lib64 -lnetsnmpagent -lnetsnmphelpers -lnetsnmpmibs -lnetsnmp -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE -lssl -lcrypto -lcrypt -lnl Use IPVS Framework : Yes IPVS sync daemon support : Yes IPVS use libnl : Yes Use VRRP Framework : Yes Use VRRP VMAC : Yes SNMP support : Yes SHA1 support : No Use Debug flags : No [root@nan85 keepalived-1.2.9]# make && make install [root@nan85 ~]# cp /usr/local/keepalived/sbin/keepalived /sbin/ [root@nan85 ~]# cp /usr/local/keepalived/bin/genhash /bin/ [root@nan85 ~]# cd /etc/keepalived/ [root@nan85 keepalived]# ls keepalived.conf samples --keepalived軟件不對keepalived語法進行檢查,在編輯前須要備份 配置文件由如下三個部分組成: global_defs vrrp_instance virtual_server