데이터 베이스 MySQL 튜토리얼 rman备份恢复命令之switch

rman备份恢复命令之switch

Jun 07, 2016 pm 05:31 PM
switch

rman备份恢复命令之switch,更新数据文件名为rman下镜像拷贝时指定的数据文件名,更新数据文件名为 set newname 命令指定的名字。

一 switch 命令
1 switch命令用途
更新数据文件名为rman下镜像拷贝时指定的数据文件名
更新数据文件名为 set newname 命令指定的名字。
 
2 switch 命令使用前提条件
rman 必须连接到目标数据库
当switch tablespaces、datafiles、tempfiles时,这些文件必须离线
当switch 整个数据库时,,数据库不能open
3 注意事项
switch....to copy 命令用于rman命令提示符下
switch没有to copy的命令用于run语句块中
 
4 语法
  第一组
  switch dtabase to copy;                 
  switch datafile number|name to copy;
  switch tablespace name to copy;
  第二组
  switch datafile all;
  switch datafile number|name;
  switch tempfile all;

推荐阅读:

Oracle基础教程之通过RMAN复制数据库

RMAN备份策略制定参考内容

RMAN备份学习笔记

Oracle数据库备份加密 RMAN加密
 
二 举例如下:
例一:用switch datafile number to copy 更新数据文件位置和名字
RMAN> backup as copy datafile 8  format '/oracle/CRM/test.dbf';
Starting backup at 2013-02-22 10:06:21
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting datafile copy
input datafile file number=00008 name=/backup/test.dbf
output file name=/oracle/CRM/test.dbf tag=TAG20130222T100621 RECID=14 STAMP=808049181
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2013-02-22 10:06:22
Starting Control File and SPFILE Autobackup at 2013-02-22 10:06:22
piece handle=/backup/c-3599153036-20130222-01 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-02-22 10:06:25

RMAN> sql 'alter tablespace test offline';
sql statement: alter tablespace test offline
RMAN> switch datafile 8 to copy;
datafile 8 switched to datafile copy "/oracle/CRM/test.dbf"

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/system01.dbf
2    540      SYSAUX              ***    /oracle/CRM/sysaux01.dbf
3    100      UNDOTBS3            ***    /oracle/CRM/undotbs3.dbf
4    1742    USERS                ***    /backup/users01.dbf
5    500      POS                  ***    /oracle/CRM/pos.dbf
6    100      ERP                  ***    /oracle/CRM/erp.dbf
7    5        USER01              ***    /oracle/CRM/user01.dbf
8    0        TEST                ***    /oracle/CRM/test.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace          Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    218      TEMP                32767      /oracle/CRM/temp01.dbf
2    3072    MYNEWTEMP            40960      /oracle/CRM/newtemp.dbf

例二 用switch tablespace name to copy更新表空间所有数据文件位置和名字
RMAN> backup  as copy  tablespace  pos format '/oracle/%N%f.dbf';
(%N为表空间名、%f为数据文件绝对文件号)
Starting backup at 2013-02-22 10:55:49
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/oracle/CRM/pos.dbf
channel ORA_DISK_2: starting datafile copy
input datafile file number=00009 name=/oracle/CRM/pos2.dbf
output file name=/oracle/POS9.dbf tag=TAG20130222T105549 RECID=18 STAMP=808052153
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:07
output file name=/oracle/POS5.dbf tag=TAG20130222T105549 RECID=19 STAMP=808052179
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:36
Finished backup at 2013-02-22 10:56:25
Starting Control File and SPFILE Autobackup at 2013-02-22 10:56:25
piece handle=/backup/c-3599153036-20130222-03 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-02-22 10:56:28
RMAN> sql 'alter tablespace  pos offline';
sql statement: alter tablespace  pos offline
RMAN> switch tablespace pos to copy;
datafile 5 switched to datafile copy "/oracle/POS5.dbf"
datafile 9 switched to datafile copy "/oracle/POS9.dbf"
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/system01.dbf
2    540      SYSAUX              ***    /oracle/CRM/sysaux01.dbf
3    100      UNDOTBS3            ***    /oracle/CRM/undotbs3.dbf
4    1742    USERS                ***    /backup/users01.dbf
5    0        POS                  ***    /oracle/POS5.dbf
6    100      ERP                  ***    /oracle/CRM/erp.dbf
7    5        USER01              ***    /oracle/CRM/user01.dbf
8    0        TEST                ***    /oracle/CRM/test.dbf
9    0        POS                  ***    /oracle/POS9.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace          Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    218      TEMP                32767      /oracle/CRM/temp01.dbf
2    3072    MYNEWTEMP            40960      /oracle/CRM/newtemp.dbf
例三 用switch dtabase to copy更新数据库所有数据文件位置和名字
RMAN> backup as copy database format '/oracle/CRM/test/%N%f.dbf';
Starting backup at 2013-02-22 11:26:52
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=129 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=192 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/backup/users01.dbf
channel ORA_DISK_2: starting datafile copy
input datafile file number=00001 name=/oracle/CRM/system01.dbf
output file name=/oracle/CRM/test/SYSTEM1.dbf tag=TAG20130222T112653 RECID=52 STAMP=808054107
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:01:41
channel ORA_DISK_2: starting datafile copy
input datafile file number=00002 name=/oracle/CRM/sysaux01.dbf
output file name=/oracle/CRM/test/USERS4.dbf tag=TAG20130222T112653 RECID=53 STAMP=808054182
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:54
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/oracle/POS5.dbf
output file name=/oracle/CRM/test/SYSAUX2.dbf tag=TAG20130222T112653 RECID=54 STAMP=808054193
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:01:11
channel ORA_DISK_2: starting datafile copy
input datafile file number=00003 name=/oracle/CRM/undotbs3.dbf
output file name=/oracle/CRM/test/UNDOTBS33.dbf tag=TAG20130222T112653 RECID=55 STAMP=808054203
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:16
channel ORA_DISK_2: starting datafile copy
input datafile file number=00006 name=/oracle/CRM/erp.dbf
output file name=/oracle/CRM/test/ERP6.dbf tag=TAG20130222T112653 RECID=56 STAMP=808054230
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_2: starting datafile copy
input datafile file number=00009 name=/oracle/POS9.dbf
output file name=/oracle/CRM/test/POS5.dbf tag=TAG20130222T112653 RECID=57 STAMP=808054247
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:58
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=/oracle/CRM/user01.dbf
output file name=/oracle/CRM/test/POS9.dbf tag=TAG20130222T112653 RECID=58 STAMP=808054247
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:08
channel ORA_DISK_2: starting datafile copy
input datafile file number=00008 name=/oracle/CRM/test.dbf
output file name=/oracle/CRM/test/USER017.dbf tag=TAG20130222T112653 RECID=59 STAMP=808054250
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:00
output file name=/oracle/CRM/test/TEST8.dbf tag=TAG20130222T112653 RECID=60 STAMP=808054250
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2013-02-22 11:30:51
Starting Control File and SPFILE Autobackup at 2013-02-22 11:30:51
piece handle=/backup/c-3599153036-20130222-06 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-02-22 11:30:59
RMAN> switch database to copy;
datafile 1 switched to datafile copy "/oracle/CRM/test/SYSTEM1.dbf"
datafile 2 switched to datafile copy "/oracle/CRM/test/SYSAUX2.dbf"
datafile 3 switched to datafile copy "/oracle/CRM/test/UNDOTBS33.dbf"
datafile 4 switched to datafile copy "/oracle/CRM/test/USERS4.dbf"
datafile 5 switched to datafile copy "/oracle/CRM/test/POS5.dbf"
datafile 6 switched to datafile copy "/oracle/CRM/test/ERP6.dbf"
datafile 7 switched to datafile copy "/oracle/CRM/test/USER017.dbf"
datafile 8 switched to datafile copy "/oracle/CRM/test/TEST8.dbf"
datafile 9 switched to datafile copy "/oracle/CRM/test/POS9.dbf"
RMAN> sql 'alter database open';
sql statement: alter database open
SQL> select file#,name,status from v$datafile;
    FILE# NAME                                    STATUS
---------- ---------------------------------------- -------
        1 /oracle/CRM/test/SYSTEM1.dbf            SYSTEM
        2 /oracle/CRM/test/SYSAUX2.dbf            ONLINE
        3 /oracle/CRM/test/UNDOTBS33.dbf          ONLINE
        4 /oracle/CRM/test/USERS4.dbf              ONLINE
        5 /oracle/CRM/test/POS5.dbf                ONLINE
        6 /oracle/CRM/test/ERP6.dbf                ONLINE
        7 /oracle/CRM/test/USER017.dbf            ONLINE
        8 /oracle/CRM/test/TEST8.dbf              ONLINE
        9 /oracle/CRM/test/POS9.dbf                ONLINE

linux

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

뜨거운 기사 태그

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

스위치 일본판과 홍콩판의 차이점은 무엇인가요? 스위치 일본판과 홍콩판의 차이점은 무엇인가요? Jun 20, 2023 pm 02:06 PM

스위치 일본판과 홍콩판의 차이점은 무엇인가요?

스위치가 TV에 응답하지 않으면 어떻게 해야 합니까? 스위치가 TV에 응답하지 않으면 어떻게 해야 합니까? Jul 03, 2023 am 11:15 AM

스위치가 TV에 응답하지 않으면 어떻게 해야 합니까?

스위치를 베이스에서 항상 충전할 수 있나요? 스위치를 베이스에서 항상 충전할 수 있나요? Jul 06, 2023 pm 04:51 PM

스위치를 베이스에서 항상 충전할 수 있나요?

Elden's Ring을 스위치로 플레이할 수 있나요? Elden's Ring을 스위치로 플레이할 수 있나요? Mar 11, 2024 am 11:31 AM

Elden's Ring을 스위치로 플레이할 수 있나요?

스위치 라이트와 스위치의 차이점은 무엇입니까 스위치 라이트와 스위치의 차이점은 무엇입니까 Jun 28, 2023 pm 02:13 PM

스위치 라이트와 스위치의 차이점은 무엇입니까

switch 문에 기본 옵션이 필요합니까? switch 문에 기본 옵션이 필요합니까? Nov 25, 2020 pm 04:03 PM

switch 문에 기본 옵션이 필요합니까?

switch32g에 메모리가 충분합니까? switch32g에 메모리가 충분합니까? Jun 20, 2023 pm 02:28 PM

switch32g에 메모리가 충분합니까?

세가에는 닌텐도 스위치 2 개발 키트가 있는 것으로 전해지고 있으며, 'FF7:R'은 스위치 2에서 실행하면 PS5 게임처럼 보인다. 세가에는 닌텐도 스위치 2 개발 키트가 있는 것으로 전해지고 있으며, 'FF7:R'은 스위치 2에서 실행하면 PS5 게임처럼 보인다. Sep 10, 2023 pm 05:33 PM

세가에는 닌텐도 스위치 2 개발 키트가 있는 것으로 전해지고 있으며, 'FF7:R'은 스위치 2에서 실행하면 PS5 게임처럼 보인다.

See all articles