Loading...

Please find below an example for how to migrate a Database to another ser using RMAN BACKUPS and without use OPEN RESETLOGS option.

Database: db01
Source Server: srv001
Target Server: srv002

1.) Copy Password File from Source to Target;

[oracle@srv001 dbs]$ scp orapwdb01 oracle@srv002:/opt/oracle/product/11.2.0.3/dbhome_1/dbs
The authenticity of host ‘srv002 (10.163.3.14)’ can’t be established.
RSA key fingerprint is 2f:60:86:4a:3f:7c:16:97:8d:d8:6e:21:f5:27:a5:75.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘srv002,10.163.3.14’ (RSA) to the list of known hosts.
oracle@srv002’s password:
orapwdb01 100% 1536 1.5KB/s 00:00

2.) Copy init.ora Source to Target

[oracle@srv001 dbs]$ sql

SQL*Plus: Release 12.1.0.2.0 Production on Fri May 18 14:24:17 2018

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create pfile=’initcheck.ora’ from spfile;

File created.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@srv001 dbs]$ ls -tlr
total 24
-rw-r–r–. 1 oracle oinstall 2851 May 15 2009 init.ora
-rw-r—–. 1 oracle oinstall 24 May 18 14:11 lkDB01
-rw-r—–. 1 oracle oinstall 1536 May 18 14:13 orapwdb01
-rw-rw—-. 1 oracle oinstall 1544 May 18 14:15 hc_db01.dat
-rw-r—–. 1 oracle oinstall 2560 May 18 14:16 spfiledb01.ora
-rw-r–r–. 1 oracle oinstall 947 May 18 14:24 initcheck.ora
[oracle@srv001 dbs]$ scp initcheck.ora oracle@srv002:/opt/oracle/product/11.2.0.3/dbhome_1/dbs
oracle@srv002’s password:
initcheck.ora 100% 947 0.9KB/s 00:00
[oracle@srv001 dbs]$

[oracle@srv002 dbs]$ ls -ltr
total 12
-rw-r–r– 1 oracle oinstall 2851 May 15 2009 init.ora
-rw-r—– 1 oracle oinstall 1536 May 18 14:19 orapwdb01
-rw-r–r– 1 oracle oinstall 947 May 18 14:22 initcheck.ora
[oracle@srv002 dbs]$ mv initcheck.ora initdb01.ora

3.) Adjust the Init parameters in the target:

Check all directories also

4.) Backup Source Database:

rman target /

RMAN> backup incremental level 0 database plus archivelog delete input;

Starting backup at 18-MAY-18
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=144 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=7 RECID=1 STAMP=976458696
channel ORA_DISK_1: starting piece 1 at 18-MAY-18
channel ORA_DISK_1: finished piece 1 at 18-MAY-18
piece handle=/opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_annnn_TAG20180518T143136_fhxkx8g8_.bkp tag=TAG20180518T143136 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_7_fhxkx7nv_.arc RECID=1 STAMP=976458696
Finished backup at 18-MAY-18

Starting backup at 18-MAY-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/opt/oracle/oradata/db01/system01.dbf
input datafile file number=00002 name=/opt/oracle/oradata/db01/sysaux01.dbf
input datafile file number=00003 name=/opt/oracle/oradata/db01/undotbs01.dbf
input datafile file number=00004 name=/opt/oracle/oradata/db01/users01.dbf
channel ORA_DISK_1: starting piece 1 at 18-MAY-18
channel ORA_DISK_1: finished piece 1 at 18-MAY-18
piece handle=/opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_nnnd0_TAG20180518T143137_fhxkx9sn_.bkp tag=TAG20180518T143137 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 18-MAY-18

Starting backup at 18-MAY-18
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=8 RECID=2 STAMP=976458712
channel ORA_DISK_1: starting piece 1 at 18-MAY-18
channel ORA_DISK_1: finished piece 1 at 18-MAY-18
piece handle=/opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_annnn_TAG20180518T143152_fhxkxs1y_.bkp tag=TAG20180518T143152 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_8_fhxkxrvy_.arc RECID=2 STAMP=976458712
Finished backup at 18-MAY-18

Starting Control File and SPFILE Autobackup at 18-MAY-18
piece handle=/opt/oracle/fast_recovery_area/DB01/autobackup/2018_05_18/o1_mf_s_976458714_fhxkxxhy_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 18-MAY-18

5) Copy the Backup to target

RMAN> list backup of database;

List of Backup Sets
===================

BS Key Type LV Size Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
8 Incr 0 1.09G DISK 00:00:13 18-MAY-18
BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20180518T153053
Piece Name: /opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_nnnd0_TAG20180518T153053_fhxodg74_.bkp
List of Datafiles in backup set 8
File LV Type Ckp SCN Ckp Time Name
—- — —- ———- ——— —-
1 0 Incr 1066831 18-MAY-18 /opt/oracle/oradata/db01/system01.dbf
2 0 Incr 1066831 18-MAY-18 /opt/oracle/oradata/db01/sysaux01.dbf
3 0 Incr 1066831 18-MAY-18 /opt/oracle/oradata/db01/undotbs01.dbf
4 0 Incr 1066831 18-MAY-18 /opt/oracle/oradata/db01/users01.dbf

RMAN> list backup of controlfile;

List of Backup Sets
===================

BS Key Type LV Size Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
10 Full 9.36M DISK 00:00:03 18-MAY-18
BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20180518T153110
Piece Name: /opt/oracle/fast_recovery_area/DB01/autobackup/2018_05_18/o1_mf_s_976462270_fhxodz38_.bkp
Control File Included: Ckp SCN: 1066849 Ckp time: 18-MAY-18

[oracle@srv001 DB01]$ pwd
/opt/oracle/fast_recovery_area/DB01
[oracle@srv001 DB01]$ ls -tlr
total 16
drwxr-x—. 2 oracle oinstall 4096 May 18 14:11 onlinelog
drwxr-x—. 3 oracle oinstall 4096 May 18 14:31 archivelog
drwxr-x—. 3 oracle oinstall 4096 May 18 14:31 backupset
drwxr-x—. 3 oracle oinstall 4096 May 18 14:31 autobackup
[oracle@srv001 DB01]$ pwd
/opt/oracle/fast_recovery_area/DB01
[oracle@srv001 DB01]$ tar -cvf backup.tar *
archivelog/
archivelog/2018_05_18/
autobackup/
autobackup/2018_05_18/
autobackup/2018_05_18/o1_mf_s_976458714_fhxkxxhy_.bkp
backupset/
backupset/2018_05_18/
backupset/2018_05_18/o1_mf_annnn_TAG20180518T143152_fhxkxs1y_.bkp
backupset/2018_05_18/o1_mf_nnnd0_TAG20180518T143137_fhxkx9sn_.bkp
backupset/2018_05_18/o1_mf_annnn_TAG20180518T143136_fhxkx8g8_.bkp
onlinelog/

target:
mkdir -p /opt/oracle/fast_recovery_area/DB01

source:
[oracle@srv001 DB01]$ pwd
/opt/oracle/fast_recovery_area/DB01
[oracle@srv001 DB01]$ scp backup.tar oracle@srv002:/opt/oracle/fast_recovery_area/DB01
oracle@srv002’s password:
backup.tar 100% 1152MB 115.2MB/s 00:10

Target:
[oracle@srv002 dbs]$ cd /opt/oracle/fast_recovery_area/DB01
[oracle@srv002 DB01]$ ls -ltr
total 1180072
-rw-r–r– 1 oracle oinstall 1208381440 May 18 14:34 backup.tar
[oracle@srv002 DB01]$
[oracle@srv002 DB01]$
[oracle@srv002 DB01]$ tar -xvf backup.tar
archivelog/
archivelog/2018_05_18/
autobackup/
autobackup/2018_05_18/
autobackup/2018_05_18/o1_mf_s_976458714_fhxkxxhy_.bkp
backupset/
backupset/2018_05_18/
backupset/2018_05_18/o1_mf_annnn_TAG20180518T143152_fhxkxs1y_.bkp
backupset/2018_05_18/o1_mf_nnnd0_TAG20180518T143137_fhxkx9sn_.bkp
backupset/2018_05_18/o1_mf_annnn_TAG20180518T143136_fhxkx8g8_.bkp
onlinelog/

6.) Set the environment variable

[oracle@srv002 dbhome_1]$ . oraenv
ORACLE_SID = [cdb01] ? db01
The Oracle base remains unchanged with value /opt/oracle

7.) Restore Controlfile into the target:

[oracle@srv002 dbhome_1]$ sql

SQL*Plus: Release 11.2.0.3.0 Production on Fri May 18 14:38:59 2018

Copyright (c) 1982, 2011, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1068937216 bytes
Fixed Size 2235208 bytes
Variable Size 281019576 bytes
Database Buffers 780140544 bytes
Redo Buffers 5541888 bytes

Using the “LIST BACKUP OF CONTROLFILE: command execute on the Source, restore the file:

rman target /
restore controlfile from ‘/opt/oracle/fast_recovery_area/DB01/autobackup/2018_05_18/o1_mf_s_976458714_fhxkxxhy_.bkp’;

Starting restore at 18-MAY-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/opt/oracle/oradata/db01/control01.ctl
output file name=/opt/oracle/fast_recovery_area/db01/control02.ctl
Finished restore at 18-MAY-18

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

8.) Restore Database:

RMAN> restore database;

Starting restore at 18-MAY-18
Starting implicit crosscheck backup at 18-MAY-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 18-MAY-18

Starting implicit crosscheck copy at 18-MAY-18
using channel ORA_DISK_1
Finished implicit crosscheck copy at 18-MAY-18

searching for all files in the recovery area
cataloging files…
cataloging done

List of Cataloged Files
=======================
File Name: /opt/oracle/fast_recovery_area/DB01/autobackup/2018_05_18/o1_mf_s_976462270_fhxodz38_.bkp

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /opt/oracle/oradata/db01/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /opt/oracle/oradata/db01/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /opt/oracle/oradata/db01/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /opt/oracle/oradata/db01/users01.dbf
channel ORA_DISK_1: reading from backup piece /opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_nnnd0_TAG20180518T153053_fhxodg74_.bkp
channel ORA_DISK_1: piece handle=/opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_nnnd0_TAG20180518T153053_fhxodg74_.bkp tag=TAG20180518T153053
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 18-MAY-18

9.) Simulating operations on Production

Target:

SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
————–
8
Source:

SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
————–
8

SQL> alter system switch logfile;

System altered.

SQL> create user x identified by x;

User created.

SQL> grant dba to x;

Grant succeeded.

SQL> create table x.t1 as select * from dba_users;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /

System altered.

10) compare Archivelog Sequence:
Source:
SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
————–
13

Target:
SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
————–
8

SQL>

11.) Take the last backup

SOurce:

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount;
ORACLE instance started.

Total System Global Area 1068937216 bytes
Fixed Size 2235208 bytes
Variable Size 281019576 bytes
Database Buffers 780140544 bytes
Redo Buffers 5541888 bytes
Database mounted.

[oracle@srv001 ~]$ $ORACLE_HOME/bin/rman target /

Recovery Manager: Release 11.2.0.3.0 – Production on Fri May 18 16:09:30 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

connected to target database: DB01 (DBID=1607725526, not open)

RMAN> backup archivelog all delete input;

Starting backup at 18-MAY-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=21 RECID=15 STAMP=976464537
input archived log thread=1 sequence=22 RECID=16 STAMP=976464538
input archived log thread=1 sequence=23 RECID=17 STAMP=976464541
channel ORA_DISK_1: starting piece 1 at 18-MAY-18
channel ORA_DISK_1: finished piece 1 at 18-MAY-18
piece handle=/opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_annnn_TAG20180518T160938_fhxqo2vh_.bkp tag=TAG20180518T160938 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_21_fhxqmsww_.arc RECID=15 STAMP=976464537
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_22_fhxqmtsp_.arc RECID=16 STAMP=976464538
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_23_fhxqmxg9_.arc RECID=17 STAMP=976464541
Finished backup at 18-MAY-18

Starting Control File and SPFILE Autobackup at 18-MAY-18
piece handle=/opt/oracle/fast_recovery_area/DB01/autobackup/2018_05_18/o1_mf_s_976464550_fhxqo578_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 18-MAY-18

12) Copy backup files to target to be restored:
[oracle@srv001 ~]$ scp /opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_annnn_TAG20180518T160938_fhxqo2vh_.bkp oracle@srv002:/opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/
oracle@srv002’s password:
o1_mf_annnn_TAG20180518T160938_fhxqo2vh_.bkp 100% 1340KB 1.3MB/s 00:00
[oracle@srv001 ~]$ scp /opt/oracle/fast_recovery_area/DB01/autobackup/2018_05_18/o1_mf_s_976464550_fhxqo578_.bkp oracle@srv002:/opt/oracle/fast_recovery_area/DB01/autobackup/2018_05_18/
oracle@srv002’s password:
o1_mf_s_976464550_fhxqo578_.bkp 100% 9600KB 9.4MB/s 00:00

13) Copy Redo Log Files/ Controlfiles to Target Database:
Source:
SQL> shut immediate
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.

target:
Please confirm that TARGET database is down before copy:

SQL> select member from v$logfile;

MEMBER
——————————————————————————–
/opt/oracle/oradata/db01/redo03.log
/opt/oracle/oradata/db01/redo02.log
/opt/oracle/oradata/db01/redo01.log

SQL> select name from v$controlfile;

NAME
——————————————————————————–
/opt/oracle/oradata/db01/control01.ctl
/opt/oracle/fast_recovery_area/db01/control02.ctl

[oracle@srv001 ~]$ scp /opt/oracle/oradata/db01/redo01.log oracle@srv002:/opt/oracle/oradata/db01/redo01.log
oracle@srv002’s password:
redo01.log 100% 50MB 50.0MB/s 00:01
[oracle@srv001 ~]$ scp /opt/oracle/oradata/db01/redo02.log oracle@srv002:/opt/oracle/oradata/db01/redo02.log
oracle@srv002’s password:
redo02.log 100% 50MB 50.0MB/s 00:00
[oracle@srv001 ~]$ scp /opt/oracle/oradata/db01/redo03.log oracle@srv002:/opt/oracle/oradata/db01/redo03.log
oracle@srv002’s password:
redo03.log 100% 50MB 50.0MB/s 00:00
[oracle@srv001 ~]$ scp /opt/oracle/oradata/db01/control01.ctl oracle@srv002:/opt/oracle/oradata/db01/control01.ctl
oracle@srv002’s password:
control01.ctl 100% 9520KB 9.3MB/s 00:00
[oracle@srv001 ~]$ scp /opt/oracle/fast_recovery_area/db01/control02.ctl oracle@srv002:/opt/oracle/fast_recovery_area/db01/control02.ctl
oracle@srv002’s password:
control02.ctl 100% 9520KB 9.3MB/s 00:00

14) Start TARGET database in mount state:

SQL*Plus: Release 11.2.0.3.0 Production on Fri May 18 16:13:05 2018

Copyright (c) 1982, 2011, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1068937216 bytes
Fixed Size 2235208 bytes
Variable Size 281019576 bytes
Database Buffers 780140544 bytes
Redo Buffers 5541888 bytes
Database mounted.

15) recover database:

RMAN> recover database;

Starting recover at 18-MAY-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 device type=DISK

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=15
channel ORA_DISK_1: reading from backup piece /opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_annnn_TAG20180518T153109_fhxodxgs_.bkp
channel ORA_DISK_1: piece handle=/opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_annnn_TAG20180518T153109_fhxodxgs_.bkp tag=TAG20180518T153109
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_15_fhxqwv4f_.arc thread=1 sequence=15
channel default: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_15_fhxqwv4f_.arc RECID=18 STAMP=976464827
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=16
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=17
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=18
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=19
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=20
channel ORA_DISK_1: reading from backup piece /opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_annnn_TAG20180518T154918_fhxpgyhh_.bkp
channel ORA_DISK_1: piece handle=/opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_annnn_TAG20180518T154918_fhxpgyhh_.bkp tag=TAG20180518T154918
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_16_fhxqwwdh_.arc thread=1 sequence=16
channel default: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_16_fhxqwwdh_.arc RECID=23 STAMP=976464828
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_17_fhxqwwhs_.arc thread=1 sequence=17
channel default: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_17_fhxqwwhs_.arc RECID=22 STAMP=976464828
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_18_fhxqwwfj_.arc thread=1 sequence=18
channel default: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_18_fhxqwwfj_.arc RECID=21 STAMP=976464828
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_19_fhxqwwdw_.arc thread=1 sequence=19
channel default: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_19_fhxqwwdw_.arc RECID=19 STAMP=976464828
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_20_fhxqwwf6_.arc thread=1 sequence=20
channel default: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_20_fhxqwwf6_.arc RECID=20 STAMP=976464828
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=21
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=22
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=23
channel ORA_DISK_1: reading from backup piece /opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_annnn_TAG20180518T160938_fhxqo2vh_.bkp
channel ORA_DISK_1: piece handle=/opt/oracle/fast_recovery_area/DB01/backupset/2018_05_18/o1_mf_annnn_TAG20180518T160938_fhxqo2vh_.bkp tag=TAG20180518T160938
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_21_fhxqx0rw_.arc thread=1 sequence=21
channel default: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_21_fhxqx0rw_.arc RECID=26 STAMP=976464832
channel default: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_22_fhxqx0t5_.arc RECID=25 STAMP=976464832
channel default: deleting archived log(s)
archived log file name=/opt/oracle/fast_recovery_area/DB01/archivelog/2018_05_18/o1_mf_1_23_fhxqx0sf_.arc RECID=24 STAMP=976464832
media recovery complete, elapsed time: 00:00:01
Finished recover at 18-MAY-18

RMAN>

RMAN> alter database open;

database opened

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Sqlplus / as sysdba

SQL> show pdbs

    CON_ID CON_NAME                     OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                     READ ONLY  NO
         3 PDBPROD1                     READ WRITE NO


SQL> alter session set container=pdbprod1
/

Session altered.

SQL> select name from v$datafile;


NAME
-----------------------------------------------------------------------
/u02/oradata/cdbprod/undotbs01.dbf
/u02/oradata/cdbprod/pdbprod1/system01.dbf
/u02/oradata/cdbprod/pdbprod1/sysaux01.dbf
/u02/oradata/cdbprod/pdbprod1/SAMPLE_SCHEMA_users01.dbf
/u02/oradata/cdbprod/pdbprod1/example01.dbf

SQL> create temporary tablespace temp01 
tempfile '/u02/oradata/cdbprod/pdbprod1/temp01.dbf' 
size 10m autoextend on tablespace group grptemp;

Tablespace created.

1* create temporary tablespace temp02 
tempfile '/u02/oradata/cdbprod/pdbprod1/temp02.dbf' 
size 10m autoextend on tablespace group grptemp

SQL> /

Tablespace created.


  • If needed to change the GROUP after the creation:
SQL> alter tablespace temp01 tablespace group grptemp;

Tablespace altered.

SQL> alter tablespace temp02 tablespace group grptemp;

Tablespace altered.

  • Setting the GROUP as default:
SQL> alter database default temporary tablespace grptemp;

Database altered.
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Procedure Tested on Oracle Database Appliance versions : X4-2 and X5-2
Procedure Files Reference
PRE-Task Execute All – OAKCLI VALIDATE, to check the Infra before start
REIMAGE Patch 12999313: ORACLE DATABASE APPLIANCE 12.1.2.12.0 BARE METAL OS ISO IMAGE Oracle Database Appliance Bare Metal Restore Steps
DEPLOY p12978712_1212120_Linux-x86-64_1of2.zip p12978712_1212120_Linux-x86-64_2of2.zip Obs: In case of failure during the deploy, follow the note below:
(Copy the custom configuration file to the template,
before execute the note below. https://docs.oracle.com/cd/E68623_01/doc.121/e68637/GUID-D49D8699-406E-49CA-9E7E-F02C76D05C74.htm#CMTAR458 Ex: oakcli copy -conf absolute_conf_file [-h] oakcli copy -conf /tmp/ODA_EBRC_CONFIG_DEPLOY.param ODA (Oracle Database Appliance): Deployment &
Cleanup Steps (Doc ID 1409835.1)
Database_Appliance_deployment
PATCH
ORACLE DATABASE APPLIANCE PATCH BUNDLE 12.1.2.12.0 (Patch)
p26433712_1212120_Linux-x86-64_1of2.zip 1.5 GB
p26433712_1212120_Linux-x86-64_2of2.zip 3.1 GB
HUGEPAGES Check if it’s a good value: ODA Oracle Database Appliance Huge Page / Large page
sizing (Doc ID 2108596.1)
CPU Capping IF NEEDED Oracle Database Appliance – Steps to Generate a Key via MOS to change your CORE Count and apply this Database_Appliance_deploymentCore Key (Doc ID 1447093.1) /opt/oracle/oak/bin/oakcli apply core_config_key /tmp/SerialNumber_NumberofCores_Configkey.txt
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

References:
https://oracle-base.com/articles/12c/multitenant-transparent-data-encryption-tde-12cr1

https://docs.oracle.com/database/121/SQLRF/statements_1003.htm#SQLRF55976
https://docs.oracle.com/cloud/latest/db121/ASOAG/asotrans_config.htm#ASOAG10474

The tablespace will be create inside of Pluggable Database: PDBPROD3

Datafile location: /u02/oradata/cdbprod/pdbprod3/
 Keystore location: /u01/oracle/admin/$ORACLE_SID/encryption_keystore/

1.) Include in SQLNET.ora:
 ENCRYPTION_WALLET_LOCATION =  
(SOURCE =(METHOD = FILE)(METHOD_DATA =    
(DIRECTORY = /u01/oracle/admin/$ORACLE_SID/encryption_keystore/)

2.)Create the directory, if doesn’t exist:

mkdir -p /u01/oracle/admin/$ORACLE_SID/encryption_keystore/

3.)Create the KEY store:

[oracle@vm1 admin]$ cd /u01/oracle/admin/$ORACLE_SID/encryption_keystore/
[oracle@vm1 encryption_keystore]$ pwd
/u01/oracle/admin/cdbprod/encryption_keystore

Inside of Root Container execute:

ADMINISTER KEY MANAGEMENT CREATE KEYSTORE 
'/u01/oracle/admin/cdbprod/encryption_keystore/' IDENTIFIED BY oracle;

SQL> !ls -ltr /u01/oracle/admin/cdbprod/encryption_keystore/
 total 4
 -rw-r--r--. 1 oracle oinstall 2408 Dec 13 16:35 ewallet.p12

4.)Open the KEY from ROOT container:

ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY oracle 
CONTAINER=ALL;

5.) Activate the KEY from ROOT Container, please note the Container=ALL:

ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY oracle 
WITH BACKUP CONTAINER=ALL;

6.) Check the Keys:
 SELECT con_id, key_id FROM v$encryption_keys;

    CON_ID KEY_ID
---------- --------------------------------------------------------------
         0 AZoc0eniGk+fvxf6hFmTPX8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
         0 AWT1SYl9Y09Sv5KM701+2ngAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
         0 ATAVGrOY8k8nv3VLAuTAjwwAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
         0 AZK1GySH8k+Jv2lpedKOP/8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
         0 AZyR5AVR3k9Mv6r7CBrT1REAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

COLUMN wrl_parameter FORMAT A50

SELECT * FROM v$encryption_wallet;

WRL_TYPE            WRL_PARAMETER                                   STATUS     WALLET_TYPE            WALLET_OR FULLY_BAC    CON_ID
-------------------- -------------------------------------------------- ---------- -------------------- --------- --------- ----------
FILE                /u01/oracle/admin/cdbprod/encryption_keystore/  OPEN       PASSWORD               SINGLE    NO                0

7.) Use the KEY

SQL> alter session set container=pdbprod3;

Session altered.

Create tablespace ts_tde datafile 
'/u02/oradata/cdbprod/pdbprod3/ts_tde.dbf' 
size 100m ENCRYPTION USING 'AES256' DEFAULT STORAGE (ENCRYPT);
  • Note: if the CDB is restarted we need to open again the KEY
    from the ROOT:
ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY oracle 
CONTAINER=ALL;

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

https://docs.oracle.com/database/121/ADMIN/tables.htm#ADMIN12898
Below the example with External tables using PREPROCESSOR option,
this is usefull where you have compressed files. The example has been
done with Pluggable Database.

Files:
C1.txt
C2.txt
ENG,England,English
SCO,Scotland,English
IRE,Ireland,English
WAL,Wales,Welsh
FRA,France,French
GER,Germany,German
USA,Unites States of America,English
 gzip c1.txt c2.txt

-rw-r--r--. 1 oracle oinstall       77 Dec 12 16:00 c1.txt.gz
-rw-r--r--. 1 oracle oinstall       92 Dec 12 16:00 c2.txt.gz

sqlplus / as sysdba
SQL> alter session set container=PDBPROD2;
Session altered.
  • Create a directory where the DATA is placed:
    SQL> create or replace directory dir_dba as '/home/oracle/dba';
    
    Directory created.
    
    SQL> grant read , write on directory dir_dba to public;
    
    Grant succeeded.
  • Create a directory pointing to the Utility that will be used to
    UNCOPRESS the file:
    
    [oracle@vm1 dba]$ which gunzip
    /usr/bin/gunzip
    
    [oracle@vm1 dba]$ which zcat
    
    /usr/bin/zcat
    
    SQL> create or replace directory dir_bin as '/usr/bin';
    
    Directory created.
    
    SQL> grant read, write on directory dir_bin to public;
    
    Grant succeeded.
    
    Drop table cmagno.countries_ext;
    
    CREATE TABLE cmagno.countries_ext (
      country_code      VARCHAR2(5),
      country_name      VARCHAR2(50),
      country_language  VARCHAR2(50)
    )
    ORGANIZATION EXTERNAL (
      TYPE ORACLE_LOADER
      DEFAULT DIRECTORY dir_dba
      ACCESS PARAMETERS (
        RECORDS DELIMITED BY NEWLINE
        PREPROCESSOR dir_bin:'zcat'
        FIELDS TERMINATED BY ','
        MISSING FIELD VALUES ARE NULL
        (
          country_code      CHAR(5),
          country_name      CHAR(50),
          country_language  CHAR(50)
        )
      )
      LOCATION ('c1.txt.gz','c1.txt.gz')
    )
    PARALLEL 1
    REJECT LIMIT UNLIMITED;
    
    SQL> select * from cmagno.countries_ext;
    
    COUNT COUNTRY_NAME                                   COUNTRY_LANGUAGE
    ----- -------------------------------------------------- -----------------
    ENG   England                                        English
    SCO   Scotland                                       English
    IRE   Ireland                                        English
    WAL   Wales                                          Welsh
    ENG   England                                        English
    SCO   Scotland                                       English
    IRE   Ireland                                        English
    WAL   Wales                                          Welsh
    
    After you can check inside of the data directory to see the logs:
    
    -rw-r--r--. 1 oracle oinstall       77 Dec 12 16:00 c1.txt.gz
    -rw-r--r--. 1 oracle oinstall       92 Dec 12 16:00 c2.txt.gz
    -rw-r--r--. 1 oracle oinstall      676 Dec 12 16:59 COUNTRIES_EXT_15232.log
    -rw-r--r--. 1 oracle oinstall      676 Dec 12 16:59 COUNTRIES_EXT_15230.log

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

https://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmxplat.htm#BRADV89983
For this, I created a tablespace in a SUN Solaris 12c environment and did an export tts.

Tablespace name: TS_TEST
Schema Objects : HR
Objects : T1, T2, T3 tables, to checked inside of PDBPROD3 after the import
TARGET : CDBPROD:PDBPROD3 
All tables have 39 rows

Export:

BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0
PL/SQL Release 12.1.0.2.0 - Production 0
CORE 12.1.0.2.0 Production 0
TNS for Solaris: Version 12.1.0.2.0 - Production 0
NLSRTL Version 12.1.0.2.0 - Production 0

SQL> SELECT PLATFORM_NAME
FROM V$TRANSPORTABLE_PLATFORM
WHERE PLATFORM_ID =
 ( SELECT PLATFORM_ID
 FROM V$DATABASE ); 2 3 4 5

PLATFORM_NAME
-----------------------------------------------------------------------------------------------------
Solaris Operating System (x86-64)

SQL> alter tablespace ts_test read only;
Tablespace altered.

PDB: PDDPOC01
oracle@vdds-racdb-01:~$ expdp hr/hr@PDDPOC01 directory=dir_tmp transport_tablespaces=ts_test

Export: Release 12.1.0.2.0 - Production on Thu Nov 30 16:09:10 2017
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
Starting "HR"."SYS_EXPORT_TRANSPORTABLE_01": hr/********@PDDPOC01 directory=dir_tmp transport_tablespaces=ts_test
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "HR"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for HR.SYS_EXPORT_TRANSPORTABLE_01 is:

/tmp/expdat.dmp

******************************************************************************

Datafiles required for transportable tablespace TS_TEST:
 +DATA/DDDSRACDB0/5926684743AC6B8BE054020820FA629A/DATAFILE/ts_test.dbf

Job "HR"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at Thu Nov 30 16:10:03 2017 elapsed 0 00:00:42

ORACLE_SID = [DDDSRACD1] ? +ASM1
The Oracle base remains unchanged with value /u01/oracle
oracle@vdds-racdb-01:~$ asmcmd cp +DATA/DDDSRACDB0/5926684743AC6B8BE054020820FA629A/DATAFILE/ts_test.dbf /tmp

copying +DATA/DDDSRACDB0/5926684743AC6B8BE054020820FA629A/DATAFILE/ts_test.dbf -> /tmp/ts_test.dbf




racle@racdb01:/tmp$ ls -ltr
total 20968
drwxr----- 2 oracle oinstall 178 Nov 30 10:53 hsperfdata_oracle
drwxrwxrwx 2 root root 117 Nov 30 16:30 oracle
-rw-r----- 1 oracle oinstall 229376 Nov 30 16:36 test.dmp
-rw-r----- 1 oracle oinstall 10493952 Nov 30 16:37 ts_test.dbf
drwxr-xr-x 2 root root 302 Nov 30 16:37 hsperfdata_root

ON VM1:

-rwxr-x---. 1 oracle oinstall 229376 Nov 30 16:39 test.dmp
-rwxr-x---. 1 oracle oinstall 10493952 Nov 30 16:39 ts_test.dbf

[oracle@vm1 dba]$ pwd

/home/oracle/dba

Copy the files to an existent directory into the server or create a new directory to be used during the import:

SQL> !ls -ltr /home/oracle/dba
total 10476
-rw-r--r--. 1 oracle oinstall 137 Nov 27 16:53 afiedt.buf
drwxrwxrwx. 2 oracle oinstall 64 Nov 30 10:56 scripts
-rwxr-x---. 1 oracle oinstall 229376 Nov 30 16:39 test.dmp
-rwxr-x---. 1 oracle oinstall 10493952 Nov 30 16:39 ts_test.dbf

SQL> create or replace directory dir_dba as '/home/oracle/dba';

Directory created.

SQL> grant read,write on directory dir_dba to public;

Grant succeeded.

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
 5 PDBPROD3 READ WRITE NO

Convert the datafile:

SELECT PLATFORM_NAME, ENDIAN_FORMAT
FROM V$TRANSPORTABLE_PLATFORM;

Convert to the same directory where the datafiles are placed.

rman target /

RMAN> CONVERT DATAFILE '/home/oracle/dba/ts_test.dbf'
DB_FILE_NAME_CONVERT '/home/oracle/dba', '/u02/oradata/cdbprod/pdbprod3'
FROM PLATFORM 'Solaris Operating System (x86-64)';
2> 3>

Starting conversion at target at 30-NOV-17
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
channel ORA_DISK_1: starting datafile conversion
input file name=/home/oracle/dba/ts_test.dbf
converted datafile=/u02/oradata/cdbprod/pdbprod3/ts_test.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Finished conversion at target at 30-NOV-17

Starting Control File and SPFILE Autobackup at 30-NOV-17
piece handle=/u03/fra/CDBPROD/autobackup/2017_11_30/o1_mf_s_961435712_f20dfjv3_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 30-NOV-17

[oracle@vm1 datafile]$ ls -ltr /u02/oradata/cdbprod/pdbprod3/ts_test.dbf
-rw-r-----. 1 oracle oinstall 10493952 Nov 30 17:28 /u02/oradata/cdbprod/pdbprod3/ts_test.dbf

Check the TNS entry for PDBPROD3

PDBPROD3 =
 (DESCRIPTION =
 (ADDRESS_LIST =
 (ADDRESS = (PROTOCOL = TCP)(HOST = vm1)(PORT = 1521))
 )
 (CONNECT_DATA =
 (SERVER = DEDICATED)
 (SERVICE_NAME = pdbprod3)
 )
 )

--> Import the datafile

impdp system/oracle@pdbprod3 dumpfile=test.dmp directory=dir_dba transport_datafiles=/u02/oradata/cdbprod/pdbprod3/ts_test.dbf

Import: Release 12.1.0.2.0 - Production on Thu Nov 30 17:34:50 2017
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Source time zone is +02:00 and target time zone is +00:00.

Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/********@pdbprod3 dumpfile=test.dmp directory=dir_dba transport_datafiles=/u02/oradata/cdbprod/pdbprod3/ts_test.dbf
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at Thu Nov 30 17:35:34 2017 elapsed 0 00:00:41

--> Check the information

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
 2 PDB$SEED READ ONLY NO
 3 PDBPROD1 READ WRITE NO
 4 PDBPROD2 READ WRITE NO
 5 PDBPROD3 READ WRITE NO
 6 PDBPROD4 READ WRITE NO

SQL> alter session set container=PDBPROD3;

Session altered.

SQL> SELECT COUNT(*) FROM HR.T1;
 COUNT(*)
----------
 39

SQL> SELECT COUNT(*) FROM HR.t2;
 COUNT(*)
----------
 39

SQL> SELECT COUNT(*) FROM HR.t3;
 COUNT(*)
----------
 39

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

A friend wrote a very good article about Oracle Databases on Docker. Please find below the link.

Enjoy !!!

https://www.linkedin.com/pulse/running-oracle-database-122-docker-carlos-henrique-duarte


Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
Carlos Magno – EzDBA by Carlos Magno - 4M ago

Notes:
SCRIPT: Basic example to manage AUD$ table in 11.2 with dbms_audit_mgmt (Doc ID 1362997.1)
DBMS_AUDIT_MGMT.INIT_CLEANUP Fails With ORA-46267 (Doc ID 1508787.1)

This is a procedure to clean the AUD$ table to avoid locks during 
the truncate process. Even being online process is recommended to be 
executed in a maintenance window. For small environments or non-prod you
can try execute online, without stop the application.
Script: purge_job.sql ==> Run this script as SYS database user account.

=> Please before start take the current size of AUD$ on DBA_SEGMENTS.
select sum(bytes)/(1024*1024) mb 
from dba_segments where segment_name='AUD$';

=> Create a new tablespace based on the value returned on the previous 
select.
create tablespace AUDTBS datafile '/oradata/db/audtbs1.dbf' 
size <VALUE>g autoextend on next 128m maxsize 20g;

=> Take the current number of rows, just to check after <OPTIONAL>
select count(*) from aud$;

prompt start of the script

set serveroutput on
prompt Change based on our customization done 
update dam_config_param$ set string_value='AUDTBS' 
where audit_trail_type#=1 and param_id=22;
commit;

prompt First Step: init cleanup (if not already)

BEGIN
IF NOT DBMS_AUDIT_MGMT.IS_CLEANUP_INITIALIZED(
DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD) THEN
dbms_output.put_line('Calling DBMS_AUDIT_MGMT.INIT_CLEANUP');
 DBMS_AUDIT_MGMT.INIT_CLEANUP(
audit_trail_type => dbms_audit_mgmt.AUDIT_TRAIL_AUD_STD,
default_cleanup_interval => 12);
else
 dbms_output.put_line('Cleanup for STD was already initialized');
end if;
end;
/

prompt revert back to default values again
update dam_config_param$ set string_value='SYSAUX' 
where audit_trail_type#=1 and param_id=22;
commit;

prompt set last archive timestamp to older than 7 days

begin
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(
audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
last_archive_time => sysdate - 7);
end;
/

prompt setup a purge job

BEGIN
DBMS_AUDIT_MGMT.CREATE_PURGE_JOB (
AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
AUDIT_TRAIL_PURGE_INTERVAL => 12,
AUDIT_TRAIL_PURGE_NAME => 'Standard_Audit_Trail_PJ',
USE_LAST_ARCH_TIMESTAMP => TRUE );
END;
/

prompt call DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP 
regularly to advance the last archive timestamp

create or replace 
procedure set_archive_retention (retention in number default 7) as
begin
 DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(
 audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
 last_archive_time => sysdate - retention);
end;
/

BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'advance_archive_timestamp',
job_type => 'STORED_PROCEDURE',
job_action => 'SET_ARCHIVE_RETENTION',
number_of_arguments => 1,
start_date => SYSDATE,
repeat_interval => 'freq=hourly;interval=12' ,
enabled => false,auto_drop => FALSE);
dbms_scheduler.set_job_argument_value(
job_name =>'advance_archive_timestamp',
argument_position =>1,argument_value => 7);
DBMS_SCHEDULER.ENABLE('advance_archive_timestamp');
End;
/

BEGIN
DBMS_SCHEDULER.run_job (
job_name => 'advance_archive_timestamp',use_current_session => FALSE);
END;
/

prompt End of the script

To verify the purge status and configured jobs status execute 
the following queries.

select min(NTIMESTAMP#) from aud$;
select LAST_START_DATE,LAST_RUN_DURATION,NEXT_RUN_DATE 
from dba_scheduler_jobs where job_name='ADVANCE_ARCHIVE_TIMESTAMP';
select LAST_START_DATE,LAST_RUN_DURATION,NEXT_RUN_DATE 
from dba_scheduler_jobs where job_name='STANDARD_AUDIT_TRAIL_PJ';

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Here the article to how to create a dataguard with broker:
https://ezdba.wordpress.com/2017/05/15/dataguard-setup-with-broke
--- convert the physical standby database to a snapshot database 
and open it for read-write operations.

-- Primary: Boston hostname(vddl-ocme1-rac-01)
-- Standby: London hostname(vddl-ocm-odg-01)

1.) Terminal windows with LONDON variables

[oracle@vddl-ocm-odg-01 ~]$ . oraenv
ORACLE_SID = [oracle] ? london
The Oracle base remains unchanged with value /opt/oracle
[oracle@vddl-ocm-odg-01 ~]$

sqlplus / as sysdba

SQL> select database_role from v$database;

DATABASE_ROLE
----------------
PHYSICAL STANDBY

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
YES

SQL> show parameter DB_FLASHBACK_RETENTION_TARGET

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target integer 1440

SQL> show parameter DB_RECOVERY_FILE_DEST

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /opt/oracle/oradata/london/arc
db_recovery_file_dest_size big integer 11105M

select file_type,number_of_files,percent_space_used
from v$recovery_area_usage;

FILE_TYPE NUMBER_OF_FILES PERCENT_SPACE_USED
----------------------- -------------------- --------------------
CONTROL FILE 0 0
REDO LOG 4 1.8
ARCHIVED LOG 27 7.6
BACKUP PIECE 2 .31
IMAGE COPY 0 0
FLASHBACK LOG 6 2.7
FOREIGN ARCHIVED LOG 0 0
AUXILIARY DATAFILE COPY 0 0

2.) Stop the RECOVERY

alter database recover managed standby database cancel;

3.) Convert to snapshot

alter database convert to snapshot standby;
SQL> select database_role from v$database;

DATABASE_ROLE
----------------
SNAPSHOT STANDBY

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
YES

SQL> select name, storage_size from v$restore_point;

NAME STORAGE_SIZE
---------------------------------------- --------------------
SNAPSHOT_STANDBY_REQUIRED_06/19/2017 10: 52428800
33:40

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
MOUNTED

4.) Open the database

SQL> alter database open;

Database altered.

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

5.) Test

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
-------------------- ------------------------------ ---------- ----------
 2 PDB$SEED READ ONLY NO
 3 DEV1 MOUNTED
SQL>
SQL>
SQL> alter pluggable database dev1 open;

Pluggable database altered.

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
-------------------- ------------------------------ ---------- ----------
 2 PDB$SEED READ ONLY NO
 3 DEV1 READ WRITE NO
SQL>
SQL>
SQL> alter session set container=dev1;

Session altered.

SQL>
SQL> create table misc1 (x varchar2(50) );

Table created.

SQL> insert into misc1 values ('Test Row');

1 row created.

SQL> commit;

Commit complete.

SQL> conn / as sysdba
Connected.

INSTANCE_NAME
----------------
london

6.) Check the Primary database: Boston

. oraenv
boston

SELECT MAX(SEQUENCE#), THREAD# FROM V$ARCHIVED_LOG GROUP BY THREAD#;

MAX(SEQUENCE#) THREAD#
-------------------- --------------------
 74 1

alter system switch logfile;

7.) Check the Sequence on standby snapshot database london.

SQL> SELECT MAX(SEQUENCE#), THREAD# FROM V$ARCHIVED_LOG GROUP BY THREAD#;

MAX(SEQUENCE#) THREAD#
-------------------- --------------------
 75 1

Note: Here we have a sequence bigger than primary because on this configuration i am using
FAR SYNC also.

8.) Convert back to standby:

. oraenv

london

sqlplus / as sysdba

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 520093696 bytes
Fixed Size 2926272 bytes
Variable Size 356518208 bytes
Database Buffers 155189248 bytes
Redo Buffers 5459968 bytes
Database mounted.
SQL> alter database convert to physical standby;

Database altered.

CON_ID CON_NAME OPEN MODE RESTRICTED
-------------------- ------------------------------ ---------- ----------
 2 PDB$SEED MOUNTED
 3 DEV1 MOUNTED

SQL> select file_type,number_of_files,percent_space_used
from v$recovery_area_usage; 2

FILE_TYPE NUMBER_OF_FILES PERCENT_SPACE_USED
----------------------- -------------------- --------------------
CONTROL FILE 0 0
REDO LOG 4 1.8
ARCHIVED LOG 29 7.67
BACKUP PIECE 2 .31
IMAGE COPY 0 0
FLASHBACK LOG 6 2.7
FOREIGN ARCHIVED LOG 0 0
AUXILIARY DATAFILE COPY 0 0

8 rows selected.

SQL>
SQL>
SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
-------------------- ------------------------------ ---------- ----------
 2 PDB$SEED MOUNTED
 3 DEV1 MOUNTED
SQL> alter database open;

Database altered.

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
-------------------- ------------------------------ ---------- ----------
 2 PDB$SEED READ ONLY NO
 3 DEV1 MOUNTED
SQL> alter pluggable database dev1 open;

Pluggable database altered.

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
-------------------- ------------------------------ ---------- ----------
 2 PDB$SEED READ ONLY NO
 3 DEV1 READ ONLY NO
SQL> alter session set container=dev1;

Session altered.

SQL> select * from misc1;
select * from misc1
 *
ERROR at line 1:
ORA-00942: table or view does not exist




SQL> conn / as sysdba
Connected.

INSTANCE_NAME
----------------
london

1 row selected.




SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 520093696 bytes
Fixed Size 2926272 bytes
Variable Size 356518208 bytes
Database Buffers 155189248 bytes
Redo Buffers 5459968 bytes
Database mounted.
SQL> alter database recover managed standby database disconnect;

Database altered.


exit;

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Here the article to how to create a dataguard with broker:
https://ezdba.wordpress.com/2017/05/15/dataguard-setup-with-broker/
FAR SYNC:
https://docs.oracle.com/database/121/SBYDB/create_fs.htm#SBYDB5441

Dataguard Far Sync.

Primary: Boston - hostname(vddl-ocme1-rac-01)
Standby: London - hostname(vddl-ocm-odg-01)

Far Sync:
bostonFS - hostname(vddl-ocm-odg-01)
londonFS - hostname(vddl-ocme1-rac-01)

tns entries on both sides for:

BOSTON 
LONDON 
LONDONFS 
BOSTONFS

1.)
create pfile='/tmp/initbostonFS.ora' from spfile;

2.)
alter database create far sync instance controlfile as '/tmp/bostonFS.ctl';

3.)
cp /opt/oracle/product/12.1.0.2/standalone/dbs/orapwboston /tmp

4.) 
[oracle@vddl-ocme1-rac-01 tmp]$ scp *boston* vddl-ocm-odg-01:/tmp
oracle@vddl-ocm-odg-01s password:
bostonFS.ctl 100% 17MB 17.4MB/s 00:00
initbostonFS.ora 100% 1983 1.9KB/s 00:00
orapwboston

5.) on Standby server:
mkdir -p /opt/oracle/oradata/bostonFS/
mkdir -p /opt/oracle/oradata/bostonFS/dev1/
mkdir -p /opt/oracle/fast_recovery_area/BOSTONFS
mkdir -p /opt/oracle/fast_recovery_area/bostonFS
mkdir -p /opt/oracle/admin/bostonFS/adump

6.) On Standby set the variables
. oraenv
bostonFS

7.) Edit

vi /tmp/initbostonFS.ora
:%s/boston/bostonFS/g

*.db_name='boston'
*.log_archive_config='dg_config=(boston,bostonFS,london,londonFS)'
*.log_archive_dest_2='SERVICE=london SYNC REOPEN=15 valid_for=(STANDBY_LOGFILES,STANDBY_ROLE) db_unique_name=london'
*.control_files='/opt/oracle/oradata/bostonFS/bostonFS01.ctl','/opt/oracle/fast_recovery_area/bostonFS/bostonFS02.ctl'
#*.local_listener='LISTENER_BOSTON'
*.db_unique_name=bostonFS
*.fal_server=boston
*.log_file_name_convert='boston','bostonFS'

8.) Copy controlfile

cp /tmp/bostonFS.ctl /opt/oracle/oradata/bostonFS/bostonFS01.ctl
cp /tmp/bostonFS.ctl /opt/oracle/fast_recovery_area/bostonFS/bostonFS02.ctl

9.) Copy Password FILE
cp /tmp/orapwboston $ORACLE_HOME/dbs/orapwbostonFS

10.) Check the environment variables to see if are pointed to bostonFS

set | grep ORA

11.) Create the spfile:

sqlplus / as sysdba
create spfile from pfile='/tmp/initbostonFS.ora';

12.) Mount the FAR Sync Instance:
startup mount;

13.) From Primary Server
sqlplus / as sysdba

--> Old Configurations
service="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=vddl-ocm-odg-01.lux.eproseed.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=london.example.com)(SERVER=DEDICATED)))", ASYNC NOAFFIRM delay=0 optional compression=disable max_failure=0 max_connections=1 reopen=300 db_unique_name="london" net_timeout=30,valid_for=(online_logfile,all_roles)

--> New configuration
alter system set log_archive_config='dg_config=(boston,bostonFS,london,londonFS,london2)' scope=both; --> Must be also on London Standby
alter system set log_archive_dest_2='SERVICE=bostonFS SYNC REOPEN=15 valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=bostonFS' scope=both;

14.) Check the sequences:

Primary:
SELECT MAX(SEQUENCE#), THREAD# FROM V$ARCHIVED_LOG GROUP BY THREAD#;

MAX(SEQUENCE#) THREAD#
-------------------- --------------------
 49 1

alter system switch logfile;

SELECT MAX(SEQUENCE#), THREAD# FROM V$ARCHIVED_LOG GROUP BY THREAD#;

MAX(SEQUENCE#) THREAD#
-------------------- --------------------
 50 1

StandBy: bostonFS,
At this time all of TNS must be working fine, check the logs (Broker) to see if there is no error inside.

SELECT MAX(SEQUENCE#), THREAD# FROM V$ARCHIVED_LOG GROUP BY THREAD#;

MAX(SEQUENCE#) THREAD#
-------------------- --------------------
 50 1

StandBy: london:

SELECT MAX(SEQUENCE#), THREAD# FROM V$ARCHIVED_LOG GROUP BY THREAD#;

MAX(SEQUENCE#) THREAD#
-------------------- --------------------
 50 1


15.) On standby server as bostonFS:
Check the Standby redolog files

1* select * from v$logfile
SQL> col member format a75
SQL> /

GROUP# STATUS TYPE MEMBER IS_ CON_ID
-------------------- ------- ------- --------------------------------------------------------------------------- --- --------------------
 3 ONLINE /opt/oracle/oradata/bostonFS/redo03.log NO 0
 2 ONLINE /opt/oracle/oradata/bostonFS/redo02.log NO 0
 1 ONLINE /opt/oracle/oradata/bostonFS/redo01.log NO 0
 4 STANDBY /opt/oracle/fast_recovery_area/BOSTONFS/onlinelog/o1_mf_4_dn7z8tbx_.log YES 0
 5 STANDBY /opt/oracle/fast_recovery_area/BOSTONFS/onlinelog/o1_mf_5_dn7z8wgm_.log YES 0
 6 STANDBY /opt/oracle/fast_recovery_area/BOSTONFS/onlinelog/o1_mf_6_dn7z8x7c_.log YES 0
 7 STANDBY /opt/oracle/fast_recovery_area/BOSTONFS/onlinelog/o1_mf_7_dn7z8tbm_.log YES 0

16.) Adding a second far sync, now for London standby. When London becomes primary the archived logs will sent to londonFS
instead of to send to boston.

. oraenv
boston

connect to vddl-ocme1-rac-01 - PRIMARY

[oracle@vddl-ocme1-rac-01 trace]$ cd /tmp
[oracle@vddl-ocme1-rac-01 tmp]$ ls -ltr
total 17988
drwx------. 2 root root 40 Jun 2 11:29 hsperfdata_root
-rw-r--r--. 1 oracle oinstall 135548 Jun 13 15:52 dwh_test.log
drwxr-xr-x. 2 oracle oinstall 60 Jun 14 22:19 hsperfdata_oracle
-rw-r--r--. 1 oracle oinstall 1983 Jun 16 16:01 initbostonFS.ora <-------
-rw-r-----. 1 oracle oinstall 18268160 Jun 16 16:01 bostonFS.ctl
-rw-r-----. 1 oracle oinstall 7680 Jun 16 16:02 orapwboston

mv /tmp/initbostonFS.ora /tmp/initlondonFS.ora

mkdir -p /opt/oracle/oradata/londonFS/
mkdir -p /opt/oracle/oradata/londonFS/dev1/
mkdir -p /opt/oracle/fast_recovery_area/LONDONFS
mkdir -p /opt/oracle/fast_recovery_area/londonFS
mkdir -p /opt/oracle/admin/londonFS/adump

17.) Fix the /tmp/initlondonFS.ora

:%s/boston/london/g

please fix:

*.db_name='boston'
*.control_files='/opt/oracle/oradata/londonFS/londonFS01.ctl','/opt/oracle/fast_recovery_area/londonFS/londonFS02.ctl'
*.log_archive_config='dg_config=(boston,bostonFS,london,londonFS,london2)'
*.log_file_name_convert='boston','londonFS'
*.log_archive_dest_2='SERVICE=boston ASYNC REOPEN=15 valid_for=(STANDBY_LOGFILES,STANDBY_ROLE) db_unique_name=boston'
*.db_unique_name=londonFS
*.fal_server=london

18.) Copy controlfiles

[oracle@vddl-ocme1-rac-01 tmp]$ ls -tlr /tmp/*.ctl
-rw-r-----. 1 oracle oinstall 18268160 Jun 16 16:01 /tmp/bostonFS.ctl

cp /tmp/bostonFS.ctl /opt/oracle/oradata/londonFS/londonFS01.ctl
cp /tmp/bostonFS.ctl /opt/oracle/fast_recovery_area/londonFS/londonFS02.ctl

19.) Copy Passwordfile

[oracle@vddl-ocme1-rac-01 tmp]$ ls -ltr /tmp/orapw*
-rw-r-----. 1 oracle oinstall 7680 Jun 16 16:02 /tmp/orapwboston

cp /tmp/orapwboston $ORACLE_HOME/dbs/orapwlondonFS

19.) env variables

please include londonFS in /etc/oratab

. oraenv
londonFS

20.) Create spfile for londonFS
sqlplus / as sysdba
create spfile from pfile='/tmp/initlondonFS.ora';
startup mount;

21.) On standby Server:

. oraenv
london

sqlplus / as sysdba

SQL> show parameter log_archive_dest_2

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string

alter system set log_archive_dest_2='SERVICE=londonFS SYNC REOPEN=15 valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=londonFS' scope=both;

Now the far sync for London database is done, this will be tested during the switchover tests.

Read Full Article
Visit website

Read for later

Articles marked as Favorite are saved for later viewing.
close
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview