我在一台服务器上有数据库和表 collection_city 。它有 21 行。我在第二台服务器上有数据库和表 collection_city 。它也有 21 行。
他们都有这一行:
tinker=# table collection_city;
id | name | alias | postal_code | region_id
----+---------------+--------------+-------------+-----------
2 | Obrenovac | obrenovac | | 1
Run Code Online (Sandbox Code Playgroud)
id 列是主键。
我在第一台服务器上创建了发布:
CREATE PUBLICATION tinkerpub FOR ALL TABLES;
tinker=# \dRp[+]
Publication tinkerpub
Owner | All tables | Inserts | Updates | Deletes | Truncates
----------+------------+---------+---------+---------+-----------
postgres | t | t | t | t | t
(1 row)
Run Code Online (Sandbox Code Playgroud)
我在第二台服务器上创建了订阅:
CREATE SUBSCRIPTION tinkersub CONNECTION 'dbname=tinker host=192.168.150.5 user=postgres password=test port=5432' …
Run Code Online (Sandbox Code Playgroud) postgresql replication master-slave-replication postgresql-11