I want to setup primary and replica on the same server. My server is CentOS 9. primary and replica servers ports are 5433 and 5434. I create replica server using pg_basebackup command as follows:
pg_basebackup -h localhost -U repuser --checkpoint=fast -D /tmp/replica_db/ -R --slot=some_name -C --port=5433
Now when starting replica server I get following error and the primary server could not connect to replica server:
could not connect to the primary server: invalid connection option "sslsni"
What should I do to make primary connect to replica server?
Related
I have private subnet for my EC2 instance, I use NAT Gateway for it to access internet. I created user-data script for my EC2 where I've created docker-compose.yml with postgres service defined. After defining this i have:
docker-compose up -d
# i use terraform for ${PGPASSWORD} template variable
export PGPASSWORD="${PGPASSWORD}"
psql -h localhost -U my_user -p 5432 -d my_db < ./mydump.sql
Inside EC2 I already have mydump.sql file.
The problem here it gives me error for psql like this:
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
I can't understand why. Although my postgres container is up and LOG: database system is ready to accept connections. Can someone help with this?
Maybe this problem relates to root under which user-data script is executed and session closes so it interrupts connection for psql. Or this relates to docker and port-forwarding. Can't understand the reason actually
I'm deploying two servers with two PostgreSQL databases (one Primary and one Standby model). I have set the pg_hba.conf on my primary server to
host replication replicator <my standby ip addr> md5
and I've also enable the listen_address settings in postgresql.conf
listen_addresses = '*'
But when I was trying to run this command on my standby server
pg_basebackup -h <primary server ip addr> -D /var/lib/postgresql/12/main -U replicator -P -v -R -X stream -C -S node2
it returned this error message
pg_basebackup: error: could not connect to server: Connection refused
Is the server running on host "<primary ip addr>" and accepting
TCP/IP connections on port 5432
It is also verified that access to port 5432 has been enabled since I am able to connect to it from pgadmin via SSH.
my server is running on Ubuntu 20.04 with Postgresql version 12 installed
Is there anything I'm missing?
I'm trying to setup postgres cluster of two nodes (primary and standby). In order to activate automatic failover, I'm using pgpool-II.
I followed the following article: https://www.pgpool.net/docs/41/en/html/example-cluster.html
and the only thing difference I did is installing postgresql version 12 instead of version 11.
Knowing that I'm trying it useing two centos7 images on VMware. I faced the following issues:
When I run systemctl status pgpool.service on both nodes, it returned success.
Also I can access postgresql using the watchdog delegate IP.
But what testing failover, everything goes wrong.
Scenario 1:
I accessed my database using watchdog delegate Ip.
I disconnect the standby server.
Result: My session to postgresql continued to work for less than a minute and then it failed. and I'm unable to connect again, until I reconnect the standby node, and restart the pgpool service again.
Scenario 2:
I accessed my database using watchdog delegate Ip.
I disconnect the primary server.
Result: My session stopped directly. and the standby server is not promoted to be master.
I noticed something (might be related to the above described problem): when I try to run the following command
psql 192.168.220.146 -p 9999 -U postgres -c "show pool_nodes"
it fails to work and returned the following:
psql: error: could not connect to server: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.9999"
However if I ran: psql 192.168.220.160 -p 5432 -U postgres
it works fine and I can access the postgres shell.
My pool_hba file:
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
host all pgpool 0.0.0.0/0 scram-sha-256
host all postgres 0.0.0.0/0 scram-sha-256
Any help would be appreciated.
I followed the following article: https://www.pgpool.net/docs/41/en/html/example-cluster.html and the only thing difference I did is installing postgresql version 11.
I not ping delegate_IP = '192.168.1.233'. May i help you?
Thanks you.
you are not providing -h argument to psql for specifying the IP address. So effectively psql is trying to connect to UNIX domain socket and considering the IP address in the command as the database name.
Try putting -h before the IP address
psql -h 192.168.220.146 -p 9999 -U postgres -c "show pool_nodes"
We are using PGBOUNCER (connection pool mechanisam). PGBOUNCER uses port 5433.
Postgres database port number is 6433. By using port 5433 PGBOUNCER is connecting to the Postgres database on port 6433.
Now PGBOUNCER is establishing the connections properly, but when I try to run pg_basebackup through port 5433 (PGBOUNCER port), we are receiving the below error. Please guide me.
/opt/postgres/9.2/bin/pg_basebackup -p 5433 -U postgres -P -v -x --format=tar --gzip --compress=1 --pgdata=- -D /opt/rao
pg_basebackup: could not connect to server: ERROR: Unsupported startup parameter: replication
pgBouncer cannot speak the replication protocol, so you cannot run pg_basebackup through it.
It doesn't make sense to speak the replication protocol through a connection pooler anyway, because replication connections tend to be long lived, and there are not too many of them. So pooling makes no sense.
Connect to PostgreSQL directly to run your backup.
Needless to say, but it is a very bad idea to be running PostgreSQL 9.2 today.
I have updated my pg_hba on the master to this.
host loko replicator 10.0.2.15/32 trust
and created a user with this command
CREATE USER replicator REPLICATION LOGIN ENCRYPTED PASSWORD 'repl'
loko which is the databse on my master and replicator as the user.
and running this command on the slave
pg_basebackup -h x.x.x.x -D "C:\Program Files\PostgreSQL\9.4\data" -U
replicator -v -P --write-recovery-conf -X stream
results to
no pg_hba.conf entry for replication connection from host x.x.x.x.
user replicator, SSL off
Thanks a lot for any help. Im new to this so I don't have any idea whats wrong with this. I just followed a tutorial.
Change database loco to replication:
host replication replicator 10.0.2.15/32 trust