问题描述
我正在尝试使用主从(都在同一台机器上 - 不同的端口)配置一个简单的 pgpool。 每当我通过 psql -p 9999 进入 pgpool 并运行 show pool_nodes;我看到了主集群和从集群,但从集群状态正在等待(它们都在运行)。 master 和 slave 被配置为 primary 和 hot_standby 以进行复制。但是每当我通过 pgpool 插入/选择时,都会通过主... 我想说的是插入将在主中进行,选择将在从中进行。
su - postgres
mkdir production_server
mkdir slave1
mkdir slave_archive
create new cluster on production_server
changes for those values on postgresql.conf (production_server):
-------------------------------------------------------
wal_level = replica
archive_mode on
listen_address = *
archive_command= cp %p /var/lib/pgsql/slave_archive/%f
port=5435
-------------------------------------------------------
restart the cluster on production_server
pg_basebackup -p 5435 -D /var/lib/pgsql/slave1
changes for those values on postgresql.conf (slave1):
-------------------------------------------------------
port=5466
hot_standby=on
primary_conninfo= host =127.0.0.1 port=5435
restore_command = cp /var/lib/pgsql/slave_archive/%f %p
-------------------------------------------------------
create also a standby.signal file (we're using postgres version 12.x)
switch to root and chmod 700 on slave1 directory
switch back to postgres: su - postgres
start the cluster on -D /var/lib/pgsql/slave1
psql -p 5435
create table table1 as SELECT * FROM generate_series(1,10000);
select pg_switch_wal();
---> on psql -p 5466 we will also see this insert/table
let's configure the pg_pool:
------------------------------------------------------------
cd /etc/pgpool-II
cp pgpool.conf.sample pgpool.conf
vi pgpool.conf:
----------------------------------------
listen_address=*
backend_hostname0=127.0.0.1
backend_port0=5435
backend_directory0=/var/lib/pgsql/production_server
backend_hostname0=127.0.0.1
backend_port0=5466
backend_directory0=/var/lib/pgsql/slave1
health_check_user=postgres
----------------------------------------
./pgpool &
psql -p 9999
in order to see the active nodes in the pool run:
show pool_nodes;
---> we need to recieve 2 nodes: 5435 / 5466
这是我配置 pgpool + master & slave 的脚本。如何解决等待状态?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)