KFS Oracle RAC 数据解析同步配置方法
一、logminer方式解析
1、数据库配置 - Oracle
1. 数据库中需要先设置 NSL_DATE_FORMAT,命令如下,设置好以后需要重启数据库:
ALTER SYSTEM SET NLS_DATE_FORMAT='YYYY-MM-DD' SCOPE=SPFILE; --logmini模式必须
2. 创建 KFS用户并赋予相应的权限:
假设 KFS 用户为 FLYSYNC,如果能够提供 DBA 权限,那么该用户应该赋予的权限包括:
GRANT CONNECT, RESOURCE TO FLYSYNC; GRANT EXECUTE_CATALOG_ROLE TO FLYSYNC; GRANT CREATE SESSION TO FLYSYNC; GRANT SELECT ANY TRANSACTION TO FLYSYNC; GRANT SELECT ANY TABLE TO FLYSYNC; GRANT UNLIMITED TABLESPACE TO FLYSYNC; GRANT DBA TO FLYSYNC;
假设 Logminer 用户为 FLYSYNC,如果不能够提供 DBA 权限,可以赋予以下权限包括:
GRANT CONNECT TO FLYSYNC; GRANT CREATE SESSION TO FLYSYNC; GRANT UNLIMITED TABLESPACE TO FLYSYNC; GRANT CREATE TABLE TO FLYSYNC; GRANT CREATE MINING MODEL TO FLYSYNC; GRANT LOGMINING TO FLYSYNC; GRANT EXECUTE ON DBMS_FLASHBACK TO FLYSYNC; GRANT EXECUTE ON DBMS_LOGMNR TO FLYSYNC; GRANT EXECUTE ON DBMS_LOGMNR_D TO FLYSYNC; GRANT EXECUTE ON SYS.DBMS_LOGMNR TO FLYSYNC; GRANT EXECUTE ON SYS.DBMS_LOGMNR_D TO FLYSYNC; GRANT EXECUTE ON SYS.DBMS_LOGMNR_INTERNAL TO FLYSYNC; GRANT EXECUTE ON SYS.DBMS_LOGMNR_LOGREP_DICT TO FLYSYNC; GRANT EXECUTE ON SYS.DBMS_LOGMNR_SESSION TO FLYSYNC; GRANT EXECUTE_CATALOG_ROLE TO FLYSYNC; GRANT SELECT ANY DICTIONARY TO FLYSYNC; GRANT SELECT ANY TABLE TO FLYSYNC; GRANT SELECT ANY TRANSACTION TO FLYSYNC; GRANT SELECT ON SYS.V_$ARCHIVED_LOG TO FLYSYNC; GRANT SELECT ON SYS.V_$DATABASE TO FLYSYNC; GRANT SELECT ON SYS.V_$LOGMNR_CONTENTS TO FLYSYNC; GRANT SELECT ON V_$ARCHIVED_LOG TO FLYSYNC; GRANT SELECT ON V_$DATABASE TO FLYSYNC; GRANT SELECT ON V_$LOG TO FLYSYNC; GRANT SELECT ON V_$LOGFILE TO FLYSYNC; GRANT SELECT ON V_$LOGMNR_CONTENTS TO FLYSYNC; GRANT SELECT ON V_$LOGMNR_DICTIONARY TO FLYSYNC; GRANT SELECT ON V_$LOGMNR_LOGS TO FLYSYNC; GRANT SELECT ON V_$LOGMNR_PARAMETERS TO FLYSYNC; GRANT SELECT ON V_$PARAMETER TO FLYSYNC;
备注说明:
• Oracle 12c 以上版本的数据库在创建用户时,有以下几种方式:
(1)、PDB数据库
CDB里创建用户,需要带c##前缀,如:C##FLYSYNC
PDB里创建用户,不用带C##前缀,如:FLYSYNC
(2)、非PDB数据库
不用带C##前缀,如:FLYSYNC
3. 安装 Logminer(如果没有安装 Logminer 需要在 sqlplus 中执行下面的语句(均需要用 sys 管理员执行))工具,命令如下(Oracle 10g、Oracle 11g 和 Oracle 12c):
@$ORACLE_HOME/RDBMS/ADMIN/dbmslm.sql @$ORACLE_HOME/RDBMS/ADMIN/dbmslmd.sql @$ORACLE_HOME/RDBMS/ADMIN/dbmslms.sql
注意:以上三个 SQL 脚本,如果在安装的 Oralce 数据库相应的目录中有则必须执行;如果没有则可忽略
4. 开启 Oracle 数据库的归档日志(必须开启)了,具体步骤如下:
• 检查是否归档已经开启
SQL> select log_mode from v$database; LOG_MODE ------------ NOARCHIVELOG
• 开启归档(需要重启数据库)
(1)设置归档路径:
RAC的归档路径设置在共享磁盘内
SQL>alter system set log_archive_dest=’+DATA’ scope=spfile sid=’*’;
(2)然后关闭所有实例,启动1个实例,更改数据库为归档模式:
SQL>shutdown immediate;
SQL>startup mount;
SQL>alter database archivelog;
SQL>alter database open;
SQL>archive log list;
(3)启动其他节点,完成归档模式的变更过程。
SQL>startup;
在RAC环境下,归档路径的选择是值得斟酌的,如果使用共享的归档目录作为归档路径,则可以减少备份时的复杂性。如果使用独立的目录,则备份时需要进行特殊处理。
• 再次查看数据库归档情况
SQL> select log_mode from v$database;
LOG_MODE
------------
ARCHIVELOG
5. 开启补全日志
• 检查补全日志的状态
SQL> SELECT supplemental_log_data_min, supplemental_log_data_pk, supplemental_log_data_all FROM v$database; SUPPLEME SUP SUP -------- --- --- NO NO NO
• 开启补全日志 (建议在 MOUNT 模式下执行)
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; Database altered. SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS; Database altered. SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS; Database altered.
• 再次检查补全日志的状态
SQL> SELECT supplemental_log_data_min, supplemental_log_data_pk,supplemental_log_data_all FROM v$database; SUPPLEME SUP SUP -------- --- --- YES YES YES
6. 切换日志文件
SQL> ALTER SYSTEM SWITCH LOGFILE;
System altered
7. 若使用插接式数据库(pdb)
使用 sys 用户登录 sqlplus,查看所有 pdb 状态,并将使用的 pdb 开启, 例如 orclpdb
SQL> select con_id,dbid,name,open_mode from v$pdbs;
SQL> alter pluggable database orclpdb open;
2、flysync.ini配置
Flysync.ini这里需要添加集群的相关配置
[defaults] install-directory=/home/flysync/kfsrep profile-script=~/.bash_profile rmi-port=11000 [oracle12rac] role=master master=rac1 members=rac1 kufl-port=3112 replication-host=192.168.100.103 replication-port=1521 replication-user=FLYSYNC replication-password=123456 datasource-type=oracle datasource-oracle-service=ORCL #非PDB为SID名,PDB为PDB名称 oracle-extractor-method=logminer svc-extractor-filters=dropstatementdata property=replicator.extractor.dbms.tablePatterns=FLYSYNC.*,TEST.* property=replicator.extractor.dbms.scnSegmentationThreshold=5000 #开启集群 property=replicator.datasource.global.connectionSpec.use_cluster=true #集群其他节点IP,多个节点用逗号隔开 property=replicator.datasource.global.connectionSpec.slave_add=192.168.100.104 #集群其他节点端口,多个节点用逗号隔开 property=replicator.datasource.global.connectionSpec.slave_port=1521
二、redo方式解析
(一)数据库配置
1. 数据库中需要先设置 NSL_DATE_FORMAT,命令如下,设置好以后需要重启数据库:
ALTER SYSTEM SET NLS_DATE_FORMAT='YYYY-MM-DD' SCOPE=SPFILE; --logmini模式必须
2. 创建 KFS用户并赋予相应的权限:
假设 KFS用户为 FLYSYNC,如果能够提供 DBA 权限,那么该用户应该赋予的权限包括:
GRANT CONNECT, RESOURCE TO FLYSYNC; GRANT EXECUTE_CATALOG_ROLE TO FLYSYNC; GRANT CREATE SESSION TO FLYSYNC; GRANT SELECT ANY TRANSACTION TO FLYSYNC; GRANT SELECT ANY TABLE TO FLYSYNC; GRANT UNLIMITED TABLESPACE TO FLYSYNC; GRANT DBA TO FLYSYNC; 假设 kfs用户为 FLYSYNC,如果不能够提供 DBA 权限,可以赋予以下权限包括: GRANT CONNECT TO FLYSYNC; GRANT CREATE SESSION TO FLYSYNC; GRANT UNLIMITED TABLESPACE TO FLYSYNC; GRANT CREATE TABLE TO FLYSYNC; GRANT EXECUTE_CATALOG_ROLE TO FLYSYNC; GRANT SELECT ANY DICTIONARY TO FLYSYNC; GRANT SELECT ON V_$PARAMETER TO FLYSYNC;
3. 开启 Oracle 数据库的归档日志(必须开启)了,具体步骤如下:
• 检查是否归档已经开启
SQL> select log_mode from v$database;
LOG_MODE
------------
NOARCHIVELOG
• 开启归档(需要重启数据库)
(1)设置归档路径:
RAC的归档路径设置在共享磁盘内
SQL>alter system set log_archive_dest=’+DATA’ scope=spfile sid=’*';
(2)然后关闭所有实例,启动1个实例,更改数据库为归档模式:
SQL>shutdown immediate; SQL>startup mount; SQL>alter database archivelog; SQL>alter database open; SQL>archive log list;
(3)启动其他节点,完成归档模式的变更过程。
SQL>startup;
在RAC环境下,归档路径的选择是值得斟酌的,如果使用共享的归档目录作为归档路径,则可以减少备份时的复杂性。如果使用独立的目录,则备份时需要进行特殊处理。
• 再次查看数据库归档情况
SQL> select log_mode from v$database; LOG_MODE ------------ ARCHIVELOG
4. 开启补全日志
• 检查补全日志的状态
SQL> SELECT supplemental_log_data_min, supplemental_log_data_pk, supplemental_log_data_all FROM v$database; SUPPLEME SUP SUP -------- --- --- NO NO NO
• 开启补全日志 (建议在 MOUNT 模式下执行)
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; Database altered. SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS; Database altered. SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS; Database altered.
• 再次检查补全日志的状态
SQL> SELECT supplemental_log_data_min, supplemental_log_data_pk, supplemental_log_data_all FROM v$database; SUPPLEME SUP SUP -------- --- --- YES YES YES
5. 切换日志文件
SQL> ALTER SYSTEM SWITCH LOGFILE;
System altered
6. 若使用插接式数据库(pdb)
使用 sys 用户登录 sqlplus,查看所有 pdb 状态,并将使用的 pdb 开启, 例如 orclpdb
SQL> select con_id,dbid,name,open_mode from v$pdbs;
SQL> alter pluggable database orclpdb open;
(二)、flysync.ini配置
Redo模式的flysync.ini里不仅要配置集群相关参数,如果使用的是ASM存储,还需要配置ASM相关参数。
[defaults] install-directory=/home/flysync/flysync_test profile-script=~/.bash_profile rmi-port=11000 [oracle11rac] role=master master=flysync-1 members=flysync-1 kufl-port=3112 replication-host=192.168.11.31 replication-port=1521 replication-user=TEST replication-password=123456 datasource-type=oracle datasource-oracle-service=RACDB2 oracle-extractor-method=redo svc-extractor-filters=dropstatementdata property=replicator.extractor.dbms.tablePatterns=TEST.* property=replicator.extractor.dbms.scnSegmentationThreshold=5000 #开启集群 property=replicator.datasource.global.connectionSpec.use_cluster=true #集群其他节点的IP,有多个节点使用逗号隔开 property=replicator.datasource.global.connectionSpec.slave_add=192.168.28.176,192.168.28.177 #集群其他节点端口,有多个节点使用逗号隔开 property=replicator.datasource.global.connectionSpec.slave_port=1521,1521 #ASM用户,此用户必须要有sysasm权限 property=replicator.datasource.oracle_redo.connectionSpec.asm_user=asmfly #ASM用户密码 property=replicator.datasource.oracle_redo.connectionSpec.asm_password=Flyl234 #ASM侦听服务名 property=replicator.datasource.oracle_redo.connectionSpec.asm_serviceName=+ASM
附:创建ASM用户方法:
su - grid sqlplus / as sysasm SQL> create user asmfly identified by 123456; SQL> GRANT SYSASM TO asmfly;