Editing
KeepAlived
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Balansare IP cu KeepAlived pe Ubuntu 2X.04 LTS == [[File:Keepalived.png|782x782px|none|Keepalived]] Pentru instalare keepalived se cere uneori (depinzand de ditributie si/sau versiune) instalarea librariei libipset13 <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- -->apt install -y keepalived libipset13 </code> Pe fiecare dintre noduri se creaza si editeaza urmatorul fisier: <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- -->nano /etc/keepalived/keepalived.conf </code> cu urmatorul continut ===== ha01 ===== <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- -->vrrp_instance VIP { state MASTER interface ens18 virtual_router_id 66 priority 99 advert_int 1 unicast_src_ip 192.168.14.11 unicast_peer { 192.168.14.22 192.168.14.33 } authentication { auth_type PASS auth_pass <span style="color:#f00">[pass1234]</span> } virtual_ipaddress { 192.168.14.123/24 } } </code> ===== ha02 si ha03 ===== <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- -->vrrp_instance VIP { state BACKUP interface ens18 virtual_router_id 66 priority 97 <span style="color:#f00"><- pentru ha02</span> priority 95 <span style="color:#f00"><- pentru ha03</span> advert_int 1 unicast_src_ip 192.168.14.22 <span style="color:#f00"><- pentru ha02</span> unicast_src_ip 192.168.14.33 <span style="color:#f00"><- pentru ha03</span> unicast_peer { 192.168.14.11 192.168.14.33 <span style="color:#f00"><- pentru ha02</span> 192.168.14.22 <span style="color:#f00"><- pentru ha03</span> } authentication { auth_type PASS auth_pass <span style="color:#f00">[pass1234]</span> } virtual_ipaddress { 192.168.14.123/24 } } </code> ===== Legenda ===== '''vrrp_instance''' = numele instantei de VIP<br> '''state''' = numele NIC-ului fizic sau virtual<br> '''virtual_router_id''' = este un ID ce se aloca instantei respective (keepalived poate balansa mai multe IP-uri de pe mai multe NIC-uri)<br> '''priority''' = reprezinta prioritatea serverului respectiv in lantul de redundanta<br> '''advert_int''' = intervalul (secunde) in care se face verificarea celoralte instante de VIP<br> '''unicast_src_ip''' = se trece IP-ul NIC-ului de pe serverul curent<br> '''unicast_peer''' = se trec IP-urile celorlalte servere din instanta<br> '''auth_pass''' = parola de maxim opt caractere persistenta pe toate instantele<br> '''virtual_ipaddress''' = identifica IP-ul flotant de pe instantele de keepalived == Monitorizarea Apache2 in vederea balansarii IP-ului == In vederea migrarii IP-ului in cazul unui fail al Apache2, se adauga urmatorul continut in toate serverele pe care instanta de Keepalived este configurata: * nano /etc/keepalived/keepalived.conf ===== ha01, ha02 si ha03 ===== <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- --><span style="color:#f00">vrrp_track_process trkap2 { process apache2 weight 10 }</span> vrrp_instance VIP { state MASTER interface ens18 virtual_router_id 66 priority 99 advert_int 1 unicast_src_ip 192.168.14.11 unicast_peer { 192.168.14.22 192.168.14.33 } <span style="color:#f00"> track_process { trkap2 }</span> authentication { auth_type PASS auth_pass [pass1234] } virtual_ipaddress { 192.168.14.123/24 } } </code> ===== Weight ===== Weight-ul se adauga la priority astfel incat toate nodurile cu Apache2 pornit vor avea urmatoarele prioritati: * ha01=109 * ha02=107 * ha03=105 In momentul in care Apache2 este oprit pe ha01 priority va scade de la 109 la 99 astfel incat IP-ul va migra pe ha02 care la momentul respectiv va avea o prioritate de 107. == Alertare Keepalived prin SMTP == Keepalived poate trimite alerte pe mail la migrarea unui IP de pe un nod pe altul: * nano /etc/keepalived/keepalived.conf ===== ha01, ha02 si ha03 ===== <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- --><span style="color:#f00">global_defs { notification_email { monitorizare@domeniu.ro } notification_email_from keepalived@domeniu.ro smtp_server mail.domeniu.ro smtp_connect_timeout 30 }</span> vrrp_track_process track_apache { process apache2 weight 10 } vrrp_instance VIP { state MASTER interface ens18 virtual_router_id 66 priority 99 <span style="color:#f00"> smtp_alert</span> advert_int 1 unicast_src_ip 192.168.14.11 unicast_peer { 192.168.14.22 192.168.14.33 } track_process { track_apache } authentication { auth_type PASS auth_pass [pass1234] } virtual_ipaddress { 192.168.14.123/24 } } </code> ===== Legenda ===== '''notification_email''' = se va trece adresa de mail care va primi alertele de migrare IP<br> '''notification_email_from''' = se va trece adresa de mail de la care se trimit alertele. Desi keepalived nu face autentificare in serverul de mail, adresa trebuie sa fie una valida<br> '''smtp_server''' = fqdn-ul serverului de mail<br> '''smtp_connect_timeout''' = perioada (secunde) ce va trece din momentul din care nodul pierde IP-ul pana va trimite alertarea pe mail == Recomandari == https://www.keepalived.org/
Summary:
Please note that all contributions to Linux Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Linux Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Navigation
Main page
Aplicatii Linux
UrBackup
rSyslog
KeepAlived
DHCP
BIND DNS
USB over IP
Hardware Linux
Adaugare Disk
Extindere Disk
Docker
Instalare Docker CE
Portainer
Container UrBackup
Container PiHole
Snippets
History Command
Access Control List
Tools
What links here
Related changes
Special pages
Page information