Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1 | ========== |
| 2 | Keepalived |
| 3 | ========== |
| 4 | |
| 5 | Keepalived 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 | |
| 8 | Sample pillar |
| 9 | ============= |
| 10 | |
Ales Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 11 | Simple virtual IP on an interface |
| 12 | |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 13 | .. code-block:: yaml |
| 14 | |
| 15 | keepalived: |
| 16 | cluster: |
| 17 | enabled: True |
| 18 | instance: |
Ales Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 19 | VIP1: |
Jakub Pavlik | 2680d65 | 2016-08-26 17:35:40 +0200 | [diff] [blame] | 20 | nopreempt: True |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 21 | priority: 100 (highest priority must be on primary server, different for cluster members) |
| 22 | virtual_router_id: 51 |
Vasyl Saienko | a4165fd | 2017-11-16 16:47:19 +0200 | [diff] [blame] | 23 | auth_type: AH |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 24 | password: pass |
| 25 | address: 192.168.10.1 |
| 26 | interface: eth0 |
Ales Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 27 | VIP2: |
Jakub Pavlik | 2680d65 | 2016-08-26 17:35:40 +0200 | [diff] [blame] | 28 | nopreempt: True |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 29 | priority: 150 (highest priority must be on primary server, different for cluster members) |
| 30 | virtual_router_id: 52 |
Vasyl Saienko | a4165fd | 2017-11-16 16:47:19 +0200 | [diff] [blame] | 31 | auth_type: PASS |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 32 | password: pass |
| 33 | address: 10.0.0.5 |
| 34 | interface: eth1 |
Ales Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 35 | |
| 36 | Multiple virtual IPs on single interface |
| 37 | |
| 38 | .. code-block:: yaml |
| 39 | |
| 40 | keepalived: |
| 41 | cluster: |
| 42 | enabled: True |
| 43 | instance: |
| 44 | VIP1: |
Jakub Pavlik | 2680d65 | 2016-08-26 17:35:40 +0200 | [diff] [blame] | 45 | 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ál | 1431a92 | 2017-05-25 17:04:18 +0200 | [diff] [blame] | 54 | |
| 55 | Use 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 Pavlik | 2680d65 | 2016-08-26 17:35:40 +0200 | [diff] [blame] | 76 | Disable 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 | |
| 94 | Notify action in keepalived. |
| 95 | |
| 96 | .. code-block:: yaml |
| 97 | |
| 98 | keepalived: |
| 99 | cluster: |
| 100 | enabled: True |
| 101 | instance: |
| 102 | VIP1: |
| 103 | nopreempt: True |
Filip Pytloun | 424120b | 2016-08-26 19:31:42 +0200 | [diff] [blame] | 104 | 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 Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 115 | virtual_router_id: 51 |
| 116 | password: pass |
| 117 | addresses: |
| 118 | - 192.168.10.1 |
| 119 | - 192.168.10.2 |
| 120 | interface: eth0 |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 121 | |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 122 | Track/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 Michalec | 8863f47 | 2017-05-05 15:57:22 +0200 | [diff] [blame] | 138 | track_script: check_haproxy |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 139 | 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 Michalec | b48338d | 2017-05-18 15:20:55 +0200 | [diff] [blame] | 147 | track_script: |
| 148 | check_random_exit: |
| 149 | interval: 10 |
| 150 | check_port: |
| 151 | weight: 50 |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 152 | vrrp_scripts: |
Petr Michalec | 8863f47 | 2017-05-05 15:57:22 +0200 | [diff] [blame] | 153 | 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 Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 175 | interval: 10 |
| 176 | content: | |
| 177 | #!/bin/bash |
| 178 | exit $(($RANDOM%2)) |
Petr Michalec | b48338d | 2017-05-18 15:20:55 +0200 | [diff] [blame] | 179 | weight: 50 |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 180 | |
| 181 | |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 182 | Read more |
| 183 | ========= |
| 184 | |
| 185 | * https://raymii.org/s/tutorials/Keepalived-Simple-IP-failover-on-Ubuntu.html |
Filip Pytloun | 27be686 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 186 | |
| 187 | Documentation and Bugs |
| 188 | ====================== |
| 189 | |
| 190 | To learn how to install and update salt-formulas, consult the documentation |
| 191 | available online at: |
| 192 | |
| 193 | http://salt-formulas.readthedocs.io/ |
| 194 | |
| 195 | In the unfortunate event that bugs are discovered, they should be reported to |
| 196 | the appropriate issue tracker. Use Github issue tracker for specific salt |
| 197 | formula: |
| 198 | |
| 199 | https://github.com/salt-formulas/salt-formula-keepalived/issues |
| 200 | |
| 201 | For feature requests, bug reports or blueprints affecting entire ecosystem, |
| 202 | use Launchpad salt-formulas project: |
| 203 | |
| 204 | https://launchpad.net/salt-formulas |
| 205 | |
| 206 | You can also join salt-formulas-users team and subscribe to mailing list: |
| 207 | |
| 208 | https://launchpad.net/~salt-formulas-users |
| 209 | |
| 210 | Developers wishing to work on the salt-formulas projects should always base |
| 211 | their work on master branch and submit pull request against specific formula. |
| 212 | |
| 213 | https://github.com/salt-formulas/salt-formula-keepalived |
| 214 | |
| 215 | Any questions or feedback is always welcome so feel free to join our IRC |
| 216 | channel: |
| 217 | |
| 218 | #salt-formulas @ irc.freenode.net |