oracle goldengate实现postgresql 到 postgresql的实时同步

oracle goldengate实现postgresql 到 postgresql的实时同步

源端:postgresql1 -> postgresql2 流复制主备同步

目标端:postgresql

数据库版本:postgresql 12.14

ogg版本:21.3

数据库安装以及流复制主备同步配置忽略。以下直接进入OGG的配置

odbc配置:

复制代码
[root@oradb1 ogg213]# yum list |grep postgresql-odbc.x86_64
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
postgresql-odbc.x86_64                  09.03.0100-2.el7               @centos7 
[root@oradb1 ogg213]# 

[root@oradb1 ogg213]# cat /etc/odbcinst.ini 
# Example driver definitions

# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description	= ODBC for PostgreSQL
Driver		= /usr/lib64/psqlodbcw.so
Setup		= /usr/lib64/libodbcpsqlS.so
Driver64	= /usr/lib64/psqlodbcw.so
Setup64		= /usr/lib64/libodbcpsqlS.so
FileUsage	= 1


# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description	= ODBC for MySQL
Driver		= /usr/lib/libmyodbc5.so
Setup		= /usr/lib/libodbcmyS.so
Driver64	= /usr/lib64/libmyodbc5.so
Setup64		= /usr/lib64/libodbcmyS.so
FileUsage	= 1
[root@oradb1 ogg213]# cat /etc/odbc.ini 
#Sample DSN entries
[ODBC Data Sources]
PG_src=DataDirect 12.14 PostgreSQL Wire Protocol
PG_tgt=DataDirect 12.14 PostgreSQL Wire Protocol

[ODBC]
IANAAppCodePage=4
InstallDir=/ogg213




[pg_src1]
Driver=/ogg213/lib/GGpsql25.so
Description=DataDirect 12.14 PostgreSQL Wire Protocol
Database=testdb
HostName=192.168.56.11
PortNumber=5432
LogonID=ggadmin
Password=Bai_yun123
TransactionErrorBehavior=2


[pg_src]
Driver=/ogg213/lib/GGpsql25.so
Description=DataDirect 12.14 PostgreSQL Wire Protocol
Database=testdb
HostName=192.168.56.12
PortNumber=5432
LogonID=ggadmin
Password=Bai_yun123
TransactionErrorBehavior=2

[pg_tgt]
Driver=/ogg213/lib/GGpsql25.so
Description=DataDirect 12.14 PostgreSQL Wire Protocol
Database=testdb
HostName=192.168.56.101
PortNumber=5432
LogonID=ggadmin
Password=Bai_yun123
TransactionErrorBehavior=2
[root@oradb1 ogg213]# 

验证登录成功:

复制代码
GGSCI (oradb1) 6> dblogin sourcedb pg_src userid ggadmin password Bai_yun123

2025-05-30 21:45:31  INFO    OGG-03036  Database character set identified as UTF-8. Locale: en_US.UTF-8.

2025-05-30 21:45:31  INFO    OGG-03037  Session character set identified as UTF-8.
Successfully logged into database.

GGSCI (oradb1 as ggadmin@pg_src) 7> dblogin sourcedb pg_tgt userid ggadmin password Bai_yun123

2025-05-30 21:45:38  INFO    OGG-03036  Database character set identified as UTF-8. Locale: en_US.UTF-8.

2025-05-30 21:45:38  INFO    OGG-03037  Session character set identified as UTF-8.
Successfully logged into database.

GGSCI (oradb1 as ggadmin@pg_tgt) 8> 

OGG解压:

复制代码
[root@oradb1 soft]# cd oggsoft/
[root@oradb1 oggsoft]# ll
total 467684
-rwxrwxr-x 1 postgres postgres  97040905 May 30 16:04 213000_ggs_Linux_x64_PostgreSQL_64bit.zip
-rw-rw-rw- 1 postgres postgres 381552640 Aug  5  2021 ggs_Linux_x64_PostgreSQL_64bit.tar
-rw-r--r-- 1 postgres postgres      2409 Aug 11  2021 OGG-21.3.0.0-README.txt
-rw-r--r-- 1 postgres postgres    306395 Aug 11  2021 oracle-goldengate-release-notes_21.3.pdf
[root@oradb1 oggsoft]# 

$ tar -xvf ggs_Linux_x64_PostgreSQL_64bit.tar -C /ogg213

$ cd /ogg213
$ ./ggsci
$ create subdirs

链接到备库注册抽取进程,失败。

复制代码
GGSCI (oradb1 as ggadmin@pg_src) 9> register extract ep1

2025-05-30 21:47:59  WARNING OGG-00552  Database operation failed: Executing statement to create replication slot. Called from PGUTIL_registerExtract:178. ODBC error: SQLSTATE S1C00 native database error 466560. [Oracle][ODBC PostgreSQL Wire Protocol driver][PostgreSQL]ERROR: VERROR; logical decoding cannot be used while in recovery(File logical.c; Line 113; Routine CheckLogicalDecodingRequirements;.

链接到主库注册抽取进程,成功。

复制代码
GGSCI (oradb1 as ggadmin@pg_src) 10> dblogin sourcedb pg_src1 userid ggadmin password Bai_yun123

2025-05-30 21:52:04  INFO    OGG-03036  Database character set identified as UTF-8. Locale: en_US.UTF-8.

2025-05-30 21:52:04  INFO    OGG-03037  Session character set identified as UTF-8.
Successfully logged into database.

GGSCI (oradb1 as ggadmin@pg_src1) 11> register extract ep1

2025-05-30 21:52:16  INFO    OGG-25355  Successfully created replication slot 'ep1_831e5a3f6113dbb2' for Extract group 'EP1' in database 'testdb'.


GGSCI (oradb1 as ggadmin@pg_src1) 12> edit param ep1



GGSCI (oradb1 as ggadmin@pg_src1) 13> view param ep1

extract ep1
setenv(PGCLIENTENCODING = "UTF8")
setenv(ODBCINI="/etc/odbc.ini" )
sourcedb testdb, userid ggadmin, password Bai_yun123
exttrail ./dirdat/e1
discardfile ./dirrpt/ep1.dsc
table public.tab1;

启动进程失败:

复制代码
2025-05-30 22:13:22  ERROR   OGG-00551  Database operation failed: Couldn't connect to testdb. ODBC error: SQLSTATE IM002 native database error 0. [DataDirect][ODBC lib] D
ata source name not found and no default driver specified.

2025-05-30 22:13:22  ERROR   OGG-01668  PROCESS ABENDING.

修改

sourcedb pg_src1, userid ggadmin, password Bai_yun123

复制代码
2025-05-30 22:16:24  ERROR   OGG-25516  Oracle GoldenGate capture using LIBPQ client library version as 90,401 which is incompatible with the connected PostgreSQL server v
ersion 121,400 for streaming the log record. The LIBPQ client library version must be the same as or bigger than, that of the connected PostgreSQL server library version.

Source Context :
  SourceModule            : [ggvam.gen]
  SourceID                : [../gglib/ggvam/cvamgen.cpp]
  SourceMethod            : [vamInitialize]
  SourceLine              : [536]
  ThreadBacktrace         : [14] elements
                          : [/ogg213/libgglog.so(CMessageContext::AddThreadContext())]
                          : [/ogg213/libgglog.so(CMessageFactory::CreateMessage(CSourceContext*, unsigned int, ...))]
                          : [/ogg213/libgglog.so(_MSG_String_Int32(CSourceContext*, int, char const*, int, CMessageFactory::MessageDisposition))]
                          : [/ogg213/extract(com_goldengate_vam::CVamGen::vamInitialize())]
                          : [/ogg213/extract()]
                          : [/ogg213/extract(ggs::er::VAMDataSource::finalizeConfiguration())]
                          : [/ogg213/extract(ggs::gglib::ggapp::ReplicationContext::finalizeConfiguration())]
                          : [/ogg213/extract()]
                          : [/ogg213/extract(ggs::gglib::MultiThreading::MainThread::ExecMain())]
                          : [/ogg213/extract(ggs::gglib::MultiThreading::Thread::RunThread(ggs::gglib::MultiThreading::Thread::ThreadArgs*))]
                          : [/ogg213/extract(ggs::gglib::MultiThreading::MainThread::Run(int, char**))]
                          : [/ogg213/extract(main)]
                          : [/lib64/libc.so.6(__libc_start_main)]
                          : [/ogg213/extract()]

2025-05-30 22:16:24  ERROR   OGG-00145  Call to VAMInitialize returned with error status 16002.

2025-05-30 22:16:24  ERROR   OGG-01668  PROCESS ABENDING.
相关推荐
不辉放弃3 分钟前
HiveSQL语法全解析与实战指南
数据库·hive·大数据开发
Elastic 中国社区官方博客34 分钟前
Elastic 和 AWS 合作将 GenAI 引入 DevOps、安全和搜索领域
大数据·数据库·elasticsearch·搜索引擎·云计算·全文检索·aws
20242817李臻1 小时前
李臻20242817_安全文件传输系统项目报告_第14周
数据库·安全
MyikJ1 小时前
Java求职面试:从Spring到微服务的技术挑战
java·数据库·spring boot·spring cloud·微服务·orm·面试技巧
betazhou2 小时前
oracle goldengate同步SQL server到SQL server的实时数据同步
数据库·mysql·oracle
alex18012 小时前
ubuntu磁盘挂载
linux·数据库·ubuntu
惜.己2 小时前
MySql(十一)
java·javascript·数据库
先做个垃圾出来………3 小时前
接口自动化常用断言方式
数据库·自动化·lua
ClouGence4 小时前
MySQL + CloudCanal + Iceberg + StarRocks 构建全栈数据服务
数据库·mysql·iceberg·dba
喝养乐多长不高4 小时前
深入探讨redis:万字讲解集群
java·数据库·redis·docker·集群·集群扩容·数据分片算法