亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

keepalived+haproxy高可用

發布時間:2020-07-04 15:44:23 來源:網絡 閱讀:680 作者:無雙戰績 欄目:云計算
環境:
主Haproxy服務器    192.168.80.100   keepalived+Haproxy
備Haproxy服務器    192.168.80.101   keepalived+Haproxy
web服務器1             192.168.80.102  httpd(nginx、tomcat)
web服務器2             192.168.80.103  httpd
80.100和80.101需要聯網

———————————————————————————————————————
在80.100虛擬機上:

systemctl stop firewalld        //關閉防火墻
setenforce 0                 //關閉監控
cd /etc/yum.repos.d/    //進入目錄
cp back/* ./         //把back里內容移動到上一個目錄
ls               //查看目錄內容

keepalived+haproxy高可用

yum install -y epel-release
yum install ntp -y           //安裝ntp
ntpdate time1.aliyun.com        //同步網絡時間
date

keepalived+haproxy高可用

yum install keepalived -y         //安裝keepalived
cd       //回到根目錄
vi /etc/keepalived/keepalived.conf`
刪除所有內容并添加以下內容:
! Configuration File for keepalived
global_defs {
        route_id haproxy-01
   }
vrrp_script haproxy {    定義一個熱備腳本取名為haproxy
        script "/opt/haproxy.sh"    # 檢測 haproxy 狀態的腳本路徑
        interval 2    # 檢測時間間隔
        weight 2    # 如果條件成立,權重+2
}
vrrp_instance VI_1 {
    state MASTER
    interface ens32
    virtual_router_id 51
    priority 150
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    track_script {    # 將 track_script 塊加入 instance 配置塊
        haproxy    # 檢查 HAProxy 服務是否存活
        }
    virtual_ipaddress {
        192.168.80.188
    }
}

:wq

keepalived+haproxy高可用

scp /etc/keepalived/keepalived.conf root@192.168.80.101:/etc/keepalived/keepalived.conf      //把keepalived.conf傳送到80.101中
yes
root密碼

keepalived+haproxy高可用

yum install lrz* -y        //安裝上傳軟件
把haproxy軟件包拉入

keepalived+haproxy高可用

scp haproxy-1.5.15.tar.gz root@192.168.80.101:/root      //把haproxy軟件包傳送到80.101中
密碼

keepalived+haproxy高可用

tar xf haproxy-1.5.15.tar.gz -C /opt/          //解壓haproxy軟件包
cd /opt/haproxy-1.5.15/           
源碼編譯安裝haproxy
yum install -y \
pcre-devel \
bzip2-devel \
gcc \
gcc-c++ \
make
make TARGET=linux26  PREFIX=/usr/local/haproxy    //標識64為系統
make install PREFIX=/usr/local/haproxy
mkdir /etc/haproxy          //創建目錄
cd
useradd -M -s /sbin/nologin haproxy
id  haproxy

keepalived+haproxy高可用

cd /opt/haproxy-1.5.15/
cp examples/haproxy.cfg /etc/haproxy
vi /etc/haproxy/haproxy.cfg
修改以下內容:
#       chroot /usr/share/haproxy        注釋這一行
uid 1000
gid 1000
在default模塊下
統計頁面模塊內容
listen admin_stats
    bind 0.0.0.0:8089
    stats enable
    mode http
    log global
    stats uri  /stats
    stats realm Haproxy\ Statistics
    stats auth  admin:admin
    #stats hide-version
    stats admin if TRUE
    stats refresh 30s
web服務器/終端
listen webcluster
        bind 0.0.0.0:80
        mode http
        option httpchk GET /index.html
        log global
        maxconn 3000
        balance roundrobin
server web01 192.168.80.102:80 check inter 2000 fall 5
server web02 192.168.80.103:80 check inter 2000 fall 5

:wq

keepalived+haproxy高可用
keepalived+haproxy高可用

cd /opt/
ls

keepalived+haproxy高可用

vi haproxy.sh
#!/bin/bash
if [ $(ps -C haproxy --no-header | wc -l) -eq 0 ];then
        /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg      啟動haproxy服務
fi
sleep 2     等待2秒
if [ $(ps -C haproxy --no-header | wc -l) -eq 0 ];then
        service keepalived stop
fi

   :wq        //保存退出

keepalived+haproxy高可用

chmod +x /opt/haproxy.sh       //給這個文件設置權限
cd /opt/haproxy-1.5.15/
cp examples/haproxy.init /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy
ll /etc/init.d/haproxy
chkconfig --add haproxy
ln -s /usr/local/haproxy/sbin/haproxy  /usr/sbin/haproxy     //軟鏈接
cat /var/log/messages

keepalived+haproxy高可用

service haproxy start        //啟動服務

keepalived+haproxy高可用

netstat -anpt | grep haproxy

keepalived+haproxy高可用

在網頁上輸入192.168.80.100:8089/stats

keepalived+haproxy高可用

scp haproxy.cfg root@192.168.80.101:/etc/haproxy/             //把haproxy.cfg 傳送到80.101虛擬機上
密碼

keepalived+haproxy高可用

service haproxy stop
netstat -anpt | grep haproxy
systemctl start keepalived
ip addr show ens32
netstat -anpt | grep haproxy

keepalived+haproxy高可用
——————————————————————————————————————
在80.101虛擬機上:

systemctl stop firewalld        //關閉防火墻
setenforce 0                 //關閉監控
cd /etc/yum.repos.d/    //進入目錄
cp back/* ./         //把back里內容移動到上一個目錄
ls               //查看目錄內容

keepalived+haproxy高可用

yum install -y epel-release
yum install ntp -y           //安裝ntp
ntpdate time1.aliyun.com        //同步網絡時間
date
yum install keepalived -y         //安裝keepalived
cd       //回到根目錄

vi /etc/keepalived/keepalived.conf //進入成以下內容:
keepalived+haproxy高可用
修改成以下內容:
keepalived+haproxy高可用

ls
tar xf haproxy-1.5.15.tar.gz -C /opt/
cd /opt/haproxy-1.5.15/

keepalived+haproxy高可用

源碼編譯安裝haproxy
yum install -y \
pcre-devel \
bzip2-devel \
gcc \
gcc-c++ \
make
make TARGET=linux26  PREFIX=/usr/local/haproxy    //標識64為系統
make install PREFIX=/usr/local/haproxy
mkdir /etc/haproxy
useradd -s /sbin/nologin -M  haproxy
id  haproxy

keepalived+haproxy高可用

ls /etc/haproxy/
cp examples/haproxy.init /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy             //給這個文件設置權限
chkconfig --add haproxy
ln -s /usr/local/haproxy/sbin/haproxy  /usr/sbin/haproxy     //軟鏈接

keepalived+haproxy高可用

service haproxy start        //啟動服務
netstat -anpt | grep haproxy
service haproxy stop       //關閉服務
netstat -anpt | grep haproxy
cd /opt/
vi haproxy.sh
#!/bin/bash
#Filename:
A=$(ip addr | grep 192.168.80.188/32 | grep -v grep | wc -l)
if [ $A -gt 0 ]; then
        service haproxy start
else
        service haproxy stop
fi

   :wq
chmod +x haproxy.sh         //設置權限
ll                          
systemctl start keepalived     
ip addr show ens32
netstat -anpt | grep haproxy

————————————————————————————————————
在80.102虛擬機上:

systemctl stop firewalld      //關閉防火墻
setenforce 0          //關閉監控
yum install httpd -y        //安裝httpd
vi /etc/httpd/conf/httpd.conf
把ServerName www.example.com:80 前面的#刪除

keepalived+haproxy高可用

cd /var/www/html/       //進入這個目錄
echo "<h2>server aa</h2>" > index.html
systemctl start httpd      //啟動服務
在網頁上輸入192.168.80.102

keepalived+haproxy高可用
—————————————————————————————————————
在80.103虛擬機上:

systemctl stop firewalld      //關閉防火墻
setenforce 0          //關閉監控
yum install httpd -y        //安裝httpd
vi /etc/httpd/conf/httpd.conf
把ServerName www.example.com:80 前面的#刪除

keepalived+haproxy高可用

cd /var/www/html/       //進入這個目錄
echo "<h2>server bb</h2>" > index.html
systemctl start httpd      //啟動服務
在網頁上輸入192.168.80.103

keepalived+haproxy高可用

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

启东市| 汾西县| 墨玉县| 清徐县| 鹤岗市| 昭觉县| 荣成市| 宿迁市| 武胜县| 宝山区| 苍梧县| 如东县| 来宾市| 鄂托克前旗| 自贡市| 林芝县| 涞源县| 梅河口市| 桓台县| 通河县| 施甸县| 诏安县| 赣州市| 通山县| 全州县| 浦北县| 柘荣县| 甘孜| 彭水| 清镇市| 大石桥市| 南华县| 田东县| 阿城市| 涿鹿县| 绥德县| 东明县| 鄂尔多斯市| 南平市| 渭南市| 乌拉特后旗|