Keepalived+postgresql高可用搭建

PGSQL主从+keepalived高可用配置

- host文件添加服务器地址(2台机器都操作)
[root@master ~]# vim /etc/hosts
192.168.124.3 master 
192.168.124.4 slave 
192.168.124.20 vip
- 安装ekppalived软件包(2台机器都操作)
[root@master ~]# yum install -y keepalived
- 修改配置文件(主配置文件)
[root@master ~]# cd /etc/keepalived/
[root@master keepalived]# vim keepalived.conf
bal_defs {
   
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id pg
}
vrrp_script chk_pgsql {
   
   script "/etc/keepalived/scripts/pgsql_check.sh"
   interval 2
   weight -5
   fall 2
   rise 1
}
vrrp_instance VI_1 {
   
    state BACKUP 
    interface ens33
    virtual_router_id 61
    priority 100
    nopreempt
    advert_int 1
    authentication {
   
        auth_type PASS
        auth_pass hxh
    }
       track_script {
   
       chk_pgsql
    }
    virtual_ipaddress {
   
        192.168.124.20/24
    }
}
- 修改配置文件(备配置文件)
[root@slave ~]# cd /etc/keepalived/
[root@slave keepalived]# vim keepalived.conf
bal_defs {
   
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id pg
}
vrrp_script chk_pgsql {
   
   script "/etc/keepalived/scripts/pgsql_check.sh"
   interval 2
   weight -5
   fall 2
   rise 1
}
vrrp_instance VI_1 {
   
    state BACKUP 
    interface ens33
    virtual_router_id 61
    priority 80
    nopreempt
    advert_int 1
    authentication {
   
        auth_type PASS
        auth_pass hxh
    }
       track_script {
   
       chk_pgsql
    }
    virtual_ipaddress {
   
        192.168.124.20/24
    }
}
- 创建目录及脚本(2台机器都操作)
[root@master keepalived]#  mkdir scripts
[root@master keepalived]#  mkdir log
[<
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值