mysql叢集之keepalived簡單搭建

來源:互聯網
上載者:User

標籤:keepalived mysql

1安裝必須的相關包

yum -y install  kernel-devel  openssl* popt popt-devel 


2下載安裝

wget http://www.keepalived.org/software/keepalived-1.2.9.tar.gz

tar  -xf keepalived-1.2.9.tar.gz 

mkdir /usr/local/keepalived 

cd ~/ keepalived-1.2.9

./configure  --prefix=/usr/local/keepalived/

make && make install

cp /usr/local/keepalived/sbin/keepalived  /usr/sbin/ 

cp /usr/local/keepalived/etc/sysconfig/keepalived  /etc/sysconfig

cp /usr/local/keepalived/etc/rc.d/init.d/keepalived  /etc/init.d/

chmod +x /etc/init.d/keepalived

mkdir /etc/keepalived

cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived


3修改設定檔如下

[[email protected] ~]# vim /etc/keepalived/keepalived.conf

global_defs {

    notification_email {

 [email protected]

    }

    notification_email_from [email protected]

      smtp_server smtp.126.com   # 郵件伺服器地址  

    smtp_connect_timeout 30     # 連線逾時時間  

    router_id LVS_Master

}

vrrp_script chk_http_port {

    script  "/etc/keepalived/check_haproxy.sh"    # haproxy運行檢測指令碼[haproxy宕掉重啟haproxy服務]  

    interval        5                     # 指令碼執行間隔  

    weight         -5                    # 執行指令碼後優先順序變更:5表示優先順序+5;-5則表示優先順序-5

}

vrrp_instance VI_A {

    state MASTER                    # 主上此值為MASTER,從上為BACKUP 

    interface eth0

    virtual_router_id 50           # 此值主從必須一致

    priority 100

    advert_int 1

    authentication {                   # authentication兩個參數值,主從也必須一致  

        auth_type PASS

    auth_pass yiban

    }

track_script {

    chk_http_port

    }

    virtual_ipaddress {

          192.168.78.220

    }

}


5啟動keepalived

確保網路正常

service network restart (線上不要這麼做) 

/etc/init.d/keepalived start

查看結果

ip a


                     

本文出自 “雪藤六” 部落格,請務必保留此出處http://879100963.blog.51cto.com/6686639/1705086

mysql叢集之keepalived簡單搭建

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.