Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
. ./setenv.sh `pwd`
OPENSQL_INSTALL_HOME is set to: /home/opensql3.0-rockylinux9.4-pg16.8
OPENSQL_HOME is set to: /home/opensql
OPENSQL_HOME added to /home/opensql/.bashrc./install.sh barman$ barman --version
3.11.1 Barman by EnterpriseDB (www.enterprisedb.com)OpenHA์ ํต์ฌ ๊ด๋ฆฌ ๋ชจ๋์ธ OpenHA ํด๋ฌ์คํฐ ๋งค๋์ (OpenHA Cluster Manager) ์ค์น ๊ณผ์ ์ ๋ํด์ ์๋ดํฉ๋๋ค.
. ./setenv.sh `pwd`
OPENSQL_INSTALL_HOME is set to: /home/opensql3.0-rockylinux9.4-pg16.8
OPENSQL_HOME is set to: /home/opensql
OPENSQL_HOME added to /home/opensql/.bashrc sudo -E ./install.sh patroni[root@396dd54381db scripts]$ patroni --version
patroni 4.0.5
[root@396dd54381db scripts]$ patronictl version
patronictl version 4.0.5. ./setenv.sh `pwd`
OPENSQL_INSTALL_HOME is set to: /home/opensql3.0-rockylinux9.4-pg16.8
OPENSQL_HOME is set to: /home/opensql
OPENSQL_HOME added to /home/opensql/.bashrc./install.sh etcd[opensql@396dd54381db etcd-v3.5.6-linux-amd64]etcd --version
etcd Version: 3.5.6
Git SHA: cecbe35ce
Go Version: go1.16.15
Go OS/Arch: linux/amd64
[opensql@396dd54381db etcd-v3.5.6-linux-amd64]etcdctl version
etcdctl version: 3.5.6
API version: 3.5OpenSQL ์ค์น๋ฅผ ์ํ ๊ธฐ๋ณธํ๊ฒฝ ์ค์ ๋ฐ PostgreSQL ์ค์น ๊ณผ์ ์ ์๋ดํฉ๋๋ค.
[root@5c9e5c6ae5f2 openproxy]# ls
openproxy openproxy.service openproxy.toml. ./setenv.sh `pwd`
OPENSQL_INSTALL_HOME is set to: /home/opensql3.0-rockylinux9.4-pg16.8
OPENSQL_HOME is set to: /home/opensql
OPENSQL_HOME added to /home/opensql/.bashrc./install.sh openproxy[root@5c9e5c6ae5f2 openproxy]# openproxy --version
openproxy 1.1.0./create_user.sh <password>export OPENSQL_HOME="path/to/install"
export PG_HOME="path/to/pg"
export PG_DATA_DIR="path/to/pg_data". ./setenv.sh `pwd`
OPENSQL_INSTALL_HOME is set to: /home/opensql3.0-rockylinux9.4-pg16.8sudo -E ./install.sh postgresql$ $PG_HOME/bin/pg_config
BINDIR = /usr/pgsql-16/bin
DOCDIR = /usr/pgsql-16/doc
HTMLDIR = /usr/pgsql-16/doc/html
INCLUDEDIR = /usr/pgsql-16/include
PKGINCLUDEDIR = /usr/pgsql-16/include
INCLUDEDIR-SERVER = /usr/pgsql-16/include/server
LIBDIR = /usr/pgsql-16/lib
PKGLIBDIR = /usr/pgsql-16/lib
LOCALEDIR = /usr/pgsql-16/share/locale
MANDIR = /usr/pgsql-16/share/man
SHAREDIR = /usr/pgsql-16/share
SYSCONFDIR = /etc/sysconfig/pgsql
PGXS = /usr/pgsql-16/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--enable-rpath' '--prefix=/usr/pgsql-16' '--includedir=/usr/pgsql-16/include' '--mandir=/usr/pgsql-16/share/man' '--datadir=/usr/pgsql-16/share' '--libdir=/usr/pgsql-16/lib' '--with-lz4' '--with-zstd' '--enable-tap-tests' '--with-icu' '--with-llvm' '--with-perl' '--with-python' '--with-tcl' '--with-tclconfig=/usr/lib64' '--with-openssl' '--with-pam' '--with-gssapi' '--with-includes=/usr/include' '--with-libraries=/usr/lib64' '--enable-nls' '--enable-dtrace' '--with-uuid=e2fs' '--with-libxml' '--with-libxslt' '--with-ldap' '--with-selinux' '--with-systemd' '--with-system-tzdata=/usr/share/zoneinfo' '--sysconfdir=/etc/sysconfig/pgsql' '--docdir=/usr/pgsql-16/doc' '--htmldir=/usr/pgsql-16/doc/html' 'CFLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' 'LDFLAGS=-Wl,--as-needed' 'LLVM_CONFIG=/usr/bin/llvm-config-64' 'CLANG=/usr/bin/clang' 'PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'
CC = gcc
CPPFLAGS = -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
CFLAGS_SL = -fPIC
LDFLAGS = -Wl,--as-needed -L/usr/lib64 -L/usr/lib64 -Wl,--as-needed -Wl,-rpath,'/usr/pgsql-16/lib',--enable-new-dtags
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgcommon -lpgport -lselinux -lzstd -llz4 -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lm
VERSION = PostgreSQL 16.8cluster : ํ์ ํญ๋ชฉ์ผ๋ก Barman ํ๊ฒฝ ๊ตฌ์ฑ์์ ์ค์ ํ ์๋ฒ ์ด๋ฆ๊ณผ ์ผ์นํด์ผ ํ๋ค. barman config-switch ๋ช
๋ น์ ์คํํ ๋ ์ฐธ์กฐ๋ฉ๋๋ค.; Main configuration file
[barman] # ๊ธ๋ก๋ฒ ํ๊ฒฝ ๊ตฌ์ฑ, OS ์ฌ์ฉ์ ์ด๋ฆ ๋ฐ barman ๋ฐ์ดํฐ์ ๋ก๊ทธ๋ฅผ ์ ์ฅํ ๊ฒฝ๋ก ๋ฑ์ ์ง์
; System user
barman_user = barman
configuration_files_directory = /etc/barman.d
; Main directory
barman_home = /var/lib/barman
log_file = /var/log/barman/barman.log
log_level = INFO[opensql] # ์๋ฒ ์ด๋ฆ
cluster = opensql # ํ์ ํ ๋ชจ๋๋ค๊ณผ ๊ฐ์ ๊ตฌ์ฑ์์ ๋ํ๋ด๊ธฐ ์ํ ํ๊ทธ
conninfo = host=node1 port=5432 user=opensql dbname=opensql
streaming_conninfo = host=node1 port=5432 user=opensql_streaming dbname=opensql
backup_method = postgres
streaming_archiver = on
slot_name = barman
; conninfo ์ฌ์ฉ์ ๊ถํ ์๊ตฌ์ฌํญ
; user=opensql : pg_monitor ๋๋ superuser ๊ถํ ํ์
; user=opensql_streaming: REPLICATION ๊ถํ ํ์
; pg_hba.conf์์ barman ํธ์คํธ์ ์ ๊ทผ์ ํ์ฉํด์ผ ํฉ๋๋ค.
[pg-1] # ๋ชจ๋ธ ์ด๋ฆ, Patroni REST API์์ ์ ๊ณตํ๋ ๋ฉค๋ฒ ์ด๋ฆ๊ณผ ์ผ์นํด์ผ ํจ
cluster = opensql # ์ด ๋ชจ๋ธ์ด ์ข
์๋ ์๋ฒ๋ฅผ ๊ตฌ๋ถํ๊ธฐ ์ํ ํ๊ทธ
model = true # ์๋ฒ ์ ์๊ฐ ์๋, ์๋ฒ์ ์ข
์๋์ด ์ผ๋ถ ์ต์
์ ์ค๋ฒ๋ผ์ด๋ฉ ํ๋ '๋ชจ๋ธ'์์ ๋ช
์
conninfo = host=node1 port=5432 user=opensql dbname=opensql
streaming_conninfo = host=node1 port=5432 user=opensql_streaming dbname=opensql
[pg-2] # ๋ชจ๋ธ ์ด๋ฆ, Patroni REST API์์ ์ ๊ณตํ๋ ๋ฉค๋ฒ ์ด๋ฆ๊ณผ ์ผ์นํด์ผ ํจ
cluster = opensql # ์ด ๋ชจ๋ธ์ด ์ข
์๋ ์๋ฒ๋ฅผ ๊ตฌ๋ถํ๊ธฐ ์ํ ํ๊ทธ
model = true # ์๋ฒ ์ ์๊ฐ ์๋, ์๋ฒ์ ์ข
์๋์ด ์ผ๋ถ ์ต์
์ ์ค๋ฒ๋ผ์ด๋ฉ ํ๋ '๋ชจ๋ธ'์์ ๋ช
์
conninfo = host=node2 port=5432 user=opensql dbname=opensql
streaming_conninfo = host=node2 port=5432 user=opensql_streaming dbname=opensql
[pg-3] # ๋ชจ๋ธ ์ด๋ฆ, Patroni REST API์์ ์ ๊ณตํ๋ ๋ฉค๋ฒ ์ด๋ฆ๊ณผ ์ผ์นํด์ผ ํจ
cluster = opensql # ์ด ๋ชจ๋ธ์ด ์ข
์๋ ์๋ฒ๋ฅผ ๊ตฌ๋ถํ๊ธฐ ์ํ ํ๊ทธ
model = true # ์๋ฒ ์ ์๊ฐ ์๋, ์๋ฒ์ ์ข
์๋์ด ์ผ๋ถ ์ต์
์ ์ค๋ฒ๋ผ์ด๋ฉ ํ๋ '๋ชจ๋ธ'์์ ๋ช
์
conninfo = host=node3 port=5432 user=opensql dbname=opensql
streaming_conninfo = host=node3 port=5432 user=opensql_streaming dbname=opensql
$ pip install -r requirements.txt# ์
ธ์์ ์ง์ ์คํํ๊ณ ์ ํ๋ ๊ฒฝ์ฐ
## Barman์ ์คํํ ์ ์๋ ๊ถํ์ด ์๋ ์ฌ์ฉ์์ฌ์ผ ํ๋ค.
## Barman ๊ธฐ๋ณธ ํ๊ฒฝ ์ค์ ์ [barman] ์น์
barman_user ํ๋
$ python3 server.py &
# systemd ์๋น์ค๋ก ๋ฑ๋กํ๋ ๊ฒฝ์ฐ
## barman-agent ์คํํ์ผ๊ณผ config.yml ํ์ผ์ ๊ฒฝ๋ก๋ systemd ์๋น์ค ํ์ผ์ ์ ์๋ ๊ธฐ๋ณธ๊ฐ์ด๋ค.
## ํ์์ ๋ฐ๋ผ ํด๋น ํ์ผ๋ค์ ๊ฒฝ๋ก ๋๋ ์คํํ ์ฌ์ฉ์๋ฅผ ์๋น์ค ํ์ผ์ ์์ ํ์ฌ ๋ณ๊ฒฝํ ์ ์๋ค.
$ sudo chmod 755 server.py
$ sudo cp server.py /usr/local/bin/barman-agent
$ sudo cp config.yml /var/lib/barman/config.yml
$ sudo cp barman-agent.service /usr/lib/systemd/system/.
$ sudo systemctl daemon-reload
$ sudo systemctl enable barman-agent
$ sudo systemctl start barman-agent
listen: "192.168.0.100" ## Optional. ๋ฐ์ธ๋ฉํ ์ธํฐํ์ด์ค ์ฃผ์. ๊ธฐ๋ณธ๊ฐ: 0.0.0.0 (๋ชจ๋ ์ธํฐํ์ด์ค ํ์ฉ)
port: 8080 ## Optional. ๋ฐ์ธ๋ฉํ TCP ํฌํธ ๋ฒํธ. ๊ธฐ๋ณธ๊ฐ: 8080
cluster: opensql ## ํ์. /etc/barman.d/opensql.conf ์ ์๋ฒ ์ด๋ฆ([opensql])๊ณผ ์ผ์นํด์ผ ํฉ๋๋ค.
patroni: ## ํ์. Patroni ๋
ธ๋๋ค์ REST API ์๋ํฌ์ธํธ๋ฅผ ๋ฆฌ์คํธ๋ก ์
๋ ฅํฉ๋๋ค.
- node1:8008
- node2:8008
- node3:8008name: pg-1 ## Patroni ๋ฉค๋ฒ ์ด๋ฆ. Barman ํ๊ฒฝ๊ตฌ์ฑ ํ์ผ์ ์ ์ํ ๋ชจ๋ธ ์ด๋ฆ([pg-1], [pg-2], ...)๊ณผ ์ผ์นํด์ผ ํ๋ค.
bootstrap:
dcs:
slots:
barman:
type: physical
postgresql:
callbacks:
on_role_change: "curl 'http://{barman-host}:8080/renew_config'"$ barman receive-wal opensql ## Foreground ํ๋ก์ธ์ค๋ก receive-wal ์์
Starting receive-wal for server opensql
$ barman cron ## barman receive-wal ์ ์คํํ๋ Cron Job์ ๋ฑ๋ก
Starting WAL archiving for server opensql
Starting streaming archiver for server opensql
$ which barman ## barman ์คํ ํ์ผ ๊ฒฝ๋ก ํ์ธ
/usr/local/bin/barman
$ crontab -e -u barman
## ์๋ ๋ด์ฉ ์ถ๊ฐ (๊ฒฝ๋ก๋ ์ which barman ๊ฒฐ๊ณผ๋ก ๋์ฒด)
* * * * * /usr/local/bin/barman cron$ barman check opensql# /etc/patroni/patroni.yml
scope: opensql
name: postgresql0
restapi:
listen: 0.0.0.0:8008
connect_address: 192.168.0.1:8008
etcd3:
protocol: http
hosts:
- 192.168.0.1:2379
- 192.168.0.2:2379
- 192.168.0.3:2379
bootstrap:
# This section will be written into Etcd:/<namespace>/<scope>/config after initializing new cluster
# and all other cluster members will use it as a `global configuration`.
# WARNING! If you want to change any of the parameters that were set up
# via `bootstrap.dcs` section, please use `patronictl edit-config`!
dcs:
ttl: 30
loop_wait: 10
retry_timeout: 10
maximum_lag_on_failover: 1048576
failsafe_mode: true
postgresql:
use_pg_rewind: true
parameters:
# wal_level: hot_standby
# hot_standby: "on"
max_connections: 100
max_worker_processes: 8
# wal_keep_segments: 8
# max_wal_senders: 10
# max_replication_slots: 10
# max_prepared_transactions: 0
# max_locks_per_transaction: 64
# wal_log_hints: "on"
# track_commit_timestamp: "off"
# archive_mode: "on"
# archive_timeout: 1800s
# archive_command: mkdir -p ../wal_archive && test ! -f ../wal_archive/%f && cp %p ../wal_archive/%f
# recovery_conf:
# restore_command: cp ../wal_archive/%f %p
# some desired options for 'initdb'
initdb: # Note: It needs to be a list (some options need values, others are switches)
- encoding: UTF8
- data-checksums
post_bootstrap: /home/opensql/scripts/post_bootstrap.sh # $OPENSQL_HOME/scripts/post_bootstrap.sh
postgresql:
listen: 0.0.0.0:5432
connect_address: 192.168.0.1:5432
proxy_address: 192.168.0.1:6432 # The address of connection pool (e.g.,openproxy) running next to Patroni/Postgres. Only for service discovery.
data_dir: /home/opensql/data #
bin_dir: /home/opensql/bin #
# config_dir:
pgpass: /tmp/pgpass0
authentication:
replication:
username: patroni_repl
password: patroni_repl
superuser:
username: postgres
password: postgres
rewind: # Has no effect on postgres 10 and lower
username: patroni_rewind
password: patroni_rewind
pg_hba:
- local all all trust
- host replication patroni_repl all md5
- host all all all md5
parameters:
log_line_prefix: '%m [%r] [%u] [%a]'
tags:
noloadbalance: false
clonefrom: false
nostream: false# /etc/patroni/patroni.yml
scope: opensql
name: postgresql0
restapi:
listen: 0.0.0.0:8008
connect_address: 192.168.0.1:8008
etcd3:
protocol: http
hosts:
- 192.168.0.1:2379
- 192.168.0.2:2379
- 192.168.0.3:2379
bootstrap:
# This section will be written into Etcd:/<namespace>/<scope>/config after initializing new cluster
# and all other cluster members will use it as a `global configuration`.
# WARNING! If you want to change any of the parameters that were set up
# via `bootstrap.dcs` section, please use `patronictl edit-config`!
dcs:
ttl: 30
loop_wait: 10
retry_timeout: 10
maximum_lag_on_failover: 1048576
failsafe_mode: true
postgresql:
use_pg_rewind: true
parameters:
# wal_level: hot_standby
# hot_standby: "on"
max_connections: 100
max_worker_processes: 8
# wal_keep_segments: 8
# max_wal_senders: 10
# max_replication_slots: 10
# max_prepared_transactions: 0
# max_locks_per_transaction: 64
# wal_log_hints: "on"
# track_commit_timestamp: "off"
# archive_mode: "on"
# archive_timeout: 1800s
# archive_command: mkdir -p ../wal_archive && test ! -f ../wal_archive/%f && cp %p ../wal_archive/%f
# recovery_conf:
# restore_command: cp ../wal_archive/%f %p
# some desired options for 'initdb'
initdb: # Note: It needs to be a list (some options need values, others are switches)
- encoding: UTF8
- data-checksums
post_bootstrap: /home/opensql/scripts/post_bootstrap.sh # $OPENSQL_HOME/scripts/post_bootstrap.sh
postgresql:
listen: 0.0.0.0:5432
connect_address: 192.168.0.1:5432
proxy_address: 192.168.0.1:6432 # The address of connection pool (e.g.,openproxy) running next to Patroni/Postgres. Only for service discovery.
data_dir: /home/opensql/data #
bin_dir: /home/opensql/bin #
# config_dir:
pgpass: /tmp/pgpass0
authentication:
replication:
username: patroni_repl
password: patroni_repl
superuser:
username: postgres
password: postgres
rewind: # Has no effect on postgres 10 and lower
username: patroni_rewind
password: patroni_rewind
pg_hba:
- local all all trust
- host replication patroni_repl all md5
- host all all all md5
parameters:
log_line_prefix: '%m [%r] [%u] [%a]'
tags:
noloadbalance: false
clonefrom: false
nostream: false
$ patroni $OPENSQL_HOME/etc/patroni.ymlpostgres@opensql3:~$ patronictl -c $OPENSQL_HOME/etc/patroni.yml list
+ Cluster: cluster (7488929455988801618) ------+----+-----------+
| Member | Host | Role | State | TL | Lag in MB |
+----------+-------------+---------+-----------+----+-----------+
| patroni1 | 192.168.0.1 | Replica | streaming | 1 | 0 |
| patroni2 | 192.168.0.2 | Replica | streaming | 1 | 0 |
| patroni3 | 192.168.0.3 | Leader | running | 1 | |
+----------+-------------+---------+-----------+----+-----------+# $OPENSQL_HOME/etc/etcd.env
# mandatory configuration
ETCD_NAME=<ETCD_NODE_NAME>
# Initial cluster configuration
ETCD_INITIAL_CLUSTER=<ETCD_NODE_NAME>=http://<NODE1_IP>:2380,<ETCD_NODE_NAME2>=http://<NODE2_IP>:2380, ...
ETCD_INITIAL_CLUSTER_STATE=new
ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster
# Peer configuration
ETCD_INITIAL_ADVERTISE_PEER_URLS=http://<NODE_IP>:2380
ETCD_LISTEN_PEER_URLS=http://<NODE_IP>:2380
# Client/server configuration
ETCD_ADVERTISE_CLIENT_URLS=http://<NODE_IP>:2379
ETCD_LISTEN_CLIENT_URLS=http://<NODE_IP>:2379,http://127.0.0.1:2379
#data dir
ETCD_DATA_DIR=/opensql/etc/etcd#$OPENSQL_HOME/etc/etcd.env
## ์ด ์๋ฒ์ etcd ๋
ธ๋ ์ด๋ฆ์ node1 ๋ก ์ง์
ETCD_NAME=node1
## ํด๋ฌ์คํฐ์ ๋ชจ๋ etcd ๋
ธ๋ ์ด๋ฆ๊ณผ ์ ๊ทผ ๊ฐ๋ฅํ peer url์ ์ค์
ETCD_INITIAL_CLUSTER=node1=http://172.176.0.2:2380,node2=http://172.176.0.3:2380,node3=http://172.176.0.4:2380
ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster1
## ์ด๊ธฐ ํด๋ฌ์คํฐ ๊ตฌ์ฑ ์์๋ 3 ๋
ธ๋ ๋ชจ๋ 'new' ๋ก ์ค์ ํ๊ณ ๋์. ์ดํ existing์ผ๋ก ์์ .
ETCD_INITIAL_CLUSTER_STATE=new
## etcd ๋
ธ๋๊ฐ ํต์ ํ๊ธฐ ์ํด ์ฌ์ฉํ๋ peer url์ ์ง์ . ๊ธฐ๋ณธ port๋ 2380์
ETCD_INITIAL_ADVERTISE_PEER_URLS=http://172.176.0.2:2380
ETCD_LISTEN_PEER_URLS=http://172.176.0.2:2380
# Client/server configuration
ETCD_ADVERTISE_CLIENT_URLS=http://172.176.0.2:2379
ETCD_LISTEN_CLIENT_URLS=http://172.176.0.2:2379,http://127.0.0.1:2379
# data dir
ETCD_DATA_DIR=/opensql/lib/etcd$ sudo vim /usr/lib/systemd/system/etcd.service
[Unit]
Description=etcd
Documentation=https://github.com/coreos/etcd
Conflicts=etcd-member.service
Conflicts=etcd2.service
[Service]
EnvironmentFile=/etc/etcd/etcd.env
ExecStart=/usr/bin/etcd
Type=notify
TimeoutStartSec=0
Restart=on-failure
RestartSec=5s
LimitNOFILE=65536
Nice=-10
IOSchedulingClass=best-effort
IOSchedulingPriority=2
MemoryLow=200M
[Install]
WantedBy=multi-user.target$ sudo systemctl daemon-reload$ sudo systemctl enable etcd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/etcd.service to /usr/lib/systemd/system/etcd.service.$ sudo systemctl start etcd.service
## ์๋น์ค๋ฅผ ์ค์งํ๋ ์์
$ sudo systemctl stop etcd.service
## ์๋น์ค๋ฅผ ์ฌ์์ํ๋ ์์
$ sudo systemctl restart etcd.service$ sudo systemctl status -l etcd
โ etcd.service - etcd
Loaded: loaded (/usr/lib/systemd/system/etcd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2025-03-17 16:49:45 KST; 3 weeks 2 days ago
Docs: https://github.com/coreos/etcd
Main PID: 4763 (etcd)
CGroup: /system.slice/etcd.service
โโ4763 /usr/bin/etcd
Apr 09 17:46:30 node2 etcd[4763]: {"level":"warn","ts":"2025-04-09T17:46:30.542+0900","caller":"etcdserver/util.go:170","msg":"apply request took too long","took":"402.056395ms","expected-duration":"100ms","prefix":"read-only range ","request":"key:\"/service/opensql/\" range_end:\"/service/opensql\" ","response":"range_response_count:9 size:6173"}$ etcd --name 'node1' \
--data-dir '/var/lib/etcd' \
--initial-cluster 'node1=http://172.18.0.2:2380,node2=http://172.18.0.3:2380,node3=http://172.18.0.4:2380' \
--initial-cluster-token 'etcd-cluster1'
--initial-cluster-state 'new'$ etcdctl member list -w=table
+------------------+---------+-------+----------------------+-------------------------+------------+
| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER |
+------------------+---------+-------+----------------------+-------------------------+------------+
| bfac432fd36a61d5 | started | etcd3 | http://opensql3:2380 | http://178.176.0.3:2379 | false |
| c41cad57348d886f | started | etcd2 | http://opensql2:2380 | http://178.176.0.2:2379 | false |
| dc3ff6e1d56a1012 | started | etcd1 | http://opensql1:2380 | http://178.176.0.4:2379 | false |
+------------------+---------+-------+----------------------+-------------------------+------------+[๋ก์ปฌ ์ค์น]
node1์์ ์ง์ ์คํ
python3 opensql_local_installer.py
node2์์ ์ง์ ์คํ
python3 opensql_local_installer.py
node3์์ ์ง์ ์คํ
python3 opensql_local_installer.py
[์๊ฒฉ ์ค์น]
python3 opensql_remote_installer.py
โ SSH
โโโโโโโโถ node1
โโโโโโโโถ node2
โโโโโโโโถ node3opensql-installer/
โโโ opensql_local_installer.py # ๋ก์ปฌ ์ค์น ์คํฌ๋ฆฝํธ
โโโ opensql_remote_installer.py # ์๊ฒฉ ์ค์น ์คํฌ๋ฆฝํธ
โโโ config/ # ์ค์ ๋๋ ํ ๋ฆฌ
โ โโโ common.env # ๊ณตํต ์ค์ (๋ก์ปฌ/์๊ฒฉ ๊ณตํต, ํ์ ์์ )
โ โโโ remote.env # ์๊ฒฉ ์ค์น ์ ์ฉ ์ค์ (์๊ฒฉ ์ค์น ์ ํ์ ์์ )
โ โโโ etcd.config.env # etcd ์ ์ฉ ์ต์
โ โโโ patroni.config.env # Patroni/PostgreSQL ์ ์ฉ ์ต์
โ โโโ openproxy.config.env # OpenProxy ์ ์ฉ ์ต์
โ โโโ etcd.env # etcd ํ๊ฒฝ๋ณ์ ํ
ํ๋ฆฟ
โ โโโ etcd.service # etcd ์๋น์ค ํ์ผ ํ
ํ๋ฆฟ
โ โโโ patroni.yml # Patroni ์ค์ ํ
ํ๋ฆฟ
โ โโโ openproxy.toml # OpenProxy ์ค์ ํ
ํ๋ฆฟ
โ โโโ openproxy.service # OpenProxy ์๋น์ค ํ์ผ ํ
ํ๋ฆฟ
โโโ licenses/ # ๋
ธ๋๋ณ ๋ผ์ด์ ์ค XML ๋ฐฐ์น ๋๋ ํ ๋ฆฌ (ํ์ ์์ฑ)
โ โโโ node1_license.xml (์์)
โ โโโ ...
โโโ src/ # ๊ณตํต ๋ชจ๋ (์์ ๋ถํ์)
โโโ config.py
โโโ functions.py
โโโ package_requirements.json# Rocky Linux / RHEL ์ค์น ์์
dnf install -y openssh-clients python3 sshpassopensql-installer/
โโโ licenses/
โโโ node1_license.xml
โโโ node2_license.xml (3node, 2node-witness)
โโโ node3_license.xml (3node)# ์์: Rocky Linux 8.10์ฉ ํจํค์ง
tar -xzf Tmax_OpenSQL_3.18.1.3_rockylinux8.10_buildtime20260223.tar.gzTmax_OpenSQL_3.18.1.3_rockylinux8.10_buildtime20260223/
โโโ opensql-installer/
โโโ opensql_local_installer.py
โโโ opensql_remote_installer.py
โโโ config/
โโโ common.env โ ๋ก์ปฌ/์๊ฒฉ ๊ณตํต ์ค์ (ํ์ ์์ )
โโโ remote.env โ ์๊ฒฉ ์ค์น ์ ์ฉ ์ค์ (์๊ฒฉ ์ค์น ์ ํ์ ์์ )# ํด๋ฌ์คํฐ์ ๋ชจ๋ ๋
ธ๋ IP (ํ์ฌ ๋
ธ๋ ํฌํจ)
# ์ธ์คํจ๋ฌ๊ฐ ํ์ฌ ์๋ฒ IP์ ๋น๊ตํ์ฌ ์์ ์ ๋
ธ๋๋ฅผ ๊ฐ์งํฉ๋๋ค.
NODE1_IP="<node1_ip>"
NODE2_IP="<node2_ip>"
NODE3_IP="<node3_ip>"
# ํ์ฌ ๋
ธ๋์ ํ์ ์ด๋ฆ (๋ก์ปฌ ์ค์น ์ ๋ก๊ทธ์ ํ์๋จ)
NODE_NAME="<node_name>"
# OpenSQL ํ ๋๋ ํ ๋ฆฌ (์ ๋ ๊ฒฝ๋ก)
# ๋ฐ์ด๋๋ฆฌ, ๋ฐ์ดํฐ, ์ค์ , ๋ก๊ทธ๊ฐ ์ด ๊ฒฝ๋ก ํ์์ ์์นํฉ๋๋ค.
# ํจํค์ง ์ค์น ๊ฒฝ๋ก๋ ์๋์ผ๋ก $OPENSQL_HOME/install ๋ก ์ค์ ๋ฉ๋๋ค.
OPENSQL_HOME="/path/to/opensql/home"
PG_HOME="/path/to/pg/home"
PG_DATA_DIR="/path/to/pg/data"
# ํ์ฌ ๋
ธ๋์ ์ ์ฉํ ๋ผ์ด์ ์ค ํ์ผ๋ช
(licenses/ ๋๋ ํ ๋ฆฌ ๊ธฐ์ค)
# ๋ก์ปฌ ์ค์น ์ ํ์. ์๊ฒฉ ์ค์น ์์๋ remote.env์์ ๋
ธ๋๋ณ๋ก ์ค์ ํฉ๋๋ค.
LICENSE_NAME="<license file>"# ํ์ ํจํค์ง ์๋ ์ค์น (๊ธฐ๋ณธ: false)
# AUTO_INSTALL_PREREQS=false
# OpenSQL ์ด์ ์ ์ /๊ทธ๋ฃน ์ด๋ฆ (๊ธฐ๋ณธ: opensql)
# OPENSQL_USER=opensql
# OPENSQL_GROUP=opensql
# OpenSQL ํจํค์ง ๋๋ ํ ๋ฆฌ ํจํด (๊ธฐ๋ณธ: Tmax_OpenSQL*)
# OPENSQL_PACKAGE_PATTERN="Tmax_OpenSQL*"
# 2node-witness ๋ชจ๋: witness ๋
ธ๋์ etcd ํฌํธ (ํ์)
# WITNESS_ETCD_CLIENT_PORT=2379
# WITNESS_ETCD_PEER_PORT=2380# ๋
ธ๋ ํ์ ์ด๋ฆ (๋ก๊ทธ์ ํ์๋จ)
NODE1_NAME="db-node1"
NODE2_NAME="db-node2"
NODE3_NAME="db-node3"
# SSH ์ ์ ์ ์ (๊ฐ ๋
ธ๋์ ์กด์ฌํด์ผ ํจ, sudo ๊ถํ ํ์)
NODE1_SSH_USER="ec2-user"
NODE2_SSH_USER="ec2-user"
NODE3_SSH_USER="ec2-user"
# SSH ํฌํธ (๊ธฐ๋ณธ 22๊ฐ ์๋ ๊ฒฝ์ฐ ๋ช
์)
NODE1_SSH_PORT="22"
NODE2_SSH_PORT="22"
NODE3_SSH_PORT="22"
# ๋
ธ๋๋ณ OpenSQL ํ ๋๋ ํ ๋ฆฌ (common.env์ OPENSQL_HOME๊ณผ ๋ค๋ฅผ ๊ฒฝ์ฐ)
NODE1_OPENSQL_HOME="/home/opensql"
NODE2_OPENSQL_HOME="/home/opensql"
NODE3_OPENSQL_HOME="/home/opensql"
# ๋
ธ๋๋ณ PG ๋๋ ํฐ๋ฆฌ
NODE1_PG_HOME="/path/to/pg/"
NODE2_PG_HOME="/path/to/pg/"
NODE3_PG_HOME="/path/to/pg/"
# ๋
ธ๋๋ณ PG_DATA ์์น
NODE1_PG_DATA="/path/to/pg/data"
NODE2_PG_DATA="/path/to/pg/data"
NODE3_PG_DATA="/path/to/pg/data"
# ๋
ธ๋๋ณ ๋ผ์ด์ ์ค ํ์ผ๋ช
(opensql-installer/licenses/ ๊ธฐ์ค)
# Patroni๊ฐ ๋์ํ๋ ๋
ธ๋์๋ง ํ์ํฉ๋๋ค.
# 2node-witness ๋ชจ๋์ witness(node3)๋ ๋น์๋ก๋๋ค.
NODE1_LICENSE_NAME="node1_license.xml"
NODE2_LICENSE_NAME="node2_license.xml"
NODE3_LICENSE_NAME="node3_license.xml"๋
ธ๋๋ณ ๋น๋ฐ๋ฒํธ (NODE{n}_PASSWORD)
> ์ ์ฒด ๊ณตํต ๋น๋ฐ๋ฒํธ (COMMON_PASSWORD)
> ๋ํํ ์
๋ ฅ (์คํ ์ ํ๋กฌํํธ)python3 opensql_remote_installer.py --password "my_password"
python3 opensql_remote_installer.py --node1-password "pw1" --node2-password "pw2" --node3-password "pw3"# ์ ์ฒด ๊ณตํต ๋น๋ฐ๋ฒํธ
# COMMON_PASSWORD=""
# ๋
ธ๋๋ณ ๊ฐ๋ณ ์ง์
# NODE1_PASSWORD=""
# NODE2_PASSWORD=""
# NODE3_PASSWORD=""# SSH ํค ๊ฒฝ๋ก (๊ธฐ๋ณธ: ~/.ssh/id_rsa_opensql)
# SSH_KEY="$HOME/.ssh/id_rsa_opensql"
# SSH ์ถ๊ฐ ์ต์
(๊ธฐ๋ณธ: StrictHostKeyChecking=no, ConnectTimeout=10)
# SSH_OPTS="-o StrictHostKeyChecking=no -o ConnectTimeout=10"# 2node-witness ๋ชจ๋์์ ํด๋ฌ์คํฐ ์๋ณ์ (๊ธฐ๋ณธ: c1)
# CLUSTER_ID=c1
# etcd ํฌํธ (๊ธฐ๋ณธ: 2379/2380)
# ETCD_CLIENT_PORT=2379
# ETCD_PEER_PORT=2380
# etcd ๋ฐ์ดํฐ/ํ๊ฒฝ ํ์ผ ๊ฒฝ๋ก (๋น์๋๋ฉด ์๋ ์ค์ )
# ETCD_DATA_DIR=/etc/opensql/etcd_data
# ETCD_ENV_FILE=/etc/opensql/etcd.env# Patroni ์ธ์คํด์ค ์ด๋ฆ (๊ธฐ๋ณธ: postgresql1/2/3)
# NODE1_PATRONI_NAME=postgresql1
# NODE2_PATRONI_NAME=postgresql2
# NODE3_PATRONI_NAME=postgresql3
# Patroni ์ค์ (๊ธฐ๋ณธ๊ฐ)
# PATRONI_SCOPE_BASE=opensql
# PATRONI_API_PORT=8008
# PATRONI_TTL=30
# PATRONI_LOOP_WAIT=10
# PATRONI_RETRY_TIMEOUT=10
# PostgreSQL ํฌํธ/๊ณ์ (๊ธฐ๋ณธ๊ฐ)
# PG_PORT=5432
# PG_SUPERUSER=postgres
# PG_SUPERUSER_PASSWORD=postgres
# PG_REPLICATION_USER=patroni_repl
# PG_REPLICATION_PASSWORD=patroni_repl
# PG_REWIND_USER=patroni_rewind
# PG_REWIND_PASSWORD=patroni_rewind# OpenProxy ํฌํธ (๊ธฐ๋ณธ: 6432/6433)
# OPENPROXY_PORT=6432
# OPENPROXY_ADMIN_PORT=6433
# OpenProxy ๋์ ์ค์ (๊ธฐ๋ณธ๊ฐ)
# OPENPROXY_CONNECT_TIMEOUT=10000 # ํด๋ผ์ด์ธํธ ์ฐ๊ฒฐ ํ์์์ (๋ฐ๋ฆฌ์ด)
# OPENPROXY_POOL_MODE=session # ํ ๋ชจ๋: session / transaction
# OPENPROXY_DEFAULT_ROLE=primary # ๊ธฐ๋ณธ ๋ผ์ฐํ
: primary / replica
# OPENPROXY_QUERY_PARSER_ENABLED=false
# OPENPROXY_POOL_SIZE=10 # ํ๋น ์ต๋ ์๋ฒ ์ฐ๊ฒฐ ์
# OPENPROXY_DATABASE=postgres # ์ฐ๊ฒฐ ๋์ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ช
WITNESS_ETCD_CLIENT_PORT=2379
WITNESS_ETCD_PEER_PORT=2380NODE1_IP="192.168.1.10"
NODE2_IP=""
NODE3_IP=""
NODE_NAME="db-single"
OPENSQL_HOME="/home/opensql"
LICENSE_NAME="node1_license.xml"NODE1_NAME="db-single"
NODE1_SSH_USER="ec2-user"
NODE1_SSH_PORT="22"
NODE1_OPENSQL_HOME="/home/opensql"
NODE1_LICENSE_NAME="node1_license.xml"# ๋ก์ปฌ ์ค์น (node1์์ ์ง์ )
cd opensql-installer
python3 opensql_local_installer.py --mode single
# ์๊ฒฉ ์ค์น (์ ์ด ์๋ฒ์์)
cd opensql-installer
python3 opensql_remote_installer.py --mode singlenode1: Primary PostgreSQL + Patroni + etcd
node2: Standby PostgreSQL + Patroni + etcd + OpenProxy
node3: Standby PostgreSQL + Patroni + etcd + OpenProxy# ๋ชจ๋ ๋
ธ๋์์ ๊ณตํต
NODE1_IP="192.168.1.10"
NODE2_IP="192.168.1.11"
NODE3_IP="192.168.1.12"
OPENSQL_HOME="/home/opensql"
# node1์์ ์คํ ์
NODE_NAME="db-primary"
LICENSE_NAME="node1_license.xml"
# node2์์ ์คํ ์ โ NODE_NAME="db-standby1", LICENSE_NAME="node2_license.xml"
# node3์์ ์คํ ์ โ NODE_NAME="db-standby2", LICENSE_NAME="node3_license.xml"NODE1_NAME="db-primary"
NODE1_SSH_USER="ec2-user"
NODE1_SSH_PORT="22"
NODE1_OPENSQL_HOME="/home/opensql"
NODE1_LICENSE_NAME="node1_license.xml"
NODE2_NAME="db-standby1"
NODE2_SSH_USER="ec2-user"
NODE2_SSH_PORT="22"
NODE2_OPENSQL_HOME="/home/opensql"
NODE2_LICENSE_NAME="node2_license.xml"
NODE3_NAME="db-standby2"
NODE3_SSH_USER="ec2-user"
NODE3_SSH_PORT="22"
NODE3_OPENSQL_HOME="/home/opensql"
NODE3_LICENSE_NAME="node3_license.xml"# ๋ก์ปฌ ์ค์น (๊ฐ ๋
ธ๋์์ NODE_NAME/LICENSE_NAME ๋ณ๊ฒฝ ํ ์คํ)
cd opensql-installer
python3 opensql_local_installer.py --mode 3node
# ์๊ฒฉ ์ค์น (์ ์ด ์๋ฒ์์ ํ ๋ฒ์ ์คํ)
cd opensql-installer
python3 opensql_remote_installer.py --mode 3nodenode1: PostgreSQL + Patroni + etcd + OpenProxy
node2: PostgreSQL + Patroni + etcd + OpenProxy
node3: etcd (witness only)# ๋ชจ๋ ๋
ธ๋์์ ๊ณตํต
NODE1_IP="192.168.1.10"
NODE2_IP="192.168.1.11"
NODE3_IP="192.168.1.12"
OPENSQL_HOME="/home/opensql"
# witness etcd ํฌํธ (ํ์ โ ๋ชจ๋ ๋
ธ๋์์ ๋์ผํ๊ฒ ์ค์ )
WITNESS_ETCD_CLIENT_PORT=2379
WITNESS_ETCD_PEER_PORT=2380
# node1์์ ์คํ ์
NODE_NAME="db-primary"
LICENSE_NAME="node1_license.xml"
# node2์์ ์คํ ์ โ NODE_NAME="db-standby", LICENSE_NAME="node2_license.xml"
# node3(witness)์์ ์คํ ์ โ NODE_NAME="witness", LICENSE_NAME=""CLUSTER_ID=c1NODE1_NAME="db-primary"
NODE1_SSH_USER="ec2-user"
NODE1_SSH_PORT="22"
NODE1_OPENSQL_HOME="/home/opensql"
NODE1_LICENSE_NAME="node1_license.xml"
NODE2_NAME="db-standby"
NODE2_SSH_USER="ec2-user"
NODE2_SSH_PORT="22"
NODE2_OPENSQL_HOME="/home/opensql"
NODE2_LICENSE_NAME="node2_license.xml"
NODE3_NAME="witness"
NODE3_SSH_USER="ec2-user"
NODE3_SSH_PORT="22"
NODE3_OPENSQL_HOME="/home/opensql"
# witness(node3)๋ Patroni ์์ โ LICENSE_NAME ๋น์๋ก๋๋ค.
NODE3_LICENSE_NAME=""# ๋ก์ปฌ ์ค์น (๊ฐ ๋
ธ๋์์ NODE_NAME/LICENSE_NAME ๋ณ๊ฒฝ ํ ์คํ)
cd opensql-installer
python3 opensql_local_installer.py --mode 2node-witness
# ์๊ฒฉ ์ค์น (์ ์ด ์๋ฒ์์ ํ ๋ฒ์ ์คํ)
cd opensql-installer
python3 opensql_remote_installer.py --mode 2node-witnesscd opensql-installer
python3 opensql_local_installer.py --mode 3node
python3 opensql_local_installer.py --mode single
python3 opensql_local_installer.py --mode 2node-witnesscd opensql-installer
# ๊ธฐ๋ณธ ์คํ (3node, ๋ํํ sudo ๋น๋ฐ๋ฒํธ ์
๋ ฅ)
python3 opensql_remote_installer.py --mode 3node
# ๊ณตํต ๋น๋ฐ๋ฒํธ ์ง์
python3 opensql_remote_installer.py --mode 3node --password "my_password"
# ๋
ธ๋๋ณ ๋น๋ฐ๋ฒํธ
python3 opensql_remote_installer.py --mode 3node \
--node1-password "pw1" \
--node2-password "pw2" \
--node3-password "pw3"export OPENSQL_HOME=/home/opensql
export PATH=/home/opensql/bin:$PATH
export LD_LIBRARY_PATH=/home/opensql/lib:$LD_LIBRARY_PATH
export PGHOST=/home/opensql/tmp
export PGDATA=/home/opensql/data
export OPENSQL_LICENSE_PATH=/home/opensql/license/node1_license.xmlvi /home/opensql/.opensqlrc
# ํ์ผ ๋์ ์ถ๊ฐ
export PGOPTIONS="-c log_min_duration_statement=1000"
export PGTZ="Asia/Seoul"source ~/.opensqlrc# etcd ์๋น์ค ์ํ
sudo systemctl status opensql-etcd
# Patroni ํ๋ก์ธ์ค
ps aux | grep patroni
# OpenProxy ํ๋ก์ธ์ค
pgrep -f openproxy
# ํด๋ฌ์คํฐ ์ํ (opensql ์ ์ ๋ก)
patronictl -c /home/opensql/etc/patroni.yml listss -tunlp | grep -E "5432|6432|6433|2379|2380|8008"# opensql ์ ์ ๋ก
psql -h 127.0.0.1 -p 5432 -U postgres
# OpenProxy๋ฅผ ํตํ ์ ์
psql -h 127.0.0.1 -p 6432 -U postgresRuntimeError: ํ์ฌ ์๋ฒ IP(x.x.x.x)๊ฐ ์ค์ ๋ ๋
ธ๋ IP์ ์ผ์นํ์ง ์์ต๋๋ค.ERROR: ํค ๋ฑ๋ก ์คํจssh-copy-id -i ~/.ssh/id_rsa_opensql ec2-user@192.168.1.10ERROR: ํ์ ํจํค์ง ์๊ฑด์ ์ถฉ์กฑํ์ง ์์ต๋๋ค.
ERROR: ๋๋ฝ๋ ํ์ ํจํค์ง: python3-psycopg2ERROR: ๋ผ์ด์ ์ค ๋๋ ํ ๋ฆฌ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค: .../licenses
ERROR: ๋ผ์ด์ ์ค ํ์ผ์ ์ฐพ์ ์ ์์ต๋๋ค: .../licenses/node1_license.xmlERROR: ๋ผ์ด์ ์ค edition์ ํ์ธํ ์ ์์ต๋๋ค.ERROR: ๋ผ์ด์ ์ค signature๊ฐ ์ค๋ณต๋ฉ๋๋ค.ERROR: OPENSQL_LICENSE_PATH ๋ฏธ์ค์
ERROR: OPENSQL_LICENSE_PATH ๋ถ์ผ์น (expected=..., actual=...)ERROR: etcd ์์ ์คํจsudo journalctl -u opensql-etcd -n 100 --no-pagerss -tunlp | grep 2379ERROR: OpenProxy ํ๋ก์ธ์ค๊ฐ ์คํ๋์ง ์์์ต๋๋ค.cat /home/opensql/logs/openproxy.log | tail -50ss -tunlp | grep 6432WARN: Patroni ์ํ ํ์ธ ํ์cat /home/opensql/logs/patroni.log | tail -50curl http://192.168.1.10:8008/healthRust ๊ธฐ๋ฐ ์๋ฒ ํ๋ก์ธ์ค์ธ ์คํํ๋ก์(OpenProxy) ์ค์ ๋ฐ ์คํ์ ๋ํด ์ค๋ช ํฉ๋๋ค.
sudo systemctl enable --now chronydtimedatectl status
chronyc sources -v
date[general]
port = 6432
admin_username = "postgres"
admin_password = "postgres"
worker_threads = 3
[pools.postgres]
pool_mode = "transaction"
query_parser_enabled = true
query_parser_read_write_splitting = true
[pools.postgres.users.0]
username = "postgres"
password = "postgres"
server_username = "postgres"
server_password = "postgres"
pool_size = 10
statement_timeout = 0
[pools.postgres.shards.0]
database = "postgres"
servers = [
["172.176.0.2", 5432, "auto"],
["172.176.0.3", 5432, "auto"],
["172.176.0.4", 5432, "auto"]
]
use_patroni = true
## virtual-ip
[general.virtual_router]
interface = "eth0"
router_id = 50
priority = 50
advert_int = 3
vip_addresses = ["178.176.0.200/24"]$ ./openproxy /home/myUser/openproxy.toml$ openproxy --help
OpenProxy: PostgreSQL pooler for OpenSQL - fork of pgCat
Usage: openproxy [OPTIONS] [CONFIG_FILE] [COMMAND]
Commands:
show Print current config and exit (loads config from file/etcd same as normal startup)
edit Edit config and save. Without --set: interactive (open in $EDITOR). With --set: non-interactive
encode Encode user password into SCRAM-SHA-256 compatible password that can be used for "password" in config
stop Stop a running openproxy instance via the admin console
help Print this message or the help of the given subcommand(s)
Arguments:
[CONFIG_FILE] Path to a configuration TOML file [env: CONFIG_FILE=] [default: openproxy.toml]
Options:
--force-config-file
Load config only from file; ignore etcd even if enabled in config
--log-target <LOG_TARGET>
Where to emit logs: file only, stdout only, or both [env: LOG_TARGET=] [default: both] [possible values: file, stdout, both]
-l, --log-level <LOG_LEVEL>
Logging level (trace, debug, info, warn, error) [env: LOG_LEVEL=] [default: INFO]
--max-logfile-num <MAX_LOGFILE_NUM>
Maximum number of log files to keep when rotating [env: MAX_LOGFILE_NUM=] [default: 5]
--log-dir <LOG_DIR>
Directory for log files (used when log_target is file or both) [env: LOG_DIR=/home/opensql/logs/openproxy] [default: logs]
--revision
Print revision number
-F, --log-format <LOG_FORMAT>
Log output format: text (human-readable), structured (e.g. JSON), or debug [env: LOG_FORMAT=] [default: text] [possible values: text, structured, debug]
-h, --help
Print help
-V, --version
Print version$ openproxy --help
$ openproxy --version
openproxy 1.1.0
$ openproxy --revision
revision number: 681[Unit]
Description=OpenProxy connection pooler - fork of postgresml's pgcat
After=network.target
StartLimitIntervalSec=0
[Service]
User=opensql
Type=simple
Restart=always
RestartSec=1
Environment=LOG_LEVEL=info
LimitNOFILE=65536
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW
ExecStart=/usr/bin/openproxy /etc/openproxy.toml
[Install]
WantedBy=multi-user.target$ psql -h 127.0.0.1 -p 6432 -d openproxy -U postgres
openproxy=> SHOW HELP;
NOTICE: Console usage
DETAIL:
SHOW HELP|CONFIG|DATABASES|POOLS|CLIENTS|SERVERS|USERS|VERSION
SHOW LISTS
SHOW STATS
SET key = arg
RELOAD
PAUSE [<db>, <user>]
RESUME [<db>, <user>]
SHUTDOWNopenproxy=> SHOW VERSION;
version
-------------------------
OpenProxy 1.1.0
(1 row)openproxy=> SHOW CONFIG;
key | value | default | changeable
--------------------------------------------------+----------------+---------+------------
idle_client_in_transaction_timeout | 30000 | - | yes
pools."postgres".users | postgres | - | yes
prometheus_exporter_port | 9930 | - | yes
pools.postgres.query_parser_max_length | unlimited | - | yes
pools.postgres.load_balancing_mode | random | - | yes
pools."postgres".shard_count | 1 | - | yes
port | 6432 | - | no
connect_timeout | 1000 | - | no
healthcheck_timeout | 1000 | - | yes
pools.postgres.default_role | any | - | yes
healthcheck_delay | 30000 | - | yes
pools.postgres.query_parser_read_write_splitting | true | - | yes
pools.postgres.sharding_function | pg_bigint_hash | - | yes
ban_time | 60 | - | yes
pools.postgres.pool_mode | transaction | - | yes
shutdown_timeout | 60000 | - | yes
host | 0.0.0.0 | - | no
pools.postgres.primary_reads_enabled | false | - | yes
idle_timeout | 600000 | - | yes
pools.postgres.query_parser_enabled | true | - | yes
(20 rows)openproxy=> SHOW DATABASES;
name | host | port | database | force_user | pool_size | min_pool_size | reserve_pool | pool_mode | max_connections | current_connections | paused | disabled
----------------------------+----------------+------+----------+------------+-----------+---------------+--------------+-------------+-----------------+---------------------+--------+----------
postgres_shard_0_primary | 192.168.131.12 | 5432 | postgres | postgres | 1100 | 0 | 0 | transaction | 1100 | 0 | 0 | 0
postgres_shard_0_replica_0 | 192.168.131.13 | 5432 | postgres | postgres | 1100 | 0 | 0 | transaction | 1100 | 0 | 0 | 0
postgres_shard_0_replica_1 | 192.168.131.14 | 5432 | postgres | postgres | 1100 | 0 | 0 | transaction | 1100 | 0 | 0 | 0
(3 rows)openproxy=> SHOW POOLS;
database | user | pool_mode | cl_idle | cl_active | cl_waiting | cl_cancel_req | sv_active | sv_idle | sv_used | sv_tested | sv_login | maxwait | maxwait_us
-----------+-------------+-------------+---------+-----------+------------+---------------+-----------+---------+---------+-----------+----------+---------+------------
simple_db | simple_user | session | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
postgres | postgres | transaction | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 0 | 0 | 0 | 0
(2 rows)openproxy=> SHOW CLIENTS;
client_id | database | user | application_name | state | transaction_count | query_count | error_count | age_seconds | maxwait | maxwait_us
------------+----------+----------+------------------+-------+-------------------+-------------+-------------+-------------+---------+------------
0x43332945 | postgres | postgres | openproxy | idle | 8 | 8 | 0 | 9 | 0 | 8
0x993A6EA2 | postgres | postgres | openproxy | idle | 10 | 10 | 0 | 9 | 0 | 8
0x09CFDA65 | pgcat | postgres | psql | idle | 0 | 0 | 0 | 208 | 0 | 0
0x1E5A084D | postgres | postgres | openproxy | idle | 10 | 10 | 0 | 4 | 0 | 9
(4 rows)openproxy=> SHOW SERVERS;
server_id | database_name | user | address_id | application_name | state | transaction_count | query_count | bytes_sent | bytes_received | age_seconds | prepare_cache_hit | prepare_cache_miss | prepare_cache_eviction | prepare_cache_size
------------+---------------+----------+--------------------------+--------------------------------------+-------+-------------------+-------------+------------+----------------+-------------+-------------------+--------------------+------------------------+--------------------
0x342F491B | postgres | postgres | postgres_shard_0_primary | DBeaver 22.3.4 - SQLEditor <Console> | idle | 41 | 41 | 18760 | 302727 | 25 | 123 | 82 | 0 | 41
(1 row)openproxy=> SHOW USERS;
name | pool_mode
----------+-------------
postgres | transaction
(1 row)openproxy=> SHOW LISTS;
list | items
---------------+-------
databases | 4
users | 2
pools | 4
free_clients | 4
used_clients | 0
login_clients | 0
free_servers | 1
used_servers | 0
dns_names | 0
dns_zones | 0
dns_queries | 0
dns_pending | 0
(12 rows)openproxy=> SHOW STATS;
instance | database | user | total_xact_count | total_query_count | total_received | total_sent | total_xact_time | total_query_time | total_wait_time | total_errors | avg_xact_count | avg_query_count | avg_recv | avg_sent | avg_errors | avg_xact_time | avg_query_time | avg_wait_time
----------------------------+----------+----------+------------------+-------------------+----------------+------------+-----------------+------------------+-----------------+--------------+----------------+-----------------+----------+----------+------------+---------------+----------------+---------------
postgres_shard_0_primary | postgres | postgres | 41 | 41 | 302727 | 18760 | 0 | 39 | 14152 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
postgres_shard_0_replica_0 | postgres | postgres | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
postgres_shard_0_replica_1 | postgres | postgres | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
(3 rows)
