RMAN duplicate搭建辅助数据库
使用RMAN DUPLICATE命令可以在保留目标数据库的基础上依靠目标数据库(TargetDatabase)的备份创建一个副本数据库(DuplicateDatabase),目标数据库和辅助数据库可以在同一台机器上,辅助数据库是目标数据库的一个拷贝。
复制新库步骤
1)将辅助库上安装数据库软件,不建库,建立Oracle Home
2)为辅助库建立口令文件,Active方式下与源数据库口令相同
3)确保到辅助实例的网络连通性(辅助库建立静态监听)
4)为辅助实例创建参数文件
5)以nomount方式启动辅助实例(启动静态监听)
6)生产数据库处于mount或open模式下
7)创建备份或将备份和归档日志文件复制到辅助库实例可以访问的某个位置,或者使用活动(active)数据库复制
8)如果有必要分配辅助通道
9)运行rman duplicate命令
10)使用resetlogs打开辅助数据库
duplicate是个不完全恢复,因为current log没有办法通过RMAN备份
实战演示:
数据库ASM - > ASM
配置本地新数据库的环境:
export ORACLE_SID=newdkf
vi /tmp/initnewdkf.ora
*.db_name='newdkf'
*.enable_pluggable_database=true
配置本地新数据库的密码文件:
[oracle@dkf dbs]$ ls -al orapw*
-rw-r----- 1 oracle oinstall 2048 Apr 4 2022 orapwdkf006
-rw-r----- 1 oracle oinstall 2048 Mar 18 19:09 orapwnewdkf
[oracle@dkf dbs]$
启动新的目标数据库:
SQL> startup nomount pfile='/tmp/initnewdkf.ora'
ORACLE instance started.
Total System Global Area 297795128 bytes
Fixed Size 9133624 bytes
Variable Size 234881024 bytes
Database Buffers 50331648 bytes
Redo Buffers 3448832 bytes
SQL>
配置静态监听:
[oracle@dkf admin]$ cat listener.ora
dkf=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.19)(PORT = 1522))
)
SID_LIST_dkf=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = dkf006)
(ORACLE_HOME =/u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = dkf006)
)
(SID_DESC =
(GLOBAL_DBNAME = newdkf)
(ORACLE_HOME =/u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = newdkf)
)
)
监听状态
[oracle@dkf admin]$ lsnrctl start dkf
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 18-MAR-2023 19:15:09
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Starting /u01/app/oracle/product/19.3.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/dkf/dkf/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.0.0.19)(PORT=1522)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.0.19)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias dkf
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 18-MAR-2023 19:15:09
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/dkf/dkf/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.0.0.19)(PORT=1522)))
Services Summary...
Service "dkf006" has 1 instance(s).
Instance "dkf006", status UNKNOWN, has 1 handler(s) for this service...
Service "newdkf" has 1 instance(s).
Instance "newdkf", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
连接现有数据库和目标数据库实例:
rman target sys/oracle auxiliary sys/oracle@newdkf
通过duplicate target database 命令创建新的数据库;
RMAN通过网络(active方式)在本地复制用于新的数据库,
如果duplicate在复制时,位置不同的时候,我们会用參数db_file_name_convert 对文件位置进行转换, 本地复制样例中我们用的是同样的位置, 所以这里必须加上nofilenamecheck參数,该參数通知复制操作不必在运行还原操作前确认文件名称是不同的,如果没有指定nofilenamecheck參数,rman会给出例如以下错误:
RMAN-05001: auxiliary filename /DBSoft/oracle/oradata/woo/users01.dbf conflicts with a file used by the target database
数据库duplicate日志输出:
[oracle@dkf admin]$ rman target sys/oracle auxiliary sys/oracle@newdkf
Recovery Manager: Release 19.0.0.0.0 - Production on Sat Mar 18 19:20:59 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: DKF006 (DBID=2651711443)
connected to auxiliary database: NEWDKF (not mounted)
RMAN>
RMAN> duplicate target database to newdkf from active database nofilenamecheck;
Starting Duplicate Db at 2023:03:1819:21:12
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=40 device type=DISK
current log archived
contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 297795128 bytes
Fixed Size 9133624 bytes
Variable Size 234881024 bytes
Database Buffers 50331648 bytes
Redo Buffers 3448832 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''DKF0