blob: eccd9a0165654610c1ce93e606a099a0213ba082 [file] [log] [blame]
Filip Pytloun4ab64a02015-10-06 16:28:32 +02001==========
2Keepalived
3==========
4
5Keepalived is a routing software written in C. The main goal of this project is to provide simple and robust facilities for loadbalancing and high-availability to Linux system and Linux based infrastructures. Loadbalancing framework relies on well-known and widely used Linux Virtual Server (IPVS) kernel module providing Layer4 loadbalancing. Keepalived implements a set of checkers to dynamically and adaptively maintain and manage loadbalanced server pool according their health. On the other hand high-availability is achieved by VRRP protocol. VRRP is a fundamental brick for router failover. In addition, Keepalived implements a set of hooks to the VRRP finite state machine providing low-level and high-speed protocol interactions. Keepalived frameworks can be used independently or all together to provide resilient infrastructures.
6
7
8Sample pillar
9=============
10
Ales Komarek733b0922016-01-05 16:27:21 +010011Simple virtual IP on an interface
12
Filip Pytloun4ab64a02015-10-06 16:28:32 +020013.. code-block:: yaml
14
15 keepalived:
16 cluster:
17 enabled: True
18 instance:
Ales Komarek733b0922016-01-05 16:27:21 +010019 VIP1:
Jakub Pavlik2680d652016-08-26 17:35:40 +020020 nopreempt: True
Filip Pytloun4ab64a02015-10-06 16:28:32 +020021 priority: 100 (highest priority must be on primary server, different for cluster members)
22 virtual_router_id: 51
Vasyl Saienkoa4165fd2017-11-16 16:47:19 +020023 auth_type: AH
Filip Pytloun4ab64a02015-10-06 16:28:32 +020024 password: pass
25 address: 192.168.10.1
26 interface: eth0
Ales Komarek733b0922016-01-05 16:27:21 +010027 VIP2:
Jakub Pavlik2680d652016-08-26 17:35:40 +020028 nopreempt: True
Filip Pytloun4ab64a02015-10-06 16:28:32 +020029 priority: 150 (highest priority must be on primary server, different for cluster members)
30 virtual_router_id: 52
Vasyl Saienkoa4165fd2017-11-16 16:47:19 +020031 auth_type: PASS
Filip Pytloun4ab64a02015-10-06 16:28:32 +020032 password: pass
33 address: 10.0.0.5
34 interface: eth1
Ales Komarek733b0922016-01-05 16:27:21 +010035
36Multiple virtual IPs on single interface
37
38.. code-block:: yaml
39
40 keepalived:
41 cluster:
42 enabled: True
43 instance:
44 VIP1:
Jakub Pavlik2680d652016-08-26 17:35:40 +020045 nopreempt: True
46 priority: 100 (highest priority must be on primary server, different for cluster members)
47 virtual_router_id: 51
48 password: pass
49 addresses:
50 - 192.168.10.1
51 - 192.168.10.2
52 interface: eth0
53
Tomáš Kukrál1431a922017-05-25 17:04:18 +020054
55Use unicast
56
57.. code-block:: yaml
58
59 keepalived:
60 cluster:
61 enabled: True
62 instance:
63 VIP1:
64 nopreempt: True
65 priority: 100 (highest priority must be on primary server, different for cluster members)
66 virtual_router_id: 51
67 password: pass
68 address: 192.168.10.1
69 interface: eth0
70 unicast_src_ip: 172.16.10.1
71 unicast_peer:
72 172.16.10.2
73 172.16.10.3
74
75
Jakub Pavlik2680d652016-08-26 17:35:40 +020076Disable nopreempt mode to have Master. Highest priority is taken in all cases.
77
78.. code-block:: yaml
79
80 keepalived:
81 cluster:
82 enabled: True
83 instance:
84 VIP1:
85 nopreempt: False
86 priority: 100 (highest priority must be on primary server, different for cluster members)
87 virtual_router_id: 51
88 password: pass
89 addresses:
90 - 192.168.10.1
91 - 192.168.10.2
92 interface: eth0
93
94Notify action in keepalived.
95
96.. code-block:: yaml
97
98 keepalived:
99 cluster:
100 enabled: True
101 instance:
102 VIP1:
103 nopreempt: True
Filip Pytloun424120b2016-08-26 19:31:42 +0200104 notify_action:
105 master:
106 - /usr/bin/docker start jenkins
107 - /usr/bin/docker start gerrit
108 backup:
109 - /usr/bin/docker stop jenkins
110 - /usr/bin/docker stop gerrit
111 fault:
112 - /usr/bin/docker stop jenkins
113 - /usr/bin/docker stop gerrit
114 priority: 100 # highest priority must be on primary server, different for cluster members
Ales Komarek733b0922016-01-05 16:27:21 +0100115 virtual_router_id: 51
116 password: pass
117 addresses:
118 - 192.168.10.1
119 - 192.168.10.2
120 interface: eth0
Filip Pytloun4ab64a02015-10-06 16:28:32 +0200121
Petr Michalec97aab162017-02-21 14:16:18 +0100122Track/vrrp scripts for keepalived instance:
123
124.. code-block:: yaml
125
126 keepalived:
127 cluster:
128 enabled: True
129 instance:
130 VIP2:
131 priority: 100
132 virtual_router_id: 10
133 password: pass
134 addresses:
135 - 192.168.11.1
136 - 192.168.11.2
137 interface: eth0
Petr Michalec8863f472017-05-05 15:57:22 +0200138 track_script: check_haproxy
Petr Michalec97aab162017-02-21 14:16:18 +0100139 VIP3:
140 priority: 100
141 virtual_router_id: 11
142 password: pass
143 addresses:
144 - 192.168.10.1
145 - 192.168.10.2
146 interface: eth0
Petr Michalecb48338d2017-05-18 15:20:55 +0200147 track_script:
148 check_random_exit:
149 interval: 10
150 check_port:
151 weight: 50
Petr Michalec97aab162017-02-21 14:16:18 +0100152 vrrp_scripts:
Petr Michalec8863f472017-05-05 15:57:22 +0200153 check_haproxy:
154 name: check_pidof
155 args:
156 - haproxy
157 check_mysql_port:
158 name: check_port
159 args:
160 - 3306
161 - TCP
162 - 4
163 check_ssh:
164 name: check_port
165 args: "22"
166 check_mysql_cluster:
167 args:
168 # github: olafz/percona-clustercheck
169 # <user> <pass> <available_when_donor=0|1> <log_file> <available_when_readonly=0|1> <defaults_extra_file>
170 - clustercheck
171 - clustercheck
172 - available_when_donor=0
173 - available_when_readonly=0
174 check_random_exit:
Petr Michalec97aab162017-02-21 14:16:18 +0100175 interval: 10
176 content: |
177 #!/bin/bash
178 exit $(($RANDOM%2))
Petr Michalecb48338d2017-05-18 15:20:55 +0200179 weight: 50
Petr Michalec97aab162017-02-21 14:16:18 +0100180
181
Filip Pytloun4ab64a02015-10-06 16:28:32 +0200182Read more
183=========
184
185* https://raymii.org/s/tutorials/Keepalived-Simple-IP-failover-on-Ubuntu.html
Filip Pytloun27be6862017-02-02 13:02:03 +0100186
187Documentation and Bugs
188======================
189
190To learn how to install and update salt-formulas, consult the documentation
191available online at:
192
193 http://salt-formulas.readthedocs.io/
194
195In the unfortunate event that bugs are discovered, they should be reported to
196the appropriate issue tracker. Use Github issue tracker for specific salt
197formula:
198
199 https://github.com/salt-formulas/salt-formula-keepalived/issues
200
201For feature requests, bug reports or blueprints affecting entire ecosystem,
202use Launchpad salt-formulas project:
203
204 https://launchpad.net/salt-formulas
205
206You can also join salt-formulas-users team and subscribe to mailing list:
207
208 https://launchpad.net/~salt-formulas-users
209
210Developers wishing to work on the salt-formulas projects should always base
211their work on master branch and submit pull request against specific formula.
212
213 https://github.com/salt-formulas/salt-formula-keepalived
214
215Any questions or feedback is always welcome so feel free to join our IRC
216channel:
217
218 #salt-formulas @ irc.freenode.net