真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

keepalivedMysql雙主熱備配置的示例分析-創(chuàng)新互聯(lián)

這篇文章主要介紹keepalived Mysql雙主熱備配置的示例分析,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

目前創(chuàng)新互聯(lián)建站已為上千的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站改版維護(hù)、企業(yè)網(wǎng)站設(shè)計(jì)、玉樹網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

基于keepalived雙主熱備:
一.環(huán)境:
OS:CentOS 6.5 X64
DB Version:Percona Mysql 5.7.15-9-log
路徑:/app/mysql57
數(shù)據(jù)文件路徑:/data/mysql57/data
DB1:192.168.213.4
DB2:192.168.213.5


二.安裝keepalived包(兩臺(tái)主機(jī)都需操作)
1.下載keepalived包
cd /usr/local/tools
wget http://www.keepalived.org/software/keepalived-1.2.23.tar.gz


2.安裝所需包
yum -y install openssl-devel


3.安裝keepalived
mkdir -pv /app/keepalived
cd /usr/local/tools
tar xf keepalived-1.2.23.tar.gz
cd keepalived-1.2.23
./configure --prefix=/app/keepalived/
make
make install


4.配置keepalived
cp /app/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf
cp /app/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/keepalived
cp /app/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /app/keepalived/sbin/keepalived /usr/sbin/


db01 keepalived配置
cat /etc/keepalived/keepalived.conf 
! Configuration File for keepalived
global_defs {
   router_id HA_MYSQL
}
vrrp_script chk_mysql {
script "/etc/init.d/mysql57 status"
}
vrrp_instance VI_1 {
    state MASTER
    interface eth0    !虛擬IP對(duì)應(yīng)接口,也就是業(yè)務(wù)接口對(duì)應(yīng)的網(wǎng)卡編號(hào)
    virtual_router_id 51
    priority 105    !權(quán)重
    advert_int 1
    nopreempt    !自己上線后不搶占當(dāng)前 master 的位置,即使其權(quán)重比自己低
    virtual_ipaddress {
        192.168.213.100    !VIP
    }
    track_script {
        chk_mysql    !啟用頭部定義的檢查MySQL狀態(tài)的腳本
    }
}
virtual_server 192.168.213.100 3306 {
    delay_loop 3
    lb_algo rr
    lb_kind NAT
    persistence_timeout 60
    protocol TCP    sorry_server 192.168.213.5 3306    ! real_server 掛掉后臨時(shí)使用 sorry_server 頂上
    real_server 192.168.213.4 3306 {
        weight 1
        TCP_CHECK {
            connect_port    3306
            connect_timeout 3
        }
    }
}




db02 keepalived配置
[root@ORADB-213-5 ~]# cat /etc/keepalived/keepalived.conf 
! Configuration File for keepalived
global_defs {
   router_id HA_MYSQL
}
vrrp_script chk_mysql {
script "/etc/init.d/mysql57 status"
}
vrrp_instance VI_1 {
    state BACKUP
    interface eth0    !虛擬IP對(duì)應(yīng)接口,也就是業(yè)務(wù)接口對(duì)應(yīng)的網(wǎng)卡編號(hào)
    virtual_router_id 51
    priority 100    !權(quán)重
    advert_int 1
    nopreempt    !自己上線后不搶占當(dāng)前 master 的位置,即使其權(quán)重比自己低
    virtual_ipaddress {
        192.168.213.100    !VIP
    }
    track_script {
        chk_mysql    !啟用頭部定義的檢查MySQL狀態(tài)的腳本
    }
}
virtual_server 192.168.213.100 3306 {
    delay_loop 3
    lb_algo rr
    lb_kind NAT
    persistence_timeout 60
    protocol TCP    sorry_server 192.168.213.4 3306    ! real_server 掛掉后臨時(shí)使用 sorry_server 頂上
    real_server 192.168.213.5 3306 {
        weight 1
        TCP_CHECK {
            connect_port    3306
            connect_timeout 3
        }
    }
}


5.兩臺(tái)DB啟動(dòng)keepalived
/etc/init.d/keepalived start


查看VIP
[root@ORA11G-213-4 keepalived-1.2.23]# ip addr
1: lo:  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:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:c7:d5:27 brd ff:ff:ff:ff:ff:ff
    inet 192.168.213.4/24 brd 192.168.213.255 scope global eth0
    inet 192.168.213.100/32 scope global eth0
    inet6 fe80::20c:29ff:fec7:d527/64 scope link 
       valid_lft forever preferred_lft forever
  
測試
[root@ORA11G-213-4 keepalived-1.2.23]# mysql -unetdata -pnetdata -h 192.168.213.100
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2881
Server version: 5.7.15-9-log Source distribution


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.


netdata@192.168.213.100 23:41:  [(none)]> system ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:C7:D5:27  
          inet addr:192.168.213.4  Bcast:192.168.213.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fec7:d527/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:156643 errors:0 dropped:0 overruns:0 frame:0
          TX packets:191173 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:39459924 (37.6 MiB)  TX bytes:31911844 (30.4 MiB)


lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:17378 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17378 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1002566 (979.0 KiB)  TX bytes:1002566 (979.0 KiB)
 
停止掉db01
[root@ORA11G-213-4 keepalived-1.2.23]# /etc/init.d/mysql57 stop
Shutting down MySQL (Percona Server)............. SUCCESS! 


查看db02
[root@ORADB-213-5 ~]# ip addr
1: lo:  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:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:63:54:39 brd ff:ff:ff:ff:ff:ff
    inet 192.168.213.5/24 brd 192.168.213.255 scope global eth0
    inet 192.168.213.100/32 scope global eth0
    inet6 fe80::20c:29ff:fe63:5439/64 scope link 
       valid_lft forever preferred_lft forever

以上是“keepalived Mysql雙主熱備配置的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道!


網(wǎng)頁題目:keepalivedMysql雙主熱備配置的示例分析-創(chuàng)新互聯(lián)
網(wǎng)頁網(wǎng)址:http://weahome.cn/article/cssdpg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部