| 1 | <h2>A example from keepalived document</h2> |
| 2 | <pre><code> |
| 3 | # Configuration File for keepalived |
| 4 | global_defs { |
| 5 | notification_email { |
| 6 | [email protected] |
| 7 | [email protected] |
| 8 | } |
| 9 | notification_email_from [email protected] |
| 10 | smtp_server 192.168.200.20 |
| 11 | smtp_connect_timeout 30 |
| 12 | router_id LVS_MAIN |
| 13 | } |
| 14 | |
| 15 | # VRRP Instances definitions |
| 16 | vrrp_instance VI_1 { |
| 17 | state MASTER |
| 18 | interface eth0 |
| 19 | virtual_router_id 51 |
| 20 | priority 150 |
| 21 | advert_int 1 |
| 22 | authentication { |
| 23 | auth_type PASS |
| 24 | auth_pass k@l!ve1 |
| 25 | } |
| 26 | virtual_ipaddress { |
| 27 | 192.168.200.10 |
| 28 | 192.168.200.11 |
| 29 | } |
| 30 | } |
| 31 | vrrp_instance VI_2 { |
| 32 | state MASTER |
| 33 | interface eth1 |
| 34 | virtual_router_id 52 |
| 35 | priority 150 |
| 36 | advert_int 1 |
| 37 | authentication { |
| 38 | auth_type PASS |
| 39 | auth_pass k@l!ve2 |
| 40 | } |
| 41 | virtual_ipaddress { |
| 42 | 192.168.100.10 |
| 43 | } |
| 44 | } |
| 45 | vrrp_instance VI_3 { |
| 46 | state BACKUP |
| 47 | interface eth0 |
| 48 | virtual_router_id 53 |
| 49 | priority 100 |
| 50 | advert_int 1 |
| 51 | authentication { |
| 52 | auth_type PASS |
| 53 | auth_pass k@l!ve3 |
| 54 | } |
| 55 | virtual_ipaddress { |
| 56 | 192.168.200.12 |
| 57 | 192.168.200.13 |
| 58 | } |
| 59 | } |
| 60 | vrrp_instance VI_4 { |
| 61 | state BACKUP |
| 62 | interface eth1 |
| 63 | virtual_router_id 54 |
| 64 | priority 100 |
| 65 | advert_int 1 |
| 66 | authentication { |
| 67 | auth_type PASS |
| 68 | auth_pass k@l!ve4 |
| 69 | } |
| 70 | virtual_ipaddress { |
| 71 | 192.168.100.11 |
| 72 | } |
| 73 | } |
| 74 | # Virtual Servers definitions |
| 75 | virtual_server 192.168.200.10 80 { |
| 76 | delay_loop 30 |
| 77 | lb_algo wrr |
| 78 | lb_kind NAT |
| 79 | persistence_timeout 50 |
| 80 | protocol TCP |
| 81 | sorry_server 192.168.100.100 80 |
| 82 | real_server 192.168.100.2 80 { |
| 83 | weight 2 |
| 84 | HTTP_GET { |
| 85 | url { |
| 86 | path /testurl/test.jsp |
| 87 | digest ec90a42b99ea9a2f5ecbe213ac9eba03 |
| 88 | } |
| 89 | url { |
| 90 | path /testurl2/test.jsp |
| 91 | digest 640205b7b0fc66c1ea91c463fac6334c |
| 92 | } |
| 93 | connect_timeout 3 |
| 94 | retry 3 |
| 95 | delay_before_retry 2 |
| 96 | } |
| 97 | } |
| 98 | real_server 192.168.100.3 80 { |
| 99 | weight 1 |
| 100 | HTTP_GET { |
| 101 | url { |
| 102 | path /testurl/test.jsp |
| 103 | digest 640205b7b0fc66c1ea91c463fac6334c |
| 104 | } |
| 105 | connect_timeout 3 |
| 106 | retry 3 |
| 107 | delay_before_retry 2 |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | virtual_server 192.168.200.12 443 { |
| 112 | delay_loop 20 |
| 113 | lb_algo rr |
| 114 | lb_kind NAT |
| 115 | persistence_timeout 360 |
| 116 | protocol TCP |
| 117 | real_server 192.168.100.2 443 { |
| 118 | weight 1 |
| 119 | TCP_CHECK { |
| 120 | connect_timeout 3 |
| 121 | } |
| 122 | } |
| 123 | real_server 192.168.100.3 443 { |
| 124 | weight 1 |
| 125 | TCP_CHECK { |
| 126 | connect_timeout 3 |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | </code></pre> |