Chinaunix首页 | 论坛 | 博客
  • 博客访问: 511225
  • 博文数量: 161
  • 博客积分: 6010
  • 博客等级: 准将
  • 技术积分: 1947
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-25 01:20
文章分类

全部博文(161)

文章存档

2011年(44)

2010年(47)

2009年(48)

2008年(22)

我的朋友

分类: Oracle

2010-11-17 16:09:15

实验平台CentOS 5.2+Oracle 10g

源库

Oracle_SID=NODE2

复制的数据库实例名:ANK


1>创建复制数据库目录结构

[oracle@node2 oradata]$ mkdir ANK

[oracle@node2 oradata]$ ls

ANK  NODE2

[oracle@node2 admin]$ pwd   

/u01/app/oracle/admin

[oracle@node2 admin]$ ls

NODE2

[oracle@node2 admin]$ mkdir ANK

[oracle@node2 ANK]$ mkdir adump

[oracle@node2 ANK]$ mkdir bdump

[oracle@node2 ANK]$ mkdir cdump

[oracle@node2 ANK]$ mkdir pfile

[oracle@node2 ANK]$ mkdir udump

[oracle@node2 ANK]$ mkdir dpdump

2>修改init.ora初始化文件

node中导出参数文件

Create pfile from spfile


修改

NODE2.__db_cache_size=83886080

NODE2.__java_pool_size=4194304

NODE2.__large_pool_size=4194304

NODE2.__shared_pool_size=71303168

NODE2.__streams_pool_size=0

*.audit_file_dest='/u01/app/oracle/admin/ANK/adump'

*.background_dump_dest='/u01/app/oracle/admin/ANK/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/u01/app/oracle/oradata/ANK/control01.ctl','/u01/app/oracle/oradata/ANK/control02.ctl','/u01/app/oracle/oradata/ANK/control03.ctl'

*.core_dump_dest='/u01/app/oracle/admin/ANK/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_name='ANK'

*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=2147483648

*.dispatchers='(PROTOCOL=TCP) (SERVICE=NODE2XDB)'

*.job_queue_processes=10

*.open_cursors=300

*.pga_aggregate_target=16777216

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=167772160

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/u01/app/oracle/admin/ANK/udump'

db_file_name_convert=('/u01/app/oracle/oradata/NODE2','/u01/app/oracle/oradata/ANK')

log_file_name_convert=('/u01/app/oracle/oradata/NODE2','/u01/app/oracle/oradata/ANK')

Db_file_name_convertlog_file_name_convert ,用来转换用 


3>创建DAVE实例的口令文件 

[oracle@node2 dbs]$ pwd

/u01/app/oracle/product/10.2.0/db/dbs

[oracle@node2 dbs]$ orapwd file=orapwANK password=ank88ank

4>备份源库

[oracle@node2 ~]$ export ORACLE_SID=NODE2

[oracle@node2 ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Nov 17 06:04:42 2010

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

connected to target database: NODE2 (DBID=1900966120)

RMAN脚本:

RUN { 

allocate channel c1 type disk;

allocate channel c2 type disk;

BACKUP FORMAT '/u03/backup/NODE2_%U_%T' skip inaccessible filesperset 5  DATABASE TAG orcl_hot_db_bk; 

sql 'alter system archive log current';

BACKUP FORMAT '/u03/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT; 

backup current controlfile tag='bak_ctlfile' format='/u03/backup/ctl_file_%U_%T';

backup spfile tag='spfile' format='/u03/backup/NODE2_spfile_%U_%T';

release channel c2;

release channel c1;

}

5>添加,配置监听 

建议用netmgr来配

[..]$mgr

Listener.ora

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)

      (PROGRAM = extproc)

    )

    (SID_DESC =

      (GLOBAL_DBNAME = DAVE)

      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)

      (SID_NAME = DAVE)

    )

  )

tnsnames.ora

ANK =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.19.130)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = ANK)

    )

  )

5>启动辅助库到nomount状态 

[oracle@node2 admin]$ export ORACLE_SID=ANK

[oracle@node2 admin]$ sqlplus / as sydba

SQL> startup nomount  pfile='/u01/initANK.ora'

ORACLE instance started.

Total System Global Area  167772160 bytes

Fixed Size                  1218316 bytes

Variable Size              62916852 bytes

Database Buffers          100663296 bytes

Redo Buffers                2973696 bytes

SQL> create spfile from pfile='/u01/initANK.ora';

File created.

7>RMAN 连接到目标实例和辅助实例,运行duplicate 命令复制数据库 

备份在磁带上:

[oracle@node2 ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Nov 17 06:18:51 2010

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

connected to target database: NODE2 (DBID=1900966120)

RMAN> connect auxiliary sys/ank88ank@ANK    

connected to auxiliary database: ANK (not mounted)

执行复制

RMAN>duplicate target database to ANK





8>修改参数文件(也可以不修改,RMAN复制时候,自动修补)

NODE2.__db_cache_size=83886080

ANK.__db_cache_size=100663296

NODE2.__java_pool_size=4194304

ANK.__java_pool_size=4194304

NODE2.__large_pool_size=4194304

ANK.__large_pool_size=4194304

NODE2.__shared_pool_size=71303168

ANK.__shared_pool_size=54525952

NODE2.__streams_pool_size=0

ANK.__streams_pool_size=0

删除node2的部分

db_file_name_convert = ('/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/DAVE')

log_file_name_convert = ('/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/DAVE')

自动删除了





Starting Duplicate Db at 17-NOV-10
using target database control file instead of recovery catalog  //用原来的控制文件
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK

contents of Memory Script:
{
   set until scn 456636;
   set newname for datafile 1 to      
 //转换位置,还原
 "/u01/app/oracle/oradata/ANK/system01.dbf";
   set newname for datafile 2 to
 "/u01/app/oracle/oradata/ANK/undotbs01.dbf";
   set newname for datafile 3 to
 "/u01/app/oracle/oradata/ANK/sysaux01.dbf";
   set newname for datafile 4 to
 "/u01/app/oracle/oradata/ANK/users01.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

Starting restore at 17-NOV-10
using channel ORA_AUX_DISK_1

//开始restore数据库
channel ORA_AUX_DISK_1: starting datafile backupset restore 
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /u01/app/oracle/oradata/ANK/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/ANK/sysaux01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u03/backup/NODE2_02lt74mi_1_1_20101117
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u03/backup/NODE2_02lt74mi_1_1_20101117 tag=ORCL_HOT_DB_BK
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:17
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 /u01/app/oracle/oradata/ANK/system01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/ANK/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u03/backup/NODE2_01lt74mi_1_1_20101117
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u03/backup/NODE2_01lt74mi_1_1_20101117 tag=ORCL_HOT_DB_BK
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 17-NOV-10




//开始创建控制文件,进行还原
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ANK" RESETLOGS ARCHIVELOG
  MAXLOGFILES 16
  MAXLOGMEMBERS 3
  MAXDATAFILES 100
  MAXINSTANCES 8
  MAXLOGHISTORY 292
 LOGFILE
  GROUP 1 ( '/u01/app/oracle/oradata/ANK/redo01.log' ) SIZE 50 M REUSE,
  GROUP 2 ( '/u01/app/oracle/oradata/ANK/redo02.log' ) SIZE 50 M REUSE,
  GROUP 3 ( '/u01/app/oracle/oradata/ANK/redo03.log' ) SIZE 50 M REUSE
 DATAFILE
  '/u01/app/oracle/oradata/ANK/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=735286924 filename=/u01/app/oracle/oradata/ANK/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=735286924 filename=/u01/app/oracle/oradata/ANK/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=735286924 filename=/u01/app/oracle/oradata/ANK/users01.dbf




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

executing command: SET until clause

Starting recover at 17-NOV-10
allocated channel: ORA_AUX_DISK_1       //开始recover恢复数据
channel ORA_AUX_DISK_1: sid=155 devtype=DISK 
//rman将归档复制到备份之前的归档目录,如果clone的数据库无法访问这个归档目录,将发生错误
starting media recovery
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=4
channel ORA_AUX_DISK_1: reading from backup piece /u03/backup/arch_06lt74nt_1_1_20101117
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u03/backup/arch_06lt74nt_1_1_20101117 tag=TAG20101117T060653
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
archive log filename=/u01/app/oracle/flash_recovery_area/ANK/archivelog/2010_11_17/o1_mf_1_4_6g7gq1p7_.arc thread=1 sequence=4
channel clone_default: deleting archive log(s)
archive log filename=/u01/app/oracle/flash_recovery_area/ANK/archivelog/2010_11_17/o1_mf_1_4_6g7gq1p7_.arc recid=1 stamp=735286929
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=5
channel ORA_AUX_DISK_1: reading from backup piece /u03/backup/arch_07lt74o0_1_1_20101117
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u03/backup/arch_07lt74o0_1_1_20101117 tag=TAG20101117T060653
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
archive log filename=/u01/app/oracle/flash_recovery_area/ANK/archivelog/2010_11_17/o1_mf_1_5_6g7gq4d9_.arc thread=1 sequence=5
channel clone_default: deleting archive log(s)
archive log filename=/u01/app/oracle/flash_recovery_area/ANK/archivelog/2010_11_17/o1_mf_1_5_6g7gq4d9_.arc recid=2 stamp=735286932
media recovery complete, elapsed time: 00:00:01
Finished recover at 17-NOV-10



contents of Memory Script:
{


//这里要注意的一个地方,在这一步的时候,辅助实例不能有任何session打开,即不能有有任何连接连接//

//到DAVE上,不然它会一直那个session 退出后才能执行
   shutdown clone;
   startup clone nomount ;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 167772160 bytes

Fixed Size 1218316 bytes
Variable Size 62916852 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes


//创建新的控制文件(在新的数据库上,辅助clone)

sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ANK" RESETLOGS ARCHIVELOG
  MAXLOGFILES 16
  MAXLOGMEMBERS 3
  MAXDATAFILES 100
  MAXINSTANCES 8
  MAXLOGHISTORY 292
 LOGFILE
  GROUP 1 ( '/u01/app/oracle/oradata/ANK/redo01.log' ) SIZE 50 M REUSE,
  GROUP 2 ( '/u01/app/oracle/oradata/ANK/redo02.log' ) SIZE 50 M REUSE,
  GROUP 3 ( '/u01/app/oracle/oradata/ANK/redo03.log' ) SIZE 50 M REUSE
 DATAFILE
  '/u01/app/oracle/oradata/ANK/system01.dbf'
 CHARACTER SET WE8ISO8859P1


contents of Memory Script:
{
   set newname for tempfile 1 to
 "/u01/app/oracle/oradata/ANK/temp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy "/u01/app/oracle/oradata/ANK/undotbs01.dbf";
   catalog clone datafilecopy "/u01/app/oracle/oradata/ANK/sysaux01.dbf";
   catalog clone datafilecopy "/u01/app/oracle/oradata/ANK/users01.dbf";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed temporary file 1 to /u01/app/oracle/oradata/ANK/temp01.dbf in control file

cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/ANK/undotbs01.dbf recid=1 stamp=735286998

cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/ANK/sysaux01.dbf recid=2 stamp=735286999

cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/ANK/users01.dbf recid=3 stamp=735286999

datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=735286998 filename=/u01/app/oracle/oradata/ANK/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=735286999 filename=/u01/app/oracle/oradata/ANK/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=735286999 filename=/u01/app/oracle/oradata/ANK/users01.dbf

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 17-NOV-10


阅读(623) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-06-05 02:06:50

大连法律咨询在线 http://www.fabowang.com 大连律师在线咨询 http://www.fabowang.com 大连法律顾问网 http://www.fabowang.com 大连律师咨询 http://www.fabowang.com

chinaunix网友2010-11-18 17:34:12

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com