手机版
你好,游客 登录 注册
背景:
阅读新闻

rman备份恢复命令之switch

[日期:2013-08-19] 来源:Linux社区  作者:Linux [字体:大 中 小]

例四 用switch tempfile all更新所有临时数据文件位置和名字
SQL> select file#,name,status from v$tempfile;
    FILE# NAME                                    STATUS
---------- ---------------------------------------- -------
        1 /Oracle/CRM/temp01.dbf                  ONLINE
        2 /oracle/CRM/newtemp.dbf                  ONLINE
 
语句如下: 
startup force mount
run{
set newname for tempfile 1 to '/oracle/CRM/test/temp01.dbf';
set newname for tempfile 2 to '/oracle/CRM/test/temp02.dbf';
switch tempfile all;
alter database open;
}
执行过程如下:
RMAN> startup force mount
run{
set newname for tempfile 1 to '/oracle/CRM/test/temp01.dbf';
set newname for tempfile 2 to '/oracle/CRM/test/temp02.dbf';
switch tempfile all;
alter database open;
}
Oracle instance started
database mounted
Total System Global Area    1252663296 bytes
Fixed Size                    2226072 bytes
Variable Size              1006635112 bytes
Database Buffers            234881024 bytes
Redo Buffers                  8921088 bytes
RMAN> 2> 3> 4> 5> 6>
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /oracle/CRM/test/temp01.dbf in control file
renamed tempfile 2 to /oracle/CRM/test/temp02.dbf in control file
database opened
RMAN> report schema;
Report of database schema for database with db_unique_name CRM
List of Permanent Datafiles
===========================
File Size(MB) Tablespace          RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    750      SYSTEM              ***    /oracle/CRM/test/SYSTEM1.dbf
2    540      SYSAUX              ***    /oracle/CRM/test/SYSAUX2.dbf
3    100      UNDOTBS3            ***    /oracle/CRM/test/UNDOTBS33.dbf
4    1742    USERS                ***    /oracle/CRM/test/USERS4.dbf
5    500      POS                  ***    /oracle/CRM/test/POS5.dbf
6    100      ERP                  ***    /oracle/CRM/test/ERP6.dbf
7    5        USER01              ***    /oracle/CRM/test/USER017.dbf
8    1        TEST                ***    /oracle/CRM/test/TEST8.dbf
9    10      POS                  ***    /oracle/CRM/test/POS9.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace          Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    218      TEMP                32767      /oracle/CRM/test/temp01.dbf
2    3072    MYNEWTEMP            40960      /oracle/CRM/test/temp02.dbf
例五 用switch datafile all更新表空间所有数据位置和名字
语句:
run{
sql 'alter tablespace pos offline immediate';
set newname for datafile '/oracle/CRM/test/POS5.dbf' to '/oracle/CRM/pos1.dbf';
set newname for datafile '/oracle/CRM/test/POS9.dbf' to '/oracle/CRM/pos2.dbf';
restore tablespace pos;
switch datafile all;
recover tablespace pos;
sql 'alter tablespace pos online';
}
执行过程如下:
RMAN> run{
2> sql 'alter tablespace pos offline immediate';
3> set newname for datafile '/oracle/CRM/test/POS5.dbf' to '/oracle/CRM/pos1.dbf';
4> set newname for datafile '/oracle/CRM/test/POS9.dbf' to '/oracle/CRM/pos2.dbf';
5> restore tablespace pos;
6> switch datafile all;
7> recover tablespace pos;
8> sql 'alter tablespace pos online';
9> }
sql statement: alter tablespace pos offline immediate
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 2013-02-22 15:18:37
using channel ORA_DISK_1
using channel ORA_DISK_2
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 00005 to /oracle/CRM/pos1.dbf
channel ORA_DISK_1: restoring datafile 00009 to /oracle/CRM/pos2.dbf
channel ORA_DISK_1: reading from backup piece /backup/20130222_hho2k7jn_1_1
channel ORA_DISK_1: piece handle=/backup/20130222_hho2k7jn_1_1 tag=TAG20130222T145756
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 2013-02-22 15:19:03
datafile 5 switched to datafile copy
input datafile copy RECID=72 STAMP=808067944 file name=/oracle/CRM/pos1.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=73 STAMP=808067944 file name=/oracle/CRM/pos2.dbf
Starting recover at 2013-02-22 15:19:04
using channel ORA_DISK_1
using channel ORA_DISK_2
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 2013-02-22 15:19:05
sql statement: alter tablespace pos online
RMAN> report schema;
Report of database schema for database with db_unique_name CRM
List of Permanent Datafiles
===========================
File Size(MB) Tablespace          RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    750      SYSTEM              ***    /oracle/CRM/test/SYSTEM1.dbf
2    540      SYSAUX              ***    /oracle/CRM/test/SYSAUX2.dbf
3    100      UNDOTBS3            ***    /oracle/CRM/test/UNDOTBS33.dbf
4    1742    USERS                ***    /oracle/CRM/test/USERS4.dbf
5    500      POS                  ***    /oracle/CRM/pos1.dbf
6    100      ERP                  ***    /oracle/CRM/test/ERP6.dbf
7    5        USER01              ***    /oracle/CRM/test/USER017.dbf
8    1        TEST                ***    /oracle/CRM/test/TEST8.dbf
9    10      POS                  ***    /oracle/CRM/pos2.dbf

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款