近期碰上一个需求,希望能同步Oracle 数据库的用户,而不仅是数据库表里的业务用户,因为有的应用与DB用户名有关。
经测试,使用如下配置参数,可实现表数据同步及DB用户的同步。
ddl include mapped include objtype user include optype grant
ddloptions report
exttrail ./dirdat/e1
table scott.*;
上述参数除了同步表的数据,也可以同步新建的用户、alter, grant, revoke等操作的同步。
即如果A库的用户有新增,则可以在同步的B库上使用新增用户登录,如果有修改密码或授权等操作,在B库上也可以实现完整的复制。
如果有其它操作或对象(如存储过程或触发器等)需要同步,也可以在ddl 语句中进行配置,详细参数可参考官方文档。
以下是本测试中的日志:
2020-11-27 12:25:55 INFO OGG-00487 DDL operation included [include optype grant], optype [GRANT], objtype [ROLE PRIVILEGE], objowner "", objname "".
2020-11-27 12:25:56 INFO OGG-00497 Writing DDL operation to extract trail file.
2020-11-27 12:26:01 INFO OGG-01021 Command received from GGSCI: STATS total.
2020-11-27 12:26:21 INFO OGG-01487 DDL found, operation [revoke dba from u1 (size 18)], start SCN [3399312], commit SCN [3399319] instance [ (1)], DDL seqno [0], marker seqno [0].
2020-11-27 12:26:21 INFO OGG-00488 DDL operation excluded [not included by any filter], optype [REVOKE], objtype [ROLE PRIVILEGE], objowner "", objname "".
2020-11-27 12:26:23 INFO OGG-01021 Command received from GGSCI: STATS total.
2020-11-27 12:27:00 INFO OGG-01487 DDL found, operation [alter user u1 account lock (size 26)],