Skip navigation

Dude!'s Blog

15 posts
Dude!

Dockpie

Posted by Dude! Sep 16, 2019
Dude!

Oracle Dismounter for Linux

Posted by Dude! Apr 25, 2019

 

 

1. About

 

The following demonstrates several ways how to run Oracle database tasks using cron, for example, to use sqlplus or rman.

 

OS: Oracle Linux

 

2. Configuring the Oracle Environment

 

Keep in mind that cron does not perform a user login and will not process the user login profile, such as .profile or .bash_profile, or execute .bashrc for interactive sessions.

 

It is necessary to define the Oracle command shell environment to run any Oracle Database applications. You can either define required environment variables by hand or use oraenv provided by Oracle. The oraenv script is typically located in /usr/local/bin unless specified otherwise.

 

You can define the Oracle database shell environment in a crontab file or shell script in several ways. Method 1 or 2 are probably the safest, but there is no real advantage one way or the other.

 

 

2.1 Method 1

 

#/bin/bash

ORACLE_SID=orcl  # your Oracle SID

ORAENV_ASK=NO

grep -wo "$ORACLE_SID" /etc/oratab >/dev/null \

&& { source /usr/local/bin/oraenv >/dev/null

     export NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'; } \

|| { echo "ERROR: Unknown Oracle SID $ORACLE_SID"; }

 

 

2.2 Method 2

 

#/bin/bash

ORACLE_SID=$(grep -wo orcl /etc/oratab) # your Oracle SID

if [ "$ORACLE_SID" ]; then

  . /usr/local/bin/oraenv <<<${ORACLE_SID} >\dev\null

  export NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'

else

  echo "ERROR: Unknown Oracle SID $ORACLE_SID"

fi

 

 

2.3 Method 3

 

#/bin/bash

ORACLE_SID=orcl # your Oracle SID

if [ "$(grep -wo $ORACLE_SID /etc/oratab)" ]; then

  export ORACLE_SID

  export ORACLE_BASE=/u01/app/oracle

  export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1

  export LD_LIBRARY_PATH=$ORACLE_HOME/lib

  export PATH=$ORACLE_HOME/bin:$PATH

  export NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'

else

  echo "ERROR: Unknown Oracle SID $ORACLE_SID"

fi

 

Note:

 

Any script that defines Oracle environment variables, as well as oraenv, needs to be source executed, so it applies to the current shell process. You can source execute a script using source or [dot space].

 

 

 

3. Scripting RMAN and SQLPLUS Examples

 

 

The below uses a simple EOI as the "here document" marker. This allows to use shell variables, e.g.: $spoolfile, but $ signs in SQL need to be escaped with a forward slash.

#/bin/bash

 

# This procedure uses a temporary SQL spoolfile.

spoolfile=/tmp/orafra_$(date +%N).tmp

sqlplus -s /nolog 1>/dev/null 2>&1 <<EOI

connect system/oracle_4U

set pages 0 feed off

spool ${spoolfile}

select * from v\$recovery_file_dest;

EOI

 

# Get the data and convert free_space to human readable.

values=$( cat ${spoolfile} )

values=$( echo $values ) # convert CR and blanks to blank.

fra_dir=$( cut -d' ' -f1 <<<${values} )

free_space=$( cut -d' ' -f3 <<<${values} )

free_space=$( numfmt --from=si --to=iec $free_space )

 

# Mail a message

mail_msg="Free space in $fra_dir: $free_space"

echo $mail_msg

mailx -s "FRA free" root@localhost <<<${mail_msg}

 

The next example uses "EOI" between double quotes, which does not require to escape $ signs in SQL, however, it won't translate shell variables. The example also redirects all sqlplus output into variable dump_loc.

#/bin/bash

 

 

dump_loc=$( sqlplus -s /nolog <<"EOI"

connect system/oracle_4U

set pages 0 feed off

select value from v$parameter

where name='background_dump_dest';

EOI

)

echo $dump_loc

 

Executing a simply command, using sqlplus -S to suppress the SQL banner, etc.

#/bin/bash

 

echo "shutdown immediate" | sqlplus -S / as sysdba

 

An alternative to using "here document" marker by creating a variable.

#/bin/bash

 

cmd="

backup incremental level 1 database plus archivelog delete input;

delete noprompt obsolete;

"

rman target / <<<${cmd}

1. About

 

The following demonstrates how to enable users tom and bob to modify cron as user oracle.

 

OS: Oracle Linux 7

 

2. Example

 

Login as root:

 

[root@localhost ~]# groupadd oracron

[root@localhost ~]# adduser oracle

 

[root@localhost /]# visudo

 

Insert the following (press i):

 

## Allow members of the oracron group to execute crontab -e as user oracle

%oracron ALL=(oracle) NOPASSWD: crontab -e

 

Save and exit (type :wq)

 

Add user tom and bob to the oracron group.

 

[root@localhost ~]# usermod -a -G oracron tom

[root@localhost ~]# usermod -a -G oracron bob

 

Login as user tom or bob and execute the following respectively:

 

[tom@localhost ~]$ sudo -u oracle crontab -e

[bob@localhost ~]$ sudo -u oracle crontab -e

 

 

 

This document is the result of my own research and testing and was written in the hope to provide useful information for members of the Oracle community. It does not substitute any documentation provided by Oracle. Use at your own risk.

 

The information herein is provided under the terms and conditions of http://www.oracle.com/us/legal/terms/index.html. Please do not plagiarize.

 

1. About

 

The following demonstrates how to use RMAN to restore database ORCL112 using a different file directory structure.

 

System: Oracle Linux 7.3 (VM VirtualBox), Oracle Database 11.2.0.1

 

 

 

This document is the result of my private research and was written in the hope to provide useful information for members of the Oracle community. It is not meant to be a reference or to substitute any documentation provided by Oracle. Use on your own risk.

 

The information herein is provided under the terms and conditions of http://www.oracle.com/us/legal/terms/index.html.

Please do not plagiarize.

 

Copyright 2018, Dude! @ Oracle Community

 

 

2. Example

 

2.1 Create a backup of the database


Set the Oracle environment:

 

[ oracle@701 ~]$ . oraenv > /dev/null <<< ORCL112

 

[oracle@701 ~]$ rman target /
connected to target database: ORCL112 (DBID=3497253474)

 

Note the DBID!

 

Configure Controlfile Autobackup ON:

 

RMAN> configure controlfile autobackup on;

 

RMAN> backup database plus archivelog delete input;

 

If you restoring on a different server, verify the following:

 

The server has access to the RMAN backups, for example: /u03/fast_recovery_area.

$ORACLE_HOME/dbs/orapwORCL112 password file has been copied.

/etc/oratab includes an entry for ORCL112.

 

2.2 Restore the spfile from autobackup

 

oracle@702 ~]$ . oraenv > /dev/null <<< ORCL112

 

[oracle@702 ~]$ cd $ORACLE_HOME/dbs

 

Note: If you are restoring on the same server, shutdown ORCL112 and delete the init or spfile first.

 

[oracle@702 dbs]$ rman target /
connected to target database (not started)

RMAN> set DBID 3497253474  
RMAN> startup nomount

startup failed: ORA-01078: failure in processing system parameters
starting Oracle instance without parameter file for retrieval of spfile

RMAN> restore spfile from autobackup
      db_recovery_file_dest='/u03/orafra' db_name='ORCL112'; 

recovery area destination: /u03/orafra
database name (or database unique name) used for search: ORCL112
channel ORA_DISK_1: AUTOBACKUP /u03/orafra/ORCL112/autobackup/2018_08_27/o1_mf_s_985266639_fr7q1j2m_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180827
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u03/orafra/ORCL112/autobackup/2018_08_27/o1_mf_s_985266639_fr7q1j2m_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 27-AUG-18



2.3 Create a pfile and modify the location of the control files

 

[oracle@702 dbs]$ echo "create pfile from spfile;" | sqlplus / as sysdba

 

Edit initORCL112.ora and modfiy location of controlfiles. E.g. /tmp/control01.ctl

 

2.4 Create a spfile and restore the control files

 

[oracle@702 dbs]$ echo "create spfile from pfile;" | sqlplus / as sysdba

 

[oracle@702 dbs]$ rman target /

RMAN> startup force nomount
(load new spfile)

RMAN> restore controlfile to '/tmp/control01.ctl' from autobackup;

recovery area destination: /u03/orafra
database name (or database unique name) used for search: ORCL112
channel ORA_DISK_1: AUTOBACKUP /u03/orafra/ORCL112/autobackup/2018_08_27/o1_mf_s_985265630_fr7p1z55_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180827
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u03/orafra/ORCL112/autobackup/2018_08_27/o1_mf_s_985265630_fr7p1z55_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
Finished restore at 27-AUG-18

Restore the second controlfile, as defined in init parameter file:

RMAN> restore controlfile to '/tmp/control02.ctl' from autobackup;

RMAN> startup force mount  

 

You may have to reset the incarnation, in case the restore may not find any backups:

 

For example: RMAN> reset database incarnation to 4;

 

RMAN> List of Database Incarnations

DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time

------- ------- -------- ---------------- --- ---------- ----------

1       1       ORCL112  3497253474       PARENT  1          24-AUG-13

2       2       ORCL112  3497253474       PARENT  925702     14-FEB-17

3       3       ORCL112  3497253474       PARENT  2041934    25-JUL-17

4       4       ORCL112  3497253474       CURRENT 2402794    27-AUG-18

 

 

2.5 Retrieve all database file names, including redo log and temp files:

 

[ oracle@702 dbs]$ sqlplus / as sysdba <<'EOI'
COLUMN NAME FORMAT a60
SELECT FILE#, NAME FROM V$DATAFILE
UNION
SELECT GROUP#, MEMBER FROM V$LOGFILE
UNION
SELECT FILE#, NAME FROM V$TEMPFILE;
EOI


     1 /u02/oradata/orcl112/redo01.log
     1 /u02/oradata/orcl112/system01.dbf
     1 /u02/oradata/orcl112/temp01.dbf
     2 /u02/oradata/orcl112/redo02.log
     2 /u02/oradata/orcl112/sysaux01.dbf
     3 /u02/oradata/orcl112/redo03.log
     3 /u02/oradata/orcl112/undotbs01.dbf
     4 /u02/oradata/orcl112/users01.dbf
     5 /u02/oradata/orcl112/example01.dbf

 

 

2.6 Restore the database

 

[oracle@702 dbs]$ rman target /

 

Find the lowest SCN in the archivelog backups to avoid recovering using the online redo

logs, which do not exist on the new server.

 

Note: You can probably also use RMAN "RECOVER NOREDO" instead of "UNTIL SCN". This

           performs a recovery using archivelogs, but will not look for redo logs.

 

 

RMAN> list backup of archivelog all;

  List of Archived Logs in backup set 64
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    2       2403184    27-AUG-18 2403207    27-AUG-18


RMAN> run {
      ALLOCATE CHANNEL ch1 DEVICE TYPE disk;
      set until scn 2403184;
      SET NEWNAME FOR DATAFILE 1 TO '/tmp/system01.dbf';
      SET NEWNAME FOR DATAFILE 2 TO '/tmp/sysaux01.dbf';
      SET NEWNAME FOR DATAFILE 3 TO '/tmp/undotbs01.dbf';
      SET NEWNAME FOR DATAFILE 4 TO '/tmp/users01.dbf';
      SET NEWNAME FOR DATAFILE 5 TO '/tmp/example01.dbf';
      SET NEWNAME FOR TEMPFILE 1 TO '/tmp/temp01.dbf';
      sql "ALTER DATABASE RENAME FILE ''/u02/oradata/orcl112/redo01.log'' 
                                   TO ''/tmp/redo01.log'' ";
      sql "ALTER DATABASE RENAME FILE ''/u02/oradata/orcl112/redo02.log''
                                   TO ''/tmp/redo02.log'' ";
      sql "ALTER DATABASE RENAME FILE ''/u02/oradata/orcl112/redo03.log''
                                   TO ''/tmp/redo03.log'' ";
      restore database;
      switch datafile all;
      switch tempfile all;
      recover database;
}

allocated channel: ch1
channel ch1: SID=133 device type=DISK

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

sql statement: ALTER DATABASE RENAME FILE ''/u02/oradata/orcl112/redo01.log''                                    TO ''/tmp/redo01.log'' 

sql statement: ALTER DATABASE RENAME FILE ''/u02/oradata/orcl112/redo02.log''                                   TO ''/tmp/redo02.log'' 

sql statement: ALTER DATABASE RENAME FILE ''/u02/oradata/orcl112/redo03.log''                                   TO ''/tmp/redo03.log'' 

Starting restore at 27-AUG-18
Starting implicit crosscheck backup at 27-AUG-18
Crosschecked 8 objects
Finished implicit crosscheck backup at 27-AUG-18

Starting implicit crosscheck copy at 27-AUG-18
Finished implicit crosscheck copy at 27-AUG-18

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

List of Cataloged Files
=======================
File Name: /u03/orafra/ORCL112/autobackup/2018_08_27/o1_mf_s_985265630_fr7p1z55_.bkp
File Name: /u03/orafra/ORCL112/autobackup/2018_08_27/o1_mf_s_985266639_fr7q1j2m_.bkp


channel ch1: starting datafile backup set restore
channel ch1: specifying datafile(s) to restore from backup set
channel ch1: restoring datafile 00001 to /tmp/system01.dbf
channel ch1: restoring datafile 00002 to /tmp/sysaux01.dbf
channel ch1: restoring datafile 00003 to /tmp/undotbs01.dbf
channel ch1: restoring datafile 00004 to /tmp/users01.dbf
channel ch1: restoring datafile 00005 to /tmp/example01.dbf
channel ch1: reading from backup piece /u03/orafra/ORCL112/backupset/2018_08_27/o1_mf_nnndf_TAG20180827T125255_fr7p07m7_.bkp
channel ch1: piece handle=/u03/orafra/ORCL112/backupset/2018_08_27/o1_mf_nnndf_TAG20180827T125255_fr7p07m7_.bkp tag=TAG20180827T125255
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:01:15
Finished restore at 27-AUG-18

datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=985267288 file name=/tmp/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=985267288 file name=/tmp/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=985267288 file name=/tmp/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=985267288 file name=/tmp/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=985267288 file name=/tmp/example01.dbf

renamed tempfile 1 to /tmp/temp01.dbf in control file

Starting recover at 27-AUG-18

starting media recovery

channel ch1: starting archived log restore to default destination
channel ch1: restoring archived log
archived log thread=1 sequence=34
channel ch1: reading from backup piece /u03/orafra/ORCL112/backupset/2018_08_27/o1_mf_annnn_TAG20180827T131010_fr7q0lcz_.bkp
channel ch1: piece handle=/u03/orafra/ORCL112/backupset/2018_08_27/o1_mf_annnn_TAG20180827T131010_fr7q0lcz_.bkp tag=TAG20180827T131010
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
archived log file name=/u03/orafra/ORCL112/archivelog/2018_08_27/o1_mf_1_34_fr7qotql_.arc thread=1 sequence=34
channel ch1: starting archived log restore to default destination
channel ch1: restoring archived log
archived log thread=1 sequence=1
channel ch1: reading from backup piece /u03/orafra/ORCL112/backupset/2018_08_27/o1_mf_annnn_TAG20180827T131010_fr7q0mnx_.bkp
channel ch1: piece handle=/u03/orafra/ORCL112/backupset/2018_08_27/o1_mf_annnn_TAG20180827T131010_fr7q0mnx_.bkp tag=TAG20180827T131010
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
archived log file name=/u03/orafra/ORCL112/archivelog/2018_08_27/o1_mf_1_1_fr7qow9l_.arc thread=1 sequence=1
channel default: deleting archived log(s)
archived log file name=/u03/orafra/ORCL112/archivelog/2018_08_27/o1_mf_1_34_fr7qotql_.arc RECID=95 STAMP=985267290
channel default: deleting archived log(s)
archived log file name=/u03/orafra/ORCL112/archivelog/2018_08_27/o1_mf_1_1_fr7qow9l_.arc RECID=96 STAMP=985267292
media recovery complete, elapsed time: 00:00:00
Finished recover at 27-AUG-18
released channel: ch1

 

2.7 Open the database and verify the result

 

RMAN> alter database open resetlogs;

database opened

sqlplus / as sysdba <<'EOI'
COLUMN NAME FORMAT a60
SELECT FILE#, NAME FROM V$DATAFILE
UNION
SELECT GROUP#, MEMBER FROM V$LOGFILE
UNION
SELECT FILE#, NAME FROM V$TEMPFILE;
EOI

     1 /tmp/redo01.log
     1 /tmp/system01.dbf
     1 /tmp/temp01.dbf
     2 /tmp/redo02.log
     2 /tmp/sysaux01.dbf
     3 /tmp/redo03.log
     3 /tmp/undotbs01.dbf
     4 /tmp/users01.dbf
     5 /tmp/example01.dbf

 

 

Ref: https://docs.oracle.com/cd/E18283_01/backup.112/e10642/rcmdupad.htm#CIHFIJJH

1. About

 

Starting with Oracle Database 12c, RMAN active database duplication supports a push or pull method:

 

Push method:

 

It relies on Oracle Net to internally transmit online image copies of the database files to the auxiliary instance. This is the same as in 11g.

 

Pull method:

 

The target database uses Oracle Net to transmit backup sets to the auxiliary location. The restore of the database to duplicate the target database is done at the auxiliary instance. To use the pull method, you specify the new "using backupset, or section size" clause. Active duplication will default to the new pull method depending on certain criteria. Please see the Oracle documentation for more information.

 

Note: Image copies or backup sets during active duplication are directly transmitted via Oracle Net and not written do disk.

 

The following demonstrates how to perform an active database duplication using backup sets, which is a new feature of 12c. The task is to duplicate database CDB1 to CDB1DUP on the same host, both using ASM.

 

System: Oracle Linux 7.3 (VM VirtualBox), Oracle Database 12.1.0.2

 

 

 

This document is the result of my private research and was written in the hope to provide useful information for members of the Oracle community. It is not meant to be a reference or to substitute any documentation provided by Oracle. Use on your own risk.

 

The information herein is provided under the terms and conditions of http://www.oracle.com/us/legal/terms/index.html.

Please do not plagiarize.

 

Copyright 2018, Dude! @ Oracle Community

 

 

2. Example

 

a) Login as user oracle:

Saturn:~ dude$ ssh oracle@10.0.70.1

oracle@10.0.70.1's password:

Last login: Mon Aug 27 09:58:26 2018 from 10.0.0.1

 

b) Set the Linux shell environment to CDB1:

[oracle@701 ~]$ . oraenv <<< CDB1 >/dev/null

 

c) Create a parameter file for the auxiliary instance CDB1DUP using CDB1 spfile:

[oracle@701 ~]$ cd $ORACLE_HOME/dbs

[oracle@701 dbs]$ echo 'create pfile from spfile;' | sqlplus -s / as sysdba

[oracle@701 dbs]$ mv initCDB1.ora initCDB1DUP.ora

 

Modify the pfile using a text editor such as gedit or vim, or command line:

[oracle@701 dbs]$ sed -i 's/cdb1/cdb1dup/g' initCDB1DUP.ora

[oracle@701 dbs]$ sed -i 's/CDB1/CDB1DUP/g' initCDB1DUP.ora

[oracle@701 dbs]$ sed -i "s/^*.control_files=.*/*.control_files='+DATA','+FRA'/" initCDB1DUP.ora

 

Example:

[oracle@701 dbs]$ cat initCDB1DUP.ora

CDB1DUP.__data_transfer_cache_size=0

CDB1DUP.__db_cache_size=704643072

CDB1DUP.__java_pool_size=16777216

CDB1DUP.__large_pool_size=33554432

CDB1DUP.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment

CDB1DUP.__pga_aggregate_target=603979776

CDB1DUP.__sga_target=1140850688

CDB1DUP.__shared_io_pool_size=67108864

CDB1DUP.__shared_pool_size=301989888

CDB1DUP.__streams_pool_size=0

*._catalog_foreign_restore=FALSE

*.audit_file_dest='/u01/app/oracle/admin/cdb1dup/adump'

*.audit_trail='db'

*.compatible='12.1.0.2.0'

*.control_files='+DATA'

*.db_block_size=8192

*.db_create_file_dest='+DATA'

*.db_domain='example.com'

*.db_name='cdb1dup'

*.db_recovery_file_dest='+FRA'

*.db_recovery_file_dest_size=12g

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=CDB1DUPXDB)'

*.enable_pluggable_database=true

*.local_listener='LISTENER_CDB1DUP'

*.log_archive_format='%t_%s_%r.dbf'

*.memory_target=1664m

*.open_cursors=300

*.processes=300

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_tablespace='UNDOTBS1'

 

d) Copy the Oracle password file and create directories:

[oracle@701 dbs]$ cp orapwCDB1 orapwCDB1DUP

[oracle@701 dbs]$ mkdir -p /u01/app/oracle/admin/cdb1dup/adump

 

e) Edit /etc/oratab:

[oracle@701 dbs]$ echo "CDB1DUP:/u01/app/oracle/product/12.1.0/dbhome_1:N" >> /etc/oratab

 

f) Edit tnsnames.ora:

 

Determin the locaiton of the default tnsnames.ora directory:

[oracle@701 dbs]$ tnsping cdb1

Used parameter files:

/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora

 

Use a text editor to modify the file, or command line:

[oracle@701 dbs]$ cd /u01/app/oracle/product/12.1.0/dbhome_1/network/admin

[oracle@701 dbs]$ cp tnsnames.ora tnsnames.bck

[oracle@701 dbs]$ cat >> tnsnames.ora <<EOM

 

LISTENER_CDB1DUP =

  (ADDRESS = (PROTOCOL = TCP)(HOST = 701.example.com)(PORT = 1521))

 

CDB1DUP =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 701.example.com)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = cdb1dup.example.com)

    )

  )

 

EOM

 

g) Edit listener.ora

 

Determine the location of the listener configuration file. The Listener is typcialy owned by the Gi installation:

[oracle@701 admin]$ lsnrctl status

Listener Parameter File   /u01/app/grid/product/12.1.0/grid/network/admin/listener.ora

 

The following applies to Grid role separation:

[oracle@701 admin]$ su - grid

Password:

[grid@701 grid]$ . oraenv <<< +ASM >/dev/null

[grid@701 grid]$ cd /u01/app/grid/product/12.1.0/grid/network/admin/

 

[grid@701 admin]$ cp listener.ora listener.bck

[grid@701 admin]$ cat >> listener.ora <<EOM

 

SID_LIST_LISTENER =

  (SID_LIST =

      (SID_DESC =

      (SID_NAME = CDB1DUP)

      (ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/db_1)

      (GLOBAL_DBNAME = cdb1dup.example.com)

    )

  )

 

EOM

 

For the change to take affect, the listener needs to be reloaded - this will not interrupt existing connections.

[grid@701 admin]$ lsnrctl services

...

Service "cdb1dup.example.com" has 1 instance(s).

  Instance "CDB1DUP", status UNKNOWN, has 1 handler(s) for this service...

 

You can now logoff from the Grid account and return back to the Oracle user:

 

h) Create spfile and start the auxiliary instance (CDB1DUP):

[oracle@701 ~]$ . oraenv <<< CDB1DUP >/dev/null

[oracle@701 ~]$ cd $ORACLE_HOME/dbs

[oracle@701 dbs]$ echo 'create spfile from pfile;' | sqlplus -s / as sysdba

[oracle@701 dbs]$ echo "startup nomount;" | sqlplus / as sysdba

 

i) Connect RMAN to target and auxiliary database:

[oracle@701 ~]$ rman target sys/oracle_4U@CDB1 auxiliary sys/oracle_4U@CDB1DUP

 

connected to target database: CDB1 (DBID=909549395)

connected to auxiliary database: CDB1DUP (not mounted)

 

j) Duplicate the database:

RMAN> duplicate target database to cdb1dup from active database using backupset;

 

Starting Duplicate Db at 27-AUG-18

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=251 device type=DISK

current log archived

 

contents of Memory Script:

{

   sql clone "alter system set  control_files =

  ''+DATA/CDB1DUP/CONTROLFILE/current.271.985264461'', ''+FRA/CDB1DUP/CONTROLFILE/current.305.985264461'' comment=

''Set by RMAN'' scope=spfile";

   sql clone "alter system set  db_name =

''CDB1'' comment=

''Modified by RMAN duplicate'' scope=spfile";

   sql clone "alter system set  db_unique_name =

''CDB1DUP'' comment=

''Modified by RMAN duplicate'' scope=spfile";

   shutdown clone immediate;

   startup clone force nomount

   restore clone from service  'CDB1' primary controlfile;

   alter clone database mount;

}

executing Memory Script

 

sql statement: alter system set  control_files =   ''+DATA/CDB1DUP/CONTROLFILE/current.271.985264461'', ''+FRA/CDB1DUP/CONTROLFILE/current.305.985264461'' comment= ''Set by RMAN'' scope=spfile

 

sql statement: alter system set  db_name =  ''CDB1'' comment= ''Modified by RMAN duplicate'' scope=spfile

 

sql statement: alter system set  db_unique_name =  ''CDB1DUP'' comment= ''Modified by RMAN duplicate'' scope=spfile

 

Oracle instance shut down

 

Oracle instance started

 

Total System Global Area    1744830464 bytes

 

Fixed Size                     2925312 bytes

Variable Size               1023413504 bytes

Database Buffers             704643072 bytes

Redo Buffers                  13848576 bytes

 

Starting restore at 27-AUG-18

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=249 device type=DISK

 

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: restoring control file

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:06

output file name=+DATA/CDB1DUP/CONTROLFILE/current.271.985264461

output file name=+FRA/CDB1DUP/CONTROLFILE/current.305.985264461

Finished restore at 27-AUG-18

 

database mounted

 

contents of Memory Script:

{

   set newname for clone datafile  1 to new;

   set newname for clone datafile  3 to new;

   set newname for clone datafile  4 to new;

   set newname for clone datafile  5 to new;

   set newname for clone datafile  6 to new;

   set newname for clone datafile  7 to new;

   set newname for clone datafile  8 to new;

   set newname for clone datafile  9 to new;

   set newname for clone datafile  10 to new;

   set newname for clone datafile  11 to new;

   restore

   from service  'CDB1'   clone database

   ;

   sql 'alter system archive log current';

}

executing Memory Script

 

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

 

Starting restore at 27-AUG-18

using channel ORA_AUX_DISK_1

 

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00001 to +DATA

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:56

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00003 to +DATA

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00004 to +DATA

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00005 to +DATA

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:26

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00006 to +DATA

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00007 to +DATA

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:36

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00008 to +DATA

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:26

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00009 to +DATA

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:46

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00010 to +DATA

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00011 to +DATA

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:26

Finished restore at 27-AUG-18

 

sql statement: alter system archive log current

current log archived

 

contents of Memory Script:

{

   restore clone force from service  'CDB1'

           archivelog from scn  3086144;

   switch clone datafile all;

}

executing Memory Script

 

Starting restore at 27-AUG-18

using channel ORA_AUX_DISK_1

 

channel ORA_AUX_DISK_1: starting archived log restore to default destination

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: restoring archived log

archived log thread=1 sequence=56

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02

channel ORA_AUX_DISK_1: starting archived log restore to default destination

channel ORA_AUX_DISK_1: using network backup set from service CDB1

channel ORA_AUX_DISK_1: restoring archived log

archived log thread=1 sequence=57

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01

Finished restore at 27-AUG-18

 

datafile 1 switched to datafile copy

input datafile copy RECID=17 STAMP=985265074 file name=+DATA/CDB1DUP/DATAFILE/system.257.985264723

datafile 3 switched to datafile copy

input datafile copy RECID=18 STAMP=985265074 file name=+DATA/CDB1DUP/DATAFILE/sysaux.258.985264779

datafile 4 switched to datafile copy

input datafile copy RECID=19 STAMP=985265075 file name=+DATA/CDB1DUP/DATAFILE/undotbs1.279.985264833

datafile 5 switched to datafile copy

input datafile copy RECID=20 STAMP=985265075 file name=+DATA/CDB1DUP/48661CA91C1513F6E0530146000AA754/DATAFILE/system.280.985264849

datafile 6 switched to datafile copy

input datafile copy RECID=21 STAMP=985265075 file name=+DATA/CDB1DUP/DATAFILE/users.281.985264875

datafile 7 switched to datafile copy

input datafile copy RECID=22 STAMP=985265075 file name=+DATA/CDB1DUP/48661CA91C1513F6E0530146000AA754/DATAFILE/sysaux.282.985264877

datafile 8 switched to datafile copy

input datafile copy RECID=23 STAMP=985265075 file name=+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/system.283.985264913

datafile 9 switched to datafile copy

input datafile copy RECID=24 STAMP=985265075 file name=+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/sysaux.284.985264939

datafile 10 switched to datafile copy

input datafile copy RECID=25 STAMP=985265075 file name=+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/users.285.985264985

datafile 11 switched to datafile copy

input datafile copy RECID=26 STAMP=985265075 file name=+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/example.286.985264985

 

contents of Memory Script:

{

   set until scn  3086475;

   recover

   clone database

    delete archivelog

   ;

}

executing Memory Script

 

executing command: SET until clause

 

Starting recover at 27-AUG-18

using channel ORA_AUX_DISK_1

 

starting media recovery

 

archived log for thread 1 with sequence 56 is already on disk as file +FRA/CDB1DUP/ARCHIVELOG/2018_08_27/thread_1_seq_56.306.985265073

archived log for thread 1 with sequence 57 is already on disk as file +FRA/CDB1DUP/ARCHIVELOG/2018_08_27/thread_1_seq_57.307.985265073

archived log file name=+FRA/CDB1DUP/ARCHIVELOG/2018_08_27/thread_1_seq_56.306.985265073 thread=1 sequence=56

archived log file name=+FRA/CDB1DUP/ARCHIVELOG/2018_08_27/thread_1_seq_57.307.985265073 thread=1 sequence=57

media recovery complete, elapsed time: 00:00:01

Finished recover at 27-AUG-18

Oracle instance started

 

Total System Global Area    1744830464 bytes

 

Fixed Size                     2925312 bytes

Variable Size               1023413504 bytes

Database Buffers             704643072 bytes

Redo Buffers                  13848576 bytes

 

contents of Memory Script:

{

   sql clone "alter system set  db_name =

''CDB1DUP'' comment=

''Reset to original value by RMAN'' scope=spfile";

   sql clone "alter system reset  db_unique_name scope=spfile";

}

executing Memory Script

 

sql statement: alter system set  db_name =  ''CDB1DUP'' comment= ''Reset to original value by RMAN'' scope=spfile

 

sql statement: alter system reset  db_unique_name scope=spfile

Oracle instance started

 

Total System Global Area    1744830464 bytes

 

Fixed Size                     2925312 bytes

Variable Size               1023413504 bytes

Database Buffers             704643072 bytes

Redo Buffers                  13848576 bytes

sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CDB1DUP" RESETLOGS ARCHIVELOG

  MAXLOGFILES     16

  MAXLOGMEMBERS      3

  MAXDATAFILES     1024

  MAXINSTANCES     8

  MAXLOGHISTORY      292

LOGFILE

  GROUP   1  SIZE 50 M ,

  GROUP   2  SIZE 50 M ,

  GROUP   3  SIZE 50 M

DATAFILE

  '+DATA/CDB1DUP/DATAFILE/system.257.985264723',

  '+DATA/CDB1DUP/48661CA91C1513F6E0530146000AA754/DATAFILE/system.280.985264849',

  '+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/system.283.985264913'

CHARACTER SET AL32UTF8

 

contents of Memory Script:

{

   set newname for clone tempfile  1 to new;

   set newname for clone tempfile  2 to new;

   set newname for clone tempfile  3 to new;

   switch clone tempfile all;

   catalog clone datafilecopy  "+DATA/CDB1DUP/DATAFILE/sysaux.258.985264779",

"+DATA/CDB1DUP/DATAFILE/undotbs1.279.985264833",

"+DATA/CDB1DUP/DATAFILE/users.281.985264875",

"+DATA/CDB1DUP/48661CA91C1513F6E0530146000AA754/DATAFILE/sysaux.282.985264877",

"+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/sysaux.284.985264939",

"+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/users.285.985264985",

"+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/example.286.985264985";

   switch clone datafile all;

}

executing Memory Script

 

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

 

renamed tempfile 1 to +DATA in control file

renamed tempfile 2 to +DATA in control file

renamed tempfile 3 to +DATA in control file

 

cataloged datafile copy

datafile copy file name=+DATA/CDB1DUP/DATAFILE/sysaux.258.985264779 RECID=1 STAMP=985265125

cataloged datafile copy

datafile copy file name=+DATA/CDB1DUP/DATAFILE/undotbs1.279.985264833 RECID=2 STAMP=985265125

cataloged datafile copy

datafile copy file name=+DATA/CDB1DUP/DATAFILE/users.281.985264875 RECID=3 STAMP=985265125

cataloged datafile copy

datafile copy file name=+DATA/CDB1DUP/48661CA91C1513F6E0530146000AA754/DATAFILE/sysaux.282.985264877 RECID=4 STAMP=985265125

cataloged datafile copy

datafile copy file name=+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/sysaux.284.985264939 RECID=5 STAMP=985265125

cataloged datafile copy

datafile copy file name=+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/users.285.985264985 RECID=6 STAMP=985265125

cataloged datafile copy

datafile copy file name=+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/example.286.985264985 RECID=7 STAMP=985265125

 

datafile 3 switched to datafile copy

input datafile copy RECID=1 STAMP=985265125 file name=+DATA/CDB1DUP/DATAFILE/sysaux.258.985264779

datafile 4 switched to datafile copy

input datafile copy RECID=2 STAMP=985265125 file name=+DATA/CDB1DUP/DATAFILE/undotbs1.279.985264833

datafile 6 switched to datafile copy

input datafile copy RECID=3 STAMP=985265125 file name=+DATA/CDB1DUP/DATAFILE/users.281.985264875

datafile 7 switched to datafile copy

input datafile copy RECID=4 STAMP=985265125 file name=+DATA/CDB1DUP/48661CA91C1513F6E0530146000AA754/DATAFILE/sysaux.282.985264877

datafile 9 switched to datafile copy

input datafile copy RECID=5 STAMP=985265125 file name=+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/sysaux.284.985264939

datafile 10 switched to datafile copy

input datafile copy RECID=6 STAMP=985265125 file name=+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/users.285.985264985

datafile 11 switched to datafile copy

input datafile copy RECID=7 STAMP=985265125 file name=+DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/example.286.985264985

 

contents of Memory Script:

{

   Alter clone database open resetlogs;

}

executing Memory Script

 

database opened

 

contents of Memory Script:

{

   sql clone "alter pluggable database all open";

}

executing Memory Script

 

sql statement: alter pluggable database all open

Finished Duplicate Db at 27-AUG-18

 

RMAN>

 

k) Database files and RMAN backup data of CDB1:

[oracle@701 ~]$ . oraenv <<< CDB1 >/dev/null

[oracle@701 ~]$ rman target /

 

Recovery Manager: Release 12.1.0.2.0 - Production on Mon Aug 27 12:48:43 2018

 

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

 

connected to target database: CDB1 (DBID=909549395)

 

RMAN> list backup;

using target database control file instead of recovery catalog

specification does not match any backup in the repository

 

RMAN> list copy of database;

specification does not match any datafile copy in the repository

 

RMAN> report schema;

using target database control file instead of recovery catalog

Report of database schema for database with db_unique_name CDB1

 

List of Permanent Datafiles

===========================

File Size(MB) Tablespace           RB segs Datafile Name

---- -------- -------------------- ------- ------------------------

1    800      SYSTEM               YES     +DATA/CDB1/DATAFILE/system.261.935831869

3    790      SYSAUX               NO      +DATA/CDB1/DATAFILE/sysaux.273.935831823

4    380      UNDOTBS1             YES     +DATA/CDB1/DATAFILE/undotbs1.278.935831915

5    250      PDB$SEED:SYSTEM      NO      +DATA/CDB1/FD9AC20F64D244D7E043B6A9E80A2F2F/DATAFILE/system.264.935831965

6    5        USERS                NO      +DATA/CDB1/DATAFILE/users.262.935831913

7    550      PDB$SEED:SYSAUX      NO      +DATA/CDB1/FD9AC20F64D244D7E043B6A9E80A2F2F/DATAFILE/sysaux.265.935831965

8    260      PDBORCL:SYSTEM       NO      +DATA/CDB1/FD9BD2B44413096FE043B6A9E80ABC28/DATAFILE/system.276.935832599

9    590      PDBORCL:SYSAUX       NO      +DATA/CDB1/FD9BD2B44413096FE043B6A9E80ABC28/DATAFILE/sysaux.275.935832599

10   5        PDBORCL:USERS        NO      +DATA/CDB1/FD9BD2B44413096FE043B6A9E80ABC28/DATAFILE/users.270.935832599

11   1243     PDBORCL:EXAMPLE      NO      +DATA/CDB1/FD9BD2B44413096FE043B6A9E80ABC28/DATAFILE/example.277.935832599

 

List of Temporary Files

=======================

File Size(MB) Tablespace           Maxsize(MB) Tempfile Name

---- -------- -------------------- ----------- --------------------

1    197      TEMP                 32767       +DATA/CDB1/TEMPFILE/temp.266.935831961

2    100      PDB$SEED:TEMP        32767       +DATA/CDB1/FD9AC20F64D244D7E043B6A9E80A2F2F/DATAFILE/pdbseed_temp012017-02-13_09-19-53-am.dbf

3    197      PDBORCL:TEMP         32767       +DATA/CDB1/FD9BD2B44413096FE043B6A9E80ABC28/DATAFILE/pdborcl_temp012017-02-13_09-30-37-am.dbf

 

RMAN> select name from v$controlfile;

+DATA/CDB1/CONTROLFILE/current.272.935831955

+FRA/CDB1/CONTROLFILE/current.256.935831955

 

l) Database files and RMAN backup data of CDB1DUP:

[oracle@701 ~]$ . oraenv <<< CDB1DUP >/dev/null

[oracle@701 ~]$ rman target /

 

Recovery Manager: Release 12.1.0.2.0 - Production on Mon Aug 27 12:49:59 2018

 

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

 

connected to target database: CDB1DUP (DBID=1460864354)

 

RMAN> list backup;

using target database control file instead of recovery catalog

 

List of Backup Sets

===================

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

1       Full    17.52M     DISK        00:00:04     27-AUG-18    

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20180827T124602

        Piece Name: +FRA/CDB1DUP/AUTOBACKUP/2018_08_27/s_985265162.311.985265165

  SPFILE Included: Modification time: 27-AUG-18

  SPFILE db_unique_name: CDB1DUP

  Control File Included: Ckp SCN: 3088089      Ckp time: 27-AUG-18

 

RMAN> list copy of database;

specification does not match any datafile copy in the repository

 

RMAN> report schema;

Report of database schema for database with db_unique_name CDB1DUP

 

List of Permanent Datafiles

===========================

File Size(MB) Tablespace           RB segs Datafile Name

---- -------- -------------------- ------- ------------------------

1    800      SYSTEM               YES     +DATA/CDB1DUP/DATAFILE/system.257.985264723

3    790      SYSAUX               NO      +DATA/CDB1DUP/DATAFILE/sysaux.258.985264779

4    380      UNDOTBS1             YES     +DATA/CDB1DUP/DATAFILE/undotbs1.279.985264833

5    250      PDB$SEED:SYSTEM      NO      +DATA/CDB1DUP/48661CA91C1513F6E0530146000AA754/DATAFILE/system.280.985264849

6    5        USERS                NO      +DATA/CDB1DUP/DATAFILE/users.281.985264875

7    550      PDB$SEED:SYSAUX      NO      +DATA/CDB1DUP/48661CA91C1513F6E0530146000AA754/DATAFILE/sysaux.282.985264877

8    260      PDBORCL:SYSTEM       NO      +DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/system.283.985264913

9    600      PDBORCL:SYSAUX       NO      +DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/sysaux.284.985264939

10   5        PDBORCL:USERS        NO      +DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/users.285.985264985

11   1243     PDBORCL:EXAMPLE      NO      +DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/DATAFILE/example.286.985264985

 

List of Temporary Files

=======================

File Size(MB) Tablespace           Maxsize(MB) Tempfile Name

---- -------- -------------------- ----------- --------------------

1    197      TEMP                 32767       +DATA/CDB1DUP/TEMPFILE/temp.290.985265141

2    100      PDB$SEED:TEMP        32767       +DATA/CDB1DUP/48661CA91C1513F6E0530146000AA754/TEMPFILE/temp.291.985265149

3    197      PDBORCL:TEMP         32767       +DATA/CDB1DUP/486643159D4918D8E0530146000A75B0/TEMPFILE/temp.292.985265155

 

RMAN> select name from v$controlfile;

+DATA/CDB1DUP/CONTROLFILE/current.271.985264461

+FRA/CDB1DUP/CONTROLFILE/current.305.985264461

 

End

Dude!

VNCpilot

Posted by Dude! Jun 17, 2018
Dude!

automount cifs OL7

Posted by Dude! Oct 12, 2017

Regarding https://docs.oracle.com/cd/E52668_01/E54669/html/ol7-s4-fsadmin.html

 

According to my tests, using a file to specify login credentials and CIFS only works when /sbin/mount.cifs exists. Otherwise, you'll see a message like: "CIFS VFS: No username specified". This requires the installation of the cifs-utils package.

 

For example:

 

#  yum install autofs cifs-utils

 

/etc/auto.master:

+auto.master

/mnt /etc/auto.backup --timeout=600 --ghost

 

/etc/auto.backup:

backup -fstype=cifs,rw,noperm,credentials=/root/.backup_credentials ://server1.example.com/backup

 

/root/.backup_credentials:

username=dude

password=mysecret

 

# systemctl enable autofs

# systemctl restart autofs

 

Usage:

cd /mnt

cd backup

ls

How to Resize LVM Root in Oracle Linux 7

 

Author: Dude!

 

 

 

1. About

This document explains how to resize the LVM root and home volumes in order to reclaim space to create additional files systems. The tasks includes a backup and restore in rescue mode to USB media using the xfsdump and xfsrestore utilities, and adding additional LVM volumes. The instructions are written for Red Hat Enterprise Linux 7 and apply to all derivatives. The system used in the example is a minimal Oracle Linux 7.3 installation on a 64 GB hard drive.

 

The information is provided under the terms and conditions of http://www.oracle.com/us/legal/terms/index.html.

Please do not plagiarize. Use on your own risk.

 

Copyright 2017, Dude@OTN

 

 

2. Analysis

 

Below example shows the space utilization of a minimal Oracle Linux 7.3 installation on a 64 GB hard drive. The installation was done using automatic partitioning and the installer created a 40 GB LVM root and a 20 GB home volume.

 

For the current project, the size of the root and home volumes are not necessary, and instead, 47 GB of disk space is needed to create additional LVM volumes named u01, u02 and u03. Volumes u02 and u03 should to be using an older EXT3 file system for reasons of application compatibility.

 

Analyze the disk space usage of the root and home file systems.

[root@ol1 ~]# df -PhT

Filesystem          Type      Size  Used Avail Use% Mounted on

devtmpfs            devtmpfs  2.0G     0  2.0G   0% /dev

tmpfs               tmpfs     2.0G     0  2.0G   0% /dev/shm@

tmpfs               tmpfs     2.0G  8.4M  2.0G   1% /run

tmpfs               tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup

/dev/mapper/ol-root xfs       40G  1.2G   39G   3% /

/dev/sda1           xfs      1014M  155M  859M  16% /boot

/dev/mapper/ol-home xfs        20G   33M   20G   1% /home

tmpfs               tmpfs     396M     0  396M   0% /run/user/0

 

Analyze current LVM volumes.

[root@ol1 ~]# lvs --segments -o +devices

  LV   VG Attr       #Str Type   SSize  Devices       

  home ol -wi-ao----    1 linear 19.39g /dev/sda2(992)

  root ol -wi-ao----    1 linear 39.72g /dev/sda2(5957)

  swap ol -wi-ao----    1 linear  3.88g /dev/sda2(0)  

 

 

The LVM volumes required are as following:

 

LVM VolumeCurrentUsedNewFS#
/dev/ol/root40 GB1.2 GB9 GBXFS- 31 GB
/dev/ol/home20 GB33 MB3 GBXFS- 17 GB
/dev/ol/u012 GBXFS+  2 GB
/dev/ol/u0215 GBEXT3+ 15 GB
/dev/ol/u0330 GBEXT3+ 30 GB

 

 

By reducing the LVM root volume to 9 GB and home to 3 GB, 48 GB of volume space can be reclaimed, which is enough to create volumes u01, u02 and u03. To avoid free space fragmentation however, both, root and home volumes will need to be relocated. A complete backup and restore of the root and home volume to external USB should be an appropriate safeguard and assist in the process.

 

 

Note:

Starting with RHEL 7 and consequently Oracle Linux 7,  XFS has become the default file system. According to XFS FAQ, it is not possible to reduce a XFS volume and the only way to shrink it is to do a complete dump, mkfs and restore.

 

 

3. Requirements

 

The following will be required:

 

  • Oracle Linux 7 standard installation DVD.
  • Direct or remote access to the physical server console.
  • External hard drive - 8 GB USB flash drive will be sufficient.

 

4. Rescue Mode

 

The LVM root volume cannot be removed while in use. It is therefore necessary to start the computer from external media and to access the system in rescue mode, also formerly known as single user mode. This will also quiescence the volumes and ensure no applications are running and no regular users are accessing the system when performing the backup and restore operations.

 

In order to start the computer from DVD or USB you may have to enter the PC boot menu, or change the boot order in the PC BIOS configuration. Please see the instruction manual of your computer for the details.

 

To start the computer into rescue mode, insert the standard Oracle Linux installation media and restart the computer.

If you are using VirtualBox, you can mount the ISO disk image and restart the guest OS.

 

Use the up and down arrow key to select Troubleshooting.

Screen Shot 2017-01-06 at 2.55.35 AM.jpg

 

Select Rescue a Oracle Linux system.

Select option 3 - Skip to shell.

Screen Shot 2017-01-06 at 3.00.41 AM.jpg

 

 

Tip:

If you are not fancy using the console, the following will let you connect using your ssh client from your desktop, assuming DHCP is available.

 

 

[anaconda root@localhost ~]# ip link show

[anaconda root@localhost ~]# ip link set enp0s3 down

[anaconda root@localhost ~]# dhclient enp0s3

[anaconda root@localhost ~]# ip address | grep global

[anaconda root@localhost ~]# ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key

[anaconda root@localhost ~]# /sbin/sshd -f /etc/ssh/sshd_config.anaconda

 

Screen Shot 2017-01-08 at 3.49.56 AM.jpg


After that, you should be able to connect with a ssh client. No prompt for password !!!

Screen Shot 2017-01-08 at 3.27.23 PM.jpg

 

 

 

5. Backup to USB

 

You will need a USB flash disk or hard drive in order to backup the LVM root and home volume.

Make it has enough capacity. As mentioned earlier, 8 GB should be sufficient.

 

Tip:To use USB in Oracle VirtualBox, attach the USB drive to your host system and select Settings from the VirtualBox Machine menu. Select Ports, then USB and add the USB device using the flash drive + symbol, where you can choose the device from the list of detected items. Press OK and unplug and re-insert the USB media so that VirtualBox can capture the device.

 

Plug in the USB device.

 

Determine the USB media device name (/dev/sdb).
[anaconda root@localhost ~]# dmesg | tac | grep -m 1 "removable"

[  658.877169] sd 3:0:0:0: [sdb] Attached SCSI removable disk ]

Partition and initialize the USB disk.

Warning: All existing data on the USB media will be erased!

[anaconda root@localhost ~]# parted -s /dev/sdb mklabel msdos mkpart primary 1 -- -1

[anaconda root@localhost ~]# parted -s /dev/sdb print

Model: SanDisk U3 Contour (scsi)

Disk /dev/sdb: 8213MB

Sector size (logical/physical): 512B/512B

Partition Table: mdse.

Disk Flags:
Number  Start   End     Size    Type     File system  Flags

1      1049kB  8212MB  8211MB  primary

Initialize partition no. 1, e.g.: /dev/sdb1

[anaconda root@localhost ~]# mkdosfs -n Linuxback -v -F 32 -I /dev/sdb1

mkfs.fat 3.0.20 (12 Jun 2013)

/dev/sdb1 has 253 heads and 62 sectors per track,

logical sector size is 512,

using 0xf8 media descriptor, with 16037888 sectors;

filesystem has 2 32-bit FATs and 8 sectors per cluster.

FAT size is 15632 sectors, and provides 2000824 clusters.

There are 32 reserved sectors.

Volume ID is 89cea7e0, volume label LINUXBACK  .

 

 

Mount the USB file system.

[anaconda root@localhost ~]# mkdir /mnt/usb

[anaconda root@localhost ~]# mount /dev/sdb1 /mnt/usb

 

[anaconda root@localhost ~]# df -hT /mnt/usb

Filesystem     Type  Size  Used Avail Use% Mounted on

/dev/sdb1      vfat  7.7G  4.0K  7.7G   1% /mnt/usb

Activate the LVM volumes.

[anaconda root@localhost ~]# vgchange -a y

3 logical volume(s) in volume group "ol" now active

[anaconda root@localhost ~]# lvscan

  ACTIVE            '/dev/ol/swap' [3.88 GiB] inherit

  ACTIVE            '/dev/ol/home' [19.39 GiB] inherit

  ACTIVE            '/dev/ol/root' [39.72 GiB] inherit

Mount LVM home and root and verify the correct file systems are mounted.

[anaconda root@localhost ~]# mkdir /mnt/root

[anaconda root@localhost ~]# mkdir /mnt/home

[anaconda root@localhost ~]# mount /dev/ol/root /mnt/root

[anaconda root@localhost ~]# mount /dev/ol/home /mnt/home

 

[anaconda root@localhost ~]# df -hT /mnt/home /mnt/root

Filesystem          Type  Size  Used Avail Use% Mounted on

/dev/mapper/ol-home xfs    20G   33M   20G   1% /mnt/home

/dev/mapper/ol-root xfs    40G  1.2G   39G   3% /mnt/root

 

 

Create a backup of the LVM root and home volume using the xfsdump utility.

 

When prompted for session and media label, simply enter "root" and "home".

(Below shows only partial output.)

[anaconda root@localhost ~]# xfsdump -f /mnt/usb/root.dmp /mnt/root

please enter label for this dump session (timeout in 300 sec)

-> root

please enter label for media in drive 0 (timeout in 300 sec)

-> root

xfsdump: media file size 1113760064 bytes

xfsdump: dump complete: 74 seconds elapsed

xfsdump: Dump Summary:

xfsdump:   stream 0 /mnt/usb/root.dmp OK (success)

xfsdump: Dump Status: SUCCESS

 

[anaconda root@localhost ~]# xfsdump -f /mnt/usb/home.dmp /mnt/home

please enter label for this dump session (timeout in 300 sec)

-> home

please enter label for media in drive 0 (timeout in 300 sec)

-> home

xfsdump: media file size 25600 bytes

 

xfsdump: dump complete: 2 seconds elapsed

xfsdump: Dump Summary:

xfsdump:   stream 0 /mnt/usb/home.dmp OK (success)

xfsdump: Dump Status: SUCCESS

 

Verify the results.

[anaconda root@localhost ~]# ls -l /mnt/usb

total 1088456

-rwxr-xr-x. 1 root root      25600 Jan  8 14:38 home.dmp

-rwxr-xr-x. 1 root root 1113760064 Jan  8 14:35 root.dmp

 

Unmount the USB backup, LVM root and home volumes.

[anaconda root@localhost ~]# umount /mnt/usb /mnt/root /mnt/home

 

 

 

6. Resizing LVM Root and Home

 

As mentioned earlier, XFS file systems cannot be resized and will essentially have to be erased and re-initialized.

 

Note:

Be sure to have completed the instructions so far. Do not continue if you do not have a backup of the LVM root and home volume, since the data is going to be deleted.

 

 

Deactivate and remove the LVM root and home volumes.

Warning: All data on these volumes will be lost!

[anaconda root@localhost ~]# vgchange -a n

  0 logical volume(s) in volume group "ol" now active

[anaconda root@localhost ~]# lvremove /dev/ol/root /dev/ol/home

  Logical volume "home" successfully removed

  Logical volume "root" successfully removed

 

Verify the physical LVM free volume space has increased.

[anaconda root@localhost ~]# pvs

  PV         VG Fmt  Attr PSize  PFree

  /dev/sda2  ol lvm2 a--  63.00g 59.12g

 

Recreate the LVM root and home volume.

Respond with "y" when prompted to wipe the previous XFS signature.

[anaconda root@localhost ~]# lvcreate -L 9G -n root ol

WARNING: xfs signature detected on /dev/ol/root at offset 0. Wipe it? [y/n]: y

  Wiping xfs signature on /dev/ol/root.

  Logical volume "root" created.

[anaconda root@localhost ~]# lvcreate -L 3G -n home ol

  Logical volume "home" created.


[anaconda root@localhost ~]# pvs

  PV         VG Fmt  Attr PSize  PFree

  /dev/sda2  ol lvm2 a--  63.00g 47.12g

 

 

Active LVM and show available LVM volumes.

[anaconda root@localhost ~]# vgchange -a y

  3 logical volume(s) in volume group "ol" now active

[anaconda root@localhost ~]# lvscan

  ACTIVE            '/dev/ol/swap' [3.88 GiB] inherit

  ACTIVE            '/dev/ol/root' [9.00 GiB] inherit

  ACTIVE            '/dev/ol/home' [3.00 GiB] inherit

 

Initialize and mount the LVM root and home volumes.
(Below shows only partial output.)

[anaconda root@localhost ~]# mkfs.xfs -L root /dev/ol/root

[anaconda root@localhost ~]# mkfs.xfs -L home /dev/ol/home

 

 

 

7. Restoring LVM Root and Home

 

Mount the LVM root and home volumes.

[anaconda root@localhost ~]# mount /dev/ol/root /mnt/root

[anaconda root@localhost ~]# mount /dev/ol/home /mnt/home

 

Verify that the correct volumes are mounted.

[anaconda root@localhost ~]# df -PhT /mnt/root /mnt/home

Filesystem          Type  Size  Used Avail Use% Mounted on

/dev/mapper/ol-root xfs   9.0G   33M  9.0G   1% /mnt/root

/dev/mapper/ol-home xfs   3.0G   33M  3.0G   2% /mnt/home

 

Mount the USB backup media.

[anaconda root@localhost ~]# mount /dev/sdb1 /mnt/usb

 

[anaconda root@localhost ~]# ls -l /mnt/usb

total 1088456

-rwxr-xr-x. 1 root root      25600 Jan  8 14:38 home.dmp

-rwxr-xr-x. 1 root root 1113760064 Jan  8 14:35 root.dmp

 

Restore the LVM root and home volumes.

(Below shows only partial output.)

[anaconda root@localhost ~]# xfsrestore -f /mnt/usb/root.dmp /mnt/root

xfsrestore: restore complete: 206 seconds elapsed

xfsrestore: Restore Summary:

xfsrestore:   stream 0 /mnt/usb/root.dmp OK (success)

xfsrestore: Restore Status: SUCCESS

 

[anaconda root@localhost ~]# xfsrestore -f /mnt/usb/home.dmp /mnt/home

xfsrestore: restore complete: 0 seconds elapsed

xfsrestore: Restore Summary:

xfsrestore:   stream 0 /mnt/usb/home.dmp OK (success)

xfsrestore: Restore Status: SUCCESS

 

Verify the result.

[anaconda root@localhost ~]# df -PhT

Filesystem          Type      Size  Used Avail Use% Mounted on

/dev/mapper/live-rw ext4      2.0G  1.1G  941M  53% /

devtmpfs            devtmpfs  2.0G     0  2.0G   0% /dev

tmpfs               tmpfs     2.0G  4.0K  2.0G   1% /dev/shm

tmpfs               tmpfs     2.0G  8.4M  2.0G   1% /run

tmpfs               tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup

/dev/sr0            iso9660   415M  415M     0 100% /run/install/repo

tmpfs               tmpfs     2.0G  380K  2.0G   1% /tmp

/dev/mapper/ol-root xfs       9.0G  1.2G  7.9G  13% /mnt/root

/dev/mapper/ol-home xfs       3.0G   33M  3.0G   2% /mnt/home

/dev/sdb1           vfat      7.7G  1.1G  6.6G  14% /mnt/usb

 

 

Make sure that there is no mismatch between the UUID of the actual device and the UUID used in the file system table (fstab) of the restored LVM root volume. If necessary, edit the file system table accordingly. Normally this is should not be necessary, because LVM root and home volumes are usually not mounted using their UUID value.

[anaconda root@localhost ~]# lsblk -o name,size,mountpoint,uuid /dev/sda

NAME        SIZE MOUNTPOINT UUID

sda          64G           

|-sda1        1G            433b636e-9b4a-4ea1-8960-6c2288433ac5

`-sda2       63G            hCDgtc-lOph-wvHY-Za5Q-VtY5-r0fo-JcKMsa

  |-ol-root   9G /mnt/root  16e712b1-c194-4591-83d1-41dc2a36d6b8

  `-ol-home   3G /mnt/home  45a6818a-b13e-4a21-806b-454394eba056

 

[anaconda root@localhost ~]# cat /mnt/root/etc/fstab

#

# /etc/fstab

# Created by anaconda on Sun Jan  5 17:30:10 2017

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/ol-root                       /      xfs     defaults        0 0

UUID=433b636e-9b4a-4ea1-8960-6c2288433ac5 /boot  xfs     defaults        0 0

/dev/mapper/ol-home                       /home  xfs     defaults        0 0

/dev/mapper/ol-swap                       swap   swap    defaults        0 0

 

 

Remove the Oracle Linux installation media and USB storage device.

 

Dismount all mounted volumes and restart the system.

[anaconda root@localhost ~]# umount /mnt/*

umount: /mnt/install: not mounted

umount: /mnt/sysimage: not mounted

 

[anaconda root@localhost ~]# reboot

 

 

Verify the result.

[root@ol1 /]# df -PhT

Filesystem          Type      Size  Used Avail Use% Mounted on

devtmpfs            devtmpfs  2.0G     0  2.0G   0% /dev

tmpfs               tmpfs     2.0G     0  2.0G   0% /dev/shm

tmpfs               tmpfs     2.0G  8.4M  2.0G   1% /run

tmpfs               tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup

/dev/mapper/ol-root xfs       9.0G  1.2G  7.9G  13% /

/dev/mapper/ol-home xfs       3.0G   33M  3.0G   2% /home

/dev/sda1           xfs      1014M  156M  859M  16% /boot

tmpfs               tmpfs     396M     0  396M   0% /run/user/0

 

 

8. Creating Additional LVM Volumes

 

It should now be possible to create the additional LVM volumes.

 

Analyze the LVM space.

[root@ol1 /]# lvs --segments -o +devices

  LV   VG Attr       #Str Type   SSize Devices       

  home ol -wi-ao----    1 linear 3.00g /dev/sda2(3296)

  root ol -wi-ao----    1 linear 9.00g /dev/sda2(992)

  swap ol -wi-ao----    1 linear 3.88g /dev/sda2(0)  

 

[root@ol1 /]# pvs

  PV         VG Fmt  Attr PSize  PFree

  /dev/sda2  ol lvm2 a--  63.00g 47.12g

 

Create new LVM volumes u01, u02 and u03.

[root@ol1 /]# lvcreate -L 2G -n u01 ol

  Logical volume "u01" created.

[root@ol1 /]# lvcreate -L 15G -n u02 ol

  Logical volume "u02" created.

[root@ol1 /]# lvcreate -L 30G -n u03 ol

  Logical volume "u03" created.

 

The LVM volume space should now be used, with only a small amount remaining.

[root@ol1 /]# pvs

  PV         VG Fmt  Attr PSize  PFree

  /dev/sda2  ol lvm2 a--  63.00g 124.00m

 

Initialize the new LVM volumes.

(Below shows only partial output.)

[root@ol1 /]# mkfs.xfs -L u01 /dev/ol/u01

 

[root@ol1 /]# mkfs.ext3 -L u02 /dev/ol/u02

 

[root@ol1 /]# mkfs.ext3 -L u03 /dev/ol/u03

 

Create mount points (/u01 /u02 /u03) and add the appropriate LVM volumes to the /etc/fstab file system table to mount during startup.

[root@ol1 /]# mkdir /u01 /u02 /u03

 

[root@ol1 /]# lvscan

  ACTIVE            '/dev/ol/swap' [3.88 GiB] inherit

  ACTIVE            '/dev/ol/root' [9.00 GiB] inherit

  ACTIVE            '/dev/ol/home' [3.00 GiB] inherit

  ACTIVE            '/dev/ol/u01' [2.00 GiB] inherit

  ACTIVE            '/dev/ol/u02' [15.00 GiB] inherit

  ACTIVE            '/dev/ol/u03' [30.00 GiB] inherit

 

Modify /etc/fstab accordingly.

[root@ol1 /]# cat /etc/fstab

#

# /etc/fstab

# Created by anaconda on Sun Jan  8 17:30:10 2017

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/ol-root                        /       xfs   defaults        0 0

UUID=433b636e-9b4a-4ea1-8960-6c2288433ac5  /boot   xfs   defaults        0 0

/dev/mapper/ol-home                        /home   xfs   defaults        0 0

/dev/mapper/ol-swap                        swap    swap  defaults        0 0

/dev/mapper/ol-u01                         /u01    xfs   defaults        0 0

/dev/mapper/ol-u02                         /u02    ext3  defaults        0 2

/dev/mapper/ol-u03                         /u03    ext3  defaults        0 2

 

Either restart the system or manually mount all devices listed in /etc/fstab.

[root@ol1 /]# mount -a

 

Verify the result.

[root@ol1 /]# df -PhT

Filesystem          Type      Size  Used Avail Use% Mounted on

devtmpfs            devtmpfs  2.0G     0  2.0G   0% /dev

tmpfs               tmpfs     2.0G     0  2.0G   0% /dev/shm

tmpfs               tmpfs     2.0G  8.4M  2.0G   1% /run

tmpfs               tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup

/dev/mapper/ol-root xfs       9.0G  1.2G  7.9G  13% /

/dev/mapper/ol-home xfs       3.0G   33M  3.0G   2% /home

/dev/sda1           xfs      1014M  156M  859M  16% /boot

tmpfs               tmpfs     396M     0  396M   0% /run/user/0

/dev/mapper/ol-u01  xfs       2.0G   33M  2.0G   2% /u01

/dev/mapper/ol-u02  ext3       15G   38M   14G   1% /u02

/dev/mapper/ol-u03  ext3       30G   44M   28G   1% /u03

 

 

That's it. Best of luck!

How To Convert a Linux System Disk to VirtualBox in Mac OS X

 

Author: Dude!

 

 

Disclaimer

 

This document is provided under the terms of http://www.oracle.com/us/legal/terms/index.html.

Please do not plagiarize. Use at your on risk. Thanks!

 

Abstract

 

Operating systems other than Linux do not support Linux LVM volumes and file systems. Accessing or analyzing the data on a Linux hard disk is therefore usually not feasible without running the original system. Computer virtualization can provide an easy solution for such scenarios in order to consolidate hardware, or access systems when hardware is not available.

 

The following instructions outline how to copy and convert a Oracle Linux 6 system hard disk to a virtual disk image and how to use it as a guest OS in VirtualBox. The task was performed on an Apple Mac Pro running OS X 10.9.5 and Oracle VirtualBox 5.0.16. Other software combinations or systems should work as well.

 

 

 

 

1. Connecting a hard drive

 

Attaching a hard drive to a computer obviously requires an appropriate hardware interface or suitable adapter. Most computers use IDE or SATA and offer USB to connect external devices. If the Linux hard drive is IDE or SATA, you may simply be able to replace the hard drive of an USB enclosure, or use a generic SATA/IDE to USB adapter. Such adapters are inexpensive and can be purchased from many online computer retail stores.

 

Your options to connect SCSI or SAS drives, which are common in enterprise servers systems and some workstations, are rather limited. Unless your computer is equipped with an extra SCSI or RAID host bus adapter, you will not be able to connect such drives directly, and probably not at all.

 

SCSI to Firewire or USB converters exist, but they are relatively expensive and primarily designed to connect older SCSI peripherals, such as a scanner. An external SCSI enclosure or appropriate adapter is still necessary to connect to the interface of a SCSI hard drive.

 

SAS is an evolution of SCSI and such controllers usually support also SATA drives, but SAS drives do not operate with SATA controllers and are keyed to prevent any chance of plugging them in incorrectly. There are simple SAS to SATA adapters, however, SAS drives will not work with SATA controllers.

 

The standard storage controller inside any Intel based Apple desktop or portable computer does not support SCSI or SAS drives. Searching on eBay or Amazon might be your best option to find converters and adapters, and depending on your Mac Pro model, find an appropriate host bus adapter card, such as the Apple RAID card, which supports SAS and SATA hard drives.

 

 

Note:As always, do not move any conventional or mechanical hard drive HDD while it is powered on, otherwise you may risk permanent damage of the disk and data.

 

 

 

2. Converting a hard disk to a virtual disk image

 

 

Note:

Copying and converting a complete hard disk can be time and disk space consuming. Make sure you have enough capacity in order not to use all your remaining free disk space and cause your computer system to malfunction. As a rule of thumb, you should always have at least 15 % of free disk space.

 

For example, to convert a 120 GB hard disk will require 120 GB plus the disk space that is actually being used on that hard drive, e.g. 30 GB. You would need more than 152 GB of free disk space on your computer for the task to complete successfully.  If you connect the hard drive via USB-2, you are not likely going to get more than 40 MB/s of data throughout, and converting a 120 GB hard disk will take at least 50 minutes.

 

 

After you have connected the hard drive to your Mac, it won't show up on the desktop, because Mac OS X does not recognize Linux LVM volumes or Linux file systems. It will display an initialization dialog instead. When prompted, choose Ignore.

 

Do not Initialize the disk, since this would erase it's contents.

 

Screen Shot 2016-12-30 at 10.55.35 AM.jpg

 

 

Open the Mac OS X Terminal application (Applications:Utilities).

 

Use the diskutil list  command to list all available disk devices. Your output may look similar to the following example:

 

Saturn:~ dude$ diskutil list

/dev/disk0

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *1.0 TB     disk0

   1:                        EFI EFI                     209.7 MB   disk0s1

   2:          Apple_CoreStorage                         999.3 GB   disk0s2

   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

/dev/disk1

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:                  Apple_HFS Saturn                 *999.0 GB   disk1

/dev/disk2

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:     FDisk_partition_scheme                        *120.0 GB   disk2

   1:                      Linux                         524.3 MB   disk2s1

   2:                  Linux_LVM                         119.5 GB   disk2s2

 

 

The Linux hard disk in the above example is obviously disk2.

 

Enter the following commands to copy and convert the Linux hard disk to a VirtualBox disk image.

 

Tip:

Be sure to use /dev/rdisk and not /dev/disk as shown in the disk utility when using the dd command to copy the device. /dev/rdisk provides direct access to the physical hard disk and is not buffered or cached by the operating system, which in this particular case would slow down the copy processes drastically.

 

You can press control-t to display the current performance and status of the dd command:

 

For example:

 

$ sudo dd if=/dev/rdisk1 of=Linux120GB.raw bs=2m

load: 0.62  cmd: dd 2651 uninterruptible 0.00u 0.57s

370+0 records in

370+0 records out

775946240 bytes transferred in 19.262300 secs (40283156 bytes/sec)

 

You will need to supply your administrator password, or current password if you use an admin account already.

 

Saturn:~ dude$ cd

Saturn:~ dude$ cd Desktop

Saturn:Desktop dude$ mkdir hdconvert

Saturn:Desktop dude$ cd hdconvert

 

Saturn:Desktop dude$ diskutil unmountdisk disk2

Unmount of all volumes on disk1 was successful

Saturn:Desktop dude$ sudo dd if=/dev/rdisk2 of=Linux120GB.raw bs=2m

Password:

Saturn:Desktop dude$ sudo chown $USER Linux120GB.raw

Password:

 

Saturn:Desktop dude$ VBoxManage convertfromraw Linux120GB.raw Linux120GB.vdi

Converting from raw image file="Linux120GB.raw" to file="Linux120GB.vdi"...

Creating dynamic image with size 120034123776 bytes (114474MB)...

 

Saturn:Desktop dude$ open ./

 

 

To save disk space, delete the Linux120GB.raw file and empty the Trash. The file is no longer going to be used.

Screen Shot 2016-12-30 at 5.45.18 PM.jpg

 

 

The file with the .vdi extension is a special VirtualBox disk image. The VirtualBox utility will create a dynamic disk image, that will automatically expand as more disk space is required, until the disk image reaches the maximum capacity that was chosen when it was created, e.g.120 GB. The size of the Linux120GB.vdi disk image is the amount of data that was actually used, e.g. 26 GB.

 

 

3. Creating a virtual machine

 

 

Note:

Keep in mind that VirtualBox is a type 2 Hypervisor and running a 64-bit virtual machine or guest OS is mandatory in order to take advantage of hardware assisted virtualization (VT-x). The host OS as such is irrelevant. Using a 32-bit virtual machine template or running a x86 guest OS would operate in software emulation mode, which is less efficient.

 

All Intel based Apple Computers ship with a 64-bit CPU with virtualization enabled. Be sure to create a virtual machine template that matches the actual operating system contained in the virtual disk image created earlier.

 

 

Open VirtualBox.

Click the New button from the toolbar,

or select New from the Machine menu.

 

Depending on your previous settings, the next series of dialogs are going to be in Guided or Expert mode.

You can choose by pressing the Guided or Expert button. For simplicity, the following shows Expert mode.

 

Feel free to give the virtual machine any useful name, but be sure to create the correct VM template.

For example, Linux, Oracle 64-bit.

 

For general purpose, 2 GB of RAM should be sufficient.

Choose "Do not add a virtual hard disk".

Click the Create button.

 

Screen Shot 2017-01-01 at 3.35.18 PM.jpg

 

Open the VirtualBox application Preferences to locate the machine folder where to place the virtual disk image.

Screen Shot 2017-01-01 at 2.09.42 PM.jpg

 

By default, the virtual machine folder is inside your home folder.

 

Screen Shot 2017-01-01 at 2.15.23 PM.jpg

 

Move the virtual disk image, converted earlier, into the appropriate virtual machine folder.

 

Screen Shot 2017-01-01 at 3.28.22 PM.jpg

 

 

Open VirtualBox.

Select the virtual machine (single click) in the left window

Choose Settings from the toolbar.

Select Storage.

Click on the SATA controller.

Click on the rightmost square icon with a plus sign to add a virtual disk image.

Select the button Choose existing disk.

 

Screen Shot 2017-01-01 at 3.42.33 PM.jpg

 

Navigate to the machine folder of the virtual machine.

Select the virtual disk image, e.g. Linux120GB

Click Open.

 

Screen Shot 2017-01-01 at 3.48.10 PM.jpg

 

 

 

4. Configuring the virtual machine network

 

You can configure up to 4 virtual network adapters and combine their function, but keep in mind that you will need to understand how TCP/IP network routing works in combination with VirtualBox. You cannot arbitrarily assign a TCP/IP addresses or network and expect it to function.

 

To understand the purpose of the various network adapters, please review the VirtualBox documentation:

https://www.virtualbox.org/manual/ch06.html

 

Below is brief overview that may help you to choose the right adapter:

Screen Shot 2017-01-01 at 4.03.04 PM.jpg

 

 

Tip:

VirtualBox uses the NAT adapter by default and it should work out of the box. When using the NAT interface, connections from the guest OS will appear as connection from the host OS. Incoming connection to the guest OS under NAT are however rejected and shielded by design.

 

Keep in mind that the NAT adapter requires a dynamic TCP/IP address assigned by the VirtualBox internal router (DHCP) in order to function. If you do not need to connect to the guest OS by SSH, or provide any other service, but allow the guest OS to access the Internet, the NAT adapter should be fine.

 

If you do not wish to limit your connectivity options and maintain your own simple network, the bridged network adapter is usually the easiest to configure, and you can assign any TCP/IP address to your guest OS that is available within your host system network.

 

 

For simplicity, the following configures the VirtualBox bridged network adapter.

 

Open VirtualBox.

Select the virtual machine (single click)

Choose Settings from the toolbar.

Select the Network icon.

Change Attached to from NAT to Bridged Adapter.

Flip the Advanced switch to show further details.

Write down the MAC address - Note that O's are Zero's!

 

Screen Shot 2017-01-02 at 11.04.48 AM.jpg

 

Click the OK button.

 

 

Note:

Regardless of the type of network adapter you choose, the guest OS will have to use a different network adapter than the computer where the hard drive was initially installed. The hardware address of the network adapter (MAC address) will be different and require some adjustment.

 

It should work to obtain the MAC address of the network device that was configured in the previous computer and update the MAC address of the virtual network adapter accordingly, however, it is better to update the guest OS to avoid potential conflicts.

 

Start the virtual machine

Login as user root.

 

If you do not see the console, open a terminal command prompt.

 

[root@ol1 ~]# cd /etc/udev/rules.d

 

The file 70-persistent-net.rules belongs to the UDEV subsystem and assures persistent network adapter names across system restarts. It assigns network adapter names to physical MAC addresses and gets automatically populated when new network devices are detected during a system start up.

 

All entries in the current file belong to the previous computer system and are irrelevant. If there was already an entry for device eth0 from the previous system, the new network interface of the virtual machine will be assigned another name, e.g. eth1. For this reason, any existing TCP/IP configuration for eth0 will not function.

 

Simply delete or rename the file and let the system recreate it during the next system restart.

 

[root@ol1 rules.d]# mv 70-persistent-net.rules 70-persistent-net.rules.backup

[root@ol1 rules.d]# shutdown -h now

 

Note:

The virtual machine must shut down to recreate the udev network device entry for eth0. You should verify that the virtual machine network adapter was indeed assigned eth0 after the next system restart. If necessary, edit 70-persistent-net.rules accordingly.

 

After the next start up, device eth0 should reflect the MAC address of the virtual machine network adapter.

 

Screen Shot 2017-01-02 at 1.19.25 PM.jpg

 

If you had a previous TCP/IP setup, analyze the content of the eth0 configuration file and make appropriate adjustments.

 

[root@ol1 ~]# cd /etc/sysconfig/network-scripts

[root@ol1 network-scripts]# cat ifcfg-eth0

 

Edit the file ifcfg-eth0 to change the TCP/IP configuration according to your requirements.

 

Tip:

You can either remove or update HWADDR. If you update HWADDR, the value must match the MAC address of the virtual network adapter, using the correct 00:00:00:00:00:00 format.

 

You may need to change or remove the Gateway address, or change the default Gateway in /etc/sysconfig/network. If you do not specify any particular interface gateway, the default gateway will be used instead.

 

Your output may look similar to the following:

Screen Shot 2017-01-04 at 5.52.51 AM.jpg

 

Restart the guest OS:

 

[root@ol1 ~]# shutdown -r now

 

 

 

 

That's all. Best of luck!

Hello,

 

I recently had to copy the ISO installation image of Oracle Linux onto a USB stick in order to perform an installation on a PC. Apparently the process used to be somewhat complex, unless you used tools like unetbootin, for example, however, as of Oracle Linux 6.6 it no longer works. The process has actually become much easier.

 

Note:

 

The following instructions requires an ISO image of Oracle Linux 6 update 6 (6.6) or later, or release version 7 and later.

It will not work with ISO images of Oracle Linux 6.5 and earlier, or OL 5.

 

In order to create a USB installation media that can be used to boot a PC and install the product you the appropriate ISO disk image:

 

Oracle Linux (x64)ISO ImageSize GBSHA-1 Checksum
7.2V100082-014.203E048F23D798C8E8E7935FAB76245C2F1341378
7.1V74844-014.0FA9666448E8A24AD6A4C7203575B66532FA833D7
7.0V46135-013.974BCAC408A164535ECD483503244E312A292BF84
6.8V138414-013.7D9C0FBE32FE59B5A9FB9A1E1625F64D85A8201B6
6.7V77197-013.6DD7231B378F23E2E846AC78B0C5D8974A23631D5
6.6V52218-013.65738F10A506D3630EDFD297EF179B553091C6A48

 

You can obtain the software from the Oracle Software Delivery Cloud, formerly known as Oracle E-Delivery, or from sources outlined in Downloading Oracle Linux. To download the software from Oracle requires a OTN registration, which is free, but may take a couple of days to verify export validation.

 

Keep in mind that Oracle Linux is free, including errata and patches, and you can use it for any purpose or business, however, you may require a valid OS support subscription by the software license you are planning to use, like Oracle Database. For information about ULN support and other Oracle Linux information see Unbreakable Linux Network.

 

After you have downloaded the Oracle Linux ISO, it is highly recommended to verify the checksum to make sure the file is not incomplete, which can otherwise result in all kinds of strange problems. The checksum information should be provided by the download link, under View Digest, or look in the above table.

 

 

The commands below need to entered at the Mac OS X command prompt. You can find Terminal.app in your standard Mac Utilities folder.

 

You can use openssl to verify the SHA-1 checksum. For example:

 

Saturn:~ dude$ openssl sha1 $HOME/Downloads/V138414-01.iso

SHA1(/Users/dude/Downloads/V138414-01.iso)= d9c0fbe32fe59b5a9fb9a1e1625f64d85a8201b6

 

Tip: you can drag and drop files from the Finder into the Terminal window.

 

Next, insert the USB flash drive. It needs to be large enough to store the ISO image data. Any 8 GB USB stick or larger will be fine.

 

You need to determine the device name, which should be easy by comparing the USB volume name or size.

 

Saturn:~ dude$ diskutil list

/dev/disk4

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *8.2 GB     disk4

   1:                        EFI EFI                     209.7 MB   disk4s1

   2:                  Apple_HFS bigstick                7.9 GB     disk4s2

 

The device name of the USB flash drive in the above example is /dev/disk4.

 

You do not need to be concerned about any existing volume format or partition scheme -- any data on the USB device will be erased anyway.

Be careful to use the correct device name according to your system!

 

Finally copy the ISO image to the USB device:

 

Saturn:~ dude$ diskutil unmountdisk /dev/disk4

Unmount of all volumes on disk4 was successful

 

Saturn:~ dude$ sudo dd if=$HOME/Downloads/V41362-01.iso of=/dev/disk4 bs=1m

Password:

load: 1.19  cmd: dd 11500 uninterruptible 0.00u 1.49s

100+0 records in

99+0 records out

103809024 bytes transferred in 31.516982 secs (3293749 bytes/sec)

 

Saturn:~ dude$ diskutil eject /dev/disk4

Disk /dev/disk4 ejected

 

Again, be sure to use the correct device since all previous data will be erased. When prompted for the password, enter the administrator password, which is usually the password of your current account. The process may take quite some time to complete. It took about 18 minutes on my Mac.

 

Tip: To monitor the current process, press Ctrl-t.

 

When the command completed, use diskutil to eject the USB drive before unplugging it from your Mac.

 

I hope that wasn't too bad. Best of luck!

 

additional keywords: macos mac os mac os x

Begin of shadow box test

 

a

[grid@vm601 ~]$ sqlplus / as sysasm

 

a

Screen Shot 2016-05-26 at 04.00.17.jpg

 

 

a

 

Tip:

If the host entry in the Oracle listener.ora file is localhost.localdomain, and the machine hostname is also localhost.localdomain, the oracle listener will accept incoming connections on all interfaces including remote connections. If the listener configuration uses localhost, but the machine name is not, the listener will not accept remote connections.

 

A

 

a

 

Note

The TCP/IP configuration to access the root file system via iSCSI needs to be set early during system startup by initrd (Init RAM disk) and appropriate Linux kernel boot parameters. If you decide to change the TCP/IP address later, you need to change the GRUB2 configuration, which will be explained later.

 

A

The following has been tested running Oracle Database 11.2.0.1 Enterprise Edition under Oracle Linux 5.11.

 

After dropping a tablespace, the RMAN metadata in the controlfile no longer shows the corresponding datafiles:

 

RMAN> list backup;
  6      Full 2302982    14-MAR-16 /u02/oradata/ORCL2/datafile/o1_mf_mydata_cgfy38bq_.dbf

SQL> drop tablespace mydata including contents;

Tablespace dropped.

RMAN> list backup;
  6      Full 2302982    14-MAR-16



 

When you perform a DBPITR using the current controlfile, the tablespace will exist in the database data dictionary, but the datafile will be missing. Also the RMAN metadata will show the datafile as missing.

 

SQL> select * from dba_data_files;

/u01/app/oracle/product/11.2.0/dbhome_1/dbs/MISSING00006
     6 MYDATA                     

RMAN> list backup;
  6       Full 2303502    14-MAR-16 /u01/app/oracle/product/11.2.0/dbhome_1/dbs/MISSING00006



 

In order to perform a point in time recovery after dropping a tablespace, the controlfile prior to dropping the tablespace must be restored as well. Note: you cannot use UNTIL SCN when restoring a controlfile from autobackup, but you can use UNTIL TIME.

 

Here is an example demonstrating the complete process:

 

$ export NLS_DATE_FORMAT="dd-MON-YYYY hh24:mi:ss"

RMAN> list backup;
  Control File Included: Ckp SCN: 2303588      Ckp time: 14-MAR-2016 18:50:15
  Control File Included: Ckp SCN: 2303622      Ckp time: 14-MAR-2016 18:56:43



 

RMAN> run {
2> shutdown abort
3> startup nomount
4> restore until time "to_date('2016-03-14:18:50:15','YYYY-MM-DD:HH24:MI:SS')"
5> controlfile from autobackup;
6> startup mount
7> set until scn 2303588;
8> restore database;
9> recover database;
10> alter database open resetlogs;
}

using target database control file instead of recovery catalog
Oracle instance shut down

connected to target database (not started)
Oracle instance started

Total System Global Area     634679296 bytes

Fixed Size                     2255912 bytes
Variable Size                469763032 bytes
Database Buffers             155189248 bytes
Redo Buffers                   7471104 bytes

Starting restore at 14-MAR-2016 19:41:22
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=246 device type=DISK

recovery area destination: /u03/fast_recovery_area
database name (or database unique name) used for search: ORCL2
channel ORA_DISK_1: AUTOBACKUP /u03/fast_recovery_area/ORCL2/autobackup/2016_03_14/o1_mf_s_906490215_cgfygqyk_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20160314
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u03/fast_recovery_area/ORCL2/autobackup/2016_03_14/o1_mf_s_906490215_cgfygqyk_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u02/oradata/ORCL2/controlfile/o1_mf_b5o6bpbx_.ctl
output file name=/u03/fast_recovery_area/ORCL2/controlfile/o1_mf_b5o6bpcy_.ctl
Finished restore at 14-MAR-2016 19:41:23

database is already started
database mounted
released channel: ORA_DISK_1

executing command: SET until clause

Starting restore at 14-MAR-2016 19:41:28
Starting implicit crosscheck backup at 14-MAR-2016 19:41:28
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=246 device type=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 14-MAR-2016 19:41:29

Starting implicit crosscheck copy at 14-MAR-2016 19:41:29
using channel ORA_DISK_1
Crosschecked 5 objects
Finished implicit crosscheck copy at 14-MAR-2016 19:41:29

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

List of Cataloged Files
=======================
File Name: /u03/fast_recovery_area/ORCL2/autobackup/2015_10_02/o1_mf_s_892064878_c0xjtg55_.bkp
File Name: /u03/fast_recovery_area/ORCL2/autobackup/2015_10_02/o1_mf_s_892063593_c0xhl9wh_.bkp
File Name: /u03/fast_recovery_area/ORCL2/autobackup/2016_03_14/o1_mf_s_906490603_cgfytw0o_.bkp
File Name: /u03/fast_recovery_area/ORCL2/autobackup/2016_03_14/o1_mf_s_906493075_cgg183br_.bkp
File Name: /u03/fast_recovery_area/ORCL2/autobackup/2016_03_14/o1_mf_s_906490215_cgfygqyk_.bkp
File Name: /u03/fast_recovery_area/ORCL2/archivelog/2016_03_14/o1_mf_1_2_cgfytpnq_.arc

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 /u02/oradata/ORCL2/datafile/o1_mf_system_c0xlc2mp_.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u02/oradata/ORCL2/datafile/o1_mf_sysaux_c0xlc2mr_.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u02/oradata/ORCL2/datafile/o1_mf_undotbs1_c0xlc2mz_.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u02/oradata/ORCL2/datafile/o1_mf_users_c0xlc2n2_.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u02/oradata/ORCL2/datafile/o1_mf_example_c0xlc2mv_.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u02/oradata/ORCL2/datafile/o1_mf_mydata_cgfydmv4_.dbf
channel ORA_DISK_1: reading from backup piece /u03/fast_recovery_area/ORCL2/backupset/2016_03_14/o1_mf_nnndf_TAG20160314T184950_cgfyfytp_.bkp
channel ORA_DISK_1: piece handle=/u03/fast_recovery_area/ORCL2/backupset/2016_03_14/o1_mf_nnndf_TAG20160314T184950_cgfyfytp_.bkp tag=TAG20160314T184950
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 14-MAR-2016 19:41:55

Starting recover at 14-MAR-2016 19:41:55
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 2 is already on disk as file /u03/fast_recovery_area/ORCL2/archivelog/2016_03_14/o1_mf_1_2_cgfytpnq_.arc
archived log file name=/u03/fast_recovery_area/ORCL2/archivelog/2016_03_14/o1_mf_1_2_cgfytpnq_.arc thread=1 sequence=2
media recovery complete, elapsed time: 00:00:00
Finished recover at 14-MAR-2016 19:41:56

database opened



 

SQL> select * from dba_data_files;

/u02/oradata/ORCL2/datafile/o1_mf_mydata_cgg1gt96_.dbf
     6 MYDATA               104857600      12800 AVAILABLE
       6 YES 3.4360E+10    4194302          12800  103809024         12672
ONLINE



The following is a simple example how to use RMAN to backup a running Oracle 11g database and how to fully restore and recover it when all database files are lost or have been destroyed. It assumes that the database is running in Archive Log mode and that the Fast Recovery Area (FRA) has been configured for easier data management. Please see the Oracle documentation for more information.

 

It all starts with a full backup of the database, including the archived redo logs, database spfile and control files:

 

[oracle@vm501 ~]$ . oraenv
ORACLE_SID = [orcle] ? orcl2
The Oracle base has been set to /u01/app/oracle

[oracle@vm501 ~]$ rman target /
connected to target database: ORCL2 (DBID=843703910)
RMAN> configure controlfile autobackup on;
RMAN> backup database plus archivelog delete input;
    

 

Note the DBID when connecting with RMAN to the database, which will be required when restoring the database controlfile from autobackup.

 

A full database backup will always include a copy of the database spfile and control file, however, with RMAN autobackup enabled, the restore process will be easier to manage. The option "delete all input" is not required, but usually a good practice to save disk space, since archived redo logs can build up and occupy a substantial amount of disk space.

 

The autobackup information will be shown at the the end of the backup.

 

Starting Control File and SPFILE Autobackup at 10-MAY-15
piece handle=/u03/fast_recovery_area/ORCL2/autobackup/2015_05_10/o1_mf_s_879364591_bnz6yhy5_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 10-MAY-15
        


Delete all database files:

 

[oracle@vm501 ~]$ echo "shutdown abort;" | sqlplus / as sysdba

[oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_system_bnz5okkg_.dbf
[oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_sysaux_bnz5okll_.dbf
[oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_undotbs1_bnz5okn4_.dbf
[oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_users_bnz5oknl_.dbf
[oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_example_bnz5okmm_.dbf
[oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_temp_bnz68bpj_.tmp
[oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/onlinelog/o1_mf_3_bnz6887c_.log
[oracle@vm501 ~]$rm -f /u03/fast_recovery_area/ORCL2/onlinelog/o1_mf_3_bnz688b0_.log
[oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/onlinelog/o1_mf_2_bnz687so_.log
[oracle@vm501 ~]$rm -f /u03/fast_recovery_area/ORCL2/onlinelog/o1_mf_2_bnz687wt_.log
[oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/onlinelog/o1_mf_1_bnz687c6_.log
[oracle@vm501 ~]$rm -f /u03/fast_recovery_area/ORCL2/onlinelog/o1_mf_1_bnz687g2_.log
        

 

In order for a database instance to know about previous data files, it is necessary to restore the database control file and spfile. Don't forget to delete the previous spfile! Otherwise, using "startup nomount" would use the already existing spfile for the instance and would not allow to restore the spfile from autobackup. When a database instance is started using nomount without a spfile, Oracle will automatically use a dummy pfile.

 

[oracle@vm501 ~]$rm -f $ORACLE_HOME/dbs/spfileorcl2.ora
  

 

To restore any database files, RMAN requires a database instance. A database instance does not require any database files and only provides the process and memory structures that can be used by an Oracle database. Using the "startup nomount" command, the Oracle instance creates the necessary processes and memory structures, but does not access the database control file and has no knowledge about the database data files. Once the spfile has been restored, we can start the database instance with the appropriate parameters and continue with restoring the database control and data files.

 

After the database has been restored, the database needs to be recovered. The following shows the commands:

 

[oracle@vm501 ~]$ . oraenv
ORACLE_SID = [orcl2] ? orcl2
The Oracle base remains unchanged with value /u01/app/oracle

[oracle@vm501 ~]$ rman target /

connected to target database (not started)

RMAN> set DBID 843703910
RMAN> startup nomount
RMAN> restore spfile from autobackup
      db_recovery_file_dest='/u03/fast_recovery_area' db_name='ORCL2';
RMAN> startup force nomount
RMAN> restore controlfile from autobackup;
RMAN> startup force mount
RMAN> restore database;
RMAN> recover database;

RMAN-06054: media recovery requesting unknown archived log for thread 1
        


The RMAN-06054 error in this case is benign. It appears because the recovery procedure continues requesting the next archive log, however, the database has been already been recovered to a consistent state and there are no more archived redo logs to apply. The error could be avoided by using the UNTIL clause and specifying the last database SCN or archivelog sequence that needs to be applied, like it is done when performing a database point in time restore and recovery (PITR), but it is not necessary in this case.

 

The database needs to be opened with RESETLOGS, which is always necessary when restoring an RMAN backup control file, or when the online redo logs are unavailable or cannot be applied. RESETLOG creates a new database incarnation resetting the log sequence to 1 and either resets or creates new redo log files according to the database init parameter (spfile).

 

RMAN> alter database open resetlogs;
database opened
        

 

That's all there is and the database has been restored and recovered. Since the recovery process did not use the online redo logs, this will be called an incomplete recovery and most recent information might be lost.

 

 

As outlined earlier, a full backup will always include the spfile file and database control file. If your RMAN configuration did not include "autobackup", you can still restore the spfile and control file. The process in such scenario is more difficult because you have to restore the spfile and control file by specifying the appropriate RMAN backupset. Since this information is stored in the database control file, you cannot access such information prior to restoring the spfile and control file, unless you made an appropriate note or synchronized the RMAN backup repository with an optional RMAN catalog database.

 

For example:

 

including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 10-MAY-15
channel ORA_DISK_1: finished piece 1 at 10-MAY-15
piece handle=/u03/fast_recovery_area/ORCL2/backupset/2015_05_10/o1_mf_ncsnf_TAG20150510T183149_bnz20tdn_.bkp
        

 

RMAN> restore spfile from '/u03/fast_recovery_area/ORCL2/backupset/2015_05_10/o1_mf_ncsnf_TAG20150510T183149_bnz20tdn_.bkp';
RMAN> restore controlfile from '/u03/fast_recovery_area/ORCL2/backupset/2015_05_10/o1_mf_ncsnf_TAG20150510T183149_bnz20tdn_.bkp'