1、查看是否开启归档
SQL> select name,log_mode from v$database;
NAME LOG_MODE
ORCL NOARCHIVELOG
2、如果没有则需要开启归档
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u01/app/oracle/product/11.2/db_1/dbs/arch
Oldest online log sequence 2
Current log sequence 4
SQL> alter system set log_archive_dest_1=‘location=/u01/app/oracle/backup/archivelog optional’; //修改目录
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 3256942592 bytes
Fixed Size 2257640 bytes
Variable Size 738200856 bytes
Database Buffers 2499805184 bytes
Redo Buffers 16678912 bytes
Database mounted.
SQL> alter database archivelog; //开启归档
Database altered.
SQL> alter database open;
Database altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/backup/archivelog
Oldest online log sequence 2
Next log sequence to archive 4
Current log sequence 4
开启附加日志(supplemental log)可以指示数据库在日志中添加额外信息到日志流中,用以支持基于日志的工具,注意:条件需要所有字段在开启ALLC为YES
SQL> alter database add supplemental log data(primary key,unique,foreign key,all) columns;
SQL> select supplemental_log_data_min min,supplemental_log_data_pk pk,supplemental_log_data_ui ui,supplemental_log_data_fk fk,supplemental_log_data_all allc from v$database;
MIN PK UI FK ALLC
YES YES YES YES YES
3、创建用户及授权
SQL> create role logmnr_role;
Role created.
SQL> grant create session to logmnr_role;
Grant succeeded.
SQL> grant execute_catalog_role,select any transaction,select any dictionary ,select any table to logmnr_role;
Grant succeeded.
SQL> create user kminer identified by kminerpass;
User created.
SQL> grant logmnr_role to kminer;
Grant succeeded.
SQL> alter user kminer quota unlimited on users;
User altered.
SQL>