91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

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

Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用

發布時間:2020-05-21 15:00:27 來源:網絡 閱讀:220 作者:三月 欄目:MySQL數據庫

文主要給大家介紹Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用,文章內容都是筆者用心摘選和編輯的,具有一定的針對性,對大家的參考意義還是比較大的,下面跟筆者一起了解下Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用吧。

1、基本環境

JDK 1.8_171
MySQL 5.7.19
CentOS 7.4
Keepalived 1.4.0
DB1:192.168.200.180
DB2:192.168.200.181
VIP: 192.168.200.99
Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用

2、下載安裝Keepalived

2.1、keepalived下載
下載地址:wget http://www.keepalived.org/software/keepalived-1.4.0.tar.gz 
2.2、keepalived安裝

2臺均按照此種方式進行安裝

yum install gcc gcc-c++ make openssl openssl-devel net-snmp-devel psmisc ipvsadm libnfnetlink-devel popt popt-devel popt-static openssl-devel kernel-devel libnl libnl-devel -y    # 安裝依賴

cd /usr/local/src
tar -zvxf keepalived-1.4.0.tar.gz    # 解壓
cd keepalived-1.4.0
./configure --prefix=/usr/local/keepalived --enable-snmp    # 編譯
make && make install    # 安裝
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/    # 拷貝配置
ln -s /usr/local/keepalived/sbin/keepalived /usr/sbin/keepalived
ln -s /usr/local/keepalived/sbin/keepalived /sbin/keepalived
2.3、Keepalived配置

DB1上面的配置:

[root@mysql01 keepalived-1.4.0]# cp /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf_bak
[root@mysql01 keepalived-1.4.0]# vim /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {
   notification_email {
     nvidiacheng@163.com
   }
   notification_email_from nvidiacheng@163.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id Node_Master
}

vrrp_instance VI_1 {
    state BACKUP          # 可配置master和backup模式,為了防止腦裂現象,主備均需要設置為backup模式,master模式會搶占VIP
    interface ens33      # 網卡名
    virtual_router_id 43     # VRRP組名,兩個節點的設置必須一樣,以指明各個節點屬于同一VRRP組
    priority 100      # 權重,主節點要大于備節點
    unicast_src_ip  192.168.200.180     # 本地IP地址
    unicast_peer {
                  192.168.200.181     # 對端IP地址,此地址一定不能忘記
                 }
    nopreempt            # 配合backup,防止切換后,主庫服務恢復正常后,IP漂移過來
    advert_int 1          # 組播信息發送間隔,兩個節點設置必須一樣
    authentication {     # 設置驗證信息,兩個節點必須一致
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {   
        192.168.200.99      # VIP地址
    }
}
virtual_server 192.168.200.99 3306 {
    delay_loop 6
    lb_algo wrr          
    lb_kind DR           
    persistence_timeout 50
    protocol TCP

    real_server 192.168.200.180 3306 {
      weight 1
      notify_down /etc/keepalived/mysql.sh 
      TCP_CHECK {
      connect_timeout 10
      nb_get_retry 3 
      delay_before_retry 3
      connect_port 3306 
        }
    }
}

 
DB2上面配置

[root@mysql02 keepalived-1.4.0]# cp /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf_bak
[root@mysql02 keepalived-1.4.0]# vim /etc/keepalived/keepalived.conf

! Configuration File for keepalived
  global_defs {
      notification_email {
      nvidiacheng@163.com
      }
      notification_email_from nvidiacheng@163.com
      smtp_server 127.0.0.1
      smtp_connect_timeout 30
      router_id Node_backup
     }
 vrrp_instance VI_1 {
      state BACKUP
      interface ens33
      virtual_router_id 43
      priority 90                  
      unicast_src_ip  192.168.200.181
      unicast_peer {
                  192.168.200.180
                   }
      advert_int 1
      authentication {
      auth_type PASS
      auth_pass 1111
      }
      virtual_ipaddress {
      192.168.200.99
      }
      }
 virtual_server 192.168.200.99 3306 {
      delay_loop 2                 
      lb_algo wrr                  
      lb_kind DR                  
      persistence_timeout 60 
      protocol TCP 

      real_server 192.168.200.181 3306{
      weight 1
      notify_down /etc/keepalived/mysql.sh
      echo '3' >  /etc/keepalived/t.log
      TCP_CHECK {
      connect_timeout 10
      nb_get_retry 3     
      delay_before_retry 3
      connect_port 3306 
      }
      }
}

mysql.sh腳本配置內容(2臺一樣):

[root@mysql01 keepalived]# vim /etc/keepalived/mysql.sh
#!/bin/bash
run_status=`service keepalived status|grep running|wc -l`
pro_status=`ps -ef |grep keepalived|grep -v grep |wc -l`

service keepalived stop

if [ ${run_status} != 0 ] || [ ${pro_status} != 0 ]
then
   pkill keepalived
fi

給mysql.sh賦可執行權限

[root@mysql01 keepalived]# chmod +x mysql.sh

都配置好后啟動keepalived進行測試:

service keepalived start   # 啟動Keepalived
service keepalived restart   # 重啟Keepalived
service keepalived stop   # 停止Keepalived
service keepalived status   # 查看Keepalived運行狀態
ps aux | grep keepalived   # 查看Keepalived進程

Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用

3.3、測試Keepalived

2臺均啟動Keepalived后,分別查看網卡
Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用
Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用
從上圖可以看出,VIP地址在主節點
 
使用Navicat工具分別連接2個節點和VIP節點
Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用
這個時候我們將節點1的MySQL停止,模擬主節點數據庫故障來測試VIP是否會漂移到備節點
Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用
如上圖,主節點MySQL停止后,Keepalived進程也結束了,VIP地址不見了
 
查看備節點的網卡,發現VIP已經漂移過來了
Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用
 
用Navicat打開VIP,可以正常訪問,主節點無法打開
Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用
重新啟動主節點MySQL服務和Keepalived服務,在停止備節點測試(略過)

看完以上關于Keepalived1.4.0應用在MySQL 5.7.19上實現主備高可用,很多讀者朋友肯定多少有一定的了解,如需獲取更多的行業知識信息 ,可以持續關注我們的行業資訊欄目的。

向AI問一下細節

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

AI

黄陵县| 芮城县| 天镇县| 衡水市| 益阳市| 绥棱县| 五大连池市| 建湖县| 平远县| 黎平县| 广德县| 秦皇岛市| 巴楚县| 沂源县| 米泉市| 安多县| 英吉沙县| 龙游县| 石阡县| 元朗区| 周宁县| 新乡县| 綦江县| 麻阳| 肃北| 桃源县| 攀枝花市| 新竹县| 旬阳县| 北票市| 潜江市| 长寿区| 黔西| 体育| 安泽县| 浠水县| 明溪县| 巴彦淖尔市| 崇礼县| 陆川县| 齐齐哈尔市|