Here they got this error when try to alter
I am trying to setup PostgreSQL replication using docker as described here.
My docker-compose.yaml
version: '3'
services:
database:
image: 'postgres:9.6'
container_name: my_postgres_database
restart: always
volumes:
- ./data:/var/lib/postgresql/data
- ./my-postgres.conf:/etc/postgresql/postgresql.conf
- ./my-pg_hba.conf:/etc/postgresql/pg_hba.conf
ports:
- "127.0.0.1:5432:5432"
environment:
- 'POSTGRES_PASSWORD=kong'
- 'POSTGRES_DB=kong'
- 'POSTGRES_USER=kong'
my-pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host replication replicator 0.0.0.0/0 trusthost all all all md5
my-postgres.conf
listen_addresses = '*'
# DB Version: 13
# OS Type: linux
# DB Type: web
# Total Memory (RAM): 62 GB
# CPUs num: 12
# Connections num: 1000
# Data Storage: ssd# Performance tweaksmax_connections = 1000
shared_buffers = 158MB
effective_cache_size = 476MB
maintenance_work_mem = 1GB
checkpoint_completion_target = 0.7
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 1.1
effective_io_concurrency = 200
work_mem = 2063kB
min_wal_size = 1GB
max_wal_size = 1GB
max_worker_processes = 12
max_parallel_workers_per_gather = 4
# Replication
wal_level = replica
hot_standby = on
max_wal_senders = 10
max_replication_slots = 10
hot_standby_feedback = on
After sudo docker-compose up -d, I connect to running postgresql container sudo docker exec -it <container-id> bash
Connect to postgresql shell using psql -h localhost -p 5432 -U kong -W and then run
SELECT * FROM pg_create_physical_replication_slot('replication_slot_slave1');
ERROR: replication slots can only be used if max_replication_slots > 0
What did I miss here? My primary goal is to replicate kong docker based gateway.
Related
So I have my strapi server, which should connect to the Docker container running my Postgres DB, but I get this error when I try to start the development server for the strapi component of my application.
no pg_hba.conf entry for host "127.0.0.1", user "admin", database "store", no encryption
error: no pg_hba.conf entry for host "127.0.0.1", user "admin", database "store", no encryption
This is what is within my pg_hba.conf file on my local
# "local" is for Unix domain socket connections only
local all all scram-sha-256
# IPv4 local connections:
host all all 127.0.0.1/32 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all scram-sha-256
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
I also have a docker-compose.yml file which creates the postgres database, so I can connect the strapi server to it.
version: '3'
services:
database:
image: 'postgres'
container_name: nndesign
build:
context: .
target: nndesign
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: nuzhat
POSTGRES_DB: store
expose:
- 5432
ports:
- 5432:5432
volumes:
- ./scripts/postgres-data:/var/lib/postgresql/data
- ./scripts/admin_users.sql:/docker-entrypoint-initdb.d/admin_users.sql
This is what I have as environment variables so the strapi server can connect to the postgres db running in the docker container
export default ({ env }) => ({
connection: {
client: 'postgres',
connection: {
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 5432),
database: env('DATABASE_NAME', 'store'),
user: env('DATABASE_USERNAME', 'admin'),
password: env('DATABASE_PASSWORD', 'nuzhat'),
ssl: env.bool('DATABASE_SSL', false),
},
},
});
I'm a bit confused on how to revolve this error. Been trying to Google and also use ChatGPT to find a solution, but to no avail.
Any help would be greatly appreciated.
Thank you.
I am trying to set up postgres docker instances with a replication function
I have working on building this based on this tutorial:
https://medium.com/swlh/postgresql-replication-with-docker-c6a904becf77
And I came across a repo build on this :
https://github.com/mekeerati/docker-compose-example/tree/main/postgresql-read-replica
The only thing I have changed
Since I have a port running on 5432, have changed the port to the following values
--> 127.0.0.1/32 to 127.0.0.1/33 (I am not sure if this was necessary)
and also the docker-compose.yml values
When I run the application I am expecting to replicate but it does not work.
It seems like everything is works fine, what should I do to provide replication properly
pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/33 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/33 trust
host replication all ::1/128 trust
host replication replicator 0.0.0.0/0 trust
host all all all scram-sha-256
docker-compose.yml
version: '3'
services:
# To start replica mode please use `docker-init.sh`
postgres_master:
container_name: postgres_master
image: postgres:14.5
restart: always
volumes:
- ./data:/var/lib/postgresql/data
- ./data-slave:/var/lib/postgresql/data-slave
- ./init-script/config/postgres.conf:/etc/postgresql/postgresql.conf
- ./init-script/config/pg_hba.conf:/etc/postgresql/pg_hba.conf
- ./init-script:/etc/postgresql/init-script
ports:
- "127.0.0.1:5433:5433"
environment:
- POSTGRES_USER=postgresql
- POSTGRES_PASSWORD=postgresql
postgres_slave:
container_name: postgres_slave
image: postgres:14.5
restart: always
volumes:
- ./data-slave:/var/lib/postgresql/data
- ./config/postgres.conf:/etc/postgresql/postgresql.conf
- ./config/pg_hba.conf:/etc/postgresql/pg_hba.conf
ports:
- "127.0.0.1:5434:5433"
environment:
- POSTGRES_USER=postgresql
- POSTGRES_PASSWORD=postgresql
I'm using docker to turn my app.
When I was using the image 'postgres:10-alpine', I didn't have any problem but after I upgraded to 'postgres:14-alpine', I can still access to the database directly in the postgres container but when I try to access with phppgadmin thorugh "http://localhost:9080" , I have the login page but the user + password don't works (but in postgres 10, no problem).
Do you have any idea how to fix it ?
my docker-compose.yml:
# Postgres BDD
postgres:
container_name: postgres
image: postgres:14-alpine
env_file:
- .env
restart : always
ports:
- "5432:5432"
environment:
POSTGRES_DB: ${DATABASE_NAME}
POSTGRES_USER: ${DATABASE_USER}
POSTGRES_PASSWORD: ${DATABASE_PASS}
volumes:
- postgres_starter_db:/var/lib/postgresql/data
- ./docker/database_utils:/home/db
# Postgres visualization tool
phppgadmin:
image: dockage/phppgadmin:latest
container_name: phppgadmin
env_file:
- .env
links:
- postgres:postgres
ports:
- "9080:80"
environment:
- PHP_PG_ADMIN_SERVER_DESC=PostgreSQL
- PHP_PG_ADMIN_SERVER_HOST=${DATABASE_HOST}
- PHP_PG_ADMIN_SERVER_PORT=${DATABASE_PORT}
the pg_hba.conf in postgres container
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host all all all scram-sha-256
Good day!
I have a task to delimit user access to databases
for example, that user_1 would have access only to the database of "oranges" and user_2 only to the database of "watermelons"
I try to do this through pg_hba.conf, but I can still connect to the watermelon database through user_1
MY pg_hba.conf
# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# Refer to the "Client Authentication" section in the PostgreSQL
# documentation for a complete description of this file. A short
# synopsis follows.
#
# This file controls: which hosts are allowed to connect, how clients
# are
#...
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
# local all all trust
# IPv4 local connections:
# host all all 127.0.0.1/32 trust
# IPv6 local connections:
# host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
# local replication all trust
# host replication all 127.0.0.1/32 trust
# host replication all ::1/128 trust
# host all all all scram-sha-256
host oranges user_1 password
host watermelons user_2 password
MY DOCKERFILE
FROM postgres:14.1
RUN rm -f /var/lib/postgresql/data/pg_hba.conf
COPY ./pg_hba.conf /var/lib/postgresql/data/pg_hba.conf
ADD ./init.sql /docker-entrypoint-initdb.d/
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["postgres"]
MY DOCKER-COMPOSE
version: "3.9"
services:
#DATABASE_SERVER
postgres:
build: ./databases/postgres
hostname: postgres
environment:
POSTGRES_PASSWORD: root
PGDATA: /var/lib/postgresql/data
ports:
- 5432:5432
What am I doing wrong? I will be grateful for any comment!
I am trying to set up a postgres server on Windows Server 2012 R2 machine. My server machine ip is 192.168.1.3 and i am trying to hit the server from Client machine 192.168.1.4 I always get connection time out and is the server up and running but i did changes to the postgres configuration files but in Vain.Please help me
I did the following steps:
Changed my Postgresql.config like the below
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
And pg_hba.config file as
# IPv4 local connections:
host all all 0.0.0.0/0 md5
host all all 192.168.1.5/32 trust
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the replication privilege.
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
host all all 192.168.1.4/32 trust