windows bat

1,C:\dba\utility\rman\rman.bat

del C:\dba\utility\rman\full_db_* /q
set TNSNAME=ceipuat
rman target /@%TNSNAME% cmdfile=C:\dba\utility\rman\rman.cmd

2.C:\dba\utility\rman\rman.cmd

backup filesperset = 5 as compressed backupset database format 'C:\dba\utility\rman\full_db_%U'  plus archivelog  delete all input format 'C:\dba\utility\rman\full_db_arch_%U';

12C引进了pdb的概念,使得rman的恢复相对来说复杂了一些,这里对pdb的常规备份和恢复进行了简单测试,供大家参考

1.cdb启动和pdb关系测试

[oracle@xifenfei tmp]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.0.2
Beta on Wed Dec 12 23:48:02
2012

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

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.0.2
- 64bit

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> startup

ORACLE instance started.

Total System Global Area  939495424 bytes

Fixed Size                 
2267128 bytes

Variable Size            
662702088 bytes

Database Buffers          268435456
bytes

Redo
Buffers               
6090752 bytes

Database mounted.

Database opened.

SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

CON_ID      
DBID NAME                          
OPEN_MODE

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

2
4043918109
PDB$SEED                      
READ ONLY

3
2346805300
LX1                           
MOUNTED

4
2385557792
LX2                           
MOUNTED

5
1565384817
FF                            
MOUNTED

SQL> alter pluggable database all open;

Pluggable database altered.

SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

CON_ID      
DBID NAME                          
OPEN_MODE

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

2
4043918109
PDB$SEED                      
READ ONLY

3
2346805300
LX1                           
READ WRITE

4
2385557792
LX2                           
READ WRITE

5
1565384817
FF                            
READ WRITE

证明直接startup cdb里面的pdb不会自动open,需要手工进行open

2.rman使用cdb备份数据库

[oracle@xifenfei ~]$ rman target /

Recovery Manager: Release 12.1.0.0.2       
on Wed Dec 12 21:36:08 2012

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

connected to target database: xifenfei
(DBID=2412861330)

RMAN> backup filesperset = 5 as
compressed backupset database format '/tmp/full_db_%U';

Starting backup at 12-DEC-12

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=259 device
type=DISK

channel ORA_DISK_1: starting compressed
full datafile backup set

channel ORA_DISK_1: specifying
datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/xifenfei/system01.dbf

input datafile file number=00010 name=/u01/app/oracle/oradata/xifenfei/LX2/system01.dbf

input datafile file number=00011 name=/u01/app/oracle/oradata/xifenfei/LX2/sysaux01.dbf

channel ORA_DISK_1: starting piece 1 at
12-DEC-12

channel ORA_DISK_1: finished piece 1 at
12-DEC-12

piece handle=/tmp/full_db_06nsn3uq_1_1 tag=TAG20121212T213626 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45

channel ORA_DISK_1: starting compressed
full datafile backup set

channel ORA_DISK_1: specifying
datafile(s) in backup set

input datafile file number=00019 name=/u01/app/oracle/oradata/xifenfei/xffexample01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/xifenfei/undotbs01.dbf

input datafile file number=00007 name=/u01/app/oracle/oradata/xifenfei/LX1/system01.dbf

input datafile file number=00018
name=/u01/app/oracle/oradata/xifenfei/xffSAMPLE_SCHEMA_users01.dbf

input datafile file number=00008 name=/u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf

channel ORA_DISK_1: starting piece 1 at
12-DEC-12

channel ORA_DISK_1: finished piece 1 at
12-DEC-12

piece handle=/tmp/full_db_07nsn407_1_1 tag=TAG20121212T213626 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45

channel ORA_DISK_1: starting compressed
full datafile backup set

channel ORA_DISK_1: specifying
datafile(s) in backup set

input datafile file number=00017 name=/u01/app/oracle/oradata/xifenfei/xffsysaux01.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/xifenfei/pdbseed/system01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/xifenfei/pdbseed/sysaux01.dbf

channel ORA_DISK_1: starting piece 1 at
12-DEC-12

channel ORA_DISK_1: finished piece 1 at
12-DEC-12

piece handle=/tmp/full_db_08nsn41l_1_1 tag=TAG20121212T213626 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15

channel ORA_DISK_1: starting compressed
full datafile backup set

channel ORA_DISK_1: specifying
datafile(s) in backup set

input datafile file number=00003 name=/u01/app/oracle/oradata/xifenfei/sysaux01.dbf

input datafile file number=00016 name=/u01/app/oracle/oradata/xifenfei/xffsystem01.dbf

input datafile file number=00006 name=/u01/app/oracle/oradata/xifenfei/users01.dbf

input datafile file number=00009 name=/u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf

input datafile file number=00012 name=/u01/app/oracle/oradata/xifenfei/LX2/LX2_users01.dbf

channel ORA_DISK_1: starting piece 1 at
12-DEC-12

channel ORA_DISK_1: finished piece 1 at
12-DEC-12

piece handle=/tmp/full_db_09nsn440_1_1 tag=TAG20121212T213626 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45

channel ORA_DISK_1: starting compressed
full datafile backup set

channel ORA_DISK_1: specifying
datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at
12-DEC-12

channel ORA_DISK_1: finished piece 1 at
12-DEC-12

piece handle=/tmp/full_db_0ansn45d_1_1 tag=TAG20121212T213626 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 12-DEC-12

RMAN> list backup summary;

List of Backups

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

Key     TY LV S Device Type
Completion Time #Pieces #Copies Compressed Tag

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

1      
B  F  A DISK       
12-DEC-12      
1       1      
YES        TAG20121212T213250

2      
B  F  A DISK       
12-DEC-12      
1       1      
YES        TAG20121212T213626

3      
B  F  A DISK       
12-DEC-12      
1       1      
YES        TAG20121212T213626

4      
B  F  A DISK       
12-DEC-12      
1       1      
YES        TAG20121212T213626

5      
B  F  A DISK       
12-DEC-12      
1       1      
YES        TAG20121212T213626

6      
B  F  A DISK       
12-DEC-12      
1       1      
YES        TAG20121212T213626

RMAN> report schema;

Report of database schema for database with db_unique_name xifenfei

List of Permanent Datafiles

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

File Size(MB)
Tablespace           RB
segs Datafile Name

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

1   
700     
SYSTEM              
***     /u01/app/oracle/oradata/xifenfei/system01.dbf

2   
210      PDB$SEED:SYSTEM     
***    
/u01/app/oracle/oradata/xifenfei/pdbseed/system01.dbf

3   
550     
SYSAUX              
***     /u01/app/oracle/oradata/xifenfei/sysaux01.dbf

4   
165     
PDB$SEED:SYSAUX      ***    
/u01/app/oracle/oradata/xifenfei/pdbseed/sysaux01.dbf

5   
310     
UNDOTBS1            
***     /u01/app/oracle/oradata/xifenfei/undotbs01.dbf

6   
5       
USERS               
***     /u01/app/oracle/oradata/xifenfei/users01.dbf

7   
210     
LX1:SYSTEM          
***     /u01/app/oracle/oradata/xifenfei/LX1/system01.dbf

8   
165     
LX1:SYSAUX          
***     /u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf

9   
5       
LX1:USERS           
***    
/u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf

10  
210     
LX2:SYSTEM          
***     /u01/app/oracle/oradata/xifenfei/LX2/system01.dbf

11  
165     
LX2:SYSAUX          
***     /u01/app/oracle/oradata/xifenfei/LX2/sysaux01.dbf

12  
5       
LX2:USERS           
***    
/u01/app/oracle/oradata/xifenfei/LX2/LX2_users01.dbf

16   270     
FF:SYSTEM           
***     /u01/app/oracle/oradata/xifenfei/xffsystem01.dbf

17  
570     
FF:SYSAUX           
***     /u01/app/oracle/oradata/xifenfei/xffsysaux01.dbf

18  
5       
FF:USERS            
***     /u01/app/oracle/oradata/xifenfei/xffSAMPLE_SCHEMA_users01.dbf

19  
341     
FF:EXAMPLE          
***     /u01/app/oracle/oradata/xifenfei/xffexample01.dbf

List of Temporary Files

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

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

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

1   
530     
TEMP                
32767      
/u01/app/oracle/oradata/xifenfei/temp01.dbf

2   
20      
PDB$SEED:TEMP       
32767      
/u01/app/oracle/oradata/xifenfei/pdbseed/temp01.dbf

3   
20       LX1:TEMP            
32767      
/u01/app/oracle/oradata/xifenfei/LX1/temp01.dbf

4   
20      
LX2:TEMP            
32767      
/u01/app/oracle/oradata/xifenfei/LX2/temp01.dbf

5   
20      
FF:TEMP             
32767       /u01/app/oracle/oradata/xifenfei/xfftemp01.dbf

试验证明:通过rman通过cdb库的备份,可以实现对对应的cdb和所包含的pdb进行备份

3.配置pdb访问tns

[oracle@xifenfei ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.1.0.0.2       
on 12-DEC-2012 22:33:27

Copyright (c) 1991, 2012, Oracle. 
All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xifenfei)(PORT=1521)))

STATUS of the LISTENER

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

Alias                    
LISTENER

Version                  
TNSLSNR for Linux: Version 12.1.0.0.2

Start
Date               
12-DEC-2012 22:31:55

Uptime                   
0 days 0 hr. 1 min. 32 sec

Trace
Level              
off

Security                 
ON: Local OS Authentication

SNMP                     
OFF

Listener Parameter File  
/u01/app/oracle/product/12.1/db_1/network/admin/listener.ora

Listener Log
File        
/u01/app/oracle/diag/tnslsnr/xifenfei/listener/alert/log.xml

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xifenfei)(PORT=1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xifenfei)(PORT=5500))(Presentation=HTTP)(Session=RAW))

Services Summary...

Service "ff" has 1 instance(s).

Instance "xff",
status READY, has 1 handler(s) for this service...

Service "xifenfei" has 1 instance(s).

Instance "xff",
status READY, has 1 handler(s) for this service...

Service "lx1" has 1 instance(s).

Instance "xff",
status READY, has 1 handler(s) for this service...

Service "lx2" has 1 instance(s).

Instance "xff",
status READY, has 1 handler(s) for this service...

Service "xffXDB" has 1 instance(s).

Instance "xff",
status READY, has 1 handler(s) for this service...

The command completed successfully

[oracle@xifenfei admin]$ vi tnsnames.ora

lx1 =

(DESCRIPTION =

(ADDRESS =
(PROTOCOL = TCP)(HOST = xifenfei)(PORT = 1521))

(CONNECT_DATA =

(SERVER
= DEDICATED)

(SERVICE_NAME
= lx1)

)

)

ff =

(DESCRIPTION =

(ADDRESS =
(PROTOCOL = TCP)(HOST = xifenfei)(PORT = 1521))

(CONNECT_DATA =

(SERVER
= DEDICATED)

(SERVICE_NAME
= ff)

)

)

sqlplus访问pdb

[oracle@xifenfei admin]$ sqlplus sys@lx1
as sysdba

SQL*Plus: Release 12.1.0.0.2
Beta on Wed Dec 12 22:35:07
2012

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

Enter password:

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.0.2
- 64bit

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show con_name;

CON_NAME

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

LX1

SQL> create user xff identified by xifenfei;

User created.

SQL> GRANT SYSDBA TO XFF;

Grant succeeded.

4.rman备份pdb数据库

[oracle@xifenfei admin]$ rman target
xff/xifenfei@lx1

Recovery Manager: Release 12.1.0.0.2       
on Wed Dec 12 22:44:46 2012

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

connected to target database: xifenfei
(DBID=2412861330)

RMAN> backup filesperset = 5 as
compressed backupset database format '/tmp/lx1_db_%U';

Starting backup at 12-DEC-12

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=256 device
type=DISK

channel ORA_DISK_1: starting compressed
full datafile backup set

channel ORA_DISK_1: specifying
datafile(s) in backup set

input datafile file number=00007 name=/u01/app/oracle/oradata/xifenfei/LX1/system01.dbf

input datafile file number=00008 name=/u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf

input datafile file number=00009 name=/u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf

channel ORA_DISK_1: starting piece 1 at
12-DEC-12

channel ORA_DISK_1: finished piece 1 at
12-DEC-12

piece handle=/tmp/lx1_db_0bnsn80f_1_1 tag=TAG20121212T224534 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25

Finished backup at 12-DEC-12

RMAN> report schema;

Report of database schema for database with db_unique_name xifenfei

List of Permanent Datafiles

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

File Size(MB)
Tablespace           RB
segs Datafile Name

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

7   
210     
LX1:SYSTEM          
***     /u01/app/oracle/oradata/xifenfei/LX1/system01.dbf

8   
165     
LX1:SYSAUX          
***     /u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf

9   
5       
LX1:USERS           
***    
/u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf

List of Temporary Files

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

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

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

3   
20      
LX1:TEMP            
32767       /u01/app/oracle/oradata/xifenfei/LX1/temp01.dbf

5.rman通过cdb备份pdb

[oracle@xifenfei admin]$ rman target /

Recovery Manager: Release 12.1.0.0.2       
on Wed Dec 12 23:02:07 2012

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

connected to target database: xifenfei
(DBID=2412861330)

RMAN> backup filesperset = 5 as
compressed backupset pluggable database FF format '/tmp/ff_db_%U';

Starting backup at 12-DEC-12

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=262 device
type=DISK

channel ORA_DISK_1: starting compressed
full datafile backup set

channel ORA_DISK_1: specifying
datafile(s) in backup set

input datafile file number=00017 name=/u01/app/oracle/oradata/xifenfei/xffsysaux01.dbf

input datafile file number=00019 name=/u01/app/oracle/oradata/xifenfei/xffexample01.dbf

input datafile file number=00016 name=/u01/app/oracle/oradata/xifenfei/xffsystem01.dbf

input datafile file number=00018 name=/u01/app/oracle/oradata/xifenfei/xffSAMPLE_SCHEMA_users01.dbf

channel ORA_DISK_1: starting piece 1 at
12-DEC-12

channel ORA_DISK_1: finished piece 1 at
12-DEC-12

piece handle=/tmp/ff_db_0cnsn8vm_1_1 tag=TAG20121212T230214 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:26

Finished backup at 12-DEC-12

6.模拟pdb库全库恢复

SQL> conn xff/xifenfei@lx1 as sysdba

Connected.

SQL> create table t_xifenfei as select * from dba_objects;

Table created.

SQL> select count(*) from t_xifenfei;

COUNT(*)

----------

19121

--在pdb中不能切换日志(因为日志是全局的)

SQL> alter system switch logfile;

alter system switch logfile

*

ERROR at line 1:

ORA-65040: operation not allowed from within a pluggable database

SQL> shutdown immediate;

Pluggable Database closed.

--删除数据文件

[oracle@xifenfei admin]$ rm
/u01/app/oracle/oradata/xifenfei/LX1/*

--rman基于cdb恢复pdb库

[oracle@xifenfei ~]$ rman target /

Recovery Manager: Release 12.1.0.0.2       
on Wed Dec 12 23:11:22
2012

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

connected to target database: xifenfei (DBID=2412861330)

RMAN> restore pluggable database lx1;

Starting restore at 12-DEC-12

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=25 device
type=DISK

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
00007 to /u01/app/oracle/oradata/xifenfei/LX1/system01.dbf

channel ORA_DISK_1: restoring datafile
00008 to /u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf

channel ORA_DISK_1: restoring datafile
00009 to /u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf

channel ORA_DISK_1: reading from backup piece /tmp/lx1_db_0bnsn80f_1_1

channel ORA_DISK_1: piece
handle=/tmp/lx1_db_0bnsn80f_1_1
tag=TAG20121212T224534

channel ORA_DISK_1: restored backup piece
1

channel ORA_DISK_1: restore complete,
elapsed time: 00:00:25

Finished restore at 12-DEC-12

RMAN> recover pluggable database lx1;

Starting recover at 12-DEC-12

using channel ORA_DISK_1

starting media recovery

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

Finished recover at 12-DEC-12

RMAN> alter pluggable database lx1 open;

Statement processed

--验证恢复结果

SQL> conn xff/xifenfei@lx1 as sysdba

Connected.

SQL> select count(*) from t_xifenfei;

COUNT(*)

----------

19121

试验证明:对于pdb库的备份,使用rman可以在cdb级别进行还原和恢复

7.模拟数据文件恢复

SQL> create table t_xifenfei tablespace example

2   as

3    select * from dba_objects;

Table created.

SQL> select count(*) from t_xifenfei;

COUNT(*)

----------

89604

SQL> col name for a60

SQL> set lines 134

SQL> select file#,name from v$datafile;

FILE# NAME

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

5
/u01/app/oracle/oradata/xifenfei/undotbs01.dbf

16
/u01/app/oracle/oradata/xifenfei/xffsystem01.dbf

17
/u01/app/oracle/oradata/xifenfei/xffsysaux01.dbf

18
/u01/app/oracle/oradata/xifenfei/xffSAMPLE_SCHEMA_users01.dbf

19
/u01/app/oracle/oradata/xifenfei/xffexample01.dbf

--离线含测试数据的数据文件

SQL> alter database datafile 19 offline;

Database altered.

--删除数据文件

SQL> !rm
/u01/app/oracle/oradata/xifenfei/xffexample01.dbf

SQL> !ls -l
/u01/app/oracle/oradata/xifenfei/xffexample01.dbf

ls:
/u01/app/oracle/oradata/xifenfei/xffexample01.dbf: No such file or directory

--尝试pdb级别恢复

[oracle@xifenfei ~]$ rman target
sys/xifenfei@ff

Recovery Manager: Release 12.1.0.0.2       
on Wed Dec 12 23:29:03
2012

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

connected to target database: xifenfei (DBID=2412861330)

RMAN> restore datafile 19;

Starting restore at 12-DEC-12

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device
type=DISK

RMAN-00571:
===========================================================

RMAN-00569: =============== ERROR MESSAGE
STACK FOLLOWS ===============

RMAN-00571:
===========================================================

RMAN-03002: failure of restore command at 12/12/2012
23:29:15

RMAN-06026: some targets not found - aborting restore

RMAN-06023: no backup or copy of datafile 19 found to restore

--pdb级别不能识别对应数据文件(一种可能是我在cdb级别备份FF库,另一种可能bug)

RMAN> list backup of datafile 19;

specification does not match any backup in the repository

--在cdb级别还原

[oracle@xifenfei tmp]$ rman target /

Recovery Manager: Release 12.1.0.0.2       
on Wed Dec 12 23:44:21
2012

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

connected to target database: xifenfei (DBID=2412861330)

RMAN> list backup of datafile 19;

using target database control file instead of recovery catalog

List of Backup Sets

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

BS Key  Type LV
Size      
Device Type Elapsed Time Completion Time

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

3      
Full   
76.81M    
DISK       
00:00:44     12-DEC-12

BP
Key: 3   Status: AVAILABLE  Compressed: YES  Tag:
TAG20121212T213626

Piece
Name: /tmp/full_db_07nsn407_1_1

List of Datafiles in backup set 3

File LV Type Ckp SCN    Ckp Time  Name

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

19     
Full 1860043    12-DEC-12
/u01/app/oracle/oradata/xifenfei/xffexample01.dbf

BS Key  Type LV
Size      
Device Type Elapsed Time Completion Time

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

8      
Full   
189.52M   
DISK       
00:01:25    
12-DEC-12

BP
Key: 8   Status: AVAILABLE  Compressed: YES  Tag:
TAG20121212T230214

Piece
Name: /tmp/ff_db_0cnsn8vm_1_1

List of Datafiles in backup set 8

File LV Type Ckp SCN    Ckp Time  Name

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

19     
Full 1860043    12-DEC-12
/u01/app/oracle/oradata/xifenfei/xffexample01.dbf

RMAN> restore datafile 19;

Starting restore at 12-DEC-12

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=28 device
type=DISK

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
00019 to /u01/app/oracle/oradata/xifenfei/xffexample01.dbf

channel ORA_DISK_1: reading from backup piece /tmp/ff_db_0cnsn8vm_1_1

channel ORA_DISK_1: piece
handle=/tmp/ff_db_0cnsn8vm_1_1 tag=TAG20121212T230214

channel ORA_DISK_1: restored backup piece
1

channel ORA_DISK_1: restore complete,
elapsed time: 00:00:45

Finished restore at 12-DEC-12

--cdb级别恢复数据文件

RMAN> recover datafile 19;

Starting recover at 12-DEC-12

using channel ORA_DISK_1

starting media recovery

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

Finished recover at 12-DEC-12

--cdb级别不能直接online

RMAN> alter database datafile 19 online;

RMAN-00571:
===========================================================

RMAN-00569: =============== ERROR MESSAGE
STACK FOLLOWS ===============

RMAN-00571:
===========================================================

RMAN-03002: failure of sql statement command at 12/12/2012
23:46:15

ORA-01516: nonexistent log file, data
file, or temporary file
"19"

RMAN> alter pluggable database ff datafile 19
online;

RMAN-00571:
===========================================================

RMAN-00569: =============== ERROR MESSAGE
STACK FOLLOWS ===============

RMAN-00571:
===========================================================

RMAN-03002: failure of sql statement command at 12/12/2012
23:47:53

ORA-65046: operation not allowed from outside a pluggable database

--进入pdb库进行online

SQL> alter database datafile 19
online;

Database altered.

--验证数据

SQL> select count(*) from t_xifenfei;

COUNT(*)

----------

89604

试验证明:rman通过cdb级别操作,还是一步步恢复了pdb中离线异常的数据文件

8.pdb数据库冷备恢复

pdb数据库冷备恢复不需要完全关闭cdb数据库,只需要pdb数据库启动到mounted状态即可。



1.确保需要冷备的pdb1的open mode是mounted状态

SQL> show pdbs





    CON_ID CON_NAME  OPEN MODE  RESTRICTED

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

2 PDB$SEED  READ ONLY  NO

3 PDB  READ WRITE NO

4 PDB1  MOUNTED





2.备份pdb1

[oracle@ora12c cdb]$ cp -r pdb1 pdb_bak

3.删除pdb1

[oracle@ora12c cdb]$ rm -rf pdb1

4.把pdb1数据库open

SQL> alter pluggable database pdb1 open;

alter pluggable database pdb1 open

*

ERROR at line 1:

ORA-01157: cannot identify/lock data file 44 - see DBWR trace file

ORA-01110: data file 44: '/u01/app/oracle/oradata/cdb/pdb1/pdb_users01.dbf'

5.利用冷备还原

[oracle@ora12c cdb]$ mv pdb_bak pdb1

6.重新把pdb1数据库open。

SQL> alter pluggable database pdb1 open;





Pluggable database altered.





SQL> show pdbs





    CON_ID CON_NAME  OPEN MODE  RESTRICTED

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

2 PDB$SEED  READ ONLY  NO

3 PDB  READ WRITE NO

4 PDB1  READ WRITE NO

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

pdb数据库冷备恢复不需要完全关闭cdb数据库,只需要pdb数据库启动到mounted状态即可。



1.确保需要冷备的pdb1的open mode是mounted状态

SQL> show pdbs





    CON_ID CON_NAME  OPEN MODE
 RESTRICTED

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

2 PDB$SEED  READ ONLY  NO

3 PDB  READ WRITE NO

4 PDB1  MOUNTED





2.备份pdb1

[oracle@ora12c cdb]$ cp -r pdb1 pdb_bak

3.删除pdb1

[oracle@ora12c cdb]$ rm -rf pdb1

4.把pdb1数据库open

SQL> alter pluggable database pdb1 open;

alter pluggable database pdb1 open

*

ERROR at line 1:

ORA-01157: cannot identify/lock data file 44 -
see DBWR trace file

ORA-01110: data file 44:
'/u01/app/oracle/oradata/cdb/pdb1/pdb_users01.dbf'

5.利用冷备还原

[oracle@ora12c cdb]$ mv pdb_bak pdb1

6.重新把pdb1数据库open。

SQL> alter pluggable database pdb1 open;





Pluggable database altered.





SQL> show pdbs





    CON_ID CON_NAME  OPEN MODE
 RESTRICTED

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

2 PDB$SEED  READ ONLY  NO

3 PDB  READ WRITE NO

4 PDB1  READ WRITE NO

12C RMAN 备份参考v1的更多相关文章

  1. 12C RMAN 备份参考

    12C引进了pdb的概念,使得rman的恢复相对来说复杂了一些,这里对pdb的常规备份和恢复进行了简单测试,供大家参考 1.cdb启动和pdb关系测试 [oracle@xifenfei tmp]$ s ...

  2. Oracle 12c RMAN备份文档

    创建备份目录,查看剩余空间 [cistest@cistest ~]$ df -h df: '/home/oratest/.gvfs': Permission denied Filesystem Siz ...

  3. Oracle RAC 实验环境RMAN备份v1.01

    Oracle RAC 实验环境RMAN备份v1.01 环境:RHEL 6.5 + Oracle GI 11.2.0.4 + RAC 11.2.0.4 (2 nodes) 需求:制定RAMN备份策略 版 ...

  4. Oracle 12c 的RMAN备份

    备份 rman只备份cdb 只备份CDB数据库需要具有SYSDBA或SYSBACKUP权限用户连接到CDB的root环境下,执行backupdatabase root命令即可完成对CDB的备份,方法如 ...

  5. 【12c】12c RMAN新特性之通过网络远程恢复数据库(RESTORE/Recover from Service)

    [12c]12c RMAN新特性之通过网络远程恢复数据库(RESTORE/Recover from Service) 通过网络远程恢复数据库(Restore/Recover from Service) ...

  6. DG环境数据库RMAN备份策略制定

    DG环境数据库RMAN备份策略制定: 主库(Primary) 全库备份 归档备份 删除历史文件夹 备库(Standby) 删除归档 引用说明 主库(Primary) $ crontab -l 0 1 ...

  7. RMAN备份演练进阶篇

    前篇介绍了通过rman进行各种备份,进阶篇则主要是rman的一些功能扩展和增加功能,利用前篇你已经完全可以完成数据库的备份,而通过本篇你可以更好更方便的完成数据库的备份. 一.建立增量备份 如果数据库 ...

  8. RMAN备份演练初级篇

    前面我们已经知道了如何进入rman,以及rman的一些基本命令,相信大家定会觉着rman操作的简单,事实也确实如此,但万不要因此小视rman的强大,简单往往意味着灵活,灵活对于那些有心人则意味着主动权 ...

  9. Oracle RMAN备份恢复指导书

    目 录 1 目的与范围... 1 2 术语和定义... 1 3 角色和职责... 2 4 使用RMAN备份数据库... 2 4.1.1 检查数据库模式... 2 4.1.2 连接到target数据库. ...

随机推荐

  1. OpenCV249 for python278 最简配置方案

    跟很多开源软件一样OpenCV也提供了完善的Python接口,非常便于调用.OpenCV 包含了超过 2500 个算法和函数,几乎任何一个能想到的成熟算法都可以通过调用OpenCV的函数来实现,超级方 ...

  2. ACM Skiing问题

    ACM Skiing问题 描述 Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.Michae ...

  3. C#基础原理拾遗——引用类型的值传递和引用传递

    C#基础原理拾遗——引用类型的值传递和引用传递 以前写博客不深动,只搭个架子,像做笔记,没有自己的思考,也没什么人来看.这个毛病得改,就从这一篇开始… 最近准备面试,深感基础之重要,奈何我不是计算机科 ...

  4. 搭建WEB邮件系统,爆强!

    Linux+postfix+extmail+dovecot打造基于web页面的邮件系统 原文地址: http://blog.csdn.net/deansrk/article/details/67177 ...

  5. [置顶] Android系统移植与调试之------->Amlogic方案编译步骤

    1. 拷贝Amlogic的SourceCode 切换目录到  /home/roco/work/amlogic/SourceCode/mx0831-0525下将mx0831-0525.tgz拷贝到  / ...

  6. message from server: "Host 'xxx' is not allowed to connect to this MySQL server的解决

    解决方法:    1. 改表法.    可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" ...

  7. swift设置textfield边框颜色

    //swift3.0,如果是2.0的话也可以照着这个样子去写,语法有所变动.根据联想出来的就可以了. let tx = UITextField(frame: CGRect(x: 100, y: 100 ...

  8. [HMLY]9.深入浅出-iOS Reactive Cocoa的常见用法

    简介 今天的主角是Reactive Cocoa,聊聊Reactive Cocoa的常见使用:KVO.Target.Delegate.Notification. Reactive Cocoa 是一个重量 ...

  9. python3的文件读写模式

    任何一种语言,文件的读写都是非常常见的.python的文件读写非常简单,仅仅一个函数open(file也可以,但是我不常用). 先看看官网的解释: open(file, mode='r', buffe ...

  10. js的eval函数解析后台返回的json数据时为什加上圆括号eval("("+data+")"),而HTML页面定义的数据不用

    一,情况如下,这是成功代码: $(function () { $.ajax({ url: "Demo.aspx", type: "post", data: { ...