PostgreSQL Reporting DB Creation¶
1. PRD DB Setup¶
- 1.1 Check publication DB parameters
Make sure that the following parameters are configured:
- Set in the
postgresql.conffile
-
Add the subscription db server IP into publication db server
pg_hba.conffilehost replication postgres 10.41.xx.xx/24 trust
-
1.2 Create publication
psql -p 6432
\c MESP131
create publication pub_cim131
for table cim131.cimmodwnlogdetail,
cim131.cimbomlocation,
cim131.cimlineetl,
cim131.cimsamplingdetail,
cim131.cimmodeletl,
cim131.cimupninfo,
cim131.cimapiniworkstation,
cim131.cimcsnrule,
cim131.cimmodel,
cim131.cimcpnstatus
with (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);
If you want to publish all the tables, please use the below SQL:
2. Reporting DB Setup¶
-
2.1 Install and create reporting DB
-
2.2 Create schema same as PRD
-
2.3 Table structure import from PRD
-
export table structure from PRD DB
pg_dump -U postgres \ -h PRD_DB_IP -p 6432 \ -d PRD_DB_NAME \ --schema-only \ --table=cim131.table1 \ --table=cim131.table2 \ --table=cim131.table3 \ > selected_tables_schema.sql--schema-only:仅导出表的结构,而不导出数据。--no-owner和--no-privileges:跳过拥有者信息和权限信息,避免跨实例时角色权限冲突。- 也可以将所有表写入文件批量导出
-
copy export file to reporting DB server
-
import table structure to reporting db
-
2.4 Create subscription
CREATE SUBSCRIPTION sub_cim131
CONNECTION 'host={PRD_DB_IP} port=6432 user=postgres dbname=MESP131 password=xxxx'
PUBLICATION pub_cim131
WITH (connect = true, enabled = true, create_slot = true, slot_name = sub_cim130, synchronous_commit = 'off');
3. Reporting sync check¶
- 3.1 Subscription endpoint (Reporting) check
- 3.2 Publication endpoint (PRD) check
make sure the
activestatus is alwaystrue
make sure the
activestatus is not set tofalse