select log_mode from v$database;
alter database archivelog;
alter system switch logfile;
This will start log miner...
SELECT distinct member LOGFILENAME FROM V$LOGFILE
docker run --name oracle-test -p 1521:1521 -p 5500:5500 -e ORACLE_SID=ORCLCDB -e ORACLE_PDB=ORCLPDB1 -e ORACLE_CHARACTERSET=AL32UTF8 -v /opt/oracle/oradata oracle/database:12.2.0.1-se2
docker run --name oracle-test -p 1521:1521 -p 5500:5500 -e ORACLE_SID=ORCLCDB -e ORACLE_PDB=ORCLPDB1 -e ORACLE_PWD=66175d775cM=1 -e ORACLE_CHARACTERSET=AL32UTF8 -v /opt/oracle/oradata oracle/database:12.2.0.1-se2
docker run --name oracle-test -p 1521:1521 -p 5500:5500 -e ORACLE_SID=ORCLCDB -e ORACLE_PDB=ORCLPDB1 -e ORACLE_PWD=66175d775cM=1 -e ORACLE_CHARACTERSET=AL32UTF8 -v /opt/oracle/oradata/:/opt/oracle/oradata oracle/database:12.2.0.1-se2
docker exec -ti oracle-test sqlplus sys/66175d775cM=1@ORCLCDB as sysdba
select log_mode from v$database;
shutdown immediate
startup mount
alter database archivelog;
alter database open;
select supplemental_log_data_min, supplemental_log_data_pk from v$database;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
alter system switch logfile;
alter session set "_ORACLE_SCRIPT"=true;
create role logminer_priv;
grant create session to logminer_priv; grant execute_catalog_role to logminer_priv; grant select any transaction to logminer_priv; grant select any dictionary to logminer_priv; grant select on SYSTEM.LOGMNR_COL$ to logminer_priv; grant select on SYSTEM.LOGMNR_OBJ$ to logminer_priv; grant select on SYSTEM.LOGMNR_USER$ to logminer_priv; grant select on SYSTEM.LOGMNR_UID$ to logminer_priv;
create user miner identified by miner; grant logminer_priv to miner; alter user miner quota unlimited on users;
GRANT CONNECT TO miner; GRANT CONNECT, RESOURCE, DBA TO miner; GRANT CREATE SESSION GRANT ANY PRIVILEGE TO miner; GRANT UNLIMITED TABLESPACE TO miner;
grant LOGMINING to logminer_priv; grant LOGMINING to miner;
create user c##miner identified by miner container=all; grant logminer_priv to c##miner container=all; alter user c##miner set container_data = (cdb$root, ORCLPDB1) container=current;
CREATE TABLE QUIESCEMARKER (source varchar2(100), status varchar2(100), sequence NUMBER(10), inittime timestamp, updatetime timestamp default sysdate, approvedtime timestamp, reason varchar2(100), CONSTRAINT quiesce_marker_pk PRIMARY KEY (source, sequence));
SELECT distinct member LOGFILENAME FROM V$LOGFILE;
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( - LOGFILENAME => '/opt/oracle/oradata/ORCLCDB/redo01.log', - OPTIONS => DBMS_LOGMNR.NEW);
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( - LOGFILENAME => '/opt/oracle/oradata/ORCLCDB/redo01.log', - OPTIONS => DBMS_LOGMNR.NEW);
execute DBMS_LOGMNR.ADD_LOGFILE ('/opt/oracle/oradata/ORCLCDB/redo03.log') execute DBMS_LOGMNR.ADD_LOGFILE ('/opt/oracle/oradata/ORCLCDB/redo02.log') execute DBMS_LOGMNR.ADD_LOGFILE ('/opt/oracle/oradata/ORCLCDB/redo01.log')
begin sys.DBMS_LOGMNR.ADD_LOGFILE ('/opt/oracle/oradata/ORCLCDB/redo03.log'); end; begin sys.DBMS_LOGMNR.ADD_LOGFILE ('/opt/oracle/oradata/ORCLCDB/redo02.log'); end; begin sys.DBMS_LOGMNR.ADD_LOGFILE ('/opt/oracle/oradata/ORCLCDB/redo01.log'); end;
execute DBMS_LOGMNR.START_LOGMNR (options => dbms_logmnr.dict_from_online_catalog);
execute DBMS_LOGMNR.START_LOGMNR (options => dbms_logmnr.committed_data_only);
EXECUTE DBMS_LOGMNR.START_LOGMNR(OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.COMMITTED_DATA_ONLY);
EXECUTE DBMS_LOGMNR.START_LOGMNR(OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.COMMITTED_DATA_ONLY);
begin sys.dbms_logmnr.start_logmnr( options => dbms_logmnr.dict_from_online_catalog); end;
begin dbms_logmnr.start_logmnr( options => dbms_logmnr.dict_from_online_catalog + dbms_logmnr.committed_data_only); end;
alter session set NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
execute DBMS_LOGMNR.START_LOGMNR(STARTTIME => '19-FEB-2019 01:01:01', ENDTIME => SYSDATE, OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE );
execute DBMS_LOGMNR.START_LOGMNR(STARTTIME => SYSDATE - interval '1' hour, ENDTIME => SYSDATE, OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE );
begin execute DBMS_LOGMNR.START_LOGMNR( STARTTIME => '14-FEB-2019 09:00:00', ENDTIME => SYSDATE, OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE + dbms_logmnr.committed_data_only); end;
execute DBMS_LOGMNR.END_LOGMNR();
begin sys.DBMS_LOGMNR.END_LOGMNR(); end;
select table_space, operation, table_name from v$logmnr_contents where start_timestamp>=sysdate-1 and username='UNKNOWN';
select operation, table_name from v$logmnr_contents where username='striim';
SELECT sql_redo FROM v$logmnr_contents WHERE table_name = 'info' AND seg_owner = 'striim' AND operation IN ('INSERT', 'UPDATE', 'DELETE');
SELECT username AS USR, SQL_REDO,SQL_UNDO FROM V$LOGMNR_CONTENTS WHERE SEG_OWNER IN ('striim');
select username, SQL_REDO, session_info from v$logmnr_contents where rownum < 50; select username, SQL_REDO, session_info from v$logmnr_contents where username = 'STRIIM'; select username, SQL_REDO, session_info from v$logmnr_contents where username not in ('SYS', 'SYSTEM') and TIMESTAMP > '10-feb-19'; select table_name, username, SQL_REDO, SQL_UNDO from v$logmnr_contents where rownum < 4 and operation = 'INSERT'; select table_name from v$logmnr_contents where operation = 'INSERT';
select commit_timestamp, table_name from v$logmnr_contents where table_name = 'INFO'; select scn, table_name, sql_redo from v$logmnr_contents where table_name = 'INFO'; select scn, table_name, operation, username, timestamp, sql_redo from v$logmnr_contents where table_name = 'INFO'; select scn, table_name, operation, username, timestamp, sql_redo from v$logmnr_contents where table_name = 'CUSTOMERS'; select scn, table_name, operation, username, timestamp, sql_redo from v$logmnr_contents where table_name in ('INFO'); select scn, table_name, operation, username, timestamp, sql_redo from v$logmnr_contents where table_name = 'INFO' and scn > 1787096;
select cscn, table_name, operation, username, timestamp, sql_redo from v$logmnr_contents where table_name = 'INFO';
- https://www.oracle-dba-online.com/log_miner.htm
- https://orajavasolutions.wordpress.com/2013/03/21/using-logminer-and-archive-logging-with-oracle-11gr2/
- https://yasinyazici.wordpress.com/2014/07/05/analyze-redo-log-with-logminer/
- https://dzone.com/articles/replication-from-oracle-to-mariadb-part-1-1
- (v$logmnr_contents)[https://docs.oracle.com/cd/B19306_01/server.102/b14237/dynviews_1154.htm#REFRN30132]
- https://docs.oracle.com/database/121/SUTIL/GUID-319446A8-6FEC-42CE-A6A4-582CA65377CF.htm#SUTIL1601
- https://github.com/singer-io/tap-oracle/blob/master/tap_oracle/sync_strategies/log_miner.py
docker exec -ti oracle-test sqlplus miner/miner//192.168.40.106:1521/ORCLCDB