2007年08月8日

RMAN auxiliary 的應用

簡介: 9i rman 除了備份的功能之外,也附加了一些額外的應用,這次是介照如何用rman 的auxiliary 產生一個副本的db

環境簡介:
os:Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
oracle: 9.2.0.4.0 (32位元)
RAM:1G


ORACLE_SID 角色 附記
binhu target資料庫  
rman rman資料庫  
clne clone資料庫  

安裝oracle跟建立新的資料庫跟使用rman catalog db不在這個文章說明,所以請自行準備好這個環境,以利後面的測試


先登入來源db,我的oracle_sid是 binhu,然後產生pfile,然後再離開
SQL> create pfile='/tmp/pfile' from spfile;

修改pfile裡的檔案 (重要的地方請看紅色的地方。重點在於路徑跟db名字)
*.aq_tm_processes=1
*.background_dump_dest='/u01/app/oracle/admin/clne/bdump'
*.compatible='9.2.0.0.0'
*.control_files='/u02/clne/control01.ctl','/u02/clne/control02.ctl','/u02/clne/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/clne/cdump'
*.db_block_size=8192
*.db_cache_size=33554432
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='clne'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=clneXDB)'
*.fast_start_mttr_target=300
*.hash_join_enabled=TRUE
*.instance_name='clne'
*.java_pool_size=83886080
*.job_queue_processes=10
*.large_pool_size=16777216
*.log_archive_dest='/u02/arch'
*.log_archive_start=TRUE
*.open_cursors=300
*.pga_aggregate_target=25165824
*.processes=150
*.query_rewrite_enabled='FALSE'
*.remote_login_passwordfile='EXCLUSIVE'
*.shared_pool_size=83886080
*.sort_area_size=524288
*.star_transformation_enabled='FALSE'
*.timed_statistics=TRUE
*.undo_management='AUTO'
*.undo_retention=10800
*.undo_tablespace='NEW_UNDO'
*.user_dump_dest='/u01/app/oracle/admin/clne/udump'
*.db_file_name_convert=('/u01/app/oracle/oradata/binhu/','/u02/clne/')
*.log_file_name_convert=('/u01/app/oracle/oradata/binhu/','/u02/clne/')
ps: 把pfile裡有設定到的目錄都需建立起來,並且要小心目錄的權限必需要能讓oracle能讀寫

增加一筆資料  $ORACLE_HOME/network/admin/tnsnames.ora  (我的clone db的名字取為clne)
clne =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.200.101)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = clne)
    )
  )



增加一筆資料 $ORACLE_HOME/network/admin/listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/9.2.0)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = binhu)
      (ORACLE_HOME = /u01/app/oracle/product/9.2.0)
      (SID_NAME = binhu)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = rman)
      (ORACLE_HOME = /u01/app/oracle/product/9.2.0)
      (SID_NAME = rman)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = clne)
      (ORACLE_HOME = /u01/app/oracle/product/9.2.0)
      (SID_NAME = clne)
    )
  )
再執行lsnrctl reload

再建立clone資料庫的密碼檔了
[oracle@db1 u01]$cd $ORACLE_HOME/dbs
[oracle@db1 dbs]$ orapwd file=orapwclne  password=oracle entries=5
ps:標準檔案名字為 orapw<ORACLE_SID>,所以以我的這個例子來說就是orapwclne


進行測試 tnsping  clne

[oracle@db1 dbs]$ tnsping clne

TNS Ping Utility for Linux: Version 9.2.0.4.0 - Production on 11-JUL-2007 19:55:02

Copyright (c) 1997 Oracle Corporation.  All rights reserved.

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


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.200.101)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = clne)))
OK (20 msec)


再進行測試環境跟查db file的schema
[oracle@db1 ~]$ rman target sys/oracle@binhu

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: BINHU (DBID=645032534)

RMAN> report schema ;

using target database controlfile instead of recovery catalog
Report of database schema
File K-bytes    Tablespace           RB segs Datafile Name
---- ---------- -------------------- ------- -------------------
1        399360 SYSTEM               ***     /u01/app/oracle/oradata/binhu/system01.dbf
2         10240 TBS                  ***     /u01/app/oracle/oradata/binhu/tbs.dbf
3         20480 CWMLITE              ***     /u01/app/oracle/oradata/binhu/cwmlite01.dbf
4         20480 DRSYS                ***     /u01/app/oracle/oradata/binhu/drsys01.dbf
5        152960 EXAMPLE              ***     /u01/app/oracle/oradata/binhu/example01.dbf
6         25600 INDX                 ***     /u01/app/oracle/oradata/binhu/indx01.dbf
7         20480 ODM                  ***     /u01/app/oracle/oradata/binhu/odm01.dbf
8         10240 TOOLS                ***     /u01/app/oracle/oradata/binhu/tools01.dbf
9         25600 USERS                ***     /u01/app/oracle/oradata/binhu/users01.dbf
10        46080 XDB                  ***     /u01/app/oracle/oradata/binhu/xdb01.dbf
11       296960 NEW_UNDO             ***     /u01/app/oracle/oradata/binhu/new_undotbs.dbf
12        10240 TTB                  ***     /u01/app/oracle/oradata/binhu/ttb.dbf


先準備等一下auxiliary動作所需要的script
ps:紅色為必要的;灰色是因為我是在同台機器上做,所以要設定新的路徑。如在新的機器上,就可不必寫,除非自已要指定新的路徑才需要寫
run {
allocate auxiliary channel tt type disk;
set newname for datafile 1 to '/u02/clne/system01.dbf';
set newname for datafile 2 to '/u02/clne/tbs.dbf';
set newname for datafile 3 to '/u02/clne/cwmlite01.dbf';
set newname for datafile 4 to '/u02/clne/drsys01.dbf';
set newname for datafile 5 to '/u02/clne/example01.dbf';
set newname for datafile 6 to '/u02/clne/indx01.dbf';
set newname for datafile 7 to '/u02/clne/odm01.dbf';
set newname for datafile 8 to '/u02/clne/tools01.dbf';
set newname for datafile 9 to '/u02/clne/users01.dbf';
set newname for datafile 10 to '/u02/clne/xdb01.dbf';
set newname for datafile 11 to '/u02/clne/new_undotbs.dbf';
duplicate target database to clne until scn 1409007 pfile='/tmp/pfile'
logfile
group 1 ('/u02/clne/redo01.log') size 10M,
group 2 ('/u02/clne/redo02.log') size 10M,
group 3 ('/u02/clne/redo03.log') size 10M;
}


使用rman 備份來源db
[oracle@db1 dbs]$ rman target sys/oracle@binhu catalog binhu/rman@rman
Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: BINHU (DBID=645032534)
connected to recovery catalog database

RMAN> list incarnation;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            CUR Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
861     875     BINHU    645032534        NO  174968     06-JUN-07
861     876     BINHU    645032534        NO  690592     13-JUN-07
861     877     BINHU    645032534        NO  690593     13-JUN-07
861     878     BINHU    645032534        NO  693462     13-JUN-07
861     879     BINHU    645032534        NO  694937     13-JUN-07
861     862     BINHU    645032534        YES 744591     29-JUN-07


RMAN> run {
2> sql 'alter system archive log current';
3> sql 'alter system archive log current';
4> sql 'alter system archive log current';
5> sql 'alter system archive log current';
6> backup full format '/u01/back/full_%s_%u_%p' database include current controlfile;
7> backup format '/u01/back/archive_%s_%u_%p' archivelog all delete input;
8> sql 'alter system archive log current';
9> }

sql statement: alter system archive log current

sql statement: alter system archive log current

sql statement: alter system archive log current

sql statement: alter system archive log current

Starting backup at 11-JUL-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=12 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/binhu/system01.dbf
input datafile fno=00011 name=/u01/app/oracle/oradata/binhu/new_undotbs.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/binhu/example01.dbf
input datafile fno=00010 name=/u01/app/oracle/oradata/binhu/xdb01.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/binhu/indx01.dbf
input datafile fno=00009 name=/u01/app/oracle/oradata/binhu/users01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/binhu/cwmlite01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/binhu/drsys01.dbf
input datafile fno=00007 name=/u01/app/oracle/oradata/binhu/odm01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/binhu/tbs.dbf
input datafile fno=00008 name=/u01/app/oracle/oradata/binhu/tools01.dbf
input datafile fno=00012 name=/u01/app/oracle/oradata/binhu/ttb.dbf
channel ORA_DISK_1: starting piece 1 at 11-JUL-07
channel ORA_DISK_1: finished piece 1 at 11-JUL-07
piece handle=/u01/back/full_64_20imjac8_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:59
Finished backup at 11-JUL-07

Starting backup at 11-JUL-07
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=35 recid=81 stamp=627567629
input archive log thread=1 sequence=36 recid=82 stamp=627567633
input archive log thread=1 sequence=37 recid=83 stamp=627567634
input archive log thread=1 sequence=38 recid=84 stamp=627567689
input archive log thread=1 sequence=39 recid=85 stamp=627567757
input archive log thread=1 sequence=40 recid=86 stamp=627570780
input archive log thread=1 sequence=41 recid=87 stamp=627570781
input archive log thread=1 sequence=42 recid=88 stamp=627570782
input archive log thread=1 sequence=43 recid=89 stamp=627570941
input archive log thread=1 sequence=44 recid=90 stamp=627570942
input archive log thread=1 sequence=45 recid=91 stamp=627577653
input archive log thread=1 sequence=46 recid=92 stamp=627577677
input archive log thread=1 sequence=47 recid=93 stamp=627590328
input archive log thread=1 sequence=48 recid=94 stamp=627590338
input archive log thread=1 sequence=49 recid=95 stamp=627590347
input archive log thread=1 sequence=50 recid=96 stamp=627590357
input archive log thread=1 sequence=51 recid=97 stamp=627590521
input archive log thread=1 sequence=52 recid=98 stamp=627590558
input archive log thread=1 sequence=53 recid=99 stamp=627591680
input archive log thread=1 sequence=54 recid=100 stamp=627659065
input archive log thread=1 sequence=55 recid=101 stamp=627681663
input archive log thread=1 sequence=56 recid=102 stamp=627681664
input archive log thread=1 sequence=57 recid=103 stamp=627681669
input archive log thread=1 sequence=58 recid=104 stamp=627681669
input archive log thread=1 sequence=59 recid=105 stamp=627681852
channel ORA_DISK_1: starting piece 1 at 11-JUL-07
channel ORA_DISK_1: finished piece 1 at 11-JUL-07
piece handle=/u01/back/archive_65_21imjahv_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:16
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u01/arch/1_35.dbf recid=81 stamp=627567629
archive log filename=/u01/arch/1_36.dbf recid=82 stamp=627567633
archive log filename=/u01/arch/1_37.dbf recid=83 stamp=627567634
archive log filename=/u01/arch/1_38.dbf recid=84 stamp=627567689
archive log filename=/u01/arch/1_39.dbf recid=85 stamp=627567757
archive log filename=/u01/arch/1_40.dbf recid=86 stamp=627570780
archive log filename=/u01/arch/1_41.dbf recid=87 stamp=627570781
archive log filename=/u01/arch/1_42.dbf recid=88 stamp=627570782
archive log filename=/u01/arch/1_43.dbf recid=89 stamp=627570941
archive log filename=/u01/arch/1_44.dbf recid=90 stamp=627570942
archive log filename=/u01/arch/1_45.dbf recid=91 stamp=627577653
archive log filename=/u01/arch/1_46.dbf recid=92 stamp=627577677
archive log filename=/u01/arch/1_47.dbf recid=93 stamp=627590328
archive log filename=/u01/arch/1_48.dbf recid=94 stamp=627590338
archive log filename=/u01/arch/1_49.dbf recid=95 stamp=627590347
archive log filename=/u01/arch/1_50.dbf recid=96 stamp=627590357
archive log filename=/u01/arch/1_51.dbf recid=97 stamp=627590521
archive log filename=/u01/arch/1_52.dbf recid=98 stamp=627590558
archive log filename=/u01/arch/1_53.dbf recid=99 stamp=627591680
archive log filename=/u01/arch/1_54.dbf recid=100 stamp=627659065
archive log filename=/u01/arch/1_55.dbf recid=101 stamp=627681663
archive log filename=/u01/arch/1_56.dbf recid=102 stamp=627681664
archive log filename=/u01/arch/1_57.dbf recid=103 stamp=627681669
archive log filename=/u01/arch/1_58.dbf recid=104 stamp=627681669
archive log filename=/u01/arch/1_59.dbf recid=105 stamp=627681852
Finished backup at 11-JUL-07

Starting Control File and SPFILE Autobackup at 11-JUL-07
piece handle=/u01/app/oracle/product/9.2.0/dbs/control_c-645032534-20070711-00 comment=NONE
Finished Control File and SPFILE Autobackup at 11-JUL-07

sql statement: alter system archive log current

RMAN>exit


再建立一些測試點
SQL> create table aux tablespace tbs as select * from dba_users;

Table created.

SQL> select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER
------------------------
                 1408703

SQL> alter system archive log current;

System altered.

SQL> select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER
------------------------
                 1408824

SQL> create table aux1 tablespace tbs as select * from dba_indexes;

Table created.

SQL> select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER
------------------------
                 1409007

SQL> alter system switch logfile;

System altered.

SQL> select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER
------------------------
                 1409127

SQL> create table aux2 tablespace tbs as select * from dba_tables;

Table created.

SQL> select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER
------------------------
                 1409347
ps:我共建了3個table在tbs的tablespace上面,並且查了當時的scn值,以方便後面的測試檢查點用


接下來準備duplicate db的測試了
[oracle@db1 tmp]$ sqlplus "sys/oracle@clne as sysdba" (登入clone的db)

SQL*Plus: Release 9.2.0.4.0 - Production on Thu Jul 12 17:01:36 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount pfile='/tmp/pfile'; (前面處理好的pfile,如檔案裏的設定有問題,後面的動作將會出現錯誤,要特別注意)
ORACLE instance started.

Total System Global Area  236000356 bytes
Fixed Size                   451684 bytes
Variable Size             201326592 bytes
Database Buffers           33554432 bytes
Redo Buffers                 667648 bytes
SQL> exit(一定要離開,不然可能會發生錯誤)



[oracle@db1 clne]$ rman target sys/oracle@binhu catalog binhu/rman@rman auxiliary sys/oracle@clne
(target sys/oracle@binhu : 我的來源db
catalog binhu/rman@rman :我的rman db
auxiliary sys/oracle@clne:我的clne db
target / catalog /auxiliary 為指令,後面接的是帳號、密碼、tnsname裏的設定值)

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: BINHU (DBID=645032534)
connected to recovery catalog database
connected to auxiliary database: clne (not mounted)

RMAN>@/tmp/tt
(執行寫好的script,注意 scn 值,之前我不是建立了3個table嗎,我模擬要回到時定的時間點,當然你也可不用scn值,使用時間格式也行)
RMAN> run {
2> allocate auxiliary channel tt type disk;
3> set newname for datafile 1 to '/u02/clne/system01.dbf';
4> set newname for datafile 2 to '/u02/clne/tbs.dbf';
5> set newname for datafile 3 to '/u02/clne/cwmlite01.dbf';
6> set newname for datafile 4 to '/u02/clne/drsys01.dbf';
7> set newname for datafile 5 to '/u02/clne/example01.dbf';
8> set newname for datafile 6 to '/u02/clne/indx01.dbf';
9> set newname for datafile 7 to '/u02/clne/odm01.dbf';
10> set newname for datafile 8 to '/u02/clne/tools01.dbf';
11> set newname for datafile 9 to '/u02/clne/users01.dbf';
12> set newname for datafile 10 to '/u02/clne/xdb01.dbf';
13> set newname for datafile 11 to '/u02/clne/new_undotbs.dbf';
14> duplicate target database to clne until scn 1409007 pfile='/tmp/pfile'  --clne 就是我的clone db的名字
15> logfile
16> group 1 ('/u02/clne/redo01.log') size 10M,
17> group 2 ('/u02/clne/redo02.log') size 10M,
18> group 3 ('/u02/clne/redo03.log') size 10M;
19> }
(後面就是由oracle 內建的script來處理了)
allocated channel: tt
channel tt: sid=13 devtype=DISK

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

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting Duplicate Db at 12-JUL-07

printing stored script: Memory Script
{
   set until scn  1409007;
   set newname for datafile  1 to
 "/u02/clne/system01.dbf";
   set newname for datafile  2 to
 "/u02/clne/tbs.dbf";
   set newname for datafile  3 to
 "/u02/clne/cwmlite01.dbf";
   set newname for datafile  4 to
 "/u02/clne/drsys01.dbf";
   set newname for datafile  5 to
 "/u02/clne/example01.dbf";
   set newname for datafile  6 to
 "/u02/clne/indx01.dbf";
   set newname for datafile  7 to
 "/u02/clne/odm01.dbf";
   set newname for datafile  8 to
 "/u02/clne/tools01.dbf";
   set newname for datafile  9 to
 "/u02/clne/users01.dbf";
   set newname for datafile  10 to
 "/u02/clne/xdb01.dbf";
   set newname for datafile  11 to
 "/u02/clne/new_undotbs.dbf";
   set newname for datafile  12 to
 "/u02/clne/ttb.dbf";
   restore
   check readonly
   clone database
   ;
}
executing script: 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

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 12-JUL-07

channel tt: starting datafile backupset restore
channel tt: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u02/clne/system01.dbf
restoring datafile 00002 to /u02/clne/tbs.dbf
restoring datafile 00003 to /u02/clne/cwmlite01.dbf
restoring datafile 00004 to /u02/clne/drsys01.dbf
restoring datafile 00005 to /u02/clne/example01.dbf
restoring datafile 00006 to /u02/clne/indx01.dbf
restoring datafile 00007 to /u02/clne/odm01.dbf
restoring datafile 00008 to /u02/clne/tools01.dbf
restoring datafile 00009 to /u02/clne/users01.dbf
restoring datafile 00010 to /u02/clne/xdb01.dbf
restoring datafile 00011 to /u02/clne/new_undotbs.dbf
restoring datafile 00012 to /u02/clne/ttb.dbf
channel tt: restored backup piece 1
piece handle=/u01/back/full_64_20imjac8_1 tag=TAG20070711T200112 params=NULL
channel tt: restore complete
Finished restore at 12-JUL-07
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "clne" RESETLOGS ARCHIVELOG
  MAXLOGFILES     50
  MAXLOGMEMBERS      5
  MAXDATAFILES      100
  MAXINSTANCES     1
  MAXLOGHISTORY      226
 LOGFILE
  GROUP  1 ( '/u02/clne/redo01.log' ) SIZE   10485760 ,
  GROUP  2 ( '/u02/clne/redo02.log' ) SIZE   10485760 ,
  GROUP  3 ( '/u02/clne/redo03.log' ) SIZE   10485760
 DATAFILE
  '/u02/clne/system01.dbf'
 CHARACTER SET AL32UTF8


printing stored script: Memory Script
{
   switch clone datafile all;
}
executing script: Memory Script

datafile 2 switched to datafile copy
input datafilecopy recid=1 stamp=627760091 filename=/u02/clne/tbs.dbf
datafile 3 switched to datafile copy
input datafilecopy recid=2 stamp=627760091 filename=/u02/clne/cwmlite01.dbf
datafile 4 switched to datafile copy
input datafilecopy recid=3 stamp=627760091 filename=/u02/clne/drsys01.dbf
datafile 5 switched to datafile copy
input datafilecopy recid=4 stamp=627760091 filename=/u02/clne/example01.dbf
datafile 6 switched to datafile copy
input datafilecopy recid=5 stamp=627760091 filename=/u02/clne/indx01.dbf
datafile 7 switched to datafile copy
input datafilecopy recid=6 stamp=627760091 filename=/u02/clne/odm01.dbf
datafile 8 switched to datafile copy
input datafilecopy recid=7 stamp=627760091 filename=/u02/clne/tools01.dbf
datafile 9 switched to datafile copy
input datafilecopy recid=8 stamp=627760091 filename=/u02/clne/users01.dbf
datafile 10 switched to datafile copy
input datafilecopy recid=9 stamp=627760091 filename=/u02/clne/xdb01.dbf
datafile 11 switched to datafile copy
input datafilecopy recid=10 stamp=627760091 filename=/u02/clne/new_undotbs.dbf
datafile 12 switched to datafile copy
input datafilecopy recid=11 stamp=627760091 filename=/u02/clne/ttb.dbf

printing stored script: Memory Script
{
   set until scn  1409007;
   recover
   clone database
    delete archivelog
   ;
}
executing script: Memory Script

executing command: SET until clause

Starting recover at 12-JUL-07

starting media recovery

archive log thread 1 sequence 60 is already on disk as file /u01/arch/1_60.dbf
archive log thread 1 sequence 61 is already on disk as file /u01/arch/1_61.dbf
archive log thread 1 sequence 62 is already on disk as file /u01/arch/1_62.dbf
archive log thread 1 sequence 63 is already on disk as file /u01/arch/1_63.dbf
channel tt: starting archive log restore to default destination
channel tt: restoring archive log
archive log thread=1 sequence=59
channel tt: restored backup piece 1
piece handle=/u01/back/archive_65_21imjahv_1 tag=TAG20070711T200413 params=NULL
channel tt: restore complete
archive log filename=/u02/arch/1_59.dbf thread=1 sequence=59
channel clone_default: deleting archive log(s)
archive log filename=/u02/arch/1_59.dbf recid=1 stamp=627760097
archive log filename=/u01/arch/1_60.dbf thread=1 sequence=60
archive log filename=/u01/arch/1_61.dbf thread=1 sequence=61
archive log filename=/u01/arch/1_62.dbf thread=1 sequence=62
archive log filename=/u01/arch/1_63.dbf thread=1 sequence=63
media recovery complete
Finished recover at 12-JUL-07

printing stored script: Memory Script
{
   shutdown clone;
   startup clone nomount pfile= '/tmp/pfile';
}
executing script: Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     236000356 bytes

Fixed Size                      451684 bytes
Variable Size                201326592 bytes
Database Buffers              33554432 bytes
Redo Buffers                    667648 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "clne" RESETLOGS ARCHIVELOG
  MAXLOGFILES     50
  MAXLOGMEMBERS      5
  MAXDATAFILES      100
  MAXINSTANCES     1
  MAXLOGHISTORY      226
 LOGFILE
  GROUP  1 ( '/u02/clne/redo01.log' ) SIZE   10485760 ,
  GROUP  2 ( '/u02/clne/redo02.log' ) SIZE   10485760 ,
  GROUP  3 ( '/u02/clne/redo03.log' ) SIZE   10485760
 DATAFILE
  '/u02/clne/system01.dbf'
 CHARACTER SET AL32UTF8


printing stored script: Memory Script
{
   catalog clone datafilecopy  "/u02/clne/tbs.dbf";
   catalog clone datafilecopy  "/u02/clne/cwmlite01.dbf";
   catalog clone datafilecopy  "/u02/clne/drsys01.dbf";
   catalog clone datafilecopy  "/u02/clne/example01.dbf";
   catalog clone datafilecopy  "/u02/clne/indx01.dbf";
   catalog clone datafilecopy  "/u02/clne/odm01.dbf";
   catalog clone datafilecopy  "/u02/clne/tools01.dbf";
   catalog clone datafilecopy  "/u02/clne/users01.dbf";
   catalog clone datafilecopy  "/u02/clne/xdb01.dbf";
   catalog clone datafilecopy  "/u02/clne/new_undotbs.dbf";
   catalog clone datafilecopy  "/u02/clne/ttb.dbf";
   switch clone datafile all;
}
executing script: Memory Script

cataloged datafile copy
datafile copy filename=/u02/clne/tbs.dbf recid=1 stamp=627760116

cataloged datafile copy
datafile copy filename=/u02/clne/cwmlite01.dbf recid=2 stamp=627760116

cataloged datafile copy
datafile copy filename=/u02/clne/drsys01.dbf recid=3 stamp=627760116

cataloged datafile copy
datafile copy filename=/u02/clne/example01.dbf recid=4 stamp=627760116

cataloged datafile copy
datafile copy filename=/u02/clne/indx01.dbf recid=5 stamp=627760116

cataloged datafile copy
datafile copy filename=/u02/clne/odm01.dbf recid=6 stamp=627760116

cataloged datafile copy
datafile copy filename=/u02/clne/tools01.dbf recid=7 stamp=627760116

cataloged datafile copy
datafile copy filename=/u02/clne/users01.dbf recid=8 stamp=627760116

cataloged datafile copy
datafile copy filename=/u02/clne/xdb01.dbf recid=9 stamp=627760116

cataloged datafile copy
datafile copy filename=/u02/clne/new_undotbs.dbf recid=10 stamp=627760116

cataloged datafile copy
datafile copy filename=/u02/clne/ttb.dbf recid=11 stamp=627760117

datafile 2 switched to datafile copy
input datafilecopy recid=1 stamp=627760116 filename=/u02/clne/tbs.dbf
datafile 3 switched to datafile copy
input datafilecopy recid=2 stamp=627760116 filename=/u02/clne/cwmlite01.dbf
datafile 4 switched to datafile copy
input datafilecopy recid=3 stamp=627760116 filename=/u02/clne/drsys01.dbf
datafile 5 switched to datafile copy
input datafilecopy recid=4 stamp=627760116 filename=/u02/clne/example01.dbf
datafile 6 switched to datafile copy
input datafilecopy recid=5 stamp=627760116 filename=/u02/clne/indx01.dbf
datafile 7 switched to datafile copy
input datafilecopy recid=6 stamp=627760116 filename=/u02/clne/odm01.dbf
datafile 8 switched to datafile copy
input datafilecopy recid=7 stamp=627760116 filename=/u02/clne/tools01.dbf
datafile 9 switched to datafile copy
input datafilecopy recid=8 stamp=627760116 filename=/u02/clne/users01.dbf
datafile 10 switched to datafile copy
input datafilecopy recid=9 stamp=627760116 filename=/u02/clne/xdb01.dbf
datafile 11 switched to datafile copy
input datafilecopy recid=10 stamp=627760116 filename=/u02/clne/new_undotbs.dbf
datafile 12 switched to datafile copy
input datafilecopy recid=11 stamp=627760117 filename=/u02/clne/ttb.dbf

printing stored script: Memory Script
{
   Alter clone database open resetlogs;
}
executing script: Memory Script

database opened
Finished Duplicate Db at 12-JUL-07

RMAN> **end-of-file**

RMAN> exit

進行測試是否真的ok
[oracle@db1 clne]$ sqlplus "sys/oracle@clne as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on Thu Jul 12 17:53:11 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production

SQL> desc aux;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 USERNAME                                  NOT NULL VARCHAR2(30)
 USER_ID                                   NOT NULL NUMBER
 PASSWORD                                           VARCHAR2(30)
 ACCOUNT_STATUS                            NOT NULL VARCHAR2(32)
 LOCK_DATE                                          DATE
 EXPIRY_DATE                                        DATE
 DEFAULT_TABLESPACE                        NOT NULL VARCHAR2(30)
 TEMPORARY_TABLESPACE                      NOT NULL VARCHAR2(30)
 CREATED                                   NOT NULL DATE
 PROFILE                                   NOT NULL VARCHAR2(30)
 INITIAL_RSRC_CONSUMER_GROUP                        VARCHAR2(30)
 EXTERNAL_NAME                                      VARCHAR2(4000)

SQL> desc aux1;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 OWNER                                     NOT NULL VARCHAR2(30)
 INDEX_NAME                                NOT NULL VARCHAR2(30)
 INDEX_TYPE                                         VARCHAR2(27)
 TABLE_OWNER                               NOT NULL VARCHAR2(30)
 TABLE_NAME                                NOT NULL VARCHAR2(30)
 TABLE_TYPE                                         VARCHAR2(11)
 UNIQUENESS                                         VARCHAR2(9)
 COMPRESSION                                        VARCHAR2(8)
 PREFIX_LENGTH                                      NUMBER
 TABLESPACE_NAME                                    VARCHAR2(30)
 INI_TRANS                                          NUMBER
 MAX_TRANS                                          NUMBER
 INITIAL_EXTENT                                     NUMBER
 NEXT_EXTENT                                        NUMBER
 MIN_EXTENTS                                        NUMBER
 MAX_EXTENTS  &n

Posted by my_work at 樂多Roodo! │09:12 │回應(8)引用(1)DB
樂多分類:網路/3C 共同主題:Oracle 工具:加入樂多書籤編輯本文
Ads by Roodo! 

引用URL

http://cgi.blog.roodo.com/trackback/3884407
引用列表:
c206250e94e8
c206250e94e80ec3b694【c206250e94e80ec3b694】 at 2007年09月4日 08:16
回應文章
請問一下,若是使用RMAN複製來源DB,就一定要跟它連線嗎
不能只拿它的備份集來做嗎
因為我是個programmer,所以經常要把客戶的DB拿回自己的電腦上,目前用的方法是export。
不知道還有沒有別的方法,謝謝
Posted by jimmy at 2007年11月5日 17:23

主要的考慮點是在於你的資料的大小,如不大的話用export較方便。還有客戶的db是運作在archive mode嗎?
Posted by 睡貓 at 2007年11月5日 20:28

那如果客戶的DB是archive mode的話
那是不是就可以用RMAN
Posted by jimmy at 2007年11月10日 16:38
是的
Posted by 睡貓 at 2007年11月10日 17:05

貓大大
請問你一下,你知道Oracle DBA,或Oracle ERP Developer的大概薪資嗎?
我是個Java Programmer三年的經驗,最近剛通過OCP的考試,想換Oracle相關工作。可以提供一些建議嗎
Posted by jimmy at 2007年12月26日 23:40
應該是看工作內容跟公司大小才能知道能給你的薪水。以之前我有面視一家是做dba維護的(要跑外面),是50k以上。如是公司內部維護oracle的dba的話,大約45k~60k(愈大薪水愈高);開發的話,我沒有面視過這類的工作,我也沒朋友有做,所以不知=.="
不論要做那類的工作,盡可能找較大點的公司,不然給的薪水都不會很高(面視時看情況可問一下他們的oracle是否有付錢買,多半付的出這錢的公司,薪水不會給的太差=.=+)
也祝你要離開最常加班的程式師了,呵呵
Posted by 睡貓 at 2007年12月26日 23:59

是啊,Programmer本來是個不錯的工作性質,可是在台灣卻是.......,唉
謝謝你提供的訊息喔
Posted by jimmy at 2007年12月27日 22:10
之前我也是java開發人員,但一路過來,還是dba較能過正常點的生活~~^O^
Posted by 睡貓 at 2007年12月27日 23:05