ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 克隆数据库之RMAN复制(二)

克隆数据库之RMAN复制(二)

原创 Linux操作系统 作者:Nalternative 时间:2011-05-28 11:52:39 0 删除 编辑

显示所有档案(含属性与隐藏文件)
[oracle@oracle oracle]$ ls -al  ~

[oracle@oracle ~]$ orapwd file=acct2.pwd password=secret entries=30
[oracle@oracle ~]$ find -name acct.pwd
./acct.pwd

SQL> conn sys/secret as sysdba
Connected.

[oracle@oracle 10g]$ echo $ORACLE_HOME
/oracle/10g

SQL> create pfile='$oracle_home/initnewdb.ora' from spfile;

 

*.instance_name=newdb
*.DB_FILE_NAME_CONVERT=(/oracle/oradata/orcl/,/newdb/oradata/orcl/)
*.LOG_FILE_NAME_CONVERT=(/oracle/oradata/orcl/,/newdb/oradata/orcl/)


SQL> create spfile='$ORACLE_HOME/dbs/spfilenewdb.ora' from pfile='$ORACLE_HOME/initnewdb.ora';
 
 
[oracle@oracle oracle]$ set oracle_sid=newdb----------------------丢人了这里。。。。。。。。。
[oracle@oracle oracle]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 25 11:36:38 2011

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

SQL> conn sys/secret as sysdba----其实这里连接的数据库实例都不对
Connected.

SQL> startup force nomount
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              92276304 bytes
Database Buffers          188743680 bytes
Redo Buffers                2973696 bytes
 
[oracle@oracle oracle]$ set oracle_sid=newdb
[oracle@oracle oracle]$ rman target sys/zja@orcl auxiliary sys/secret

 run {
 set newname for datafile 1 to '/newdb/oradata/orcl/system01.dbf';
 set newname for datafile 2 to '/newdb/oradata/orcl/undotbs01.dbf';
 set newname for datafile 3 to '/newdb/oradata/orcl/sysaux01.dbf';
 set newname for datafile 4 to '/newdb/oradata/orcl/users01.dbf';
 set newname for datafile 5 to '/newdb/oradata/orcl/example01.dbf';
 set newname for datafile 6 to '/newdb/oradata/orcl/user02.dbf';
 duplicate target database to newdb logfile
 '/newdb/oradata/orcl/redo01.log' size 10m,
 '/newdb/oradata/orcl/redo02.log' size 10m,
 '/newdb/oradata/orcl/redo03.log' size 10m;
}


RMAN>  run {
2>  set newname for datafile 1 to '/newdb/oradata/orcl/system01.dbf';
3>  set newname for datafile 2 to '/newdb/oradata/orcl/undotbs01.dbf';
4>  set newname for datafile 3 to '/newdb/oradata/orcl/sysaux01.dbf';
5>  set newname for datafile 4 to '/newdb/oradata/orcl/users01.dbf';
6>  set newname for datafile 5 to '/newdb/oradata/orcl/example01.dbf';
7>  set newname for datafile 6 to '/newdb/oradata/orcl/user02.dbf';
8>  duplicate target database to newdb logfile
9>  '/newdb/oradata/orcl/redo01.log' size 10m,
10>  '/newdb/oradata/orcl/redo02.log' size 10m,
11>  '/newdb/oradata/orcl/redo03.log' size 10m;
12> }

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 25-MAY-11
using channel ORA_AUX_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 05/25/2011 14:57:34
RMAN-05520: database name mismatch, auxiliary instance has ORCL, command specified NEWDB 
 
 
 
 
[oracle@oracle ~]$  export  ORACLE_SID=newdb
[oracle@oracle ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 25 15:51:27 2011

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

SQL> conn sys/secret as sysdba
Connected to an idle instance.
 
SQL> startup force nomount
ORA-09925: Unable to create audit trail file
Linux Error: 2: No such file or directory
Additional information: 9925
/
chown -R oracle:oinstall /newdb
 
 
[oracle@oracle ~]$ oerr ora 09925
09925, 00000,  "Unable to create audit trail file"
// *Cause:  ORACLE was not able to create the file being used to hold
//          audit trail records.
// *Action: Check the UNIX error number for a possible operating system error.
//          If there is no error, contact ORACLE customer support.
 
 
原来*.audit_file_dest   所赋的目录未创建,还得手工创建这些目录,包括其他的参数文件中所用到的目录

 
*.audit_file_dest='/newdb/admin/orcl/adump'
 
 
SQL> startup force nomount
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              92276304 bytes
Database Buffers          188743680 bytes
Redo Buffers                2973696 bytes


chown -R oracle:oinstall /newdb/oradata/orcl/

 

[oracle@oracle ~]$ export ORACLE_SID=newdb
[oracle@oracle ~]$ sqlplus sys/secret as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Fri May 27 11:11:41 2011

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

Connected to an idle instance.

SQL> startup force nomount
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              92276304 bytes
Database Buffers          188743680 bytes
Redo Buffers
 
--这下终于对了
[oracle@oracle ~]$ export ORACLE_SID=newdb
[oracle@oracle ~]$ rman target sys/zja@orcl auxiliary sys/secret

Recovery Manager: Release 10.2.0.1.0 - Production on Wed May 25 16:54:09 2011

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

connected to target database: ORCL (DBID=1278821908)
connected to auxiliary database: NEWDB (not mounted)

 run {
 set newname for datafile 1 to '/newdb/oradata/orcl/system01.dbf';
 set newname for datafile 2 to '/newdb/oradata/orcl/undotbs01.dbf';
 set newname for datafile 3 to '/newdb/oradata/orcl/sysaux01.dbf';
 set newname for datafile 4 to '/newdb/oradata/orcl/users01.dbf';
 set newname for datafile 5 to '/newdb/oradata/orcl/example01.dbf';
 set newname for datafile 6 to '/newdb/oradata/orcl/user02.dbf';
 duplicate target database to newdb logfile
 '/newdb/oradata/orcl/redo01.log' size 10m,
 '/newdb/oradata/orcl/redo02.log' size 10m,
 '/newdb/oradata/orcl/redo03.log' size 10m;
}

 
 
RMAN>  run {
2>  set newname for datafile 1 to '/newdb/oradata/orcl/system01.dbf';
 set newname for datafile 2 to '/newdb/oradata/orcl/undotbs01.dbf';
3> 4>  set newname for datafile 3 to '/newdb/oradata/orcl/sysaux01.dbf';
5>  set newname for datafile 4 to '/newdb/oradata/orcl/users01.dbf';
6>  set newname for datafile 5 to '/newdb/oradata/orcl/example01.dbf';
7>  set newname for datafile 6 to '/newdb/oradata/orcl/user02.dbf';
8>  duplicate target database to newdb logfile
9>  '/newdb/oradata/orcl/redo01.log' size 10m,
10>  '/newdb/oradata/orcl/redo02.log' size 10m,
11>  '/newdb/oradata/orcl/redo03.log' size 10m;
12> }

executing command: SET NEWNAME
using target database control file instead of recovery catalog

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting Duplicate Db at 25-MAY-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=152 devtype=DISK

contents of Memory Script.:
{
   set until scn  671526;
   set newname for datafile  1 to
 "/newdb/oradata/orcl/system01.dbf";
   set newname for datafile  2 to
 "/newdb/oradata/orcl/undotbs01.dbf";
   set newname for datafile  3 to
 "/newdb/oradata/orcl/sysaux01.dbf";
   set newname for datafile  4 to
 "/newdb/oradata/orcl/users01.dbf";
   set newname for datafile  5 to
 "/newdb/oradata/orcl/example01.dbf";
   set newname for datafile  6 to
 "/newdb/oradata/orcl/user02.dbf";
   restore
   check readonly
   clone database
   ;
}
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

executing command: SET NEWNAME

Starting restore at 25-MAY-11
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /newdb/oradata/orcl/system01.dbf
restoring datafile 00002 to /newdb/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /newdb/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /newdb/oradata/orcl/users01.dbf
restoring datafile 00005 to /newdb/oradata/orcl/example01.dbf
restoring datafile 00006 to /newdb/oradata/orcl/user02.dbf
channel ORA_AUX_DISK_1: reading from backup piece /oracle/backup/ORCL_15.bak
ORA-19870: error reading backup piece /oracle/backup/ORCL_15.bak
ORA-19504: failed to create file "/newdb/oradata/orcl/system01.dbf"
ORA-27040: file create error, unable to create file
Linux Error: 13: Permission denied
failover to previous backup

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 05/25/2011 20:52:40
RMAN-03015: error occurred in stored script. Memory Script
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 6 found to restore
RMAN-06023: no backup or copy of datafile 5 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore

---chown -R oracle:oinstall /newdb/oradata/orcl/   这里更改了权限,子目录的权限也要赋?linux还是不很懂啊


[oracle@oracle ~]$ rman target sys/zja@orcl auxiliary sys/secret

Recovery Manager: Release 10.2.0.1.0 - Production on Fri May 27 11:15:44 2011

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

connected to target database: ORCL (DBID=1278821908)
connected to auxiliary database: NEWDB (not mounted)

RMAN>  run {
2>  set newname for datafile 1 to '/newdb/oradata/orcl/system01.dbf';
3>  set newname for datafile 2 to '/newdb/oradata/orcl/undotbs01.dbf';
4>  set newname for datafile 3 to '/newdb/oradata/orcl/sysaux01.dbf';
5>  set newname for datafile 4 to '/newdb/oradata/orcl/users01.dbf';
6>  set newname for datafile 5 to '/newdb/oradata/orcl/example01.dbf';
7>  set newname for datafile 6 to '/newdb/oradata/orcl/user02.dbf';
8>  duplicate target database to newdb logfile
9>  '/newdb/oradata/orcl/redo01.log' size 10m,
10>  '/newdb/oradata/orcl/redo02.log' size 10m,
11>  '/newdb/oradata/orcl/redo03.log' size 10m;
12> }

executing command: SET NEWNAME
using target database control file instead of recovery catalog

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting Duplicate Db at 27-MAY-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK

contents of Memory Script.:
{
   set until scn  717794;
   set newname for datafile  1 to
 "/newdb/oradata/orcl/system01.dbf";
   set newname for datafile  2 to
 "/newdb/oradata/orcl/undotbs01.dbf";
   set newname for datafile  3 to
 "/newdb/oradata/orcl/sysaux01.dbf";
   set newname for datafile  4 to
 "/newdb/oradata/orcl/users01.dbf";
   set newname for datafile  5 to
 "/newdb/oradata/orcl/example01.dbf";
   set newname for datafile  6 to
 "/newdb/oradata/orcl/user02.dbf";
   restore
   check readonly
   clone database
   ;
}
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

executing command: SET NEWNAME

Starting restore at 27-MAY-11
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /newdb/oradata/orcl/system01.dbf
restoring datafile 00002 to /newdb/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /newdb/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /newdb/oradata/orcl/users01.dbf
restoring datafile 00005 to /newdb/oradata/orcl/example01.dbf
restoring datafile 00006 to /newdb/oradata/orcl/user02.dbf
channel ORA_AUX_DISK_1: reading from backup piece /oracle/backup/ORCL_15.bak
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/oracle/backup/ORCL_15.bak tag=TAG20110525T174029
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:12
Finished restore at 27-MAY-11
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "NEWDB" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 '/newdb/oradata/orcl/redo01.log' SIZE 10 M ,
  GROUP  2 '/newdb/oradata/orcl/redo02.log' SIZE 10 M ,
  GROUP  3 '/newdb/oradata/orcl/redo03.log' SIZE 10 M
 DATAFILE
  '/newdb/oradata/orcl/system01.dbf'
 CHARACTER SET WE8ISO8859P1


contents of Memory Script.:
{
   switch clone datafile all;
}
executing Memory Script

released channel: ORA_AUX_DISK_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=752239096 filename=/newdb/oradata/orcl/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=752239096 filename=/newdb/oradata/orcl/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=752239096 filename=/newdb/oradata/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=752239096 filename=/newdb/oradata/orcl/example01.dbf
datafile 6 switched to datafile copy
input datafile copy recid=5 stamp=752239096 filename=/newdb/oradata/orcl/user02.dbf

contents of Memory Script.:
{
   set until scn  717794;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 27-MAY-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK

starting media recovery

archive log thread 1 sequence 18 is already on disk as file /oracle/flash_recovery_area/ORCL/archivelog/2011_05_25/o1_mf_1_18_6xsmsv8t_.arc
archive log thread 1 sequence 19 is already on disk as file /oracle/flash_recovery_area/ORCL/archivelog/2011_05_27/o1_mf_1_19_6xy50q6z_.arc
archive log thread 1 sequence 20 is already on disk as file /oracle/flash_recovery_area/ORCL/archivelog/2011_05_27/o1_mf_1_20_6xy5tq7d_.arc
archive log filename=/oracle/flash_recovery_area/ORCL/archivelog/2011_05_25/o1_mf_1_18_6xsmsv8t_.arc thread=1 sequence=18
archive log filename=/oracle/flash_recovery_area/ORCL/archivelog/2011_05_27/o1_mf_1_19_6xy50q6z_.arc thread=1 sequence=19
archive log filename=/oracle/flash_recovery_area/ORCL/archivelog/2011_05_27/o1_mf_1_20_6xy5tq7d_.arc thread=1 sequence=20
media recovery complete, elapsed time: 00:00:10
Finished recover at 27-MAY-11

contents of Memory Script.:
{
   shutdown clone;
   startup clone nomount ;
}
executing Memory Script-------------这一步执行了很长时间,不过库最后还是启动起来了

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 05/27/2011 12:54:43
RMAN-03015: error occurred in stored script. Memory Script
RMAN-06136: ORACLE error from auxiliary database: ORA-01013: user requested cancel of current operation
/

SQL> alter database open resetlogs;

Database altered.
 
----------------------------==============================================
[oracle@oracle ~]$ rman nocatalog

Recovery Manager: Release 10.2.0.1.0 - Production on Wed May 25 17:03:46 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved. 
 
RMAN> connect target sys/zja@orcl

connected to target database: ORCL (DBID=1278821908)
using target database control file instead of recovery catalog

RMAN> report schema;

Report of database schema

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    480      SYSTEM               ***     /oracle/oradata/orcl/system01.dbf
2    30       UNDOTBS1             ***     /oracle/oradata/orcl/undotbs01.dbf
3    260      SYSAUX               ***     /oracle/oradata/orcl/sysaux01.dbf
4    5        USERS                ***     /oracle/oradata/orcl/users01.dbf
5    100      EXAMPLE              ***     /oracle/oradata/orcl/example01.dbf
6    20       USER02               ***     /oracle/oradata/orcl/user02.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMP                 32767       /oracle/oradata/orcl/temp01.dbf
 
 
--删除旧的备份
RMAN> delete obsolete;
 
--列出数据文件备份
RMAN> list backup of tablespace user02;
 
 
 
 
 
 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25323853/viewspace-696492/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-02-09

  • 博文量
    123
  • 访问量
    174258