ITPub博客

首页 > Linux操作系统 > Linux操作系统 > rman duplicate clone库的尴尬

rman duplicate clone库的尴尬

原创 Linux操作系统 作者:wengtf 时间:2011-04-08 15:58:54 0 删除 编辑
[rman clone 目标库实验]
实验环境:
Linux + 10g环境,目标库与auxiliary库在同一台主机
目标库sid:wtf
clone(auxiliary库)sid:clone
omf路径相同
1、使用rman全备目标数据库 10.128.7.224
------------------------------------
[oracle@wtf01 admin]$ rman target /
RMAN> backup database;
2、配置auxiliary库实例环境
-------------------------
2.1、配置auxiliary库的实例环境、监听、tns文件、hosts、密码文件配置
使用oracle用户 在$ORACLE_BASE/admin 下新建clone实例目录,并创建bdump等目录
[oracle@wtf01 admin]$ cd $ORACEL_BASE/admin
[oracle@wtf01 admin]$ mkdir adump
[oracle@wtf01 admin]$ mkdir bdump
[oracle@wtf01 admin]$ mkdir cdump
[oracle@wtf01 admin]$ mkdir pfile
[oracle@wtf01 admin]$ mkdir udump
创建$ORACLE_BASE/oradata/clone目录 (存放数据文件等)
2.2、连接目标库,准备clone库的pfile
[oracle@wtf01 oradata]$ sqlplus '/as sysdba'
SQL> create pfile='/oracle/admin/clone/pfile/initclone.ora' from spfile;
File created.
编辑initclone.ora 讲目标库的sid修改为clone
==vi下  :g/wtf//s/clone/g
==修改pfile中db_name=目标库sid
==增加instance_name=clone库sid(*。instnance_name=clone)
==*.lock_name_space=CLONE
==/*注意一点*/ 因为clone选择了通过tns解析并使用密码连接 ,
务必将pfile中的*.remote_login_passwordfile='shared'改过来原来是none
补充:是否远程登录认证数据库,remote_login_passwordfile
有三个值:all|none|shared,具体代表说明就不说了。呵呵

2.3 配置clone库 监听和tns (必要时修改etc/hosts,实验中用了alias解析的服务,故有以下hosts配置)
hosts 配置了 hosts如下:
#IP address of server     host name       alias
10.128.7.224                wtf          clone
listener配置:
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
  (SID_DESC =
      (GLOBAL_DBNAME = clone)
      (ORACLE_HOME = /oracle/product/10.2.0/db_1)
      (SID_NAME = clone)
    )
  )
//上处只为clone库配置一个监听协议,其他不需要配置
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = wtf01)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC01))
    )
  )
==在遇到启动listener
tnsnames.ora配置:
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

//之前有存在其他tns 连接描述,故给clone1526端口,后来已将其他连接描述删除,干净是王道
clone =
  (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = wtf01)(PORT = 1521))
    )
     (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME= clone)
    )
  )
===配置完后,tnsping去验证的时候碰到了常见问题:
tns-12154:TNS:could not resolve the connect identifier specified 
//该问题依然从hosts入手的,增加别名 10.128.7.224  wtf01  clone//别名
TNS-03505: Failed to resolve name 
//该问题是hosts文件里面 没有配置正确导致,我发现 127.0.0.1   wtf     wtf备注释掉了,
==最后我是选择解析别名来达到tnsping clone。
密码文件的配置:
在$ORACLE_HOME/dbs下 生成密码文件,具体操作如下:
orapwd file=$ORACLE_HOME/dbs/pwdclone password=clone entries=20 force=y  
//注意在window环境下 pwdclone要带.ora(即pwdclone.ora)
以上验证tns、listener、
为了方便操作,我开了3个窗口
补充:设置sql提示会话标记:set sqlprompt ‘session1’/‘session2’
session1:主库,进入主库sqlplus用
session2:auxiliary库(clone) //Linux切到clone实例下  export ORACLE_SID=clone 进入sqlplus用
session3:配置clone实例用
进入session 2 
SQL> conn sys/oracle@clone as sysdba
Connected.
SQL>startup pfilie='/oracle/admin/clone/pfile/initclone.ora' nomount

[oracle@wtf01 pfile]$ rman target / auxiliary sys/oracle@clone
Recovery Manager: Release 10.2.0.1.0 - Production on Sat Mar 19 10:50:20 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: WTF (DBID=18509537)
connected to auxiliary database: CLONE (not mounted)

到此模拟连接clone库成功

3、使用rman重新命名数据文件及控制文件
**************************************************************
//下面在session(1)跑rman duplicate脚本 
[oracle@wtf01 clone]$ env |grep ORA
ORACLE_SID=wtf
ORACLE_BASE=/oracle
ORACLE_HOME=/oracle/product/10.2.0/db_1
[oracle@wtf01 clone]$ rman target / auxiliary sys/oracle@clone
Recovery Manager: Release 10.2.0.1.0 - Production on Mon Mar 21 16:16:13 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: WTF (DBID=18509537)
connected to auxiliary database: CLONE (not mounted)
RMAN> run{
2> set newname for datafile 1 to '/oracle/oradata/clone/system001.dbf';
3> set newname for datafile 2 to '/oracle/oradata/clone/undotbs001.dbf';
4> set newname for datafile 3 to '/oracle/oradata/clone/sysaux001.dbf';
5> set newname for datafile 4 to '/oracle/oradata/clone/user001.dbf';
6> set newname for datafile 5 to '/oracle/oradata/clone/001.dbf';
7> set newname for datafile 10 to '/oracle/oradata/clone/rman001.dbf';
8> set newname for tempfile 1 to '/oracle/oradata/clone/temp001.dbf';
9> duplicate target database to 'clone'
10> logfile
11> '/oracle/oradata/clone/redo1.log' size 10M,
12> '/oracle/oradata/clone/redo2.log' size 10M,
13> '/oracle/oradata/clone/redo3.log' size 10M;
14> }
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
executing command: SET NEWNAME
Starting Duplicate Db at 21-MAR-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=154 devtype=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: sid=153 devtype=DISK
contents of Memory Script.:
{
   set until scn  5438693;
   set newname for datafile  1 to
 "/oracle/oradata/clone/system001.dbf";
   set newname for datafile  2 to
 "/oracle/oradata/clone/undotbs001.dbf";
   set newname for datafile  3 to
 "/oracle/oradata/clone/sysaux001.dbf";
   set newname for datafile  4 to
 "/oracle/oradata/clone/user001.dbf";
   set newname for datafile  5 to
 "/oracle/oradata/clone/001.dbf";
   set newname for datafile  10 to
 "/oracle/oradata/clone/rman001.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 21-MAR-11
using channel ORA_AUX_DISK_1
using channel ORA_AUX_DISK_2
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /oracle/oradata/clone/sysaux001.dbf
restoring datafile 00005 to /oracle/oradata/clone/001.dbf
restoring datafile 00010 to /oracle/oradata/clone/rman001.dbf
channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/rman_backup/0vm7pe3g_1_1
channel ORA_AUX_DISK_2: starting datafile backupset restore
channel ORA_AUX_DISK_2: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oracle/oradata/clone/system001.dbf
restoring datafile 00002 to /oracle/oradata/clone/undotbs001.dbf
restoring datafile 00004 to /oracle/oradata/clone/user001.dbf
channel ORA_AUX_DISK_2: reading from backup piece /home/oracle/rman_backup/0um7pe3g_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/home/oracle/rman_backup/0vm7pe3g_1_1 tag=TAG20110321T131944
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
channel ORA_AUX_DISK_2: restored backup piece 1
piece handle=/home/oracle/rman_backup/0um7pe3g_1_1 tag=TAG20110321T131944
channel ORA_AUX_DISK_2: restore complete, elapsed time: 00:02:20
Finished restore at 21-MAR-11
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONE" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 '/oracle/oradata/clone/redo1.log' SIZE 10 M ,
  GROUP  2 '/oracle/oradata/clone/redo2.log' SIZE 10 M ,
  GROUP  3 '/oracle/oradata/clone/redo3.log' SIZE 10 M
 DATAFILE
  '/oracle/oradata/clone/system001.dbf'
 CHARACTER SET WE8ISO8859P1

contents of Memory Script.:
{
   switch clone datafile all;
}
executing Memory Script
released channel: ORA_AUX_DISK_1
released channel: ORA_AUX_DISK_2
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=746381922 filename=/oracle/oradata/clone/undotbs001.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=746381922 filename=/oracle/oradata/clone/sysaux001.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=746381922 filename=/oracle/oradata/clone/user001.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=746381922 filename=/oracle/oradata/clone/001.dbf
datafile 10 switched to datafile copy
input datafile copy recid=5 stamp=746381923 filename=/oracle/oradata/clone/rman001.dbf
contents of Memory Script.:
{
   set until scn  5438693;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script
executing command: SET until clause
Starting recover at 21-MAR-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=153 devtype=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: sid=154 devtype=DISK
starting media recovery
archive log thread 1 sequence 156 is already on disk as file /oracle/archivelog/1_156_734599521.dbf
archive log filename=/oracle/archivelog/1_156_734599521.dbf thread=1 sequence=156
media recovery complete, elapsed time: 00:00:06
Finished recover at 21-MAR-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 03/21/2011 16:40:49
RMAN-03015: error occurred in stored script. Memory Script
RMAN-06136: ORACLE error from auxiliary database: ORA-03113: end-of-file on communication channel
//下面是我在session2里面操作open resetlogs的结果(验证库能否打开)**************************************************************
SQL> select status from v$instance;
STATUS
------------
MOUNTED
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced

SQL> select * from dual;
ERROR:
ORA-03114: not connected to ORACLE

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@wtf01 ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Mar 21 16:41:21 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
SQL> conn sys/oracle@clone as sysdba 
Connected to an idle instance.
SQL> startup
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started.
Total System Global Area 1174405120 bytes
Fixed Size                  1219040 bytes
Variable Size             301991456 bytes
Database Buffers          855638016 bytes
Redo Buffers               15556608 bytes
Database mounted.
Database opened.
SQL> select * from dual;
D
-
X
SQL> show parameter name
NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------db_file_name_convert                 string
db_name                              string      clone
db_unique_name                       string      clone
global_names                         boolean     FALSE
instance_name                        string      clone
lock_name_space                      string      CLONE
log_file_name_convert                string
service_names                        string      clone
SQL>
 
总结:
虽然最后clone库打开了,但实验我觉得应该算失败的,因为没达到我预计的效果 session 1的不响应 等待下次测试,非常尴尬!

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

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

注册时间:2011-04-07

  • 博文量
    62
  • 访问量
    190925