OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 1 | ===== |
| 2 | Usage |
| 3 | ===== |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 4 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 5 | Keepalived is a routing software written in C. The main goal of this project |
| 6 | is to provide simple and robust facilities for loadbalancing and |
| 7 | high-availability to Linux system and Linux based infrastructures. |
| 8 | Loadbalancing framework relies on well-known and widely used Linux Virtual |
| 9 | Server (IPVS) kernel module providing Layer4 loadbalancing. Keepalived |
| 10 | implements a set of checkers to dynamically and adaptively maintain and |
| 11 | manage loadbalanced server pool according their health. On the other hand |
| 12 | high-availability is achieved by VRRP protocol. VRRP is a fundamental brick |
| 13 | for router failover. In addition, Keepalived implements a set of hooks to the |
| 14 | VRRP finite state machine providing low-level and high-speed protocol |
| 15 | interactions. Keepalived frameworks can be used independently or all together |
| 16 | to provide resilient infrastructures. |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 17 | |
| 18 | Sample pillar |
| 19 | ============= |
| 20 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 21 | Simple virtual IP on an interface: |
Ales Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 22 | |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 23 | .. code-block:: yaml |
| 24 | |
| 25 | keepalived: |
| 26 | cluster: |
| 27 | enabled: True |
| 28 | instance: |
Ales Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 29 | VIP1: |
Jakub Pavlik | 2680d65 | 2016-08-26 17:35:40 +0200 | [diff] [blame] | 30 | nopreempt: True |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 31 | priority: 100 (highest priority must be on primary server, different for cluster members) |
| 32 | virtual_router_id: 51 |
Vasyl Saienko | a4165fd | 2017-11-16 16:47:19 +0200 | [diff] [blame] | 33 | auth_type: AH |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 34 | password: pass |
| 35 | address: 192.168.10.1 |
| 36 | interface: eth0 |
Ales Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 37 | VIP2: |
Jakub Pavlik | 2680d65 | 2016-08-26 17:35:40 +0200 | [diff] [blame] | 38 | nopreempt: True |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 39 | priority: 150 (highest priority must be on primary server, different for cluster members) |
| 40 | virtual_router_id: 52 |
Vasyl Saienko | a4165fd | 2017-11-16 16:47:19 +0200 | [diff] [blame] | 41 | auth_type: PASS |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 42 | password: pass |
| 43 | address: 10.0.0.5 |
| 44 | interface: eth1 |
Ales Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 45 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 46 | Multiple virtual IPs on single interface: |
Ales Komarek | 733b092 | 2016-01-05 16:27:21 +0100 | [diff] [blame] | 47 | |
| 48 | .. code-block:: yaml |
| 49 | |
| 50 | keepalived: |
| 51 | cluster: |
| 52 | enabled: True |
| 53 | instance: |
| 54 | VIP1: |
Jakub Pavlik | 2680d65 | 2016-08-26 17:35:40 +0200 | [diff] [blame] | 55 | nopreempt: True |
| 56 | priority: 100 (highest priority must be on primary server, different for cluster members) |
| 57 | virtual_router_id: 51 |
| 58 | password: pass |
| 59 | addresses: |
| 60 | - 192.168.10.1 |
| 61 | - 192.168.10.2 |
| 62 | interface: eth0 |
| 63 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 64 | Use unicast: |
Tomáš Kukrál | 1431a92 | 2017-05-25 17:04:18 +0200 | [diff] [blame] | 65 | |
| 66 | .. code-block:: yaml |
| 67 | |
| 68 | keepalived: |
| 69 | cluster: |
| 70 | enabled: True |
| 71 | instance: |
| 72 | VIP1: |
| 73 | nopreempt: True |
| 74 | priority: 100 (highest priority must be on primary server, different for cluster members) |
| 75 | virtual_router_id: 51 |
| 76 | password: pass |
| 77 | address: 192.168.10.1 |
| 78 | interface: eth0 |
| 79 | unicast_src_ip: 172.16.10.1 |
| 80 | unicast_peer: |
| 81 | 172.16.10.2 |
| 82 | 172.16.10.3 |
| 83 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 84 | Disable nopreempt mode to have Master. Highest priority is taken |
| 85 | in all cases: |
Jakub Pavlik | 2680d65 | 2016-08-26 17:35:40 +0200 | [diff] [blame] | 86 | |
| 87 | .. code-block:: yaml |
| 88 | |
| 89 | keepalived: |
| 90 | cluster: |
| 91 | enabled: True |
| 92 | instance: |
| 93 | VIP1: |
| 94 | nopreempt: False |
| 95 | priority: 100 (highest priority must be on primary server, different for cluster members) |
| 96 | virtual_router_id: 51 |
| 97 | password: pass |
| 98 | addresses: |
| 99 | - 192.168.10.1 |
| 100 | - 192.168.10.2 |
| 101 | interface: eth0 |
| 102 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 103 | Notify action in keepalived: |
Jakub Pavlik | 2680d65 | 2016-08-26 17:35:40 +0200 | [diff] [blame] | 104 | |
| 105 | .. code-block:: yaml |
| 106 | |
| 107 | keepalived: |
| 108 | cluster: |
| 109 | enabled: True |
| 110 | instance: |
| 111 | VIP1: |
| 112 | nopreempt: True |
Filip Pytloun | 424120b | 2016-08-26 19:31:42 +0200 | [diff] [blame] | 113 | notify_action: |
| 114 | master: |
| 115 | - /usr/bin/docker start jenkins |
| 116 | - /usr/bin/docker start gerrit |
| 117 | backup: |
| 118 | - /usr/bin/docker stop jenkins |
| 119 | - /usr/bin/docker stop gerrit |
| 120 | fault: |
| 121 | - /usr/bin/docker stop jenkins |
| 122 | - /usr/bin/docker stop gerrit |
| 123 | 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] | 124 | virtual_router_id: 51 |
| 125 | password: pass |
| 126 | addresses: |
| 127 | - 192.168.10.1 |
| 128 | - 192.168.10.2 |
| 129 | interface: eth0 |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 130 | |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 131 | Track/vrrp scripts for keepalived instance: |
| 132 | |
| 133 | .. code-block:: yaml |
| 134 | |
| 135 | keepalived: |
| 136 | cluster: |
| 137 | enabled: True |
| 138 | instance: |
| 139 | VIP2: |
| 140 | priority: 100 |
| 141 | virtual_router_id: 10 |
| 142 | password: pass |
| 143 | addresses: |
| 144 | - 192.168.11.1 |
| 145 | - 192.168.11.2 |
| 146 | interface: eth0 |
Petr Michalec | 8863f47 | 2017-05-05 15:57:22 +0200 | [diff] [blame] | 147 | track_script: check_haproxy |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 148 | VIP3: |
| 149 | priority: 100 |
| 150 | virtual_router_id: 11 |
| 151 | password: pass |
| 152 | addresses: |
| 153 | - 192.168.10.1 |
| 154 | - 192.168.10.2 |
| 155 | interface: eth0 |
Petr Michalec | b48338d | 2017-05-18 15:20:55 +0200 | [diff] [blame] | 156 | track_script: |
| 157 | check_random_exit: |
| 158 | interval: 10 |
| 159 | check_port: |
| 160 | weight: 50 |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 161 | vrrp_scripts: |
Petr Michalec | 8863f47 | 2017-05-05 15:57:22 +0200 | [diff] [blame] | 162 | check_haproxy: |
| 163 | name: check_pidof |
| 164 | args: |
| 165 | - haproxy |
| 166 | check_mysql_port: |
| 167 | name: check_port |
| 168 | args: |
| 169 | - 3306 |
| 170 | - TCP |
| 171 | - 4 |
| 172 | check_ssh: |
| 173 | name: check_port |
| 174 | args: "22" |
| 175 | check_mysql_cluster: |
| 176 | args: |
| 177 | # github: olafz/percona-clustercheck |
| 178 | # <user> <pass> <available_when_donor=0|1> <log_file> <available_when_readonly=0|1> <defaults_extra_file> |
| 179 | - clustercheck |
| 180 | - clustercheck |
| 181 | - available_when_donor=0 |
| 182 | - available_when_readonly=0 |
| 183 | check_random_exit: |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 184 | interval: 10 |
| 185 | content: | |
| 186 | #!/bin/bash |
| 187 | exit $(($RANDOM%2)) |
Petr Michalec | b48338d | 2017-05-18 15:20:55 +0200 | [diff] [blame] | 188 | weight: 50 |
Petr Michalec | 97aab16 | 2017-02-21 14:16:18 +0100 | [diff] [blame] | 189 | |
Filip Pytloun | 4ab64a0 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 190 | Read more |
| 191 | ========= |
| 192 | |
| 193 | * https://raymii.org/s/tutorials/Keepalived-Simple-IP-failover-on-Ubuntu.html |
Filip Pytloun | 27be686 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 194 | |
| 195 | Documentation and Bugs |
| 196 | ====================== |
| 197 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 198 | * http://salt-formulas.readthedocs.io/ |
| 199 | Learn how to install and update salt-formulas |
Filip Pytloun | 27be686 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 200 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 201 | * https://github.com/salt-formulas/salt-formula-keepalived/issues |
| 202 | In the unfortunate event that bugs are discovered, report the issue to the |
| 203 | appropriate issue tracker. Use the Github issue tracker for a specific salt |
| 204 | formula |
Filip Pytloun | 27be686 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 205 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 206 | * https://launchpad.net/salt-formulas |
| 207 | For feature requests, bug reports, or blueprints affecting the entire |
| 208 | ecosystem, use the Launchpad salt-formulas project |
Filip Pytloun | 27be686 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 209 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 210 | * https://launchpad.net/~salt-formulas-users |
| 211 | Join the salt-formulas-users team and subscribe to mailing list if required |
Filip Pytloun | 27be686 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 212 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 213 | * https://github.com/salt-formulas/salt-formula-keepalived |
| 214 | Develop the salt-formulas projects in the master branch and then submit pull |
| 215 | requests against a specific formula |
Filip Pytloun | 27be686 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 216 | |
OlgaGusarenko | 29c21fd | 2018-07-30 18:52:30 +0300 | [diff] [blame] | 217 | * #salt-formulas @ irc.freenode.net |
| 218 | Use this IRC channel in case of any questions or feedback which is always |
| 219 | welcome |
Filip Pytloun | 27be686 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 220 | |