博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Keepalive双主搭建配置
阅读量:5945 次
发布时间:2019-06-19

本文共 2826 字,大约阅读时间需要 9 分钟。

Keepalive 双主搭建配置

keepalived保证双主数据库的可用性

环境说明

192.168.1.10  keepalive 主1

192.168.1.20  keepalive 主2

192.168.1.111  keepalive 主1  从2 VIP

192.168.1.222  keepalive 从1  主2 VIP

1、官网下载最新版本

keepalived-1.2.19

2、部署安装

yum install gcc gcc-c++ make openssl openssl-develtar zxvf keepalived-1.2.19.tar.gzcd keepalived-1.2.19./configure --sysconf=/etc/ --with-kernel-dir=/usr/src/linux --prefix=/usr/local/keepalivedmake ; make installcp /usr/local/keepalive/sbin/keepalived /usr/bin/cp /usr/local/keepalived/sbin/keepalived /usr/bin/cp /usr/local/keepalived/etc/sysconfig/keepalived  /etc/sysconfig/cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/chkconfig keepalived on

3、建立配置文件

vim /etc/keepalived/keepalived.confglobal_defs {   notification_email {     cwliu@atman.com   }   notification_email_from root@localhost   smtp_server 127.0.0.1   smtp_connect_timeout 30       router_id Mariadb_keepalive1}vrrp_script notification {   script "/data/ops/script/mail.sh"   interval 1   weight 2   }vrrp_script check_alive {   script "/data/ops/script/mysql_check.sh"   interval 1   weight 2   }vrrp_instance Mariadb_keepalive_channel1 {    state MASTER    interface eth0    virtual_router_id 100    priority 200    advert_int 1    authentication {     auth_type PASS     auth_pass 1111    }    virtual_ipaddress {        192.168.1.111    }    track_script {check_alive    }}vrrp_instance Mariadb_keepalive_channel2 {    state BACKUP    interface eth0    virtual_router_id 101    priority 100    advert_int 1    authentication {        auth_type PASS        auth_pass 1111    }    virtual_ipaddress {        192.168.1.222    }    track_script {check_alive    }}

4、然后启动即可

/etc/init.d/keepalived start

5、Keepalive 另一主服务器除配置文件不一样,其他配置步骤如上,配置文件如下

vim /etc/keepalived/keepalived.confglobal_defs {   notification_email {     cwliu@atman.com   }   notification_email_from root@localhost   smtp_server 127.0.0.1   smtp_connect_timeout 30       router_id Mariadb_keepalive}vrrp_script notification {   script "/data/ops/script/mail.sh"   interval 1   weight 2}vrrp_script check_alive {   script "/data/ops/script/mysql_check.sh"   interval 1   weight 2}vrrp_instance Mariadb_keepalive_channel1 {    state BACKUP    interface eth0    virtual_router_id 100    priority 100    advert_int 1    authentication {     auth_type PASS     auth_pass 1111    }    virtual_ipaddress {        192.168.1.111    }    track_script {check_alive    }}vrrp_instance Mariadb_keepalive_channel2 {    state MASTER    interface eth0    virtual_router_id 101    priority 200    advert_int 1    authentication {        auth_type PASS        auth_pass 1111    }    virtual_ipaddress {        192.168.1.222    }    track_script {check_alive    }}

6、效果图

两台同时运行:

192.168.1.10:

192.168.1.20

192.168.1.10 keepalive 关闭后:

转载于:https://www.cnblogs.com/wangyangliuping/p/5547221.html

你可能感兴趣的文章
save
查看>>
Android DrawLayout + ListView 的使用(一)
查看>>
clear session on close of browser jsp
查看>>
关于吃掉物理的二次聚合无法实现的需要之旁门左道实现法
查看>>
mysql出现unblock with 'mysqladmin flush-hosts'
查看>>
oracle exp/imp命令详解
查看>>
开发安全的 API 所需要核对的清单
查看>>
Mycat源码中的单例模式
查看>>
WPF Dispatcher介绍
查看>>
fiddler展示serverIP方法
查看>>
已释放的栈内存
查看>>
Android网络之数据解析----SAX方式解析XML数据
查看>>
Java递归列出所有文件和文件夹
查看>>
[关于SQL]查询成绩都大于80分的学生
查看>>
Delphi(Tuxedo,BDE,ADO)三合一数据集组件HsTxQuery
查看>>
LeetCode - Longest Common Prefix
查看>>
Android图片处理
查看>>
2015年第21本:万万没想到,用理工科思维理解世界
查看>>
大家谈谈公司里的项目经理角色及职责都是干什么的?
查看>>
剑指offer
查看>>