HGDB企業版V6邏輯複製搭建
本文只要用於描述HGDB企業版V6邏輯複製在redhat7環境下的搭建過程。
一、環境介紹
資料庫版本:HGDB企業版V6.0.1
作業系統版本:Redhat7.x
伺服器IP地址:192.168.230.51(釋出端)
192.168.230.52(訂閱端)
二、邏輯複製搭建
1、釋出端修改資料庫執行引數
highgo=# alter system set listen_addresses='*';
highgo=# alter system set wal_level='logical'; highgo=# alter system set max_replication_slots=30; highgo=# alter system set max_wal_senders=40; highgo=# alter system set max_logical_replication_workers=40; highgo=# alter system set max_sync_workers_per_subscription=10; highgo=# alter user postgres with password'postgres'; |
2、釋出端修改pg_hba.conf檔案,增加以下內容
host all all 0.0.0.0/0 md5
host replication all 0.0.0.0/0 md5 |
pg_ctl start |
highgo=# create table test1(id int primary key,txt text);
highgo=# insert into test1 values(1,'a'); highgo=# insert into test1 values(2,'b'); highgo=# create table test2(id int primary key,txt text); highgo=# insert into test2 values(1,'a'); highgo=# insert into test2 values(2,'b'); |
highgo=# create user logicalrep replication login encrypted password 'Logical '; |
highgo=# grant usage on schema public to logicalrep;
highgo=# grant select on all tables in schema public to logicalrep; highgo=# alter default privileges in schema public grant select on tables to logicalrep ; |
7、釋出節點建立釋出
highgo=# create publication pub1 for table public.test1,public.test2;
highgo=# select * from pg_publication; #查詢釋出詳情 |
highgo=# alter system set listen_addresses='*';
highgo=# alter system set max_replication_slots=30; highgo=# alter system set max_wal_senders=40; highgo=# alter system set max_logical_replication_workers=40; highgo=# alter system set max_sync_workers_per_subscription=10; |
9、訂閱端匯出匯入釋出表的表結構
pg_dump -h 192.168.80.251 -d postgres -U postgres -s -t test1 -t test2 -f createtable.sql psql -f createtable.sql |
highgo=# create subscription sub1 connection 'host=192.168.230.51 port=5866 dbname=highgo user=logicalrep password=Logical ' publication pub1; |
12、訂閱端查詢同步狀態
highgo=# select * from test1;
id | txt ----+----- 1 | a 2 | b (2 rows)
highgo=# select * from test2;
id | txt ----+----- 1 | a 2 | b (2 rows) |
13、插入資料測試
##釋出端新插入資料
highgo=# insert into test1 values(3,'c');
##訂閱端查詢資料是否同步
highgo=# select * from test1;
|
通過查詢同步表內的資料可驗證邏輯複製搭建完成。
三、邏輯複製相關查詢
1、釋出端
select * from pg_publication; ##查詢資料庫內釋出資訊
select * from pg_stat_replication; ##查詢流複製相關資訊
select * from pg_publication_tables; ##查詢已經發布的表的資訊 |
2、訂閱端
select * from pg_subscription; ##查詢訂閱資訊
select * from pg_subscription_rel; ##查詢每張表的同步狀態
select * from pg_replication_origin_status; |
四、邏輯複製注意事項
不支援DDL複製(ALTER TABLE/CREATE TABLE)
不支援TEMPRORARY表和UNLOGGED表複製
不支援Sequences複製( serial/bigserial/identity)
不支援TRUNCATE操作複製
不支援大物件複製
不支援檢視、物化檢視、外部表複製被複制的表上最好有主鍵約束;如果沒有,必須執行:ALTER TABLE reptest REPLICA IDENTITY FULL;
注:訂閱端的複製表是可修改的,複製表一旦修改,釋出者和訂閱者會資料不一致,進而打破複製。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69994931/viewspace-2838309/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 邏輯複製主從搭建
- LightDB/Postgres邏輯複製的搭建
- PostgreSQL邏輯複製解密SQL解密
- PostgreSQL 邏輯複製解密SQL解密
- PostgreSQL邏輯複製資料同步到kafkaSQLKafka
- 【AIX 命令學習】複製邏輯卷 cplvAI
- hgdb資料編輯
- DataGuard搭建邏輯StandBy
- HGDB之資料編輯
- 使用vue解決複雜邏輯Vue
- Oracle Stream(3)--Stream與高階複製和邏輯Dataguard的比較Oracle
- 搭建邏輯Data Guard 12c
- MongoDB 搭建複製集MongoDB
- mongodb複製集搭建MongoDB
- MySQL5.1版本的主從複製搭建MySql
- MySQL5.7主從複製-半同步複製搭建MySql
- 【Mongodb】 可複製集搭建MongoDB
- mysql主從複製搭建MySql
- MongoDB 搭建可複製群集MongoDB
- MySQL 5.5 複製搭建流程MySql
- AWS Aurora postgresql12同一個例項之間做邏輯複製步驟SQL
- 製作IOS企業版APP網頁下載iOSAPP網頁
- React中元件邏輯複用的那些事兒React元件
- 狀態機解決複雜邏輯及使用
- MongoDB搭建Replica Set複製集MongoDB
- MySQL 5.7搭建多源複製MySql
- MySQL 複製介紹及搭建MySql
- MYSQL主從複製的搭建MySql
- MYSQL主主複製的搭建MySql
- Replica sets複製集的搭建
- 形式邏輯(普通邏輯)7:推理概述
- three.js 製作邏輯轉體遊戲(下)JS遊戲
- three.js 製作邏輯轉體遊戲(上)JS遊戲
- 關於 SAP Fiori Elements 應用標題屬性(title) 的複製邏輯單步除錯除錯
- PostgreSQL10.0preview功能增強-邏輯複製支援並行COPY初始化資料SQLView並行
- Mysql主從複製原理及搭建MySql
- MySQL 5.5 主主複製搭建流程MySql
- 簡單搭建MySQL主從複製MySql