blob: 17410a43be7a99f7d51a25da6ee2cb93db90b8a8 [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
23 password: pass
24 address: 192.168.10.1
25 interface: eth0
Ales Komarek733b0922016-01-05 16:27:21 +010026 VIP2:
Jakub Pavlik2680d652016-08-26 17:35:40 +020027 nopreempt: True
Filip Pytloun4ab64a02015-10-06 16:28:32 +020028 priority: 150 (highest priority must be on primary server, different for cluster members)
29 virtual_router_id: 52
30 password: pass
31 address: 10.0.0.5
32 interface: eth1
Ales Komarek733b0922016-01-05 16:27:21 +010033
34Multiple virtual IPs on single interface
35
36.. code-block:: yaml
37
38 keepalived:
39 cluster:
40 enabled: True
41 instance:
42 VIP1:
Jakub Pavlik2680d652016-08-26 17:35:40 +020043 nopreempt: True
44 priority: 100 (highest priority must be on primary server, different for cluster members)
45 virtual_router_id: 51
46 password: pass
47 addresses:
48 - 192.168.10.1
49 - 192.168.10.2
50 interface: eth0
51
Tomáš Kukrál1431a922017-05-25 17:04:18 +020052
53Use unicast
54
55.. code-block:: yaml
56
57 keepalived:
58 cluster:
59 enabled: True
60 instance:
61 VIP1:
62 nopreempt: True
63 priority: 100 (highest priority must be on primary server, different for cluster members)
64 virtual_router_id: 51
65 password: pass
66 address: 192.168.10.1
67 interface: eth0
68 unicast_src_ip: 172.16.10.1
69 unicast_peer:
70 172.16.10.2
71 172.16.10.3
72
73
Jakub Pavlik2680d652016-08-26 17:35:40 +020074Disable nopreempt mode to have Master. Highest priority is taken in all cases.
75
76.. code-block:: yaml
77
78 keepalived:
79 cluster:
80 enabled: True
81 instance:
82 VIP1:
83 nopreempt: False
84 priority: 100 (highest priority must be on primary server, different for cluster members)
85 virtual_router_id: 51
86 password: pass
87 addresses:
88 - 192.168.10.1
89 - 192.168.10.2
90 interface: eth0
91
92Notify action in keepalived.
93
94.. code-block:: yaml
95
96 keepalived:
97 cluster:
98 enabled: True
99 instance:
100 VIP1:
101 nopreempt: True
Filip Pytloun424120b2016-08-26 19:31:42 +0200102 notify_action:
103 master:
104 - /usr/bin/docker start jenkins
105 - /usr/bin/docker start gerrit
106 backup:
107 - /usr/bin/docker stop jenkins
108 - /usr/bin/docker stop gerrit
109 fault:
110 - /usr/bin/docker stop jenkins
111 - /usr/bin/docker stop gerrit
112 priority: 100 # highest priority must be on primary server, different for cluster members
Ales Komarek733b0922016-01-05 16:27:21 +0100113 virtual_router_id: 51
114 password: pass
115 addresses:
116 - 192.168.10.1
117 - 192.168.10.2
118 interface: eth0
Filip Pytloun4ab64a02015-10-06 16:28:32 +0200119
Petr Michalec97aab162017-02-21 14:16:18 +0100120Track/vrrp scripts for keepalived instance:
121
122.. code-block:: yaml
123
124 keepalived:
125 cluster:
126 enabled: True
127 instance:
128 VIP2:
129 priority: 100
130 virtual_router_id: 10
131 password: pass
132 addresses:
133 - 192.168.11.1
134 - 192.168.11.2
135 interface: eth0
Petr Michalec8863f472017-05-05 15:57:22 +0200136 track_script: check_haproxy
Petr Michalec97aab162017-02-21 14:16:18 +0100137 VIP3:
138 priority: 100
139 virtual_router_id: 11
140 password: pass
141 addresses:
142 - 192.168.10.1
143 - 192.168.10.2
144 interface: eth0
Petr Michalecb48338d2017-05-18 15:20:55 +0200145 track_script:
146 check_random_exit:
147 interval: 10
148 check_port:
149 weight: 50
Petr Michalec97aab162017-02-21 14:16:18 +0100150 vrrp_scripts:
Petr Michalec8863f472017-05-05 15:57:22 +0200151 check_haproxy:
152 name: check_pidof
153 args:
154 - haproxy
155 check_mysql_port:
156 name: check_port
157 args:
158 - 3306
159 - TCP
160 - 4
161 check_ssh:
162 name: check_port
163 args: "22"
164 check_mysql_cluster:
165 args:
166 # github: olafz/percona-clustercheck
167 # <user> <pass> <available_when_donor=0|1> <log_file> <available_when_readonly=0|1> <defaults_extra_file>
168 - clustercheck
169 - clustercheck
170 - available_when_donor=0
171 - available_when_readonly=0
172 check_random_exit:
Petr Michalec97aab162017-02-21 14:16:18 +0100173 interval: 10
174 content: |
175 #!/bin/bash
176 exit $(($RANDOM%2))
Petr Michalecb48338d2017-05-18 15:20:55 +0200177 weight: 50
Petr Michalec97aab162017-02-21 14:16:18 +0100178
179
Filip Pytloun4ab64a02015-10-06 16:28:32 +0200180Read more
181=========
182
183* https://raymii.org/s/tutorials/Keepalived-Simple-IP-failover-on-Ubuntu.html
Filip Pytloun27be6862017-02-02 13:02:03 +0100184
185Documentation and Bugs
186======================
187
188To learn how to install and update salt-formulas, consult the documentation
189available online at:
190
191 http://salt-formulas.readthedocs.io/
192
193In the unfortunate event that bugs are discovered, they should be reported to
194the appropriate issue tracker. Use Github issue tracker for specific salt
195formula:
196
197 https://github.com/salt-formulas/salt-formula-keepalived/issues
198
199For feature requests, bug reports or blueprints affecting entire ecosystem,
200use Launchpad salt-formulas project:
201
202 https://launchpad.net/salt-formulas
203
204You can also join salt-formulas-users team and subscribe to mailing list:
205
206 https://launchpad.net/~salt-formulas-users
207
208Developers wishing to work on the salt-formulas projects should always base
209their work on master branch and submit pull request against specific formula.
210
211 https://github.com/salt-formulas/salt-formula-keepalived
212
213Any questions or feedback is always welcome so feel free to join our IRC
214channel:
215
216 #salt-formulas @ irc.freenode.net