2017-10-17 28 views
1

installer 10 postgresql en utilisant des scripts:Postgresql 10 réplication logique ne fonctionne pas

$ wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - 

$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' 

$ sudo apt-get update 
$ sudo apt-get install postgresql postgresql-contrib 

sur le serveur maître: xx.xxx.xxx.xx-:

Et après cela dans postgresql.conf:

set wal_level = logical 

sur le serveur esclave -:

dans postgresql.conf:

set wal_level = logical 

Et après tout ce que j'utilise ci-dessous requête sur le serveur maître:

create table t1 (id integer primary key, val text); 
create user replicant with replication; 
grant select on t1 to replicant; 
insert into t1 (id, val) values (10, 'ten'), (20, 'twenty'), (30, 'thirty'); 
create publication pub1 for table t1; 

Et au serveur esclave:

create table t1 (id integer primary key, val text, val2 text); 
create subscription sub1 connection 'dbname=dbsrc user=replicant' publication pub1; 

Mais le problème est que je suis confronté est la table ne sont pas synchronisés et selon la réplication logique lorsque j'insère une nouvelle ligne sur le serveur maître, le serveur esclave n'obtient pas cette ligne.

Je suis nouveau à postgresql s'il vous plaît aidez-moi.

Merci pour votre temps précieux.

Voici mon journal de postgresql pour le serveur maître:

2017-10-17 11:06:16.644 UTC [10713] [email protected] LOG: starting logical decoding for slot "sub_1" 
2017-10-17 11:06:16.644 UTC [10713] [email protected] DETAIL: streaming transactions committing after 1/F45EB0C8, reading WAL from 1/F45EB0C8 
2017-10-17 11:06:16.645 UTC [10713] [email protected] LOG: logical decoding found consistent point at 1/F45EB0C8 
2017-10-17 11:06:16.645 UTC [10713] [email protected] DETAIL: There are no running transactions. 

Voici mon serveur esclave postgresql journal:

2017-10-17 19:14:45.622 CST [7820] WARNING: out of logical replication worker slots 
2017-10-17 19:14:45.622 CST [7820] HINT: You might need to increase max_logical_replication_workers. 
2017-10-17 19:14:45.670 CST [7821] WARNING: out of logical replication worker slots 
2017-10-17 19:14:45.670 CST [7821] HINT: You might need to increase max_logical_replication_workers. 
2017-10-17 19:14:45.680 CST [7822] WARNING: out of logical replication worker slots 
2017-10-17 19:14:45.680 CST [7822] HINT: You might need to increase max_logical_replication_workers. 
2017-10-17 19:14:50.865 CST [7820] WARNING: out of logical replication worker slots 
2017-10-17 19:14:50.865 CST [7820] HINT: You might need to increase max_logical_replication_workers. 
2017-10-17 19:14:50.917 CST [7821] WARNING: out of logical replication worker slots 
2017-10-17 19:14:50.917 CST [7821] HINT: You might need to increase max_logical_replication_workers. 
2017-10-17 19:14:50.928 CST [7822] WARNING: out of logical replication worker slots 
2017-10-17 19:14:50.928 CST [7822] HINT: You might need to increase max_logical_replication_workers. 
2017-10-17 19:14:55.871 CST [7820] WARNING: out of logical replication worker slots 
2017-10-17 19:14:55.871 CST [7820] HINT: You might need to increase max_logical_replication_workers. 

Et après avoir augmenté les max_logical_replication_workers je reçois ceci:

2017-10-17 19:44:45.898 CST [7987] LOG: logical replication table synchronization worker for subscription "sub2", table "t1" has started 
2017-10-17 19:44:45.982 CST [7988] LOG: logical replication table synchronization worker for subscription "myadav_test", table "test_replication" h$ 
2017-10-17 19:44:45.994 CST [7989] LOG: logical replication table synchronization worker for subscription "sub3", table "t1" has started 
2017-10-17 19:44:48.621 CST [7987] ERROR: could not start initial contents copy for table "staging.t1": ERROR: permission denied for schema staging 
2017-10-17 19:44:48.623 CST [7962] LOG: worker process: logical replication worker for subscription 20037 sync 20027 (PID 7987) exited with exit co$ 
2017-10-17 19:44:48.705 CST [7988] ERROR: could not start initial contents copy for table "staging.test_replication": ERROR: permission denied for$ 
2017-10-17 19:44:48.707 CST [7962] LOG: worker process: logical replication worker for subscription 20025 sync 20016 (PID 7988) exited with exit co$ 
2017-10-17 19:44:48.717 CST [7989] ERROR: duplicate key value violates unique constraint "t1_pkey" 
2017-10-17 19:44:48.717 CST [7989] DETAIL: Key (id)=(10) already exists. 
2017-10-17 19:44:48.717 CST [7989] CONTEXT: COPY t1, line 1 
2017-10-17 19:44:48.718 CST [7962] LOG: worker process: logical replication worker for subscription 20038 sync 20027 (PID 7989) exited with exit co$ 
2017-10-17 19:44:51.629 CST [8008] LOG: logical replication table synchronization worker for subscription "sub2", table "t1" has started 
2017-10-17 19:44:51.712 CST [8009] LOG: logical replication table synchronization worker for subscription "myadav_test", table "test_replication" h$ 
2017-10-17 19:44:51.722 CST [8010] LOG: logical replication table synchronization worker for subscription "sub3", table "t1" has started 

Maintenant, je réalise enfin que la réplication logique fonctionne pour postgres base de données mais pas pour mon autre base de données sur le même serveur. J'obtiens le problème d'autorisation sur le schéma qui est le journal.

+0

Vérifiez vos journaux postgresql, il devrait y avoir plus d'info – JustMe

+0

@JustMe merci pour la réponse rapide mettre à jour le journal en question . –

+0

Vous pourriez avoir plus de chance avec celui-ci sur la liste de diffusion de PostgreSQL. –

Répondre

1

Les modifications de lignes sont appliquées à l'aide des droits de l'utilisateur propriétaire de l'abonnement. Par défaut, c'est l'utilisateur qui a créé l'abonnement. Par conséquent, assurez-vous que l'abonnement appartient à un utilisateur disposant de droits suffisants. Accordez les droits nécessaires aux tables, ou si vous ne pouvez pas être dérangé, faites en sorte que l'abonnement appartienne à un super-utilisateur qui a tous les droits.

Voir:

+0

Merci pour votre réponse ...Je vais essayer et vous laisser savoir @Craig Ringer –

+0

oui son fonctionnement bien je viens d'utiliser l'utilisateur postgres pour créer une réplication logique et fonctionne bien ..... –