高可用配置

安装 Keepalived

编译安装

下载地址 open in new window

使用 ./configure 编译安装

如遇报错提示

1configure: error:
2!!! OpenSSL is not properly installed on your system. !!!
3!!! Can not include OpenSSL headers files. !!!

安装依赖

1yum install openssl-devel

yum 安装

配置

使用 yum 安装后配置文件在:/etc/keepalived/keepalived.conf

最小配置

  • 第一台机器
1! Configuration File for keepalived
2global_defs {
3 router_id lb111
4}
5vrrp_instance atguigu {
6    state MASTER
7    interface ens33
8    virtual_router_id 51
9    priority 100
10    advert_int 1
11    authentication {
12        auth_type PASS
13        auth_pass 1111
14    }
15    virtual_ipaddress {
16        192.168.44.200
17    }
18}
  • 第二台机器
1! Configuration File for keepalived
2global_defs {
3    router_id lb110
4}
5vrrp_instance atguigu {
6    state BACKUP
7    interface ens33
8    virtual_router_id 51
9    priority 50
10    advert_int 1
11    authentication {
12        auth_type PASS
13        auth_pass 1111
14    }
15    virtual_ipaddress {
16        192.168.44.200
17    }
18}
  • 启动服务
1systemctl start keepalived