N25期–第十七周作業

1、  結合圖形描述LVS的工作原理;

針對高可伸縮、高可用網絡服務的需求,給出了基于IP層和基于內容請求分發的負載平衡調度解決方法,并在Linux內核中實現了這些方法,將一組服務器構成一個實現可伸縮的、高可用網絡服務的虛擬服務器。

虛擬服務器的體系結構如圖所示,一組服務器通過高速的局域網或者地理分布的廣域網相互連接,在它們的前端有一個負載調度器(Load Balancer)。負載調度器能無縫地將網絡請求調度到真實服務器上,從而使得服務器集群的結構對客戶是透明的,客戶訪問集群系統提供的網絡服務就像訪 問一臺高性能、高可用的服務器一樣??蛻舫绦虿皇芊掌骷旱挠绊懖恍枳魅魏涡薷?。系統的伸縮性通過在服務機群中透明地加入和刪除一個節點來達到,通過檢 測節點或服務進程故障和正確地重置系統達到高可用性。由于負載調度技術是在Linux內核中實現的,稱之為Linux虛擬服務器(Linux Virtual Server)。

 

 N25期--第十七周作業

IP虛擬服務器軟件IPVS

在調度器的實現技術中,IP負載均衡技術是效率最高的。在已有的IP負載均衡技術中有通過網絡地址轉換(Network
Address Translation)將一組服務器構成一個高性能的、高可用的虛擬服務器,稱之為VS/NAT技術(Virtual
Server via Network Address Translation),大多數商品化的IP負載均衡調度器產品都是使用此方法,如Cisco的LocalDirector、F5的Big/IP和 Alteon的ACEDirector。在分析VS/NAT的缺點和網絡服務的非對稱性的基礎上,提出通過IP隧道實現虛擬服務器的方法VS/TUN (Virtual
Server via IP Tunneling),和通過直接路由實現虛擬服務器的方法VS/DR(Virtual
Server via Direct Routing),它們可以極大地提高系統的伸縮性。所以,IPVS軟件實現了這三種IP負載均衡技術,它們的大致原理如下

Virtual Server via Network Address TranslationVS/NAT
通過網絡地址轉換,調度器重寫請求報文的目標地址,根據預設的調度算法,將請求分派給后端的真實服務器;真實服務器的響應報文通過調度器時,報文的源地址被重寫,再返回給客戶,完成整個負載調度過程。

1.   Virtual
Server via IP Tunneling
VS/TUN
采用NAT技術時,由于請求和響應報文都必須經過調度器地址重寫,當客戶請求越來越多時,調度器的處理能力將成為瓶頸。為了解決這個問題,調度器把請求報 文通過IP隧道轉發至真實服務器,而真實服務器將響應直接返回給客戶,所以調度器只處理請求報文。由于一般網絡服務應答比請求報文大許多,采用 VS/TUN技術后,集群系統的最大吞吐量可以提高10倍。

2.   Virtual
Server via Direct Routing
VS/DR
VS/DR通過改寫請求報文的MAC地址,將請求發送到真實服務器,而真實服務器將響應直接返回給客戶。同VS/TUN技術一樣,VS/DR技術可極大地 提高集群系統的伸縮性。這種方法沒有IP隧道的開銷,對集群中的真實服務器也沒有必須支持IP隧道協議的要求,但是要求調度器與真實服務器都有一塊網卡連 在同一物理網段上。

針對不同的網絡服務需求和服務器配置,IPVS調度器實現了如下八種負載調度算法:

1.   輪叫(Round Robin
調度器通過”輪叫”調度算法將外部請求按順序輪流分配到集群中的真實服務器上,它均等地對待每一臺服務器,而不管服務器上實際的連接數和系統負載。

2.   加權輪叫(Weighted
Round Robin

調度器通過”加權輪叫”調度算法根據真實服務器的不同處理能力來調度訪問請求。這樣可以保證處理能力強的服務器處理更多的訪問流量。調度器可以自動問詢真實服務器的負載情況,并動態地調整其權值。

3.   最少鏈接(Least
Connections

調度器通過”最少連接”調度算法動態地將網絡請求調度到已建立的鏈接數最少的服務器上。如果集群系統的真實服務器具有相近的系統性能,采用”最小連接”調度算法可以較好地均衡負載。

4.   加權最少鏈接(Weighted
Least Connections

在集群系統中的服務器性能差異較大的情況下,調度器采用”加權最少鏈接”調度算法優化負載均衡性能,具有較高權值的服務器將承受較大比例的活動連接負載。調度器可以自動問詢真實服務器的負載情況,并動態地調整其權值。

5.   基于局部性的最少鏈接(Locality-Based
Least Connections

“基于局部性的最少鏈接” 調度算法是針對目標IP地址的負載均衡,目前主要用于Cache集群系統。該算法根據請求的目標IP地址找出該目標IP地址最近使用的服務器,若該服務器 是可用的且沒有超載,將請求發送到該服務器;若服務器不存在,或者該服務器超載且有服務器處于一半的工作負載,則用”最少鏈接”的原則選出一個可用的服務 器,將請求發送到該服務器。

6.   帶復制的基于局部性最少鏈接(Locality-Based
Least Connections with Replication

“帶復制的基于局部性最少鏈接”調度算法也是針對目標IP地址的負載均衡,目前主要用于Cache集群系統。它與LBLC算法的不同之處是它要維護從一個 目標IP地址到一組服務器的映射,而LBLC算法維護從一個目標IP地址到一臺服務器的映射。該算法根據請求的目標IP地址找出該目標IP地址對應的服務 器組,按”最小連接”原則從服務器組中選出一臺服務器,若服務器沒有超載,將請求發送到該服務器,若服務器超載;則按”最小連接”原則從這個集群中選出一 臺服務器,將該服務器加入到服務器組中,將請求發送到該服務器。同時,當該服務器組有一段時間沒有被修改,將最忙的服務器從服務器組中刪除,以降低復制的 程度。

7.   目標地址散列(Destination
Hashing

“目標地址散列”調度算法根據請求的目標IP地址,作為散列鍵(Hash Key)從靜態分配的散列表找出對應的服務器,若該服務器是可用的且未超載,將請求發送到該服務器,否則返回空。

8.   源地址散列(Source
Hashing

“源地址散列”調度算法根據請求的源IP地址,作為散列鍵(Hash Key)從靜態分配的散列表找出對應的服務器,若該服務器是可用的且未超載,將請求發送到該服務器,否則返回空。

N25期--第十七周作業

2、搭建一套LVS-DR模型的高性能集群,并實現以下功能:

  
(1)
、wordpress程序通過nfs共享給各個realserver;

  
(2)
、后端realserver中的nginxphp分離

網絡結構圖:


N25期--第十七周作業

環境說明:
    OS:centos6.7 x64
    主機IP:
        LVS-DR(director): 192.168.2.10
        realsever1 web1 Nginx: 192.168.2.11
        realserver2 web2 Nginx: 192.168.2.12
        PHP server: 192.168.2.13
        MySQL server: 192.168.2.14
    主機名:
        lvs-dr: 192.168.2.10
        realserver1: 192.168.2.11
        realserver2: 192.168.2.12
        php-server: 192.168.2.13
        mysql-server: 192.168.2.14
    selinux: disabled
    內網iptables: off
一、安裝nginx、MySQL
    1. Nginx 安裝:
    需要安裝的主機:
        Nginx:192.168.2.11、192.168.2.12
        MySQL:192.168.2.14
192.168.2.11:
(1) 搭建本地yum源:
[root@realserver1 yum.repos.d]# yum install gcc* -y     # 安裝gcc開發環境,為了編譯安裝nginx使用
[root@realserver1 yum.repos.d]# yum install ntpdate wget -y     # ntpdate 時間同步,wget 下載nginx
[root@realserver1 yum.repos.d]# ntpdate -s tiger.sina.com.cn     # 同步時間
[root@realserver1 src]# wget http://mirrors.sohu.com/nginx/nginx-1.9.9.tar.gz     # 下載nginx-1.9.9包
[root@realserver1 src]# groupadd -g 800 www    
[root@realserver1 src]# useradd -u 800 -g 800 -s /sbin/nologin www     # 創建nginx worker進程工作用戶
[root@realserver1 nginx-1.9.9]# yum install zlib zlib-devel pcre pcre-devel openssl openssl-devel -y    
# pcre 支持正則表達式 
# zlib 支持數據壓縮 
# openssl支持HTTPS
[root@realserver1 src]# tar xf nginx-1.9.9.tar.gz
[root@realserver1 src]# cd nginx-1.9.9
[root@realserver1 nginx-1.9.9]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module  --with-pcre
# --with-http_ssl_module 啟用HTTPS加密
# --with-http_stub_status_module 啟用nginx狀態監控
# --with-http_gzip_static_module  啟用靜態壓縮
# --with-http_realip_module 做代理時獲取客戶端真實IP
[root@realserver1 nginx-1.9.9]# make && make install
 
[root@realserver1 nginx-1.9.9]# vim /etc/init.d/nginx     # 創建nginx服務腳本
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
#   proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
    nginx="/usr/local/nginx/sbin/nginx"
    prog=$(basename $nginx)
    NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
    lockfile=/var/lock/subsys/nginx
 
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
[ $retval -eq 0 ] && touch $lockfile
    return $retval
}
 
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
[ $retval -eq 0 ] && rm -f $lockfile
    return $retval
    killall -9 nginx
}
 
restart() {
    configtest || return $?
    stop
    sleep 1
    start
}
 
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}
 
force_reload() {
    restart
}
 
configtest() {
    $nginx -t -c $NGINX_CONF_FILE
}
 
rh_status() {
    status $prog
}
 
rh_status_q() {
    rh_status >/dev/null 2>&1
}
 
case "$1" in
    start)
        rh_status_q && exit 0
        $1
    ;;
    stop)
        rh_status_q || exit 0
        $1
    ;;
    restart|configtest)
        $1
    ;;
    reload)
        rh_status_q || exit 7
        $1
    ;;
    force-reload)
        force_reload
    ;;
    status)
        rh_status
    ;;
    condrestart|try-restart)
        rh_status_q || exit 0
    ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac
 
[root@realserver1 conf]# chmod +x /etc/init.d/nginx
[root@realserver1 nginx-1.9.9]# cd /usr/local/nginx/conf/
[root@realserver1 conf]# vim nginx.conf
  2 user  www www;
[root@realserver1 conf]# vim /etc/profile.d/nginx.sh
[root@realserver1 conf]# source /etc/profile.d/nginx.sh
[root@realserver1 conf]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@realserver1 conf]# service nginx start
正在啟動 nginx:                                           [確定] 
[root@realserver1 conf]# chkconfig --add nginx
[root@realserver1 conf]# chkconfig nginx on
[root@realserver1 conf]# chkconfig --list nginx
nginx              0:關閉    1:關閉    2:啟用    3:啟用    4:啟用    5:啟用    6:關閉
 
[root@realserver1 conf]# curl -I http://192.168.2.11     # 測試本地訪問nginx服務
HTTP/1.1 200 OK
Server: nginx/1.9.9
Date: Sun, 19 Jun 2016 06:15:11 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Sun, 19 Jun 2016 06:03:48 GMT
Connection: keep-alive
ETag: "576635c4-264"
Accept-Ranges: bytes
測試客戶端訪問:

修改nginx配置文件如下:
行號
 43         location / {
 44             root   /webapp;
 45             index  index.html index.htm;
 46         }
 
 65         location ~ \.php$ {
 66             root           /webapp;
 67             fastcgi_pass   192.168.2.13:9000;
 68             fastcgi_index  index.php;
 69             include        fastcgi.conf;
 70         }
保存退出
[root@realserver1 conf]# mkdir /webapp
[root@realserver1 conf]# chown -R www:www /webapp/
[root@realserver1 conf]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@realserver1 conf]# service nginx reload
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
重新載入 nginx:                                           [確定]
realserver2 nginx配置如上同樣進行配置,這里不在貼代碼。
(2) MySQL: 192.168.2.14:
[root@mysql-server ~]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz
[root@mysql-server ~]# tar xf mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
[root@mysql-server local]# groupadd -g 306 mysql
[root@mysql-server local]# useradd -u 306 -g 306 -s /sbin/nologin mysql
[root@mysql-server local]# mkdir -pv /mydata/data
mkdir: created directory `/mydata'
mkdir: created directory `/mydata/data'
[root@mysql-server local]# chown -R mysql:mysql /mydata/
[root@mysql-server local]# cd mysql
[root@mysql-server mysql]# chown -R root:mysql .
[root@mysql-server mysql]# yum install libaio -y
[root@mysql-server mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
[root@mysql-server mysql]# cp -a support-files/mysql.server /etc/init.d/mysqld
[root@mysql-server mysql]# chmod +x /etc/init.d/mysqld
[root@mysql-server mysql]# mv /etc/my.cnf /etc/my.cnf_old
[root@mysql-server mysql]# cp -a support-files/my-default.cnf /etc/my.cnf
[root@mysql-server mysql]# vim /etc/my.cnf
# 添加如下一條
datadir=/mydata/data
[root@mysql-server mysql]# ln -vs /usr/local/mysql/include /usr/include/mysql
`/usr/include/mysql' -> `/usr/local/mysql/include'
[root@mysql-server mysql]# vim /etc/ld.so.conf.d/mysql.conf
[root@mysql-server mysql]# ldconfig -v | less
[root@mysql-server mysql]# service mysqld start
Starting MySQL. SUCCESS!
[root@mysql-server mysql]# ss -ntl | grep 3306
LISTEN     0      80                       :::3306                    :::*
到此,nignx和mysql安裝完畢。

(3) php 安裝:
[root@php-server yum.repos.d]# yum install wget gcc* -y
# 添加epel源
[root@php-server ~]# vim /etc/yum.repos.d/epel-centos6.repo
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
 
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=0
 
[epel-source]
name=Extra Packages for Enterprise Linux 6 - $basearch - Source
baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=0
保存退出
 
# 安裝php源碼包的依賴包
[root@php-server yum.repos.d]# yum install libmcrypt libmcrypt-devel mhash mhash-devel install libxml2-devel openssl openssl-devel bzip2-devel libcurl-devel gd -y
# gd-devel-2.0.35-11.el6.x86_64.rpm 從網上下載到的包安裝,直接百度搜包名就有。
[root@php-server ~]# yum localinstall gd-devel-2.0.35-11.el6.x86_64.rpm -y
[root@php-server ~]# groupadd -g 800 www
[root@php-server ~]# useradd -u 800 -g 800 -s /sbin/nologin www     # 創建運行php worker進程用戶
[root@php-server ~]# cd /usr/local/src/
[root@php-server src]# wget http://mirrors.sohu.com/php/php-5.6.7.tar.gz
[root@php-server php-5.6.7]# cd php-5.6.7
[root@php-server php-5.6.7]# ./configure --prefix=/usr/local/php --enable-fpm --enable-ftp --enable-zip \
--enable-xml --enable-sockets --enable-bcmath --enable-pcntl --enable-shmop --enable-soap --enable-sysvsem \
--enable-mbstring --enable-mbregex --enable-inline-optimization --enable-maintainer-zts --enable-gd-native-ttf \
--with-fpm-user=www --with-fpm-group=www --with-mysql --with-mysqli --with-pdo-mysql --with-openssl --with-freetype-dir \
--with-iconv-dir --with-jpeg-dir --with-png-dir --with-libxml-dir=/usr --with-curl  --with-zlib --with-bz2 --with-xmlrpc \
--with-gd --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d
[root@php-server php-5.6.7]# make && make install
# 編譯時間比較長
[root@php-server php-5.6.7]# cp -a sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@php-server php-5.6.7]# chmod +x /etc/init.d/php-fpm
[root@php-server php-5.6.7]# cp -a php.ini-production /usr/local/php/etc/php.ini
[root@php-server php-5.6.7]# cd /usr/local/php/etc/
[root@php-server etc]# cp -a php-fpm.conf.default php-fpm.conf
[root@php-server etc]# vim php-fpm.conf     # 修改監聽地址
164 listen = 192.168.2.13:9000
[root@php-server etc]# service php-fpm start
Starting php-fpm  done
[root@php-server etc]# ss -ntl | grep 9000
LISTEN     0      128            192.168.2.13:9000                     *:* 
[root@php-server etc]# chkconfig --add php-fpm
[root@php-server etc]# chkconfig php-fpm on
[root@php-server etc]# iptables -F
[root@php-server etc]# iptables -X
[root@php-server etc]# iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
[root@php-server etc]# iptables -A INPUT -p tcp -m multiport --sport 22,9000 -m state --state NEW -j ACCEPT
[root@php-server etc]# iptables -P INPUT DROP
[root@php-server etc]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@php-server etc]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
php 安裝完畢。

(3) nginx 連接 php 
nginx對于php的配置上面已經寫過了:
修改nginx配置文件如下:
行號
 43         location / {
 44             root   /webapp;
 45             index  index.html index.htm index.php;
 46         }
 
 65         location ~ \.php$ {
 66             root           /webapp;
 67             fastcgi_pass   192.168.2.13:9000;
 68             fastcgi_index  index.php;
 69             include        fastcgi.conf;
 70         }
保存退出
連接nfs共享web程序
php-sever 192.168.2.13 設置如下:
[root@php-server etc]# yum install nfs-utils -y     # 使用桌面虛擬機可能會碰到nfs需要重啟下機器的情況
 
[root@php-server ~]# service nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
 
 
vim /etc/exports
/webapp 192.168.2.0/24(rw,sync)
 
 
[root@php-server ~]# showmount -e 192.168.2.13
Export list for 192.168.2.13:
/webapp 192.168.2.0/24
 
# 讓兩臺nginx服務器掛載 192.168.2.11、192.168.2.12
yum install -y rpcbind nfs-utils
yum install mysql
 
 
[root@realserver1 ~]# mount -t nfs 192.168.2.13:/webapp/ /webapp/
[root@realserver2 ~]# mount -t nfs 192.168.2.13:/webapp/ /webapp/
 
# 下載wordpress并上傳到服務器
[root@php-server ~]# unzip wordpress-4.5.2-zh_CN.zip
[root@php-server ~]# cp -a wordpress/* /webapp/
[root@php-server ~]# chown -R www:www /webapp/
在數據庫服務器(192.168.2.14)上建立wordpress數據庫并賦予權限
[root@mysql-server mysql]# /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.31 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.02 sec)
 
mysql> GRANT ALL ON wordpress.* TO 'wordpress'@'192.168.2.13' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.02 sec)
 
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> Bye
通過頁面訪問安裝wordpress
填寫數據庫信息



安裝完畢。
realserver1 和 realserver2 都指向了一個站點,并能正常訪問。
(4) lvs-dr搭建
    vip: 192.168.2.200
director配置如下:
[root@lvs-dr ~]# yum install ipvsadm
[root@lvs-dr ~]# ifconfig eth0:0 192.168.2.200/32 broadcast 192.168.2.200 up
[root@lvs-dr ~]# route add -host 192.168.2.200 dev eth0:0
[root@lvs-dr ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:39:92:4f brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.10/24 brd 192.168.2.255 scope global eth0
    inet 192.168.2.200/0 brd 192.168.2.200 scope global eth0:0
    inet6 fe80::20c:29ff:fe39:924f/64 scope link
       valid_lft forever preferred_lft forever
接下來給realserver 添加vip
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
[root@realserver1 ~]# sysctl -p
[root@realserver1 ~]# ifconfig lo:0 192.168.2.200/32 broadcast 192.168.2.200 up
[root@realserver1 ~]# route add -host 192.168.2.200 dev lo:0
另一臺realserver2 一樣的操作
 
在lvs-dr主機添加規則如下:
[root@lvs-dr ~]# ipvsadm -A -t 192.168.2.200:80 -s rr
[root@lvs-dr ~]# ipvsadm -a -t 192.168.2.200:80 -r 192.168.2.11 -g -w 1
[root@lvs-dr ~]# ipvsadm -a -t 192.168.2.200:80 -r 192.168.2.12 -g -w 1
[root@lvs-dr ~]# ipvsadm -L -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.2.200:80 rr
  -> 192.168.2.11:80              Route   1      0          0         
  -> 192.168.2.12:80              Route   1      0          0

瀏覽器訪問http://192.168.2.200

3、基于heartbeat v2 crm實現HA LAMP組合;要求,部署wordpress,用于編輯的文章中的任何數據在節點切換后都能正常訪問;

原創文章,作者:victorli88,如若轉載,請注明出處:http://www.www58058.com/73120

(0)
victorli88victorli88
上一篇 2017-05-08
下一篇 2017-05-08

相關推薦

  • linux系統及簡單使用

    簡介:CentOS(Community Enterprise Operating System)社區企業操作系統,安全和穩定性較好,有優秀的社區支持。   Linux系統的原則: 1、由單一目的的較小的程序程序組成 2、一切皆文件 3、避免捕獲用戶接口 4、配置文件保存在文本中 5、鏈接程序完成復雜的功能   Linux系統安裝: 英文安…

    Linux干貨 2017-07-15
  • sed初步認識

     ◆ sed基礎概念 ◆ sed用法 一.sed 基礎概念: Stream EDitor (流/行編輯器) sed是一種流編輯器,它一次處理一行內容。處理時,把當前處理的行存儲在臨時緩沖區中,稱為“模式空間”(pattern space),接著用sed命令處理緩沖區中的內容,處理完成后,把緩沖區的內容送往屏幕…

    2017-03-16
  • Android必備的Java知識點

     Android應用程序開發是以Java語言為基礎的,所以需要有扎實的Java基礎知識。首先熟悉java基本語法,然后熟悉設計模式等。         a) Java基礎語法:看下面的《Java知識點列表》       b)設計模式:由于在Android系統的框架層當中,使用了大…

    Linux干貨 2015-04-08
  • 磁盤文件掛載與卸載

    掛載(mount)何為掛載?掛載指將文件系統與根文件系統的某個現存的目錄建立起來的關聯關系,這樣我們就可以將目錄作為訪問磁盤文件的入口,進行存取交互。掛載點:掛載點指的是被掛載的對象,通常掛載點是一個目錄,不過有時候也有文件作為掛載點格式:mount 設備 掛載點 ;此掛載方法味臨時掛載,只在當前的shell中有效,退出則清除掛載關聯設備文件在/dev/sd…

    Linux干貨 2017-04-24
  • N25期–第十四周作業

    系統的INPUT和OUTPUT默認策略為DROP; # iptables -P INPUT DROP # iptables -P OUTPUT DROP 1、 限制本地主機的web服務器在周一不允許訪問;新請求的速率不能超過100個每秒;web服務器包含了admin字符串的頁面不允許訪問;web服務器僅允許響應報文離開本機;   #iptables…

    Linux干貨 2017-04-10
  • httpd應用舉例

    應用舉例1、基于用戶和組認證的方式訪問ftp         1、編輯配置文件/etc/httpd/conf/httpd.conf,并使用httpd -t 檢查語法,并systemctl reload httpd       &n…

    Linux干貨 2016-10-23

評論列表(1條)

  • 馬哥教育
    馬哥教育 2017-06-20 11:25

    原理圖在哪里找的啊

欧美性久久久久