程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> mysql集群之keepalived簡單搭建

mysql集群之keepalived簡單搭建

編輯:MySQL綜合教程

mysql集群之keepalived簡單搭建


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修改配置文件如下
[root@M128 ~]# 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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved