Red Hat Training
A Red Hat training course is available for Red Hat Enterprise Linux
4.2. Keepalived 的直接路由配置
Keepalived 的直接路由配置與 NAT 的配置類似。以下範例會配置 Keepalived,為一群使用 HTTP(連接埠 80)的真實伺服器提供負載平衡。要配置直接路由(Direct Routing),請變更
lb_kind
參數為 DR
。其它配置選項會在〈節 4.1, “基本的 Keepalived 配置”〉中討論。
global_defs { notification_email { admin@example.com } notification_email_from noreply_admin@example.com smtp_server 127.0.0.1 smtp_connect_timeout 60 } vrrp_instance RH_1 { state MASTER interface eth0 virtual_router_id 50 priority 1 advert_int 1 authentication { auth_type PASS auth_pass password123 } virtual_ipaddress { 172.31.0.1 } } virtual_server 172.31.0.1 80 delay_loop 10 lb_algo rr lb_kind DR persistence_timeout 9600 protocol TCP real_server 192.168.0.1 80 { weight 1 TCP_CHECK { connect_timeout 10 connect_port 80 } } real_server 192.168.0.2 80 { weight 1 TCP_CHECK { connect_timeout 10 connect_port 80 } } real_server 192.168.0.3 80 { weight 1 TCP_CHECK { connect_timeout 10 connect_port 80 } } }