【大数据实时数据同步】GoldenGate实时同步异常:OGG-03533:character ‘c2 a0‘ at offset 0 that is not available报错解决

本文涉及的产品
云原生大数据计算服务 MaxCompute,5000CU*H 100GB 3个月
云原生大数据计算服务MaxCompute,500CU*H 100GB 3个月
简介: 博主所在单位目前使用Oracle GoldenGate将各个业务生产库汇聚到一起做数仓实时ODS平台,源端库可能涉及Oracle、Mysql、达梦、Guassdb库。最近遇到了这个错误:`OGG-03533:character 'c2 a0' at offset 0 that is not available。`导致报错的原因是源端库有业务人员手动用excel往数据库导入数据,源端库字符集:`AMERICAN_AMERICA.AL32UTF8` ,目标库ODS字符集:`AMERICAN_AMERICA.ZHS16GBK`。

前言

博主所在单位目前使用Oracle GoldenGate将各个业务生产库汇聚到一起做数仓实时ODS平台,源端库可能涉及Oracle、Mysql、达梦、Guassdb库。
最近遇到了这个错误:OGG-03533:character 'c2 a0' at offset 0 that is not available。
导致报错的原因是源端库有业务人员手动用excel往数据库导入数据,源端库字符集:AMERICAN_AMERICA.AL32UTF8 ,目标库ODS字符集:AMERICAN_AMERICA.ZHS16GBK
业务人员导入的数据中包含了全角空格及不间断空格,从utf8的数据库往gbk的数据库同步过程中,字符转码失败。
因为是金融领域生产环境,此同步进程中包含其他生产表,所以恢复要格外小心,否则可能会导致数据实时同步异常,数据错乱。
下面是我记录的本地测试解决方案。


一、重现报错

源端字符集:AMERICAN_AMERICA.AL32UTF8
ODS字符集:AMERICAN_AMERICA.ZHS16GBK

源端查询数据

2    SQL> select * from dept;
3    
4    DEPTNO DNAME    LOC
5    ‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
6    1 东东    a
7    10 ACCOUNTING    NEW YORK
8    20 RESEARCH    DALLAS
9    30 SALES    CHICAGO
10    40 OPERATIONS    BOSTON

ods端查询数据:

12    SQL> select deptno,dname,loc from dept;
13    
14    DEPTNO DNAME    LOC
15    ‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐
    ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
16    10 ACCOUNTING    NEW YORK
17    20 RESEARCH    DALLAS
18    30 SALES    CHICAGO
19    40 OPERATIONS    BOSTON
20    1 东东    a

源端执行插入操作:

22    
23    SQL> insert into dept values(60,'东
    123'||chr(to_number('C2A0','xxxx'))||'东A','a');
24    
25    1 row created.
26    
27    SQL> commit;
28    
29    Commit complete.

源端切换归档:

31    SQL> alter system switch logfile;
32    
33    System altered.

源端再次查询数据:

35    SQL> select * from dept;
36    
37    DEPTNO DNAME    LOC
38    ‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
39    1 东东    a
40    60 东123 东A    a
41    10 ACCOUNTING    NEW YORK
42    20 RESEARCH    DALLAS
43    30 SALES    CHICAGO
44    40 OPERATIONS    BOSTON
45    
46    6 rows selected.

ODS端查询进程状态:

49    GGSCI (ogg) 24> info all
50    
51    Program    Status    Group    Lag at Chkpt    Time Since Chkpt
52    
53    MANAGER    RUNNING
54    REPLICAT    ABENDED    R_SC    00:00:00    00:00:50

应用进程报错信息如下:

2018‐09‐20 22:39:36    INFO    OGG‐06510    Using the following key columns for target table SCOTT.DEPT_AUDIT: DEPTNO.


2018‐09‐20 22:39:36    INFO    OGG‐03010    Performing implicit conversion of column data from character set UTF‐8 to zhs16gbk.

Source Context :
SourceModule    : [ggapp.csconv]
SourceID    :
[/scratch/aime/adestore/views/aime_adc4150378/oggcore/OpenSys/src/ggli b/ggapp/csconv.cpp]
SourceFunction    : [conversion_error_handler]SourceLine    : [820]
ThreadBacktrace    : [18] elements
:
[/u01/app/oracle/ogg12/libgglog.so(CMessageContext::AddThreadContext()
+0x1b) [0x7f8e943ebf2b]]
:
[/u01/app/oracle/ogg12/libgglog.so(CMessageFactory::CreateMessage(CSou rceContext*, unsigned int, ...)+0x134) [0x7f8e943e5f84]]
:
[/u01/app/oracle/ogg12/libgglog.so(_MSG_ERR_COLUMN_CHARSET_CONVERSION_ CSTOCS2(CSourceContext*, char const*, unsigned long, ggs::gglib::ggapp::CDBObjName<(DBObjTy
pe)13> const&, ggs::gglib::ggapp::CDBObjName<(DBObjType)13> const&, char const*, char const*, CMessageFactory::MessageDisposition)+0x89) [0x7f8e943b4b63]]
:
[/u01/app/oracle/ogg12/replicat(conversion_error_handler(ULibCharSet, ULibCharSet, ULibError, ULibBadCharDetail const&, col_def const*, col_def const*, bool, ext
r_ptr_def*, bool&, bool&)+0x184) [0x634b66]]
:
[/u01/app/oracle/ogg12/replicat(CSCONV_convert(short, col_def const*, ULibCharSet, short, col_def*, ULibCharSet, char*, char*, col_def*, bool, extr_ptr_def*)+0x3
52) [0x635580]]
:
[/u01/app/oracle/ogg12/replicat(map_columns_int(ggs::gglib::gglcr::Com monLCR const&, ggs::gglib::gglcr::CommonLCR&, char*, map_col_def*, short*, short*, short, s
hort, extr_ptr_def*, bool, bool, bool)+0x1d33) [0x63f1e3]]
:
[/u01/app/oracle/ogg12/replicat(map_columns(ggs::gglib::gglcr::CommonL CR const&, ggs::gglib::gglcr::CommonLCR&, map_col_def*,  short*, short*, short, short, short
*, int, extr_ptr_def*)+0xfe) [0x63f70e]]
:
[/u01/app/oracle/ogg12/replicat(replicate_io(ggs::gglib::ggdatasource:
:DataSource*, file_def*, ggs::gglib::gglcr::CommonLCR const*, ggs::gglib::gglcr::CommonLCR*
, extr_ptr_def*, int*, int)+0x488) [0x61b858]]
:
[/u01/app/oracle/ogg12/replicat(process_record(ggs::gglib::ggdatasource::DataSource*, file_def*&, ggs::gglib::gglcr::CommonLCR const*, ggs::gglib::gglcr::CommonL
CR*, short&, extr_ptr_def*&, extr_ptr_def*&, int&, int&, int&, bool)+0x328) [0x623178]]
:
[/u01/app/oracle/ogg12/replicat(ggs::er::ReplicatContext::processRepli catLoop(ggs::Heartbeat::MapGeneratorParams&)+0x1261) [0x5da591]]
:
[/u01/app/oracle/ogg12/replicat(ggs::er::ReplicatContext::run(ggs::Hea rtbeat::MapGeneratorParams&)+0x29) [0x5ce579]]
: [/u01/app/oracle/ogg12/replicat()
[0x617936]]
:
[/u01/app/oracle/ogg12/replicat(ggs::gglib::MultiThreading::MainThread
::ExecMain()+0x60) [0x6d15c0]]
:
[/u01/app/oracle/ogg12/replicat(ggs::gglib::MultiThreading::Thread::Ru nThread(ggs::gglib::MultiThreading::Thread::ThreadArgs*)+0x14d) [0x6d25dd]]
:
[/u01/app/oracle/ogg12/replicat(ggs::gglib::MultiThreading::MainThread
::Run(int, char**)+0xb1) [0x6d26c1]]
: [/u01/app/oracle/ogg12/replicat(main+0x3b)
[0x61ab9b]]
: [/lib64/libc.so.6( libc_start_main+0xfd)
[0x3dc9c1ed1d]]
: [/u01/app/oracle/ogg12/replicat()
[0x54eb69]]

2018‐09‐20 22:44:28    ERROR    OGG‐03533    Conversion from character set UTF‐8 of source column DNAME to character set zhs16gbk of target column DNAME failed because the source column contains
a character 'c2 a0' at offset 0 that is not available in the target character set.

二、处理过程

在应用进程加入参数:

REPLACEBADCHAR ESCAPE

REPLACEBADCHAR 参 数 官 方 介 绍 如 下

REPLACEBADCHAR Valid For

Extract and Replicat

Description

Use the REPLACEBADCHAR parameter to control the response of the
process when a valid code point does not exist for either the source
or target character set when mapping character-type columns. By
default, the check for invalid code points is only performed when the
source and target databases have different character sets, and the
default response is to abend. You can use the FORCECHECK option to
force the process to check for invalid code points when the source and
target databases have the same character set. REPLACEBADCHAR applies
globally.

Default

ABORT Syntax

REPLACEBADCHAR {ABORT | SKIP | ESCAPE | SUBSTITUTE string | NULL |
SPACE} [FORCECHECK] [NOWARNING] ABORT The process abends on an invalid
code point. This is the default.

SKIP The process skips the record that has the invalid code point. Use
this option with caution, because skipping a record can cause data
discrepancies on the target.

ESCAPE The process replaces the data value with an escaped version of
the data value. Depending on the character set of the source database,
the value is output as one of the following:

If the source data is not UTF-16 (NCHAR/NVARCHAR), the output is
hexadecimal (\xXX).

If the source data is UTF-16, the output is Unicode (\uXXXX).

SUBSTITUTE string The process replaces the data with a specified
string, either Unicode notation or up to four characters. By default
the default substitution character of the target character set is used
for replacement.

NULL The process replaces an invalid character with the value of NULL
if the target column is nullable or, otherwise, assigns a white space
(U+0020).

SPACE The process replaces an invalid character with a white space
(U+0020).

FORCECHECK The process checks for invalid code points when the source
and target databases have identical character sets. This overrides the
default, where the validation is skipped when the source and target
character sets are identical.

NOWARNING The process suppresses warning messages related to
conversion and validation errors.

Examples

Example 1 The following example replaces invalid code points with
the value of NULL.

REPLACEBADCHAR NULL Example 2 Because ESCAPE is specified, Oracle
GoldenGate will replace the Euro symbol in a source NCHAR column with
the escaped version of u20AC, because the target is ISO-8859-1, which
does not support the Euro code point.

REPLACEBADCHAR ESCAPE Example 3 The following substitutes a control
character for invalid characters.

REPLACEBADCHAR SUBSTITUTE \u001A

重启进程:

1    GGSCI (ogg) 25> edit params r_Sc    
2        
3    GGSCI (ogg) 26> start r_sc    
4        
5    Sending START request to MANAGER ...    
6    REPLICAT R_SC starting    
7        
8        
9    GGSCI (ogg) 27> info all    
10        
11    Program    Status    Group    Lag at Chkpt    Time Since Chkpt
12        
13    MANAGER    RUNNING    
14    REPLICAT    RUNNING    R_SC    00:00:00    00:00:01

进程状态正常,再去ODS端查询数据:


1    SQL> select deptno,dname,loc from dept;
2    
3    DEPTNO DNAME    LOC
4    ‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐
    ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
5    10 ACCOUNTING    NEW YORK
6    20 RESEARCH    DALLAS
7    30 SALES    CHICAGO
8    40 OPERATIONS    BOSTON
9    1 东东    a
10    60 东123\xC2\xA0东A    a
11    
12    

发现之前报错的utf8编码为 c2a0的字符已在ODS端的表中替换成了源端utf8的字符编码。而其他字符还是正常的,可以在报错后不改数据库字符集的前提下将特殊字符转换成相应的uft8编码,再通过人工写函数或则存过映射替换修改这类字符,或则可以考虑将不间断空格改为GBK中的普通空格,使用如下配置:

REPLACEBADCHAR SPACE

ODS端使用这个参数后再次在源端插入相同的字符串看下:

源端插入数据:

2    SQL> insert into dept values(61,'东
    123'||chr(to_number('C2A0','xxxx'))||'东A','a');
3    
4    1 row created.
5    
6    SQL> commit;
7    
8    Commit complete.
9    
10    SQL> alter system switch logfile;
11    
12    System altered.
13    SQL> select * from dept;
14    
15    DEPTNO DNAME    LOC
16    ‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
17    1 东东    a
18    60 东123 东A    a
19    61 东123 东A    a
20    10 ACCOUNTING    NEW YORK
21    20 RESEARCH    DALLAS
22    30 SALES    CHICAGO
23    40 OPERATIONS    BOSTON

ODS端查询:

25    SQL> select deptno,dname,loc from dept;
26    
27    DEPTNO DNAME    LOC
28    ‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐
    ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
29    10 ACCOUNTING    NEW YORK
30    20 RESEARCH    DALLAS
31    30 SALES    CHICAGO
32    40 OPERATIONS    BOSTON
33    1 东东    a
34    60 东123\xC2\xA0东A    a
35    61 东123    东A    a

发现utf8的不间断空格c2a0已经被替换成GBK的普通空格(U+0020)了。问题解决,在生产环境做了配置,实时同步恢复正常!


总结

本文主要介绍的是通过GoldenGate实时同步两个字符集不同的数据库时,如果遇到字符不兼容的问题时,应该怎么处理的解决方案,生产环境需谨慎,最后测试完无异常后在生产环境做了修改。

相关实践学习
基于MaxCompute的热门话题分析
本实验围绕社交用户发布的文章做了详尽的分析,通过分析能得到用户群体年龄分布,性别分布,地理位置分布,以及热门话题的热度。
SaaS 模式云数据仓库必修课
本课程由阿里云开发者社区和阿里云大数据团队共同出品,是SaaS模式云原生数据仓库领导者MaxCompute核心课程。本课程由阿里云资深产品和技术专家们从概念到方法,从场景到实践,体系化的将阿里巴巴飞天大数据平台10多年的经过验证的方法与实践深入浅出的讲给开发者们。帮助大数据开发者快速了解并掌握SaaS模式的云原生的数据仓库,助力开发者学习了解先进的技术栈,并能在实际业务中敏捷的进行大数据分析,赋能企业业务。 通过本课程可以了解SaaS模式云原生数据仓库领导者MaxCompute核心功能及典型适用场景,可应用MaxCompute实现数仓搭建,快速进行大数据分析。适合大数据工程师、大数据分析师 大量数据需要处理、存储和管理,需要搭建数据仓库?学它! 没有足够人员和经验来运维大数据平台,不想自建IDC买机器,需要免运维的大数据平台?会SQL就等于会大数据?学它! 想知道大数据用得对不对,想用更少的钱得到持续演进的数仓能力?获得极致弹性的计算资源和更好的性能,以及持续保护数据安全的生产环境?学它! 想要获得灵活的分析能力,快速洞察数据规律特征?想要兼得数据湖的灵活性与数据仓库的成长性?学它! 出品人:阿里云大数据产品及研发团队专家 产品 MaxCompute 官网 https://www.aliyun.com/product/odps&nbsp;
相关文章
|
2月前
|
SQL DataWorks 关系型数据库
DataWorks操作报错合集之如何处理数据同步时(mysql->hive)报:Render instance failed
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
|
16天前
|
分布式计算 DataWorks 调度
oss数据同步maxcompute报错
在使用阿里云DataWorks同步OSS数据至MaxCompute时,遇到“Input is not in the .gz format”的报错。问题源于目标目录中存在一个空文件,导致同步时识别错误。
|
2月前
|
分布式计算 DataWorks 数据管理
DataWorks操作报错合集之写入ODPS目的表时遇到脏数据报错,该怎么解决
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
|
2月前
|
分布式计算 DataWorks NoSQL
DataWorks操作报错合集之遇到报错:failed: ODPS-0130071:[1,36] Semantic analysis exception,该怎么解决
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
|
2月前
|
SQL 分布式计算 DataWorks
DataWorks操作报错合集之如何解决datax同步任务时报错ODPS-0410042:Invalid signature value
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
|
2月前
|
分布式计算 DataWorks 关系型数据库
DataWorks操作报错合集之新建MAXComputer数据源时,如何解决报错ODPS-0420095: Access Denied
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
|
2月前
|
安全 C# 开发者
【C# 多线程编程陷阱揭秘】:小心!那些让你的程序瞬间崩溃的多线程数据同步异常问题,看完这篇你就能轻松应对!
【8月更文挑战第18天】多线程编程对现代软件开发至关重要,特别是在追求高性能和响应性方面。然而,它也带来了数据同步异常等挑战。本文通过一个简单的计数器示例展示了当多个线程无序地访问共享资源时可能出现的问题,并介绍了如何使用 `lock` 语句来确保线程安全。此外,还提到了其他同步工具如 `Monitor` 和 `Semaphore`,帮助开发者实现更高效的数据同步策略,以达到既保证数据一致性又维持良好性能的目标。
32 0
|
3月前
|
分布式计算 资源调度 DataWorks
MaxCompute操作报错合集之出现“查询运行日志失败”的报错,一般是什么导致的
MaxCompute是阿里云提供的大规模离线数据处理服务,用于大数据分析、挖掘和报表生成等场景。在使用MaxCompute进行数据处理时,可能会遇到各种操作报错。以下是一些常见的MaxCompute操作报错及其可能的原因与解决措施的合集。
|
3月前
|
分布式计算 关系型数据库 数据处理
美柚与MaxCompute的数据同步架构设计与实践
数据处理与分析 一旦数据同步到MaxCompute后,就可以使用MaxCompute SQL或者MapReduce进行复杂的数据处理和分析。

热门文章

最新文章

下一篇
无影云桌面