Re: Replicación simple en PG9.6 que no funciona

From: Anthony Sotolongo <asotolongo(at)gmail(dot)com>
To: Ekaterina Amez <ekaterina(dot)amez(at)zunibal(dot)com>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Replicación simple en PG9.6 que no funciona
Date: 2021-09-20 16:45:00
Message-ID: ab33143e-6627-c56a-addb-487b71b46b9d@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Gracias y el logs del esclavo que te dice?

On 20/9/21 13:42, Ekaterina Amez wrote:
> Hola Anthony,
>
> En el archivo recovery.conf tengo puesto
> Standby_mode=on
> Y en el postgresql.conf
> Hot_standby=on
>
> Saludos.
>
> El El lun, 20 sept 2021 a las 18:30, Anthony Sotolongo
> <asotolongo(at)gmail(dot)com <mailto:asotolongo(at)gmail(dot)com>> escribió:
>
> Hola Ekaterina, ¿Qué valor tiene hot_standby en el esclavo?
>
> Saludos
>
>
> On 20/9/21 11:48, Ekaterina Amez wrote:
>> Hola Lista,
>>
>> Estoy probando a montar una réplica sencilla entre mi ordenador
>> (Ubuntu 18.04) y un ordenador que tengo para pruebas (CentOS7).
>> El CentOS es el servidor maestro y el Ubuntu el esclavo. Ambos
>> con PG 9.6.23 instalado. Uno está en la IP 192.168.1.65:5433
>> <http://192.168.1.65:5433> (maestro) y el otro en la 60
>> (esclavo). Como veis, el maestro está ejecutándose en otro puerto
>> que no es el de por defecto.
>>
>> El maestro está configurado así (postgresql.conf):
>> wal_level = replica
>> archive_mode = on
>> archive_command = 'cp %p /var/lib/pgsql/9.6/wal_archive/%f'
>> max_wal_senders = 2
>> wal_keep_segments = 8
>> synchronous_standby_names = 'pgslave001'
>> hot_standby = on
>>
>> Y las conexiones están configuradas así (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 0.0.0.0/0 <http://0.0.0.0/0> trust
>> # IPv6 local connections:
>> host    all             all             ::1/128             trust
>> # Allow replication connections from localhost, by a user with the
>> # replication privilege.
>> host replication all 192.168.1.0/24 <http://192.168.1.0/24> trust
>>
>> Utilizo esta configuración porque quiero asegurarme de que no
>> tengo problemas de conexión. El firewall de CentOS está abierto:
>> [root(at)test-eka data]# sestatus
>> SELinux status:                 disabled
>> [root(at)test-eka data]# firewall-cmd --list-services
>> dhcpv6-client http postgresql ssh
>> [root(at)test-eka data]# firewall-cmd --service=postgresql
>> --add-port=5433/tcp --permanent
>> Warning: ALREADY_ENABLED: '5433:tcp'
>> success
>>
>> Desde el servidor esclavo puedo conectarme sin problemas al maestro:
>> $ /usr/lib/postgresql/9.6/bin/psql -h 192.168.1.65 -p 5433 -U
>> postgres
>> psql (9.6.23)
>> Digite «help» para obtener ayuda.
>> postgres=#  \q
>>
>> Con esto así, hago el backup inicial:
>> sudo -u postgres /usr/lib/postgresql/9.6/bin/pg_basebackup -h
>> 192.168.1.65 -p 5433 -U replicador -D
>> /var/lib/postgresql/9.6/main --verbose --progress --xlog
>>
>> Creo el archivo recovery.conf
>> restore_command = 'scp
>> 192.168.1.65:/var/lib/pgsql/9.6/wal_archive/%f %p'
>> standby_mode = on
>> primary_conninfo = 'host=192.168.1.65 port=5433 user=replicador
>> password=replicador application_name=pgslave001'
>>
>> Y arranco el esclavo:
>> ekaterina(at)ekaterina-ubuntu:$ sudo systemctl start
>> postgresql(at)9(dot)6-main(dot)service <mailto:postgresql(at)9(dot)6-main(dot)service>
>> ekaterina(at)ekaterina-ubuntu:$ sudo systemctl status
>> postgresql(at)9(dot)6-main(dot)service <mailto:postgresql(at)9(dot)6-main(dot)service>
>> ● postgresql(at)9(dot)6-main(dot)service
>> <mailto:postgresql(at)9(dot)6-main(dot)service> - PostgreSQL Cluster 9.6-main
>>    Loaded: loaded (/lib/systemd/system/postgresql(at)(dot)service;
>> indirect; vendor preset: enabled)
>>    Active: active (running) since Mon 2021-09-20 16:41:52 CEST;
>> 4s ago
>>   Process: 9783 ExecStop=/usr/bin/pg_ctlcluster
>> --skip-systemctl-redirect -m fast 9.6-main stop (code=exited,
>> status=0/SUCCESS)
>>   Process: 10060 ExecStart=/usr/bin/pg_ctlcluster
>> --skip-systemctl-redirect 9.6-main start (code=exited,
>> status=0/SUCCESS)
>>  Main PID: 10065 (postgres)
>>     Tasks: 5 (limit: 4915)
>>    CGroup:
>> /system.slice/system-postgresql.slice/postgresql(at)9(dot)6-main(dot)service
>>            ├─10065 /usr/lib/postgresql/9.6/bin/postgres -D
>> /var/lib/postgresql/9.6/main -c
>> config_file=/etc/postgresql/9.6/main/postgresql.conf
>>            ├─10066 postgres: 9.6/main: startup process  
>> recovering 00000001000000000000001A
>>            ├─10070 postgres: 9.6/main: checkpointer process
>>            ├─10071 postgres: 9.6/main: writer process
>>            └─10072 postgres: 9.6/main: wal receiver process  
>> streaming 0/1A01D7B8
>>
>> sep 20 16:41:46 ekaterina-ubuntu systemd[1]: Starting PostgreSQL
>> Cluster 9.6-main...
>> sep 20 16:41:52 ekaterina-ubuntu postgresql(at)9(dot)6-main
>> <mailto:postgresql(at)9(dot)6-main>[10060]: Warning: connection to the
>> database failed, disabling startup checks:
>> sep 20 16:41:52 ekaterina-ubuntu postgresql(at)9(dot)6-main
>> <mailto:postgresql(at)9(dot)6-main>[10060]: psql: FATAL:  el sistema de
>> base de datos está iniciándose
>> sep 20 16:41:52 ekaterina-ubuntu systemd[1]: Started PostgreSQL
>> Cluster 9.6-main.
>>
>> Me da igual arrancarlo con pg_ctl que con systemctl. El esclavo
>> parece arrancado (la última línea dice Started) pero cuando
>> intento conectar con la bd esclava me da error:
>> ekaterina(at)ekaterina-ubuntu:$ /usr/lib/postgresql/9.6/bin/psql  -U
>> postgres
>> psql: FATAL:  el sistema de base de datos está iniciándose
>>
>> Sin embargo, algo está arrancado porque cuando lanzo de nuevo
>> sudo systemctl status postgresql(at)9(dot)6-main(dot)service
>> <mailto:postgresql(at)9(dot)6-main(dot)service> veo que en "wal receiver
>> process" va avanzando y encaja con lo que se puede ver en el maestro:
>> postgres=# select * from  pg_stat_replication ;
>> -[ RECORD 1 ]----+------------------------------
>> pid              | 3556
>> usesysid         | 16404
>> usename          | replicador
>> application_name | pgslave001
>> client_addr      | 192.168.1.60
>> client_hostname  |
>> client_port      | 52418
>> backend_start    | 2021-09-20 16:41:46.648487+02
>> backend_xmin     |
>> state            | streaming
>> sent_location    | 0/1A01D898
>> write_location   | 0/1A01D898
>> flush_location   | 0/1A01D898
>> replay_location  | 0/1A01D898
>> sync_priority    | 1
>> sync_state       | sync
>>
>> ¿Qué es lo que estoy haciendo mal? Aviso por adelantado de que
>> mis conocimientos de Linux son limitados.
>>
>> Muchas gracias,
>> Ekaterina
>
> --
>
> *Ekaterina Amez González*
>
> ekaterina(dot)amez(at)zunibal(dot)com <mailto:ekaterina(dot)amez(at)zunibal(dot)com>
>
> **
>
> *ZUNIBAL*| Idorsolo 1, 48160-Derio, Spain
> <https://maps.google.com/?q=Idorsolo+1,+48160-Derio,+Spain&entry=gmail&source=g>
>
> Tel: +34 944 977 010 <tel:+34%20944%2097%2070%2010> | Fax: +34 944 522
> 81| www.zunibal.com <http://www.zunibal.com/>
>
> **
>
> /_Advertencia Legal._ El contenido de este mensaje y de toda la
> documentación anexa es confidencial y va dirigido únicamente al
> destinatario del mismo. Si usted no fuera el destinatario le
> solicitamos que nos informe y no comunique su contenido a terceros,
> procediendo a su destrucción. / Legal advice. This message contains
> confidential information for the exclusive use of the recipient. Any
> unauthorised disclosure, use or dissemination, either whole or
> partial, is prohibited. If you are not the intended recipient of the
> message, please notify the sender as soon as possible. En cumplimiento
> de la _Ley Orgánica 15/1999_ de Protección de Datos de Carácter
> Personal, le informamos que los Datos Personales de usted que están en
> nuestra Base de Datos recabados con su consentimiento, forman parte de
> un fichero automatizado registrado en la Agencia Española de
> Protección de Datos. Estos datos sólo serán utilizados para realizar
> una correcta gestión de nuestra relación comercial. Si lo desea podrá
> ejercitar en todo momento los derechos de acceso, cancelación u
> oposición, remitiendo un correo electrónico a esta dirección. /
> According to the Law 15/1999 of Personal Data Protection, we
> inform your data are included in our data base with your approval are
> registered in the spanish Agency of Data Protection. //These data are
> only used for our usual business relationship. If you want you are in
> the right of accessing or cancelling them, just sending an e-mail to
> this address./
>
> /Antes de imprimir este mensaje, asegúrese de que es necesario
> hacerlo. / Before printing this email, assess if it is really needed./
>

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Ekaterina Amez 2021-09-20 17:50:53 Re: Replicación simple en PG9.6 que no funciona
Previous Message Ekaterina Amez 2021-09-20 16:42:50 Re: Replicación simple en PG9.6 que no funciona