botang 发表于 2018-7-7 10:29:01

活动第36/37次(2018-07-07星期六上下午)

多租户AG书的P167页有错,在插件数据库OPEN时坏掉了SYSTEM表空间,不需要关CDB:



做PITR,对照实验(5),先准备一下环境:
先进行自包含集检查:


$ . oraenv
ORACLE_SID = ?
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle
$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 7 10:41:39 2018

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

SQL> conn/ as sysdba
Connected.
SQL> exec dbms_tts.transport_set_check('USERS');

PL/SQL procedure successfully completed.

SQL> select* from transport_set_violations;

VIOLATIONS
--------------------------------------------------------------------------------
ORA-39917: SYS owned object TTESTBOTANG_5 in tablespace USERS not allowed in plu
ggable set


SQL> alter table TTESTBOTANG_5move tablespace system ;

Table altered.

SQL> exec dbms_tts.transport_set_check('USERS');

PL/SQL procedure successfully completed.

SQL> select* from transport_set_violations;

no rows selected

SQL>

11.2.0.3以后,以下删除用户的命令是不需要的(对环境没有要求https://www.botangdb.com/forum.php?mod=image&aid=1120&size=300x300&key=6302c859b266a703&nocache=yes&type=fixnone):

/*SQL> selectusername from dba_users where username='OE';

USERNAME
------------------------------
OE
SH

SQL> drop user oe cascade;

User dropped.

SQL> drop user sh cascade;

User dropped.   */



做备份(之前有备份也不需要做)。

运行bcl --O11g05 5,做实验环境。

再检查是不是默认永久表空间:

SQL> selectPROPERTY_NAME, PROPERTY_VALUEfrom database_properties where PROPERTY_NAME like '%TABLESPACE%';

PROPERTY_NAME
------------------------------
PROPERTY_VALUE
--------------------------------------------------------------------------------
DEFAULT_TEMP_TABLESPACE
TEMP

DEFAULT_PERMANENT_TABLESPACE
EXAMPLE

$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 7 11:03:06 2018

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

SQL> conn / as sysdba
Connected.
SQL> alter database default tablespace example;

Database altered.

SQL>

开始执行PITR:
SQL> alter tablespace users offline immediate ;

Tablespace altered.

SQL>
LINUX环境变量:export NLS_DATE_FORMAT='YYYY-MM-DD:HH24:MI:SS'



命令和分配通道:
$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jul 7 11:05:31 2018

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

connected to target database: ORCL (DBID=1359978017)

RMAN> recover tablespace users
2> until time '2018-07-07:10:58:17'
3> auxiliary destination '/u01/app/oracle/oradata';

Starting recover at 2018-07-07:11:08:06
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=13 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=99 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=142 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=11 device type=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: SID=52 device type=DISK
allocated channel: ORA_DISK_6
channel ORA_DISK_6: SID=96 device type=DISK
allocated channel: ORA_DISK_7
channel ORA_DISK_7: SID=140 device type=DISK
allocated channel: ORA_DISK_8
channel ORA_DISK_8: SID=9 device type=DISK
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=143 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Secure Backup
allocated channel: ORA_SBT_TAPE_2
channel ORA_SBT_TAPE_2: SID=58 device type=SBT_TAPE
channel ORA_SBT_TAPE_2: Oracle Secure Backup
自动启动克隆实例(它的USERS指向真正的USERS,其他的文件是新克隆的):
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='epDa'

initialization parameters used for automatic instance:
db_name=ORCL
db_unique_name=epDa_tspitr_ORCL
compatible=11.2.0
db_block_size=8192
db_files=200
sga_target=280M
processes=50
db_create_file_dest=/u01/app/oracle/oradata
log_archive_dest_1='location=/u01/app/oracle/oradata'
#No auxiliary parameter file used


starting up automatic instance ORCL

Oracle instance started

Total System Global Area   292933632 bytes

Fixed Size                     1336092 bytes
Variable Size                100666596 bytes
Database Buffers             184549376 bytes
Redo Buffers                   6381568 bytes
Automatic instance created
Running TRANSPORT_SET_CHECK on recovery set tablespaces
TRANSPORT_SET_CHECK completed successfully

contents of Memory Script:
{
# set requested point in time
set untiltime "2018-07-07:10:58:17";
# 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';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script

executing command: SET until clause

Starting restore at 2018-07-07:11:09:28
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=81 device type=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: SID=5 device type=DISK
allocated channel: ORA_AUX_DISK_3
channel ORA_AUX_DISK_3: SID=30 device type=DISK
allocated channel: ORA_AUX_DISK_4
channel ORA_AUX_DISK_4: SID=56 device type=DISK
allocated channel: ORA_AUX_DISK_5
channel ORA_AUX_DISK_5: SID=82 device type=DISK
allocated channel: ORA_AUX_DISK_6
channel ORA_AUX_DISK_6: SID=6 device type=DISK
allocated channel: ORA_AUX_DISK_7
channel ORA_AUX_DISK_7: SID=31 device type=DISK
allocated channel: ORA_AUX_DISK_8
channel ORA_AUX_DISK_8: SID=57 device type=DISK
allocated channel: ORA_AUX_SBT_TAPE_1
channel ORA_AUX_SBT_TAPE_1: SID=83 device type=SBT_TAPE
channel ORA_AUX_SBT_TAPE_1: Oracle Secure Backup
allocated channel: ORA_AUX_SBT_TAPE_2
channel ORA_AUX_SBT_TAPE_2: SID=7 device type=SBT_TAPE
channel ORA_AUX_SBT_TAPE_2: Oracle Secure Backup

channel ORA_AUX_SBT_TAPE_1: starting datafile backup set restore
channel ORA_AUX_SBT_TAPE_1: restoring control file
channel ORA_AUX_SBT_TAPE_1: reading from backup piece 58t7d78b_1_1
channel ORA_AUX_SBT_TAPE_1: piece handle=58t7d78b_1_1 tag=TAG20180707T105052
channel ORA_AUX_SBT_TAPE_1: restored backup piece 1
channel ORA_AUX_SBT_TAPE_1: restore complete, elapsed time: 00:00:58
output file name=/u01/app/oracle/oradata/ORCL/controlfile/o1_mf_fn0crz7d_.ctl
Finished restore at 2018-07-07:11:10:30

sql statement: alter database mount clone database

sql statement: alter system archive log current

sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;

contents of Memory Script:
{
# set requested point in time
set untiltime "2018-07-07:10:58:17";
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile1 to new;
set newname for clone datafile3 to new;
set newname for clone datafile2 to new;
set newname for clone tempfile1 to new;
set newname for datafile4 to
"+DATA/orcl/datafile/users.265.980714801";
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile1, 3, 2, 4;
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

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

Starting restore at 2018-07-07:11:10:37
using channel ORA_AUX_DISK_1
using channel ORA_AUX_DISK_2
using channel ORA_AUX_DISK_3
using channel ORA_AUX_DISK_4
using channel ORA_AUX_DISK_5
using channel ORA_AUX_DISK_6
using channel ORA_AUX_DISK_7
using channel ORA_AUX_DISK_8
using channel ORA_AUX_SBT_TAPE_1
using channel ORA_AUX_SBT_TAPE_2

channel ORA_AUX_SBT_TAPE_1: starting datafile backup set restore
channel ORA_AUX_SBT_TAPE_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_SBT_TAPE_1: restoring datafile 00003 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_SBT_TAPE_1: restoring datafile 00002 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_SBT_TAPE_1: reading from backup piece 57t7d74d_1_1
channel ORA_AUX_SBT_TAPE_2: starting datafile backup set restore
channel ORA_AUX_SBT_TAPE_2: specifying datafile(s) to restore from backup set
channel ORA_AUX_SBT_TAPE_2: restoring datafile 00001 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_SBT_TAPE_2: restoring datafile 00004 to +DATA/orcl/datafile/users.265.980714801
channel ORA_AUX_SBT_TAPE_2: reading from backup piece 56t7d74d_1_1
channel ORA_AUX_SBT_TAPE_1: piece handle=57t7d74d_1_1 tag=TAG20180707T105052
channel ORA_AUX_SBT_TAPE_1: restored backup piece 1
channel ORA_AUX_SBT_TAPE_1: restore complete, elapsed time: 00:01:55
channel ORA_AUX_SBT_TAPE_2: piece handle=56t7d74d_1_1 tag=TAG20180707T105052
channel ORA_AUX_SBT_TAPE_2: restored backup piece 1
channel ORA_AUX_SBT_TAPE_2: restore complete, elapsed time: 00:02:15
Finished restore at 2018-07-07:11:12:57

datafile 1 switched to datafile copy
input datafile copy RECID=41 STAMP=980853177 file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_fn0cvhtz_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=42 STAMP=980853177 file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_fn0cvk93_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=43 STAMP=980853177 file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_fn0cvjz2_.dbf
对克隆实例做传统的不完恢复:
contents of Memory Script:
{
# set requested point in time
set untiltime "2018-07-07:10:58:17";
# online the datafiles restored or switched
sql clone "alter database datafile1 online";
sql clone "alter database datafile3 online";
sql clone "alter database datafile2 online";
sql clone "alter database datafile4 online";
# recover and open resetlogs
recover clone database tablespace"USERS", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile1 online

sql statement: alter database datafile3 online

sql statement: alter database datafile2 online

sql statement: alter database datafile4 online

Starting recover at 2018-07-07:11:12:58
using channel ORA_AUX_DISK_1
using channel ORA_AUX_DISK_2
using channel ORA_AUX_DISK_3
using channel ORA_AUX_DISK_4
using channel ORA_AUX_DISK_5
using channel ORA_AUX_DISK_6
using channel ORA_AUX_DISK_7
using channel ORA_AUX_DISK_8
using channel ORA_AUX_SBT_TAPE_1
using channel ORA_AUX_SBT_TAPE_2

starting media recovery

archived log for thread 1 with sequence 86 is already on disk as file +FRA/orcl/archivelog/2018_07_07/thread_1_seq_86.257.980852293
archived log for thread 1 with sequence 87 is already on disk as file +FRA/orcl/archivelog/2018_07_07/thread_1_seq_87.286.980852293
archived log for thread 1 with sequence 88 is already on disk as file +FRA/orcl/archivelog/2018_07_07/thread_1_seq_88.355.980852305
archived log file name=+FRA/orcl/archivelog/2018_07_07/thread_1_seq_86.257.980852293 thread=1 sequence=86
archived log file name=+FRA/orcl/archivelog/2018_07_07/thread_1_seq_87.286.980852293 thread=1 sequence=87
archived log file name=+FRA/orcl/archivelog/2018_07_07/thread_1_seq_88.355.980852305 thread=1 sequence=88
media recovery complete, elapsed time: 00:00:05
Finished recover at 2018-07-07:11:13:04

database opened
在克隆数据上,只读USERS,准备以传送表空间的方式数据泵导出USERS:
contents of Memory Script:
{
# make read only the tablespace that will be exported
sql clone 'alter tablespaceUSERS read only';
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/u01/app/oracle/oradata''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/u01/app/oracle/oradata''";
}
executing Memory Script

sql statement: alter tablespaceUSERS read only

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 metadata...
   EXPDP> Starting "SYS"."TSPITR_EXP_epDa":
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/TYPE/TYPE_SPEC
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/TYPE/TYPE_BODY
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/XMLSCHEMA/XMLSCHEMA
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX/INDEX
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/REF_CONSTRAINT
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
   EXPDP> Master table "SYS"."TSPITR_EXP_slhv" successfully loaded/unloaded
   EXPDP> ******************************************************************************
   EXPDP> Dump file set for SYS.TSPITR_EXP_slhv is:
   EXPDP>   /u01/app/oracle/oradata/tspitr_slhv_63292.dmp
   EXPDP> ******************************************************************************
   EXPDP> Datafiles required for transportable tablespace USERS:
   EXPDP>   +DATA/orcl/datafile/users.259.816169553
   EXPDP> Job "SYS"."TSPITR_EXP_slhv" successfully completed at 15:46:05
Export completed

自动地导入。




-------------以上是对照普通数据库的PITR,以下是多租户教材206页的内容但是下图选中部分是不需要做的:



-----------------------------------------插件数据库PITR:

SQL*Plus: Release 12.1.0.2.0 Production on Sat Jul 7 17:01:03 2018

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

SQL> conn / as sysdba
Connected.
SQL> alter pluggable database pdb2 close immediate;

Pluggable database altered.

SQL> exit
命令和分配通道:
$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Sat Jul 7 17:07:35 2018

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

connected to target database: CDB2 (DBID=727229478)

RMAN> run {
2> set until time '2018-07-07:16:46:16';
3> restore pluggable database pdb2;
4> recover pluggable database pdb2
5>auxiliary destination '/u01/app/oracle/oradata';
6> }

executing command: SET until clause

Starting restore at 2018-07-07:17:07:54
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=330 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=631 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=921 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=335 device type=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: SID=937 device type=DISK
allocated channel: ORA_DISK_6
channel ORA_DISK_6: SID=316 device type=DISK
allocated channel: ORA_DISK_7
channel ORA_DISK_7: SID=927 device type=DISK
allocated channel: ORA_DISK_8
channel ORA_DISK_8: SID=25 device type=DISK
allocated channel: ORA_DISK_9
channel ORA_DISK_9: SID=325 device type=DISK
allocated channel: ORA_DISK_10
channel ORA_DISK_10: SID=630 device type=DISK
allocated channel: ORA_DISK_11
channel ORA_DISK_11: SID=935 device type=DISK
allocated channel: ORA_DISK_12
channel ORA_DISK_12: SID=332 device type=DISK
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=941 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Secure Backup
allocated channel: ORA_SBT_TAPE_2
channel ORA_SBT_TAPE_2: SID=336 device type=SBT_TAPE
channel ORA_SBT_TAPE_2: Oracle Secure Backup

creating datafile file number=28 name=/u01/app/oracle/oradata/cdb2/pdb2_1/dj_pdb2.f
skipping datafile 10; already restored to file /u01/app/oracle/oradata/cdb2/pdb2_1/system01.dbf
skipping datafile 25; already restored to file /u01/app/oracle/oradata/cdb2/pdb2_1/ldata_01.dbf
skipping datafile 11; already restored to file /u01/app/oracle/oradata/cdb2/pdb2_1/sysaux01.dbf
Finished restore at 2018-07-07:17:08:11

自动启动克隆实例:
Starting recover at 2018-07-07:17:08:11
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
using channel ORA_DISK_7
using channel ORA_DISK_8
using channel ORA_DISK_9
using channel ORA_DISK_10
using channel ORA_DISK_11
using channel ORA_DISK_12
using channel ORA_SBT_TAPE_1
using channel ORA_SBT_TAPE_2
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='Fnhk'

initialization parameters used for automatic instance:
db_name=CDB2
db_unique_name=Fnhk_pitr_pdb2_CDB2
compatible=12.1.0.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_system_trig_enabled=FALSE
sga_target=2560M
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 CDB2

Oracle instance started

Total System Global Area    2684354560 bytes

Fixed Size                     2928008 bytes
Variable Size                603980408 bytes
Database Buffers            2063597568 bytes
Redo Buffers                  13848576 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set untiltime "2018-07-07:16:46:16";
# restore the controlfile
restore clone controlfile;

# mount the controlfile
sql clone 'alter database mount clone database';
}
executing Memory Script

executing command: SET until clause

Starting restore at 2018-07-07:17:08:53
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=6 device type=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: SID=87 device type=DISK
allocated channel: ORA_AUX_DISK_3
channel ORA_AUX_DISK_3: SID=169 device type=DISK
allocated channel: ORA_AUX_DISK_4
channel ORA_AUX_DISK_4: SID=250 device type=DISK
allocated channel: ORA_AUX_DISK_5
channel ORA_AUX_DISK_5: SID=7 device type=DISK
allocated channel: ORA_AUX_DISK_6
channel ORA_AUX_DISK_6: SID=89 device type=DISK
allocated channel: ORA_AUX_DISK_7
channel ORA_AUX_DISK_7: SID=170 device type=DISK
allocated channel: ORA_AUX_DISK_8
channel ORA_AUX_DISK_8: SID=251 device type=DISK
allocated channel: ORA_AUX_DISK_9
channel ORA_AUX_DISK_9: SID=8 device type=DISK
allocated channel: ORA_AUX_DISK_10
channel ORA_AUX_DISK_10: SID=90 device type=DISK
allocated channel: ORA_AUX_DISK_11
channel ORA_AUX_DISK_11: SID=171 device type=DISK
allocated channel: ORA_AUX_DISK_12
channel ORA_AUX_DISK_12: SID=252 device type=DISK
allocated channel: ORA_AUX_SBT_TAPE_1
channel ORA_AUX_SBT_TAPE_1: SID=9 device type=SBT_TAPE
channel ORA_AUX_SBT_TAPE_1: Oracle Secure Backup
allocated channel: ORA_AUX_SBT_TAPE_2
channel ORA_AUX_SBT_TAPE_2: SID=91 device type=SBT_TAPE
channel ORA_AUX_SBT_TAPE_2: Oracle Secure Backup

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/fast_recovery_area/CDB2/autobackup/2018_07_07/o1_mf_s_980872729_fn0z0tmw_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB2/autobackup/2018_07_07/o1_mf_s_980872729_fn0z0tmw_.bkp tag=TAG20180707T163849
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/CDB2/controlfile/o1_mf_fn10s9mz_.ctl
Finished restore at 2018-07-07:17:08:58

sql statement: alter database mount clone database


在克隆数据库上做不完全恢复,然后交换身份:

contents of Memory Script:
{
# set requested point in time
set untiltime "2018-07-07:17:27:45";
# switch to valid datafilecopies
switch clone datafile10 to datafilecopy
"/u01/app/oracle/oradata/cdb2/pdb2_1/system01.dbf";
switch clone datafile11 to datafilecopy
"/u01/app/oracle/oradata/cdb2/pdb2_1/sysaux01.dbf";
switch clone datafile25 to datafilecopy
"/u01/app/oracle/oradata/cdb2/pdb2_1/ldata_01.dbf";
switch clone datafile28 to datafilecopy
"/u01/app/oracle/oradata/cdb2/pdb2_1/dj_pdb2.f";
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile1 to new;
set newname for clone datafile4 to new;
set newname for clone datafile3 to new;
set newname for clone datafile6 to new;
set newname for clone datafile24 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile1, 4, 3, 6, 24;

switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

datafile 10 switched to datafile copy
input datafile copy RECID=3 STAMP=980876013 file name=/u01/app/oracle/oradata/cdb2/pdb2_1/system01.dbf

datafile 11 switched to datafile copy
input datafile copy RECID=4 STAMP=980876013 file name=/u01/app/oracle/oradata/cdb2/pdb2_1/sysaux01.dbf

datafile 25 switched to datafile copy
input datafile copy RECID=5 STAMP=980876013 file name=/u01/app/oracle/oradata/cdb2/pdb2_1/ldata_01.dbf

datafile 28 switched to datafile copy
input datafile copy RECID=6 STAMP=980876013 file name=/u01/app/oracle/oradata/cdb2/pdb2_1/dj_pdb2.f

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 2018-07-07:17:33:34
using channel ORA_AUX_DISK_1
using channel ORA_AUX_DISK_2
using channel ORA_AUX_DISK_3
using channel ORA_AUX_DISK_4
using channel ORA_AUX_DISK_5
using channel ORA_AUX_DISK_6
using channel ORA_AUX_DISK_7
using channel ORA_AUX_DISK_8
using channel ORA_AUX_DISK_9
using channel ORA_AUX_DISK_10
using channel ORA_AUX_DISK_11
using channel ORA_AUX_DISK_12
using channel ORA_AUX_SBT_TAPE_1
using channel ORA_AUX_SBT_TAPE_2

channel ORA_AUX_SBT_TAPE_1: starting datafile backup set restore
channel ORA_AUX_SBT_TAPE_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_SBT_TAPE_1: restoring datafile 00003 to /u01/app/oracle/oradata/CDB2/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_SBT_TAPE_1: restoring datafile 00006 to /u01/app/oracle/oradata/CDB2/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_SBT_TAPE_1: restoring datafile 00024 to /u01/app/oracle/oradata/CDB2/datafile/o1_mf_cdata_%u_.dbf
channel ORA_AUX_SBT_TAPE_1: reading from backup piece 0st7dp06_1_1
channel ORA_AUX_SBT_TAPE_2: starting datafile backup set restore
channel ORA_AUX_SBT_TAPE_2: specifying datafile(s) to restore from backup set
channel ORA_AUX_SBT_TAPE_2: restoring datafile 00001 to /u01/app/oracle/oradata/CDB2/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_SBT_TAPE_2: restoring datafile 00004 to /u01/app/oracle/oradata/CDB2/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_SBT_TAPE_2: reading from backup piece 0rt7dp06_1_1
channel ORA_AUX_SBT_TAPE_1: piece handle=0st7dp06_1_1 tag=TAG20180707T155550
channel ORA_AUX_SBT_TAPE_1: restored backup piece 1
channel ORA_AUX_SBT_TAPE_1: restore complete, elapsed time: 00:00:35
channel ORA_AUX_SBT_TAPE_2: piece handle=0rt7dp06_1_1 tag=TAG20180707T155550
channel ORA_AUX_SBT_TAPE_2: restored backup piece 1
channel ORA_AUX_SBT_TAPE_2: restore complete, elapsed time: 00:00:35
Finished restore at 2018-07-07:17:34:10

datafile 1 switched to datafile copy
input datafile copy RECID=12 STAMP=980876050 file name=/u01/app/oracle/oradata/CDB2/datafile/o1_mf_system_fn12874l_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=13 STAMP=980876050 file name=/u01/app/oracle/oradata/CDB2/datafile/o1_mf_undotbs1_fn12875h_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=14 STAMP=980876051 file name=/u01/app/oracle/oradata/CDB2/datafile/o1_mf_sysaux_fn1286nd_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=15 STAMP=980876051 file name=/u01/app/oracle/oradata/CDB2/datafile/o1_mf_users_fn1286or_.dbf
datafile 24 switched to datafile copy
input datafile copy RECID=16 STAMP=980876051 file name=/u01/app/oracle/oradata/CDB2/datafile/o1_mf_cdata_fn1286o2_.dbf

contents of Memory Script:
{
# set requested point in time
set untiltime "2018-07-07:17:27:45";
# online the datafiles restored or switched
sql clone "alter database datafile1 online";
sql clone "alter database datafile4 online";
sql clone "alter database datafile3 online";
sql clone 'PDB2' "alter database datafile
10 online";
sql clone 'PDB2' "alter database datafile
11 online";
sql clone 'PDB2' "alter database datafile
25 online";
sql clone 'PDB2' "alter database datafile
28 online";
sql clone "alter database datafile6 online";
sql clone "alter database datafile24 online";
# recover pdb
recover clone database tablespace"SYSTEM", "UNDOTBS1", "SYSAUX", "USERS", "CDATA" pluggable database
'PDB2'   delete archivelog;
sql clone 'alter database open read only';
plsql <<<begin
   add_dropped_ts;
end; >>>;
plsql <<<begin
   save_pdb_clean_scn;
end; >>>;
# shutdown clone before import
shutdown clone abort
plsql <<<begin
   pdbpitr_inspect(pdbname =>'PDB2');
end; >>>;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile1 online

sql statement: alter database datafile4 online

sql statement: alter database datafile3 online

sql statement: alter database datafile10 online

sql statement: alter database datafile11 online

sql statement: alter database datafile25 online

sql statement: alter database datafile28 online

sql statement: alter database datafile6 online

sql statement: alter database datafile24 online

Starting recover at 2018-07-07:17:34:12
using channel ORA_AUX_DISK_1
using channel ORA_AUX_DISK_2
using channel ORA_AUX_DISK_3
using channel ORA_AUX_DISK_4
using channel ORA_AUX_DISK_5
using channel ORA_AUX_DISK_6
using channel ORA_AUX_DISK_7
using channel ORA_AUX_DISK_8
using channel ORA_AUX_DISK_9
using channel ORA_AUX_DISK_10
using channel ORA_AUX_DISK_11
using channel ORA_AUX_DISK_12
using channel ORA_AUX_SBT_TAPE_1
using channel ORA_AUX_SBT_TAPE_2

starting media recovery

archived log for thread 1 with sequence 75 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_75_fn0xky39_.arc
archived log for thread 1 with sequence 76 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_76_fn0xo05c_.arc
archived log for thread 1 with sequence 77 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_77_fn0y8bos_.arc
archived log for thread 1 with sequence 78 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_78_fn0yccqb_.arc
archived log for thread 1 with sequence 79 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_79_fn10ffrg_.arc
archived log for thread 1 with sequence 80 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_80_fn1250l0_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_75_fn0xky39_.arc thread=1 sequence=75
archived log file name=/u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_76_fn0xo05c_.arc thread=1 sequence=76
archived log file name=/u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_77_fn0y8bos_.arc thread=1 sequence=77
archived log file name=/u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_78_fn0yccqb_.arc thread=1 sequence=78
archived log file name=/u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_79_fn10ffrg_.arc thread=1 sequence=79
archived log file name=/u01/app/oracle/fast_recovery_area/CDB2/archivelog/2018_07_07/o1_mf_1_80_fn1250l0_.arc thread=1 sequence=80
media recovery complete, elapsed time: 00:00:15
Finished recover at 2018-07-07:17:34:28

sql statement: alter database open read only



Oracle instance shut down


Removing automatic instance
Automatic instance removed
auxiliary instance file /u01/app/oracle/oradata/CDB2/datafile/o1_mf_sysaux_fn1286nd_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/CDB2/controlfile/o1_mf_fn126z64_.ctl deleted
Finished recover at 2018-07-07:17:34:35

RMAN>
这时候,就需要执行pluggable database的resetlogs;
$ sqlplus /nolog

SQL*Plus: Release 12.1.0.2.0 Production on Sat Jul 7 17:37:38 2018

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

SQL> conn / as sysdba
Connected.
SQL> selectcon_id, name , open_mode from v$pdbs;

    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                        READ ONLY
         3 PDB2                           MOUNTED
         4 PDB2_2                        READ WRITE

SQL> alter pluggable database PDB2;
alter pluggable database PDB2
                            *
ERROR at line 1:
ORA-00922: missing or invalid option


SQL> alter pluggable database PDB2 open;
alter pluggable database PDB2 open
*
ERROR at line 1:
ORA-01113: file 28 needs media recovery
ORA-01110: data file 28: '/u01/app/oracle/oradata/cdb2/pdb2_1/dj_pdb2.f'


SQL> alter pluggable database PDB2 open resetlogs;

Pluggable database altered.


------------------------多租户书的P224的实验7-15用的Cloud Control可以改成dbca:


12.1.0.2的时候,绝对不能选择下图的默认按钮:





页: [1]
查看完整版本: 活动第36/37次(2018-07-07星期六上下午)