DG RMAN 创建备库有多种方法
(备注:本次测试duplicate from active 和利用备份主库控制文件+参数文件+数据文件+日志文件(本地恢复,节约带宽资源))
一.duplicate target database for standby from active database;
环境介绍:
操作系统:Red Hat Enterprise Linux Server release 6.4 (Santiago)
数据库:Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
机器地址:192.0.2.21(主库) 192.0.2.22(备库)
实例名称:PROD5
service_names string PROD51.us.oracle.com
service_names string PROD52.us.oracle.com
数据文件和日志目录相同;
==================================================================
1.准备
主库:
开启强制日志模式:alter database force logging ;
开启归档模式:alter database archivelog; (mount状态下设置)
配置listener.ora,tnsnames.ora文件
[oracle@host01 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host01.example.com)(PORT = 1521))
)
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC =
(GLOBAL_DBNAME=PROD51.us.oracle.com)
(ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1)
(SID_NAME=PROD5)))
[oracle@host01 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
PROD51 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host01.example.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PROD51.us.oracle.com)
)
)
PROD52 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host02.example.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PROD52.us.oracle.com)
)
)
[oracle@host01 admin]$ cat sqlnet.ora
# sqlnet.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES,EZCONNECT)
[oracle@host01 ~]$ lsnrctl status
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 04-JUN-2021 09:34:15
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host01.example.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 03-JUN-2021 13:47:30
Uptime 0 days 19 hr. 46 min. 45 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/host01/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host01.example.com)(PORT=1521)))
Services Summary...
Service "PROD51.us.oracle.com" has 2 instance(s).
Instance "PROD5", status UNKNOWN, has 1 handler(s) for this service...
Instance "PROD5", status READY, has 1 handler(s) for this service...
Service "PROD5XDB.us.oracle.com" has 1 instance(s).
Instance "PROD5", status READY, has 1 handler(s) for this service...
The command completed successfully
配置DG参数:
[oracle@host01 ~]$ cat pfile1.ora
PROD5.__data_transfer_cache_size=0
PROD5.__db_cache_size=247463936
PROD5.__java_pool_size=4194304
PROD5.__large_pool_size=20971520
PROD5.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
PROD5.__pga_aggregate_target=281018368
PROD5.__sga_target=515899392
PROD5.__shared_io_pool_size=12582912
PROD5.__shared_pool_size=218103808
PROD5.__streams_pool_size=4194304
*.audit_file_dest='/u01/app/oracle/admin/PROD5/adump'
*.audit_trail='db'
*.compatible='12.1.0.2.0'
*.control_files='/u01/app/oracle/oradata/PROD5/control01.ctl','/u01/app/oracle/fast_recovery_area/PROD5/control02.ctl'
*.db_block_size=8192
*.db_domain='us.oracle.com'
*.db_name='PROD5'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=16106127360
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=PROD5XDB)'
*.heat_map='ON'
*.local_listener=''
*.memory_target=760m
*.open_cursors=300
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
DB_UNIQUE_NAME=PROD51
LOG_ARCHIVE_CONFIG='DG_CONFIG=(PROD51,PROD52)'
LOG_ARCHIVE_DEST_1=
'LOCATION=USE_DB_RECOVERY_FILE_DEST
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=PROD51'
LOG_ARCHIVE_DEST_2=
'SERVICE=PROD52 ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=PROD52'
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
FAL_SERVER=PROD52
STANDBY_FILE_MANAGEMENT=AUTO
通过编辑后的参数文件启动数据库:
create spfile from pfile='/home/oracle/pfile1.ora';
startup ;
[oracle@host01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 4 09:33:23 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@PROD5>select name,open_mode,database_role from v$database;
NAME OPEN_MODE DATABASE_ROLE
--------- -------------------- ----------------
PROD5 READ WRITE PRIMARY
配置standy.log日志4组:(大小和正在运行的redo.log大小相同)
[oracle@host01 ~]$ cat 1.sql
alter database add standby logfile '/u01/app/oracle/oradata/PROD5/standby01.log' size 50m;
alter database add standby logfile '/u01/app/oracle/oradata/PROD5/standby02.log' size 50m;
alter database add standby logfile '/u01/app/oracle/oradata/PROD5/standby03.log' size 50m;
alter database add standby logfile '/u01/app/oracle/oradata/PROD5/standby04.log' size 50m;
-------------------------------------------------------------------------------------------------------------------
备库:
配置参数文件(从主库复制而来,修改了红色部分的参数)密码文件orapwPROD5
[oracle@host02 ~]$ cat pfile2.ora
PROD5.__data_transfer_cache_size=0
PROD5.__db_cache_size=247463936
PROD5.__java_pool_size=4194304
PROD5.__large_pool_size=20971520
PROD5.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
PROD5.__pga_aggregate_target=281018368
PROD5.__sga_target=515899392
PROD5.__shared_io_pool_size=12582912
PROD5.__shared_pool_size=218103808
PROD5.__streams_pool_size=4194304
*.audit_file_dest='/u01/app/oracle/admin/PROD5/adump'
*.audit_trail='db'
*.compatible='12.1.0.2.0'
*.control_files='/u01/app/oracle/oradata/PROD5/control01.ctl','/u01/app/oracle/fast_recovery_area/PROD5/control02.ctl'
*.db_block_size=8192
*.db_domain='us.oracle.com'
*.db_name='PROD5'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=16106127360
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=PROD5XDB)'
*.heat_map='ON'
*.local_listener=''
*.memory_target=760m
*.open_cursors=300
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
DB_UNIQUE_NAME=PROD52
LOG_ARCHIVE_CONFIG='DG_CONFIG=(PROD52,PROD51)'
LOG_ARCHIVE_DEST_1=
'LOCATION=USE_DB_RECOVERY_FILE_DEST
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=PROD52'
LOG_ARCHIVE_DEST_2=
'SERVICE=PROD51 ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=PROD51'
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
FAL_SERVER=PROD51
STANDBY_FILE_MANAGEMENT=AUTO
配置listener.ora ,tnsnames.ora
[oracle@host02 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host02.example.com)(PORT = 1521))
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = PROD52.us.oracle.com)
(ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
(SID_NAME = PROD5)
)
)
[oracle@host02 admin]$ cat tnsnames.ora
PROD52 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host02.example.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PROD52.us.oracle.com)
)
)
PROD51 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host01.example.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PROD51.us.oracle.com)
)
)
[oracle@host02 admin]$ lsnrctl status
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 03-JUN-2021 18:40:53
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host02.example.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 03-JUN-2021 10:10:59
Uptime 0 days 8 hr. 29 min. 53 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/host02/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host02.example.com)(PORT=1521)))
Services Summary...
Service "PROD52.us.oracle.com" has 1 instance(s).
Instance "PROD5", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
使用参数文件pfile2.ora,启动数据库:
create spfile from pfile='/home/oracle/pfile2.ora';
startup nomount;
-------------------------------------------------------------------------------------------------------------------------------------------
测试主备测tns监听:
[oracle@host01 ~]$ tnsping prod51
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 04-JUN-2021 09:58:30
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host01.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD51.us.oracle.com)))
OK (0 msec)
[oracle@host01 ~]$ tnsping prod52
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 04-JUN-2021 09:58:32
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host02.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD52.us.oracle.com)))
OK (0 msec)
[oracle@host01 ~]$
[oracle@host02 ~]$ tnsping prod51
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 03-JUN-2021 18:46:13
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host01.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD51.us.oracle.com)))
OK (0 msec)
[oracle@host02 ~]$ tnsping prod52
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 03-JUN-2021 18:46:14
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host02.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD52.us.oracle.com)))
OK (0 msec)
[oracle@host02 ~]$
---------------------------------------------------------------------------------------------------------------------------------
在备库上进行在线复制:
[oracle@host02 ~]$ rman target sys/oracle@prod51 auxiliary sys/oracle@prod52
Recovery Manager: Release 12.1.0.2.0 - Production on Thu Jun 3 18:48:22 2021
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD5 (DBID=1772826369)
connected to auxiliary database: PROD5 (not mounted)
RMAN> duplicate target database for standby from active database nofilenamecheck;(nofilenamecheck文件名不检测)
[oracle@host02 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 3 19:28:18 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to an idle instance.
SYS@PROD5>startup mount;
ORACLE instance started.
Total System Global Area 796917760 bytes
Fixed Size 2929448 bytes
Variable Size 557845720 bytes
Database Buffers 230686720 bytes
Redo Buffers 5455872 bytes
Database mounted.
SYS@PROD5>quit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[oracle@host02 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 3 19:28:45 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@PROD5>shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SYS@PROD5>startup mount;
ORACLE instance started.
Total System Global Area 796917760 bytes
Fixed Size 2929448 bytes
Variable Size 557845720 bytes
Database Buffers 230686720 bytes
Redo Buffers 5455872 bytes
Database mounted.
SYS@PROD5>
[oracle@host02 ~]$ cat 1.sql
recover managed standby database using current logfile disconnect from session;
[oracle@host02 ~]$ cat 2.sql
recover managed standby database cancel;
[oracle@host02 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 3 19:38:17 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@PROD5>alter database open ;
SYS@PROD5>select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
PROD5 READ ONLY WITH APPLY
[oracle@host02 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 3 19:42:34 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@PROD5>select process,sequence#,status from v$managed_standby;
PROCESS SEQUENCE# STATUS
--------- ---------- ------------
ARCH 0 CONNECTED
ARCH 74 CLOSING
ARCH 0 CONNECTED
ARCH 0 CONNECTED
RFS 75 IDLE
RFS 0 IDLE
MRP0 75 APPLYING_LOG
7 rows selected.
-------------------------------------------------------------------------------------------------------
测试数据同步:
主库:创建表空间和表
[oracle@host01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 4 10:56:53 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@PROD5>create tablespace idx datafile '/u01/app/oracle/oradata/PROD5/idx.dbf' size 10 autoextend on maxsize 2g;
SYS@PROD5>create table it (id number);
SYS@PROD5>alter table it move tablespace idx;
Table altered.
SYS@PROD5>alter table it move tablespace idx;
Table altered.
SYS@PROD5>select * from it;
ID
----------
1
2
100
1000
备库:
SYS@PROD5>select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD5/system01.dbf
/u01/app/oracle/oradata/PROD5/sysaux01.dbf
/u01/app/oracle/oradata/PROD5/undotbs01.dbf
/u01/app/oracle/oradata/PROD5/users01.dbf
/u01/app/oracle/oradata/PROD5/example.dbf
/u01/app/oracle/oradata/PROD5/sales_2014.dbf
/u01/app/oracle/oradata/PROD5/idx.dbf
7 rows selected.
SYS@PROD5>select * from it;
ID
----------
1
2
100
1000
数据同步正常!
====================================================================================================
二.duplicate target database for standby
1.准备条件和上面一样,包括:安装数据库软件(目录一致,不建库),修改参数文件,listener.ora tnsnames.ora sqlnet.ora文件,创建参数文件中数据文件目录,复制密码文件orapwPROD5。
2.测试tnsping联通性
[oracle@host01 ~]$ tnsping prod51
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 04-JUN-2021 11:12:46
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host01.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD51.us.oracle.com)))
OK (0 msec)
[oracle@host01 ~]$ tnsping prod52
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 04-JUN-2021 11:12:49
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host02.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD52.us.oracle.com)))
OK (0 msec)
[oracle@host01 ~]$
[oracle@host02 ~]$ tnsping prod51
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 03-JUN-2021 20:00:34
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host01.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD51.us.oracle.com)))
OK (0 msec)
[oracle@host02 ~]$ tnsping prod52
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 03-JUN-2021 20:00:36
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host02.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD52.us.oracle.com)))
OK (0 msec)
[oracle@host02 ~]$
3.备份控制文件,备份数据文件;
主库:
[oracle@host01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 4 11:17:32 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@PROD5>alter database create standby controlfile as '/home/oracle/prod52.ctl';
Database altered.
[oracle@host01 ~]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Fri Jun 4 11:18:50 2021
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD5 (DBID=1772826369)
RMAN> backup database format '/home/oracle/backup/full_%U.bak' plus archivelog format '/home/oracle/arch_%U.bak';
将文件拷贝到host02主机
备库:
[oracle@host02 ~]$ cp prod52.ctl /u01/app/oracle/oradata/PROD5/control01.ctl
[oracle@host02 ~]$ cp prod52.ctl /u01/app/oracle/fast_recovery_area/PROD5/control02.ctl
[oracle@host02 ~]$ rman target sys/oracle@prod51 auxiliary sys/oracle@prod52
Recovery Manager: Release 12.1.0.2.0 - Production on Thu Jun 3 20:12:44 2021
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD5 (DBID=1772826369)
connected to auxiliary database: PROD5 (not mounted)
RMAN> duplicate target database for standby nofilenamecheck;
Starting Duplicate Db at 03-JUN-21
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=12 device type=DISK
contents of Memory Script:
{
restore clone standby controlfile;
}
executing Memory Script
Starting restore at 03-JUN-21
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/backup/full_1m00i6kr_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/home/oracle/backup/full_1m00i6kr_1_1.bak tag=TAG20210604T112044
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/PROD5/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/PROD5/control02.ctl
Finished restore at 03-JUN-21
contents of Memory Script:
{
sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/PROD5/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/PROD5/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/PROD5/sales_2014.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/PROD5/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/PROD5/undotbs01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/PROD5/example.dbf";
set newname for datafile 6 to
"/u01/app/oracle/oradata/PROD5/users01.dbf";
set newname for datafile 7 to
"/u01/app/oracle/oradata/PROD5/idx.dbf";
restore
clone database
;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/PROD5/temp01.dbf in control file
executing command: SET NEWNAME
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 03-JUN-21
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/PROD5/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD5/sales_2014.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD5/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD5/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/PROD5/example.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/PROD5/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/PROD5/idx.dbf
channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/backup/full_1l00i6kc_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/home/oracle/backup/full_1l00i6kc_1_1.bak tag=TAG20210604T112044
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 03-JUN-21
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=10 STAMP=1074284052 file name=/u01/app/oracle/oradata/PROD5/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=11 STAMP=1074284052 file name=/u01/app/oracle/oradata/PROD5/sales_2014.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=12 STAMP=1074284052 file name=/u01/app/oracle/oradata/PROD5/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=13 STAMP=1074284052 file name=/u01/app/oracle/oradata/PROD5/undotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=14 STAMP=1074284052 file name=/u01/app/oracle/oradata/PROD5/example.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=15 STAMP=1074284052 file name=/u01/app/oracle/oradata/PROD5/users01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=16 STAMP=1074284052 file name=/u01/app/oracle/oradata/PROD5/idx.dbf
Finished Duplicate Db at 03-JUN-21
RMAN>
[oracle@host01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 4 11:29:42 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@PROD5>select error,status from v$archive_dest where dest_id=2;
ERROR STATUS
----------------------------------------------------------------- ---------
ORA-16058: standby database instance is not mounted ERROR
[oracle@host02 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 3 20:16:46 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@PROD5>shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SYS@PROD5>startup mount;
ORACLE instance started.
Total System Global Area 796917760 bytes
Fixed Size 2929448 bytes
Variable Size 557845720 bytes
Database Buffers 230686720 bytes
Redo Buffers 5455872 bytes
Database mounted.
SYS@PROD5>select error,status from v$archive_dest where dest_id=2;
ERROR STATUS
----------------------------------------------------------------- ---------
VALID
[oracle@host02 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 3 20:20:59 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@PROD5>recover managed standby database using current logfile disconnect from session;
Media recovery complete.
SYS@PROD5>recover managed standby database cancel;
Media recovery complete.
SYS@PROD5>alter database open;
Database altered.
SYS@PROD5>recover managed standby database using current logfile disconnect from session;
Media recovery complete.
SYS@PROD5>select process,sequence#,status from v$managed_standby;
PROCESS SEQUENCE# STATUS
--------- ---------- ------------
ARCH 0 CONNECTED
ARCH 0 CONNECTED
ARCH 80 CLOSING
ARCH 0 CONNECTED
RFS 0 IDLE
RFS 81 IDLE
MRP0 81 APPLYING_LOG
7 rows selected.
SYS@PROD5>archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 0
Next log sequence to archive 0
Current log sequence 0
SYS@PROD5>
SYS@PROD5>archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 0
Next log sequence to archive 0
Current log sequence 0
SYS@PROD5>select * from it;
ID
----------
1
2
100
1000
使用备份文件恢复备库正常;