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 |
| 23 | password: pass |
| 24 | address: 192.168.10.1 |
| 25 | interface: eth0 |
Ales Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 26 | VIP2: |
Jakub Pavlik | 2680d65 | 2016-08-26 17:35:40 +0200 | [diff] [blame] | 27 | nopreempt: True |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 28 | 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 Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 33 | |
| 34 | Multiple virtual IPs on single interface |
| 35 | |
| 36 | .. code-block:: yaml |
| 37 | |
| 38 | keepalived: |
| 39 | cluster: |
| 40 | enabled: True |
| 41 | instance: |
| 42 | VIP1: |
Jakub Pavlik | 2680d65 | 2016-08-26 17:35:40 +0200 | [diff] [blame] | 43 | 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 | |
| 52 | Disable nopreempt mode to have Master. Highest priority is taken in all cases. |
| 53 | |
| 54 | .. code-block:: yaml |
| 55 | |
| 56 | keepalived: |
| 57 | cluster: |
| 58 | enabled: True |
| 59 | instance: |
| 60 | VIP1: |
| 61 | nopreempt: False |
| 62 | priority: 100 (highest priority must be on primary server, different for cluster members) |
| 63 | virtual_router_id: 51 |
| 64 | password: pass |
| 65 | addresses: |
| 66 | - 192.168.10.1 |
| 67 | - 192.168.10.2 |
| 68 | interface: eth0 |
| 69 | |
| 70 | Notify action in keepalived. |
| 71 | |
| 72 | .. code-block:: yaml |
| 73 | |
| 74 | keepalived: |
| 75 | cluster: |
| 76 | enabled: True |
| 77 | instance: |
| 78 | VIP1: |
| 79 | nopreempt: True |
Filip Pytloun | 424120b | 2016-08-26 19:31:42 +0200 | [diff] [blame] | 80 | notify_action: |
| 81 | master: |
| 82 | - /usr/bin/docker start jenkins |
| 83 | - /usr/bin/docker start gerrit |
| 84 | backup: |
| 85 | - /usr/bin/docker stop jenkins |
| 86 | - /usr/bin/docker stop gerrit |
| 87 | fault: |
| 88 | - /usr/bin/docker stop jenkins |
| 89 | - /usr/bin/docker stop gerrit |
| 90 | 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] | 91 | virtual_router_id: 51 |
| 92 | password: pass |
| 93 | addresses: |
| 94 | - 192.168.10.1 |
| 95 | - 192.168.10.2 |
| 96 | interface: eth0 |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 97 | |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 98 | Track/vrrp scripts for keepalived instance: |
| 99 | |
| 100 | .. code-block:: yaml |
| 101 | |
| 102 | keepalived: |
| 103 | cluster: |
| 104 | enabled: True |
| 105 | instance: |
| 106 | VIP2: |
| 107 | priority: 100 |
| 108 | virtual_router_id: 10 |
| 109 | password: pass |
| 110 | addresses: |
| 111 | - 192.168.11.1 |
| 112 | - 192.168.11.2 |
| 113 | interface: eth0 |
Petr Michalec | 8863f47 | 2017-05-05 15:57:22 +0200 | [diff] [blame] | 114 | track_script: check_haproxy |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 115 | VIP3: |
| 116 | priority: 100 |
| 117 | virtual_router_id: 11 |
| 118 | password: pass |
| 119 | addresses: |
| 120 | - 192.168.10.1 |
| 121 | - 192.168.10.2 |
| 122 | interface: eth0 |
Petr Michalec | b48338d | 2017-05-18 15:20:55 +0200 | [diff] [blame^] | 123 | track_script: |
| 124 | check_random_exit: |
| 125 | interval: 10 |
| 126 | check_port: |
| 127 | weight: 50 |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 128 | vrrp_scripts: |
Petr Michalec | 8863f47 | 2017-05-05 15:57:22 +0200 | [diff] [blame] | 129 | check_haproxy: |
| 130 | name: check_pidof |
| 131 | args: |
| 132 | - haproxy |
| 133 | check_mysql_port: |
| 134 | name: check_port |
| 135 | args: |
| 136 | - 3306 |
| 137 | - TCP |
| 138 | - 4 |
| 139 | check_ssh: |
| 140 | name: check_port |
| 141 | args: "22" |
| 142 | check_mysql_cluster: |
| 143 | args: |
| 144 | # github: olafz/percona-clustercheck |
| 145 | # <user> <pass> <available_when_donor=0|1> <log_file> <available_when_readonly=0|1> <defaults_extra_file> |
| 146 | - clustercheck |
| 147 | - clustercheck |
| 148 | - available_when_donor=0 |
| 149 | - available_when_readonly=0 |
| 150 | check_random_exit: |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 151 | interval: 10 |
| 152 | content: | |
| 153 | #!/bin/bash |
| 154 | exit $(($RANDOM%2)) |
Petr Michalec | b48338d | 2017-05-18 15:20:55 +0200 | [diff] [blame^] | 155 | weight: 50 |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 156 | |
| 157 | |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 158 | Read more |
| 159 | ========= |
| 160 | |
| 161 | * https://raymii.org/s/tutorials/Keepalived-Simple-IP-failover-on-Ubuntu.html |
Filip Pytloun | 27be686 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 162 | |
| 163 | Documentation and Bugs |
| 164 | ====================== |
| 165 | |
| 166 | To learn how to install and update salt-formulas, consult the documentation |
| 167 | available online at: |
| 168 | |
| 169 | http://salt-formulas.readthedocs.io/ |
| 170 | |
| 171 | In the unfortunate event that bugs are discovered, they should be reported to |
| 172 | the appropriate issue tracker. Use Github issue tracker for specific salt |
| 173 | formula: |
| 174 | |
| 175 | https://github.com/salt-formulas/salt-formula-keepalived/issues |
| 176 | |
| 177 | For feature requests, bug reports or blueprints affecting entire ecosystem, |
| 178 | use Launchpad salt-formulas project: |
| 179 | |
| 180 | https://launchpad.net/salt-formulas |
| 181 | |
| 182 | You can also join salt-formulas-users team and subscribe to mailing list: |
| 183 | |
| 184 | https://launchpad.net/~salt-formulas-users |
| 185 | |
| 186 | Developers wishing to work on the salt-formulas projects should always base |
| 187 | their work on master branch and submit pull request against specific formula. |
| 188 | |
| 189 | https://github.com/salt-formulas/salt-formula-keepalived |
| 190 | |
| 191 | Any questions or feedback is always welcome so feel free to join our IRC |
| 192 | channel: |
| 193 | |
| 194 | #salt-formulas @ irc.freenode.net |