PostgreSQL
 sql >> Teknologi Basis Data >  >> RDS >> PostgreSQL

Bagaimana cara menginstal Haproxy dan Keepalive

Halo teman-teman, hari ini saya akan memberi tahu Anda cara menginstal haproxy dan keepalive.

yum install haproxy keepalived -y

File parameter dalam layanan harus dikonfirmasi

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

Menurut file layanan di atas, /etc/haproxy/haproxy.cfg digunakan, tetapi kami mengedit file CONF, jadi kami mendapatkan kesalahan.
File conf dapat diekspor ke 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. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Cara membuat koneksi ke Postgres melalui Node.js

  2. Gunakan variabel yang disetel oleh perintah meta psql di dalam blok DO

  3. Gunakan tabel COPY biner FROM dengan psycopg2

  4. Memanggil prosedur tersimpan dalam prosedur tersimpan

  5. Memetakan teks PostgreSQL[][] tipe dan tipe Java