主主上keepalived的配置
时间: 2023-11-16 15:51:48 浏览: 86
详解Keepalived安装与配置
主主上keepalived的配置如下:
主节点配置文件:
```
global_defs {
router_id lb01
}
vrrp_instance VI_1 {
state MASTER
interface enp0s3
virtual_router_id 50
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.2.3
}
}
```
备用节点配置文件:
```
global_defs {
router_id lb02
}
vrrp_instance VI_1 {
state BACKUP
interface enp0s3
virtual_router_id 50
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.2.3
}
}
```
这里的配置文件中,主节点的router_id设置为lb01,备用节点的router_id设置为lb02。vrrp_instance中的state分别设置为MASTER和BACKUP,priority分别设置为150和100。virtual_ipaddress是虚拟IP地址,主备节点都需要配置相同的虚拟IP地址。authentication部分是认证配置,auth_type设置为PASS,auth_pass设置为1111。这样配置后,当主节点故障时,备用节点会接管虚拟IP地址和服务。\[1\] \[3\]
#### 引用[.reference_title]
- *1* *2* [keepalived:主备配置](https://blog.csdn.net/focus_lyh/article/details/126245348)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Mysql主主架构搭建以及Keepalived配置VIP](https://blog.csdn.net/pengguoyang/article/details/124732589)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文