达梦DMHS搭建(oracle 11g到dm8)

环境准备
源端数据库oracle11g,对应版本dmhs同步软件,源端ip :192.168.118.121
目标端数据库dm8,对应版本dmhs同步软件,  目标端ip:192.168.118.122
Oracle源端配置
1 Oracle数据库安装,环境变量配置(见另外一篇linux安装oracle11g),dmhs安装略
2 开启监听:
[oracle@localhost ~]$ lsnrctl start
3 检查是否开启归档日志
sqlplus / as sysdba
SQL>archive log list; -- 检查归档是否开启

如果Automatic archival为Disabled则没有开启
那么执行以下语句开启
SQL>alter database open;
SQL>alter system set db_recovery_file_dest=’’;
SQL>alter system set log_archive_dest=’’;--设置路径
重启数据库,使归档路径生效
SQL>Shutdown immediate
以mount方式启动数据库:
SQL> startup mount
SQL>alter database open;
SQL>archive log list;
4 检查数据库最小附加日志及全列日志
SQL> select SUPPLEMENTAL_LOG_DATA_MIN, SUPPLEMENTAL_LOG_DATA_ALL from v$database;
如果是为no,就执行以下语句
SQL>ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
SQL>ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
5 将Oracle的回收机制关闭
SQL>alter system set recyclebin=off deferred;
6 检查字符集是否一致
先查询oracle数据库的字符集:
SQL> select userenv('language') from dual;
再查询系统字符集
echo $NLS_LANG
如果该变量值为空或者与查询结果不一致,请将该变量设置为查询结果的值
修改~/.bash_profile文件,增加export NLS_LANG=“sql查询结果值”
7 源端DDL支持
需要在源端数据库以 sys 用户,在 sys 模式下创建 DDL 触发器及 DDL 记录表,并在DMHS配置文件中配置ddl_mask参数选项以启用该功能。在dmhs目录下的scripts目录下的ddl_sql_ora有参考代码
8 创建数据库用户dmhs
Create user dmhs identified by 'dm123';
Grant dba to dmhs;--测试时直接赋予dba权限
现实环境如果没有DBA权限,需要做如下赋权操作(例如用户是DMHS):
grant all on dmhs_ddl_sql to dmhs;
grant select any table to dmhs;
grant select any dictionary to dmhs;
grant create session to dmhs;
grant lock any table to dmhs;
grant execute on dbms_flashback to dmhs;
grant connect to dmhs
9 Root用户安装odbc ,搭建DMHS最好要2.3.0以上的版本

---wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.0.tar.gz
查看是否安装rpm -qa|grep unixODBC
tar -xvf unixODBC-2.3.0.tar.gz
cd unixODBC-2.3.0/ --如配置错误,看是否安装gcc
./configure --prefix=/usr/local/unixODBC-2.3.0 --includedir=/usr/include --libdir=/usr/lib --bindir=/usr/bin --sysconfdir=/etc
make && make install
odbcinst -j

配置UNIXODBC 
vim /usr/local/etc/odbc.ini
[ORACLE]
Description = ORACLE ODBC DSN
Driver = Oracle in OraDb11g_home1
SERVER = 127.0.0.1
UID = DMHS
PWD = dm123
Servername = ORCL
PORT = 1521

vim /usr/local/etc/odbcinst.ini
[Oracle in OraDb11g_home1]
Description = ODBC DRIVER FOR ORACLE
Driver = /ora/oracle/product/11.2.0/db_1/lib/libsqora.so.11.1
Threading = 0

配置完成之后,可使用 isql 命令测试配置是否正确。注意要用oralce安装用户测试,
isql -v ORACLE DMHS dm123

10 配置Oracle源端
dmhs安装目录bin下修改dmhs.hs文件
<?xml version="1.0" encoding="GB2312" standalone="no"?>
<dmhs>
<base>
<lang>ch</lang>
<version>2.0</version>
<mgr_port>5345</mgr_port>
<chk_interval>3</chk_interval>
<ckpt_interval>60</ckpt_interval>
<siteid>1</siteid>
</base>
<cpt>
<enable>1</enable>
<db_type>ORACLE11g</db_type>
<db_server>orcl</db_server>
<db_port>1521</db_port>
<db_user>dmhs</db_user>
<db_pwd>dm123</db_pwd>
<ddl_mask>TABLE:OPERATION</ddl_mask>
<arch>
<clear_interval>600</clear_interval>
<clear_flag>0</clear_flag>
</arch>
<send>
<ip>192.168.118.122</ip>
<mgr_port>5345</mgr_port>
<data_port>5346</data_port>
<filter>
<enable>
<item>DMHS.TEST</item>
<item>DMHS.*</item>
<item>DMHS.*</item>
<item>DMHS.DEPT</item>
<item>DMHS.EMP</item>
</enable>
<disable>
<item>DMHS.DMHS_DDL_SQL</item>
<item>DMHS.DMHS_DDL_SQL</item>
</disable>
</filter>
<map>
<item>DMHS.TEST==DMHS.TEST</item>
<item>DMHS.*==DMHS.*</item>
<item>DMHS.*==DMHS.*</item>
<item>DMHS.DEPT==DMHS.DEPT1</item>
<item>DMHS.EMP==DMHS.EMP</item>
</map>
</send>
</cpt>
</dmhs>

目标端数据库dm8 配置。

1 数据库和dmhs安装略

2  数据库配置dm.ini文件
ARCH_INI=1 开启归档
RLOG_APPEND_LOGIC=1 开启逻辑附加日志
rlog_append_systab_logic=1 (如果要执行DDL脚本,则此参数设置为0)
3 数据库配置dmarch.ini
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch #归档目录
ARCH_FILE_SIZE = 128 #归档文件大小,单位 MB
ARCH_SPACE_LIMIT = 0 #空间大小限制,0 表示不限制
4 Dmhs捕获端配置 ,dmhs安装目录bin下创建 dmhs.hs
<?xml version="1.0" encoding="GB2312" standalone="no"?>
<dmhs>
<base>
<lang>ch</lang>
<version>2.0</version>
<mgr_port>5345</mgr_port>
<chk_interval>3</chk_interval>
<ckpt_interval>60</ckpt_interval>
<siteid>9</siteid>
</base>
<exec>
<recv>
<data_port>5346</data_port>
</recv>
<db_type>DM8</db_type>
<db_server>127.0.0.1</db_server>
<db_port>5236</db_port>
<db_user>SYSDBA</db_user>
<db_pwd>SYSDBA</db_pwd>
<recv_caches>8</recv_caches>
<trxid_tables>1</trxid_tables>
<case_sensitive>0</case_sensitive>
<enable_rowid>0</enable_rowid>
<toggle_case>0</toggle_case>
<exec_policy>1</exec_policy>
<commit_policy>1</commit_policy>
<enable_merge>1</enable_merge>
<affect_row>1</affect_row>
<ddl_mode>0</ddl_mode>
<is_kafka>0</is_kafka>
<enable_ckpt_range>0</enable_ckpt_range>
<update_duplicate>0</update_duplicate>
</exec>
</dmhs>

启动 DMHS 进行数据同步流程路

 

1 执行端运行 DMHS 软件工具 dmhs_server
[dmdba@localhost bin]$ ./dmhs_serverd start
2 执行端运行 DMHS 软件工具 dmhs_console,连接执行端 DMHS 服务,启动日志执行模块,控制台管理工具中执行如下 DMHS 命令:
[dmdba@localhost bin]$ ./dmhs_console
DMHS> connect 127.0.0.1:5345
DMHS> start exec

 

3 源端运行 DMHS 软件工具dmhs_server  
[oracle@localhost bin]$ ./dmhs_serverd start

4 源端执行端运行 DMHS 软件工具dmhs_console,连接源端 DMHS 服务,设置日志捕获模块起始 LSN,装载源端字典信息及历史数据。执行 start cpt
[oracle@localhost bin]$ ./dmhs_console
DMHS> connect 127.0.0.1:5345
DMHS> clear exec lsn
DMHS> LOAD 0 "SCH.NAME='DMHS'"CREATE|INSERT|DICT
DMHS> start cpt

 

 

 在dmhs安装目录bin下面的log可以看到具体信息

 

 

登录数据库测试

 

 

rac 配置

源端

<?xml version="1.0" encoding="GB18030"?>
<dmhs>
<base>
<lang>en</lang>
<mgr_port>5345</mgr_port>
<chk_interval>45</chk_interval>
<siteid>114</siteid>
<cpt_check>0</cpt_check>
</base>
<cpt>
<name>oraclerac114</name>
<db_type>oracle11g</db_type>
<db_server>192.168.180.114/orcloa</db_server>
<db_user>dmhs</db_user>
<db_pwd>dmhs123</db_pwd>
<char_code>PG_GB18030</char_code>
<ddl_mask>TABLE:ALTER</ddl_mask>
<arch>
<clear_interval>600</clear_interval>
<clear_flag>0</clear_flag>
</arch>
<rac>
<rac_type>1</rac_type>
<db_server>ASM</db_server>
<db_user>sys</db_user>
<db_pwd>oracle123</db_pwd>
<nodes>2</nodes>
</rac>
<send>
<ip>10.143.57.2</ip>
<mgr_port>5345</mgr_port>
<data_port>5346</data_port>
<filter>
<enable>
<item>RISENETOA.*</item>
<item>RISENETDCZS.*</item>
<item>AFFAIRSGM.*</item>
</enable>
</filter>
<map>
<item>RISENETOA.*==RISENETOA.*</item>
<item>RISENETDCZS.*==RISENETDCZS.*</item>
<item>AFFAIRSGM.*==AFFAIRSGM.*</item>
</map>
</send>
</cpt>
</dmhs>

 

目的端

<?xml version="1.0" encoding="GB2312"?>
<dmhs>
<base>
<siteid>2</siteid>
<mgr_port>5345</mgr_port>
<chk_interval>3</chk_interval>
<ckpt_interval>60</ckpt_interval>
<lang>en</lang>
<version>2.0</version>
</base>
<exec>
<recv>
<data_port>5346</data_port>
</recv>
<db_type>dm8</db_type>
<db_server>10.143.57.2</db_server>
<db_user>SYSDBA</db_user>
<db_pwd>Hn@dameng123</db_pwd>
<db_port>5236</db_port>
<exec_thr>16</exec_thr>
<exec_policy>2</exec_policy>
</exec>
</dmhs>

 

如有asm报错,配置连接串
[root@racdb2 admin]# pwd
/u01/app/oracle/product/11.2.0/db_1/network/admin
[root@racdb2 admin]# cat tnsnames.ora
# tnsnames.ora.racdb2 Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora.racdb2
# Generated by Oracle configuration tools.

ORCLOA =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = racscan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcloa)
)
)
ASM =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.180.114 )(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = +ASM)
)
)

 

加载

COPY 0 "SCH.NAME IN ('RISENETOA','RISENETDCZS','AFFAIRSGM')" DICT|CREATE|COMMENT|INSERT|INDEX|THREAD|8|DROP

加载某些表

COPY 0 "SCH.NAME='RISENETOA' AND TAB_NAME='OFFICE_SWJHBTIMES'" DICT|CREATE|COMMENT|INSERT|INDEX|DROP

按条件加载

copy 0 "sch.name='ENSEMBLE' and tab.name='MB_TRAN_HIST'" drop|create|dict|insert|where|"tran_date<=to_date('2019-04-30','yyyy-mm-dd')"

 

posted @ 2020-11-11 13:41  fangzpa  阅读(1450)  评论(0编辑  收藏  举报