sql >> Databáze >  >> RDS >> PostgreSQL

Jak nainstalovat Haproxy a Keepalived

Ahoj přátelé, dnes vám řeknu, jak nainstalovat haproxy a keepalived.

yum install haproxy keepalived -y

Soubor parametrů ve službě musí být potvrzen

cat /usr/lib/systemd/system/haproxy.service
[Unit]
Description=HAProxy Load Balancer
After=syslog.target network.target

[Service]
EnvironmentFile=/etc/sysconfig/haproxy
ExecStart=/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid $OPTIONS
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed

Podle výše uvedeného servisního souboru je použit /etc/haproxy/haproxy.cfg, ale upravili jsme soubor CONF, takže došlo k chybě.
soubor conf lze exportovat do cfg

http://xxx.xxx.xx.xx:7000/ To control over the web, the server leader can be controlled with the 7000 port.
vi /etc/haproxy/haproxy.cfg

vi /etc/haproxy/haproxy.conf

global
maxconn 100
defaults
log global
mode tcp
retries 2
timeout client 30m
timeout connect 4s
timeout server 30m
timeout check 5s
listen stats
mode http
bind *:7000
stats enable
stats uri /
# Connections to port 5002
listen Master_Server
bind *:5432
mode tcp
option tcpka
option httpchk OPTIONS /master
http-check expect status 200
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server xxx.xxx.xx.xx xxx.xxx.xx.xx:5432 maxconn 100 check port 8008
server xxx.xxx.xx.xx xxx.xxx.xx.xx:5432 maxconn 100 check port 8008

# Connections to port 5003
listen Standby_Servers
bind *:5433
mode tcp
option tcpka
option httpchk OPTIONS /replica
http-check expect status 200
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server xxx.xxx.xx.xx xxx.xxx.xx.xx:5432 maxconn 100 check port 8008
server xxx.xxx.xx.xx xxx.xxx.xx.xx:5432 maxconn 100 check port 8008

vi /etc/keepalived/keepalived.conf

HAP-1 - Backup ;
vrrp_script chk_haproxy {
script "pidof haproxy"
interval 2
}

vrrp_instance VI_1 {
state MASTER
interface ens192
virtual_router_id 51
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
unicast_src_ip xxx.xxx.xx.xx
unicast_peer {
xxx.xxx.xx.xx
}
virtual_ipaddress {
xxx.xxx.xx.xx
} 
track_script {
chk_haproxy
}
}

HAP-2 - Backup ;
vrrp_script chk_haproxy {
script "pidof haproxy"
interval 2
}

vrrp_instance VI_1 {
state BACKUP
interface ens192
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
unicast_src_ip xxx.xxx.xx.xx
unicast_peer {
xxx.xxx.xx.xx
}
virtual_ipaddress {
xxx.xxx.xx.xx
}
track_script {
chk_haproxy
}
}

systemctl enable haproxy
systemctl enable keepalived

systemctl start haproxy
systemctl start keepalived

  1. Dotaz LISTAGG ORA-00937:není skupinová funkce jedné skupiny

  2. Postgres NENÍ v poli

  3. Co je MariaDB? Jak MariaDB funguje?

  4. Zrušit sloupec neodstraní odkazy na sloupce úplně - postgresql