如何进行ogg的字符分析

45次阅读
没有评论

共计 3707 个字符,预计需要花费 10 分钟才能阅读完成。

今天就跟大家聊聊有关如何进行 ogg 的字符分析,可能很多人都不太了解,为了让大家更加了解,丸趣 TV 小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

我们所熟知 oracle 的字符集一旦创建完毕后最好不要修改,关于 oracle goldengate 的字符集问题还是需要注意的,因为如果目标端和源端字符集不一致,而有些字符无法在目标端表示 ogg 可能无法保证数据一致性。

源库字符集:
SQL select value from v$nls_parameters where parameter= NLS_CHARACTERSET

VALUE
—————————————————————-
AL32UTF8

如果这里小鱼在源端设置 SETENV(NLS_LANG=“AMERICAN_AMERICA.ZHS16GBK”)去指定源端客户端的字符集
GGSCI (dg01) 21 view params exiaoyu

extract exiaoyu
SETENV (NLS_LANG= AMERICAN_AMERICA.ZHS16GBK)
SETENV (ORACLE_SID= xiaoyu)
userid ogg,password ogg
dynamicresolution
gettruncates
report at 2:00
reportrollover at 3:00
warnlongtrans 3h,checkinterval 10m
exttrail ./dirdat/dd
table xiaoyu.*;
table xiaoyugg.*;

来看看对应的 extract 进程的报告,发现此时 ogg 发觉源端客户端的 NLS_LANG 变量和源端数据库字符集不一致,从而选择源端数据库字符集,并没有根据 extract 进程参数中的 SETENV 指定。
GGSCI (dg01) 52 view report exiaoyu

** Running with the following parameters **
***********************************************************************

2013-06-04 04:50:27 INFO OGG-03035 Operating system character set identified as UTF-8. Locale: en_US, LC_ALL:.
extract exiaoyu
SETENV (NLS_LANG= AMERICAN_AMERICA.ZHS16GBK)
Set environment variable (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
SETENV (ORACLE_SID= xiaoyu)
Set environment variable (ORACLE_SID=xiaoyu)
userid ogg,password ***

2013-06-04 04:50:28 INFO OGG-03500 WARNING: NLS_LANG environment variable does not match database character set, or not set. Using database character set value of AL32UTF8.

[oracle@ogg 11.2]$ oggerr 3500
03500, 00000, WARNING: NLS_LANG environment variable does not match database character set, or not set. Using database character set value of {0}
// *{0}: nls_charset (String)
// *Cause: The NLS_LANG environment variable is not set to the same as the
// database character set. Oracle GoldenGate is using the database
// character set.
// *Action: None
看来源端设置 NLS_LANG 跟 oracle database 的字符集不一致时,ogg 还是会选择 oracle database 的字符集,而忽略掉 extract 的进程参数 SETEVN NLS_LANG

接下来测试目标端:
这里也指定 SETENV(NLS_LANG=”AMERICAN_AMERICA.ZHS16GBK”)
GGSCI (ogg.single) 15 view params rxiaoyu

replicat rxiaoyu
SETENV (NLS_LANG= AMERICAN_AMERICA.ZHS16GBK)
SETENV (ORACLE_SID= xiaoyu)
userid ogg,password ogg
assumetargetdefs
gettruncates
report at 2:00
reportrollover at 3:00
discardfile ./dirrpt/discard_rxiaoyu.dsc,append,megabytes 100
map xiaoyu.xiaoyu10,target xiaoyu.xiaoyu10,filter(@getenv( transaction , csn) 1074454806);
map xiaoyu.*,target xiaoyu.*;
map xiaoyugg.*,target ogg.*;

观察目标端的 replicat 进程,发现 ogg 选择了进程参数中 SETENV(NLS_LANG=“AMERICAN_AMERICA.ZHS16GBK”)
GGSCI (ogg.single) 17 view report rxiaoyu
。。。
2013-06-05 03:14:14 WARNING OGG-03504 NLS_LANG character set ZHS16GBK on the target is different from the source database character set AL32UTF8. Replication may not be valid if the source data has an incompatible character for the target NLS_LANG character set

此时 ogg 给出的提示需要在 replicat 进程中正确设置 SETENV NLS_LANG 变量,这里源端传递的是 AL32UTF8 字符集,目标端通过 replicat 进程参数 SETENV NLS_LANG 指定的是 ZHS16GBK,而 ogg 也采用了 replicat 进程的参数,并没有选择源端的字符集。
[oracle@ogg 11.2]$ oggerr 3504
03504, 00000, NLS_LANG character set {0} on the target is different from the source database character set {1}. Replication may not be valid if the source data has an incompatible character for the target NLS_LANG character set.
// *{0}: nls_lang_charset (String)
// *{1}: src_db_charset (String)
// *Cause: The NLS_LANG environment variable on the target is set to a
// different character set than the character set of the source
// database.
// *Action: Set the NLS_LANG environment variable on the target to the
// character set of the source database that is shown in the message.
// You can use the SETENV parameter in the Replicat parameter file to
// set it for the Replicat session.

而 ogg 报出的 3504 警告是为了提醒目标端字符集和源端不一致,可能会引起 replicat 进程异常,这里 ogg 也推荐在 replicat 进程中设置 NLS_LANG 使目标端和源端一致。

那么对于字符集对 ogg 的影响就是源端和目标端,如果源端和目标端 database 字符集一直,这里在进程中直接采用一致的 SETENV NLS_LANG 都等于缺省的数据库字符集即可,而对于源端和目标端字符集不一致的,则需要在目标端手动指定 replicat 进程参数 SETENV NLS_LANG 等于源端字符集,当然对于最后在数据库中数据行小鱼认为还是需要再次转化成目标端 oracle database 的字符集。(ogg 也是一个同步复制产品,其技术原理依然不能脱离 oracle database)

看完上述内容,你们对如何进行 ogg 的字符分析有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注丸趣 TV 行业资讯频道,感谢大家的支持。

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-17发表,共计3707字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)