Oracle 如何快速的 duplicate 一个数据库

首先

  1.duplicate daabase干什么的

   快速复制一个数据库。通常用在系统迁移、测试系统搭建。

   使用active方式复制,可以不需要有备份文件的情况下,直接复制数据库到新的地方。

   如果有备份系统,我是不建议从生产直接duplicate数据库的。因为直接操作生产系统还是有些风险的,比如你搞错源和目标了,删库跑路了。

  

那么开搞吧

  

1.新的数据库一定要使用使用新的dbname有别于生产

  因为如果使用了相同的名字,你将在最后的时候发现新的数据库无法OPEN。

*.audit_file_dest='/data/app/oracle/admin/gtmstt/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/data/app/oracle/oradata/gtmstt/control01.ctl','/data/app/oracle/fast_recovery_area/gtmstt/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='gtmstt'
*.db_recovery_file_dest='/data/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/data/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=gtmsttXDB)'
*.open_cursors=300
*.pga_aggregate_target=2434793472
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=4293918720
*.undo_tablespace='UNDOTBS1'
*.log_file_name_convert='/data/app/oracle/oradata/gtmsdb','/data/app/oracle/oradata/gtmstt'
*.db_file_name_convert='/data/app/oracle/oradata/gtmsdb','/data/app/oracle/oradata/gtmstt','/data/app/oracle/oradata','/data/app/oracle/oradata/gtmstt'


2.创建新的路径

mkdir -p /data/app/oracle/admin/gtmstt/adump

mkdir -p /data/app/oracle/oradata/gtmstt

mkdir -p /data/app/oracle/fast_recovery_area/gtmstt


3.新库要在listener中静态注册

listenser.ora 和 tnsnames.ora文件中的行缩进是不能省略的。否则你会遇到奇奇怪怪的问题。

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.3)(PORT = 1521))
    )
  )

SID_LIST_LISTENER =
   (SID_LIST =
    (SID_DESC =
      (SID_NAME = gtmstt)
      (ORACLE_HOME = /data/app/oracle/product/11.2.0/dbhome_1)
    )
  )

ADR_BASE_LISTENER = /data/app/oracle

 

[oracle@gtmstestdb ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 07-NOV-2020 17:13:54

Copyright (c) 1991, 2013, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 07-NOV-2020 16:57:03
Uptime 0 days 0 hr. 16 min. 50 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /data/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /data/app/oracle/diag/tnslsnr/gtmstestdb/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.1.1.3)(PORT=1521)))
Services Summary...
Service "gtmstt" has 2 instance(s).
Instance "gtmstt", status UNKNOWN, has 1 handler(s) for this service...  这个UNKNOWN 就是静态注册上的意思。
The command completed successfully


4.一定要检查防火墙是否关闭

[root@gtmstestdb ~]$ /bin/systemctl status firewalld

● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)

 

Nov 05 17:22:39 gtmstestdb systemd[1]: Starting firewalld - dynamic firewall daemon...
Nov 05 17:22:39 gtmstestdb systemd[1]: Started firewalld - dynamic firewall daemon.
Nov 06 16:11:54 gtmstestdb systemd[1]: Stopping firewalld - dynamic firewall daemon...
Nov 06 16:11:54 gtmstestdb systemd[1]: Stopped firewalld - dynamic firewall daemon.

 

5.配置源库tnsnames.ora 或者配置 测试库tnsnames.ora均可,取决于你想在哪一边进行操作

gtmsdb_du =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.3)(PORT = 1521))
      (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME= gtmsdb)
    )
  )

gtmsdb=
  (DESCRIPTION=
    (ADDRESS=(PROTOCOL=TCP)(HOST=10.1.1.2)(PORT=1521))
    (CONNECT_DATA=
      (SERVER=dedicated)
      (SERVICE_NAME=gtmsdb)
    )
  )

5.开始duplicate在哪一端操作均可以,命令是一样的

target 后面加源库
auxiliary 后面加新库

rman target sys/oracle@gtmsdb auxiliary sys/oracle@gtmsdb_du


run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate AUXILIARY channel c5 type disk;
allocate AUXILIARY channel c6 type disk;
allocate AUXILIARY channel c7 type disk;
allocate AUXILIARY channel c8 type disk;
duplicate target database to gtmstt from active database nofilenamecheck ;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
release channel c7;
release channel c8;

}

 

 

我的日志:

 

posted @ 2021-02-22 10:41  lizhao01  阅读(1114)  评论(0编辑  收藏  举报