ITPub博客

首页 > Linux操作系统 > Linux操作系统 > duplicate数据库

duplicate数据库

原创 Linux操作系统 作者:nmgzw 时间:2019-05-10 11:33:06 0 删除 编辑
目标:从主机rac4复制数据库orcl到主机rac3,两台机器存放数据文件、控制文件、在线日志文件的目录结构都一致
rac4 192.139.39.17
rac3 192.139.39.16
数据库系统为11g

详细步骤如下:
一、在主机rac3上的操作如下:
1、编辑listener.ora文件
rac3->view listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

#TRACE_LEVEL_LISTENER = SUPPORT

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.139.39.16)(PORT = 1521))
  )

SID_LIST_LISTENER=
   (SID_LIST=
       (SID_DESC=
                       #BEQUEATH CONFIG
          (GLOBAL_DBNAME=orcl)
          (SID_NAME=orcl)
          (ORACLE_HOME=/u01/app/oracle/product/11.0/db_1)
       )
    )

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON

2、创建密码口令文件:
orapwd file=orapworcl password=oracle entries=5

3、创建参数文件
rac3->view initorcl.ora
db_unique_name=orcl_p
db_name=orcl

4、创建tnsnames.ora文件
rac3->view tnsnames.ora
orcl_p =
   (DESCRIPTION =
        (ADDRESS = (PROTOCOL=tcp)(HOST=192.139.39.16)(PORT=1521))
        (CONNECT_DATA=(SERVICE_NAME=orcl))
   )

orcl_s =
   (DESCRIPTION =
        (ADDRESS = (PROTOCOL=tcp)(HOST=192.139.39.17)(PORT=1521))
        (CONNECT_DATA=(SERVICE_NAME=orcl))
   )
5、启动监听
6、启动实例到nomount状态
7、测试是否能够以sys登陆
rac3->sqlplus sys/oracle@orcl_p as sysdba            

SQL*Plus: Release 11.1.0.6.0 - Production on Mon May 30 08:15:32 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

二、在主机rac4上的操作如下(已经通过dbca建立了数据库orcl):
1、创建tnsnames.ora文件
rac3->view tnsnames.ora
orcl_p =
   (DESCRIPTION =
        (ADDRESS = (PROTOCOL=tcp)(HOST=192.139.39.16)(PORT=1521))
        (CONNECT_DATA=(SERVICE_NAME=orcl))
   )

orcl_s =
   (DESCRIPTION =
        (ADDRESS = (PROTOCOL=tcp)(HOST=192.139.39.17)(PORT=1521))
        (CONNECT_DATA=(SERVICE_NAME=orcl))
   )
2、验证能够分别登陆orcl_s和orcl_p
rac4->sqlplus sys/oracle@orcl_p as sysdba                                  

SQL*Plus: Release 11.1.0.6.0 - Production on Mon May 30 08:18:21 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
rac4->sqlplus sys/oracle@orcl_s as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Mon May 30 08:18:31 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

注意:如果不能够登陆orcl_s,那么请确认密码文件配置正确

3、参数文件initorcl.ora
rac4->view initorcl.ora  
*.audit_file_dest='/u01/app/oracle/admin/rman/adump'
*.audit_trail='db'
*.compatible='11.1.0.0.0'
*.control_files='/u01/app/oracle/oradata/rman/control01.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle'
*.db_domain=''
*.db_name='ORCL'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=5368709120
*.db_unique_name='orcl_s'#Is a duplicate
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=rmanXDB)'
*.fal_client='orcl_s'
*.fal_server='orcl_p'
*.log_archive_config='DG_CONFIG=(orcl_p,orcl_s)'
*.log_archive_dest_10='location=use_db_recovery_file_dest'
*.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)'
*.log_archive_dest_2='SERVICE=orcl_p SYNC COMPRESSION=enable REOPEN=60  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)   DB_UNIQUE_NAME=orcl_p'
*.log_file_name_convert='/u01/app/oracle/oradata/rman/','/u01/app/oracle/oradata/rman'
*.memory_target=397410304
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.service_names='ORCL'
*.sga_target=314572800
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

3、通过rman来连接目标库及auxiliary库
rac4->rman target sys/oracle@orcl_s auxiliary sys/oracle@orcl_p log dup.log

注意:如果遇到以下两个错误,解决办法如下

错误:RMAN-03009: failure of backup command on ORA_DISK_1 channel at 05/30/2011 08:05:28
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-01017: invalid username/password; logon denied
ORA-17629: Cannot connect to the remote database server
continuing other job steps, job failed will not be re-run
解决办法,确认连接目标库时候不要采用target /,而是要提供和auxiliary库相同的用户和密码,并且用户名必须是sys,即上面写的sys/oracle

4、执行以下操作
RMAN> duplicate target database to orcl from active database password file spfile nofilenamecheck;

如果通过dp来执行:

rman target xxx/oracle@xxx auxiliary xxx/oracle@xxxx catalog rman/***@arch

run {
allocate auxiliary  channel 'dev_0' type 'sbt_tape'
 parms 'ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=xxx,OB2BARLIST=xxx)';
allocate auxiliary   channel 'dev_1' type 'sbt_tape'
 parms 'ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=xxx,OB2BARLIST=xxx)';
allocate auxiliary  channel 'dev_2' type 'sbt_tape'
 parms 'ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=xxx,OB2BARLIST=xxx)';
allocate auxiliary  channel 'dev_3' type 'sbt_tape'
 parms 'ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=xxx,OB2BARLIST=xxx)';

duplicate target database to xxx;
}

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

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

注册时间:2002-10-18

  • 博文量
    71
  • 访问量
    59326