Tuesday, 30 May 2017

ORA-01157 and ORA-01110

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/oradata/orcl/system01.dbf'

it seems NFS storage lock on the mount point.

- Shut down the database
- run the following as root user.

service nfslock status

service nfslock stop


service nfslock start

- start the database.


Monday, 22 May 2017

TNS-12543: TNS:destination host unreachable

TNS-12543: TNS:destination host unreachable

Ex: I am trying to ping standby database from primary, got the following error.

[oracle@localhost ~]$ tnsping stdby

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 22-MAY-2017 05:22                                     :39

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)                                     (HOST = 192.168.92.129)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = stdby)))
TNS-12543: TNS:destination host unreachable

Possible issues:

1. First step to trace this error is to test the host reachability using hostname/IP ping on OS level.

> ping IP/hostname

I am able to ping here, host is reachable, if we get issue here, we need to contact network admin.

2.  Second step is to check listener is running in the remote host to where your are trying to ping, in this scenario remote server is standby.

>lsnrctl status

If listener is not running, just start the listener and check tnsping. In this scenario my listener in standby is running fine, but still i am getting TNS-12543, host unreachable.

3. Third step is to check is SElinux settings, SELINUX should be always disabled as below.

[oracle@localhost ~]$ cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

If above setting is showing enforcing, then you need to login as root edit the file /etc/selinux/config and reboot the server.

In my case its disabled, but still issue is not resolved.

4. Now i check the firewall, firewall should be always disabled. use the below steps to disable firewall.

[oracle@localhost ~]$ systemctl status firewalld
â firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2017-05-22 04:23:33 EDT; 1h 1min ago
 Main PID: 604 (firewalld)
   CGroup: /system.slice/firewalld.service
           ââ604 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

In my care firewall is the issue, i disabled as follows, issue got resolved.

[oracle@localhost ~]$ su -
Password:
Last login: Mon May 22 04:12:57 EDT 2017 on pts/2
[root@localhost ~]# systemctl status firewalld
â firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2017-05-22 04:23:33 EDT; 1h 1min ago
 Main PID: 604 (firewalld)
   CGroup: /system.slice/firewalld.service
           ââ604 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

May 22 04:22:55 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
May 22 04:23:33 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
[root@localhost ~]# service firewalld stop
Redirecting to /bin/systemctl stop  firewalld.service
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@localhost ~]# systemctl status firewalld
â firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

May 22 04:22:55 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
May 22 04:23:33 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
May 22 05:25:42 localhost.localdomain systemd[1]: Stopping firewalld - dynamic firewall daemon...
May 22 05:25:43 localhost.localdomain systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@localhost ~]# exit
logout
[oracle@localhost ~]$ tnsping stdby

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 22-MAY-2017 05:26:57

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.92.129)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = stdby)))
OK (0 msec)
[oracle@localhost ~]$

Saturday, 6 May 2017

Table recover using RMAN

table recover using RMAN (in CDB database)
[oracle@localhost trace]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Fri Jul 8 06:21:16 2016
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> conn ramesh/ramesh@testpdb
Connected.
SQL> @/u01/app/oracle/sample_data.txt
Table created.
SQL> commit;
Commit complete.
set lines 200
col TABLE_NAME for a20
select TABLE_NAME,TABLESPACE_NAME from dba_tables where TABLE_NAME='ABC';

TABLE_NAME           TABLESPACE_NAME
-------------------- ------------------------------
ABC                  USERS
SQL> exit
[oracle@localhost trace]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Fri Jul 8 06:24:42 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ORCL (DBID=1444228497)
RMAN> backup database plus archivelog;
Starting backup at 08-JUL-16
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=254 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=40 RECID=31 STAMP=916639295
input archived log thread=1 sequence=41 RECID=32 STAMP=916640035
input archived log thread=1 sequence=42 RECID=33 STAMP=916640326
input archived log thread=1 sequence=43 RECID=34 STAMP=916640699
channel ORA_DISK_1: starting piece 1 at 08-JUL-16
channel ORA_DISK_1: finished piece 1 at 08-JUL-16
piece handle=/u01/app/oracle/recovery_area/ORCL/backupset/2016_07_08/o1_mf_annnn_TAG20160708T062500_cqyzvwmx_.bkp tag=TAG20160708T062500 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-JUL-16

Starting backup at 08-JUL-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 08-JUL-16
channel ORA_DISK_1: finished piece 1 at 08-JUL-16
piece handle=/u01/app/oracle/recovery_area/ORCL/backupset/2016_07_08/o1_mf_nnndf_TAG20160708T062501_cqyzvy3b_.bkp tag=TAG20160708T062501 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00015 name=/u01/app/oracle/oradata/orcl/testpdb/sysaux01.dbf
input datafile file number=00014 name=/u01/app/oracle/oradata/orcl/testpdb/system01.dbf
input datafile file number=00016 name=/u01/app/oracle/oradata/orcl/testpdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 08-JUL-16
channel ORA_DISK_1: finished piece 1 at 08-JUL-16
piece handle=/u01/app/oracle/recovery_area/ORCL/3717BF6BA56F1C6AE055000000000001/backupset/2016_07_08/o1_mf_nnndf_TAG20160708T062501_cqyzx1fy_.bkp tag=TAG20160708T062501 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/u01/app/oracle/oradata/orcl/pdborcl/sysaux01.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/orcl/pdborcl/system01.dbf
input datafile file number=00010 name=/u01/app/oracle/oradata/orcl/pdborcl/pdborcl_users01.dbf
channel ORA_DISK_1: starting piece 1 at 08-JUL-16
channel ORA_DISK_1: finished piece 1 at 08-JUL-16
piece handle=/u01/app/oracle/recovery_area/ORCL/36F16AFE599FC018E055000000000001/backupset/2016_07_08/o1_mf_nnndf_TAG20160708T062501_cqyzxtl8_.bkp tag=TAG20160708T062501 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/app/oracle/oradata/orcl/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/pdbseed/system01.dbf
channel ORA_DISK_1: starting piece 1 at 08-JUL-16
channel ORA_DISK_1: finished piece 1 at 08-JUL-16
piece handle=/u01/app/oracle/recovery_area/ORCL/36F14F04DD26BC50E055000000000001/backupset/2016_07_08/o1_mf_nnndf_TAG20160708T062501_cqyzyn14_.bkp tag=TAG20160708T062501 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
Finished backup at 08-JUL-16

Starting backup at 08-JUL-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=44 RECID=35 STAMP=916640813
channel ORA_DISK_1: starting piece 1 at 08-JUL-16
channel ORA_DISK_1: finished piece 1 at 08-JUL-16
piece handle=/u01/app/oracle/recovery_area/ORCL/backupset/2016_07_08/o1_mf_annnn_TAG20160708T062653_cqyzzfgq_.bkp tag=TAG20160708T062653 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-JUL-16

Starting Control File Autobackup at 08-JUL-16
piece handle=/u01/app/oracle/recovery_area/ORCL/autobackup/2016_07_08/o1_mf_n_916640815_cqyzzho5_.bkp comment=NONE
Finished Control File Autobackup at 08-JUL-16

RMAN> exit
Recovery Manager complete.
============================================================================
--Drop the table
[oracle@localhost trace]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Fri Jul 8 06:27:47 2016
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> alter session set container=testpdb;
Session altered.
SQL> select count(*) from ramesh.abc;
  COUNT(*)
----------
       200
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
    1825573
SQL> drop table ramesh.abc;
Table dropped.
SQL> exit
===============================================================================
Recover the table
[oracle@localhost trace]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Fri Jul 8 06:30:31 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ORCL (DBID=1444228497)
RMAN> recover table ramesh.abc OF PLUGGABLE DATABASE TESTPDB until scn 1825573 AUXILIARY DESTINATION  '/u01/app/oracle/oradata' DATAPUMP DESTINATION '/u01/app/oracle/oradata' DUMP FILE 'ramesh_abc.dmp';
Starting recover at 08-JUL-16
using target database control file instead of recovery catalog
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=136 device type=DISK
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time

List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1

Creating automatic instance, with SID='vDxA'

initialization parameters used for automatic instance:
db_name=ORCL
db_unique_name=vDxA_pitr_TESTPDB_ORCL
compatible=12.1.0.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_system_trig_enabled=FALSE
sga_target=1504M
processes=200
db_create_file_dest=/u01/app/oracle/oradata
log_archive_dest_1='location=/u01/app/oracle/oradata'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance ORCL
Oracle instance started
Total System Global Area    1577058304 bytes
Fixed Size                     2924832 bytes
Variable Size                402656992 bytes
Database Buffers            1157627904 bytes
Redo Buffers                  13848576 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set until  scn 1825573;
# restore the controlfile
restore clone controlfile;

# mount the controlfile
sql clone 'alter database mount clone database';

# archive current online log
sql 'alter system archive log current';
}
executing Memory Script

executing command: SET until clause

Starting restore at 08-JUL-16
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=6 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/recovery_area/ORCL/autobackup/2016_07_08/o1_mf_n_916640815_cqyzzho5_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/recovery_area/ORCL/autobackup/2016_07_08/o1_mf_n_916640815_cqyzzho5_.bkp tag=TAG20160708T062654
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/ORCL/controlfile/o1_mf_cqz07jmm_.ctl
Finished restore at 08-JUL-16

sql statement: alter database mount clone database

sql statement: alter system archive log current

contents of Memory Script:
{
# set requested point in time
set until  scn 1825573;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile  1 to new;
set newname for clone datafile  4 to new;
set newname for clone datafile  3 to new;
set newname for clone datafile  14 to new;
set newname for clone datafile  15 to new;
set newname for clone tempfile  1 to new;
set newname for clone tempfile  4 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  1, 4, 3, 14, 15;

switch clone datafile all;
}
executing Memory Script

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

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 4 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_temp_%u_.tmp in control file

Starting restore at 08-JUL-16
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/recovery_area/ORCL/backupset/2016_07_08/o1_mf_nnndf_TAG20160708T062501_cqyzvy3b_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/recovery_area/ORCL/backupset/2016_07_08/o1_mf_nnndf_TAG20160708T062501_cqyzvy3b_.bkp tag=TAG20160708T062501
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00014 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00015 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/recovery_area/ORCL/3717BF6BA56F1C6AE055000000000001/backupset/2016_07_08/o1_mf_nnndf_TAG20160708T062501_cqyzx1fy_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/recovery_area/ORCL/3717BF6BA56F1C6AE055000000000001/backupset/2016_07_08/o1_mf_nnndf_TAG20160708T062501_cqyzx1fy_.bkp tag=TAG20160708T062501
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 08-JUL-16

datafile 1 switched to datafile copy
input datafile copy RECID=8 STAMP=916641140 file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_cqz07r67_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=9 STAMP=916641140 file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_cqz07r89_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=10 STAMP=916641140 file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_cqz07r7g_.dbf
datafile 14 switched to datafile copy
input datafile copy RECID=11 STAMP=916641140 file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_cqz08vcw_.dbf
datafile 15 switched to datafile copy
input datafile copy RECID=12 STAMP=916641140 file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_cqz08vbs_.dbf

contents of Memory Script:
{
# set requested point in time
set until  scn 1825573;
# online the datafiles restored or switched
sql clone "alter database datafile  1 online";
sql clone "alter database datafile  4 online";
sql clone "alter database datafile  3 online";
sql clone 'TESTPDB' "alter database datafile
 14 online";
sql clone 'TESTPDB' "alter database datafile
 15 online";
# recover and open database read only
recover clone database tablespace  "SYSTEM", "UNDOTBS1", "SYSAUX", "TESTPDB":"SYSTEM", "TESTPDB":"SYSAUX";
sql clone 'alter database open read only';
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  1 online

sql statement: alter database datafile  4 online

sql statement: alter database datafile  3 online

sql statement: alter database datafile  14 online

sql statement: alter database datafile  15 online

Starting recover at 08-JUL-16
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 44 is already on disk as file /u01/app/oracle/recovery_area/ORCL/archivelog/2016_07_08/o1_mf_1_44_cqyzzf5b_.arc
archived log for thread 1 with sequence 45 is already on disk as file /u01/app/oracle/recovery_area/ORCL/archivelog/2016_07_08/o1_mf_1_45_cqz06y3s_.arc
archived log file name=/u01/app/oracle/recovery_area/ORCL/archivelog/2016_07_08/o1_mf_1_44_cqyzzf5b_.arc thread=1 sequence=44
archived log file name=/u01/app/oracle/recovery_area/ORCL/archivelog/2016_07_08/o1_mf_1_45_cqz06y3s_.arc thread=1 sequence=45
media recovery complete, elapsed time: 00:00:00
Finished recover at 08-JUL-16

sql statement: alter database open read only

contents of Memory Script:
{
sql clone 'alter pluggable database  TESTPDB open read only';
}
executing Memory Script

sql statement: alter pluggable database  TESTPDB open read only

contents of Memory Script:
{
   sql clone "create spfile from memory";
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  control_files =
  ''/u01/app/oracle/oradata/ORCL/controlfile/o1_mf_cqz07jmm_.ctl'' comment=
 ''RMAN set'' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
# mount database
sql clone 'alter database mount clone database';
}
executing Memory Script

sql statement: create spfile from memory

database closed
database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1577058304 bytes

Fixed Size                     2924832 bytes
Variable Size                419434208 bytes
Database Buffers            1140850688 bytes
Redo Buffers                  13848576 bytes

sql statement: alter system set  control_files =   ''/u01/app/oracle/oradata/ORCL/controlfile/o1_mf_cqz07jmm_.ctl'' comment= ''RMAN set'' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1577058304 bytes

Fixed Size                     2924832 bytes
Variable Size                419434208 bytes
Database Buffers            1140850688 bytes
Redo Buffers                  13848576 bytes

sql statement: alter database mount clone database

contents of Memory Script:
{
# set requested point in time
set until  scn 1825573;
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile  16 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  16;

switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

Starting restore at 08-JUL-16
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=6 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00016 to /u01/app/oracle/oradata/VDXA_PITR_TESTPDB_ORCL/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/recovery_area/ORCL/3717BF6BA56F1C6AE055000000000001/backupset/2016_07_08/o1_mf_nnndf_TAG20160708T062501_cqyzx1fy_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/recovery_area/ORCL/3717BF6BA56F1C6AE055000000000001/backupset/2016_07_08/o1_mf_nnndf_TAG20160708T062501_cqyzx1fy_.bkp tag=TAG20160708T062501
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 08-JUL-16

datafile 16 switched to datafile copy
input datafile copy RECID=14 STAMP=916641211 file name=/u01/app/oracle/oradata/VDXA_PITR_TESTPDB_ORCL/datafile/o1_mf_users_cqz0crrc_.dbf

contents of Memory Script:
{
# set requested point in time
set until  scn 1825573;
# online the datafiles restored or switched
sql clone 'TESTPDB' "alter database datafile
 16 online";
# recover and open resetlogs
recover clone database tablespace  "TESTPDB":"USERS", "SYSTEM", "UNDOTBS1", "SYSAUX", "TESTPDB":"SYSTEM", "TESTPDB":"SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  16 online

Starting recover at 08-JUL-16
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 44 is already on disk as file /u01/app/oracle/recovery_area/ORCL/archivelog/2016_07_08/o1_mf_1_44_cqyzzf5b_.arc
archived log for thread 1 with sequence 45 is already on disk as file /u01/app/oracle/recovery_area/ORCL/archivelog/2016_07_08/o1_mf_1_45_cqz06y3s_.arc
archived log file name=/u01/app/oracle/recovery_area/ORCL/archivelog/2016_07_08/o1_mf_1_44_cqyzzf5b_.arc thread=1 sequence=44
archived log file name=/u01/app/oracle/recovery_area/ORCL/archivelog/2016_07_08/o1_mf_1_45_cqz06y3s_.arc thread=1 sequence=45
media recovery complete, elapsed time: 00:00:00
Finished recover at 08-JUL-16

database opened

contents of Memory Script:
{
sql clone 'alter pluggable database  TESTPDB open';
}
executing Memory Script

sql statement: alter pluggable database  TESTPDB open

contents of Memory Script:
{
# create directory for datapump import
sql 'TESTPDB' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/u01/app/oracle/oradata''";
# create directory for datapump export
sql clone 'TESTPDB' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/u01/app/oracle/oradata''";
}
executing Memory Script

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/app/oracle/oradata''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/app/oracle/oradata''

Performing export of tables...
   EXPDP> Starting "SYS"."TSPITR_EXP_vDxA_xsDk":
   EXPDP> Estimate in progress using BLOCKS method...
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   EXPDP> Total estimation using BLOCKS method: 64 KB
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
   EXPDP> . . exported "RAMESH"."ABC"                               8.375 KB     200 rows
   EXPDP> Master table "SYS"."TSPITR_EXP_vDxA_xsDk" successfully loaded/unloaded
   EXPDP> ******************************************************************************
   EXPDP> Dump file set for SYS.TSPITR_EXP_vDxA_xsDk is:
   EXPDP>   /u01/app/oracle/oradata/ramesh_abc.dmp
   EXPDP> Job "SYS"."TSPITR_EXP_vDxA_xsDk" successfully completed at Fri Jul 8 06:35:20 2016 elapsed 0 00:00:29
Export completed


contents of Memory Script:
{
# shutdown clone before import
shutdown clone abort
}
executing Memory Script

Oracle instance shut down

Performing import of tables...
   IMPDP> Master table "SYS"."TSPITR_IMP_vDxA_rBCx" successfully loaded/unloaded
   IMPDP> Starting "SYS"."TSPITR_IMP_vDxA_rBCx":
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   IMPDP> . . imported "RAMESH"."ABC"                               8.375 KB     200 rows
   IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
   IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
   IMPDP> Job "SYS"."TSPITR_IMP_vDxA_rBCx" successfully completed at Fri Jul 8 06:35:43 2016 elapsed 0 00:00:06
Import completed


Removing automatic instance
Automatic instance removed
auxiliary instance file /u01/app/oracle/oradata/ORCL/datafile/o1_mf_temp_cqz0b22v_.tmp deleted
auxiliary instance file /u01/app/oracle/oradata/ORCL/datafile/o1_mf_temp_cqz09std_.tmp deleted
auxiliary instance file /u01/app/oracle/oradata/VDXA_PITR_TESTPDB_ORCL/onlinelog/o1_mf_3_cqz0d0lr_.log deleted
auxiliary instance file /u01/app/oracle/oradata/VDXA_PITR_TESTPDB_ORCL/onlinelog/o1_mf_2_cqz0czks_.log deleted
auxiliary instance file /u01/app/oracle/oradata/VDXA_PITR_TESTPDB_ORCL/onlinelog/o1_mf_1_cqz0cywt_.log deleted
auxiliary instance file /u01/app/oracle/oradata/VDXA_PITR_TESTPDB_ORCL/datafile/o1_mf_users_cqz0crrc_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_cqz08vbs_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_cqz08vcw_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_cqz07r7g_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_cqz07r89_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_cqz07r67_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/ORCL/controlfile/o1_mf_cqz07jmm_.ctl deleted
auxiliary instance file ramesh_abc.dmp deleted
Finished recover at 08-JUL-16

RMAN> exit
Recovery Manager complete.
=====================================================================================
Check the table status after restore
[oracle@localhost trace]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Fri Jul 8 06:36:17 2016
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> alter session set container=testpdb;
Session altered.
SQL> select count(*) from ramesh.abc;
  COUNT(*)
----------
       200
SQL> show con_name
CON_NAME
------------------------------
TESTPDB