Postgresql pglogical подписка не работает - PullRequest
0 голосов
/ 28 февраля 2019

Я хочу настроить логическую репликацию между двумя серверами postgresql 9.5.Я мог бы заставить его работать на двух виртуальных ПК, но когда я пытаюсь сделать это на наших производственных машинах, состояние репликации снижается (pglogical.show_replication_status ()).

На нашем главном сервере многоданные (~ 250 ГБ), поэтому мы не можем позволить себе удалить их.Однако я переместил его на сервер хранения репликации с помощью pg_dump.

Основной рабочий сервер:

pg_hba.conf:

local   all             postgres                                peer
local   all             all                                     md5
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5
local   replication     all                                     trust
host    replication     all             127.0.01/32             trust
host    replication     all             ::1/128                 trust
host    all             all             all                     trust
host    replication     all             all                     trust

postgresql.conf:

data_directory = '/mnt/Data/fmeterdb/postgresql/9.5/main'       # use data in another directory
hba_file = '/etc/postgresql/9.5/main/pg_hba.conf'   # host-based authentication file
ident_file = '/etc/postgresql/9.5/main/pg_ident.conf'   # ident configuration file
external_pid_file = '/var/run/postgresql/9.5-main.pid'          # write an extra PID file
listen_addresses = '*'      # what IP address(es) to listen on;
port = 5432             # (change requires restart)
max_connections = 1000          # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
ssl = true              # (change requires restart)
ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'      # (change requires restart)
ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'     # (change requires restart)
shared_buffers = 1024MB         # min 128kB
dynamic_shared_memory_type = posix  # the default is the first option
shared_preload_libraries = 'pglogical'  # (change requires restart)
max_worker_processes = 16
wal_level = logical         # minimal, archive, hot_standby, or logical
synchronous_commit = local      # synchronization level;
archive_mode = on       # enables archiving; off, on, or always
archive_command = 'cp %p /mnt/Data/fmeterdb/postgresql/9.5/main/archive/%f'     # command to use to archive a logfile segment
max_wal_senders = 16        # max number of walsender processes
wal_keep_segments = 300     # in logfile segments, 16MB each; 0 disables
max_replication_slots = 16  # max number of replication slots
track_commit_timestamp = on # collect timestamp of transaction commit
synchronous_standby_names = 'pgslave001'    # standby servers that provide sync rep
log_line_prefix = '%t [%p-%l] %q%u@%d '         # special values:
log_timezone = 'UTC'
stats_temp_directory = '/var/run/postgresql/9.5-main.pg_stat_tmp'
datestyle = 'iso, ymd'
timezone = 'UTC'
lc_messages = 'hu_HU.UTF-8'         # locale for system error message
lc_monetary = 'hu_HU.UTF-8'         # locale for monetary formatting
lc_numeric = 'hu_HU.UTF-8'          # locale for number formatting
lc_time = 'hu_HU.UTF-8'             # locale for time formatting
default_text_search_config = 'pg_catalog.hungarian'

bash:

createuser -s --replication -P khrh_replicator
    * Enter password for new role: qwe123
    * Enter it again: qwe123
createdb -O khrh_replicator khrh_replicator
psql --username=khrh_replicator
\c fmeter
create extension pglogical;
select pglogical.create_node( node_name := 'khrh_provider', dsn := 'host=10.0.2.1 port=5432 user=khrh_replicator dbname=fmeter' );
select pglogical.create_replication_set('khrh_replication_set');
select pglogical.replication_set_add_table( set_name := 'khrh_replication_set', relation := 'measure_results' synchronize_data := true ); 
select pglogical.replication_set_add_table( set_name := 'khrh_replication_set', relation := 'measure_runs' synchronize_data := true );
select pglogical.replication_set_add_table( set_name := 'khrh_replication_set', relation := 'measures' synchronize_data := true );       

Я не получаю никаких ошибок после этих команд.

Шаги, которые я сделал на нашем сервере хранения:

pg_hba.conf:

local   all             postgres                                peer
local   all             all                                     md5
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust
host    all             all             all                     trust
host    replication     all             all                     trust

postgresql.conf:

data_directory = '/mnt/Data/fmeterdb/postgresql/9.5/main'       # use data in another directory
hba_file = '/etc/postgresql/9.5/main/pg_hba.conf'   # host-based authentication file
ident_file = '/etc/postgresql/9.5/main/pg_ident.conf'   # ident configuration file
external_pid_file = '/var/run/postgresql/9.5-main.pid'          # write an extra PID file
listen_addresses = 'localhost,172.17.11.18,10.0.2.3'        # what IP address(es) to listen on;
port = 5432             # (change requires restart)
max_connections = 1000          # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
ssl = on
ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'
shared_buffers = 1024MB         # min 128kB
dynamic_shared_memory_type = posix  # the default is the first option
shared_preload_libraries = 'pglogical'  # (change requires restart)
max_worker_processes = 16       # (change requires restart)
wal_level = logical         # minimal, replica, or logical
synchronous_commit = local      # synchronization level;
archive_mode = on
archive_command = 'cp -i %p /mnt/Data/fmeterdb/postgresql/9.5/main/archive/%f'      # command to use to archive a logfile segment
max_wal_senders = 16        # max number of walsender processes
wal_keep_segments = 400
max_replication_slots = 16  # max number of replication slots
track_commit_timestamp = on # collect timestamp of transaction commit
synchronous_standby_names = 'pgslave001'    # standby servers that provide sync rep
hot_standby = on            # "off" disallows queries during recovery
log_line_prefix = '%m [%p] %q%u@%d '        # special values:
log_timezone = 'UTC'
cluster_name = '9.5/main'           # added to process titles if nonempty
stats_temp_directory = '/var/run/postgresql/9.5-main.pg_stat_tmp'
datestyle = 'iso, ymd'
timezone = 'UTC'
lc_messages = 'hu_HU.UTF-8'         # locale for system error message
lc_monetary = 'hu_HU.UTF-8'         # locale for monetary formatting
lc_numeric = 'hu_HU.UTF-8'          # locale for number formatting
lc_time = 'hu_HU.UTF-8'             # locale for time formatting
default_text_search_config = 'pg_catalog.hungarian'
include_dir = 'conf.d'          # include files ending in '.conf' from

bash:

createuser -s --replication -P khrh_replicator
    * Enter password for new role: qwe123
    * Enter it again: qwe123
createdb -O khrh_replicator khrh_replicator
psql --username=urh_replicator
create database fmeter_khrh;
\c fmeter_khrh
create extension pglogical;
select pglogical.create_node( node_name := 'khrh_subscriber', dsn := 'host=10.0.2.3 port=5432 dbname=fmeter_khrh user=khrh_replicator' );
select pglogical.create_subscription( subscription_name := 'khrh_subscription', replication_sets := array['khrh_replication_set'], provider_dsn := 'host=10.0.2.1 port=5432 dbname=fmeter user=khrh_replicator' );

Я также не получаю никаких ошибок после этого.

Кто-нибудь встречался с этим, и как я могу это исправить?

Заранее спасибо!

1 Ответ

0 голосов
/ 20 мая 2019

Расширение pglogical использует журнал postgresql для предоставления сообщений об ошибках.Чтобы получить текущий статус репликации, используйте select * from pglogical.show_subscription_status();

Некоторые советы по начальной настройке можно найти в этом сообщении Depesz https://www.depesz.com/2016/11/08/major-version-upgrading-with-minimal-downtime/

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...