1.环境准备
2台虚拟机,操作系统安装Redhat 7.9。 其他信息规划如下:
sourcedb | targetdb | |
---|---|---|
IP地址 | 192.168.56.101 | 192.168.56.102 |
数据库SID | orcl | orcl |
DB_UNIQUE_NAME | orcl_p | orcl_s |
在2台虚拟机分别安装19c数据库软件,主库创建CDB实例orcl,PDB实例:hbhe。 备库只安装数据库软件,不创建实例。
在dg01和dg02服务器上修改/etc/hosts文件
[root@dg02 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.101 dg01
192.168.56.102 dg02
2 主库启动FORCE LOGGING
[oracle@dg01 dbhome_1]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Sep 14 22:58:33 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 HBHE READ WRITE NO
SQL> col name for a20
SQL> select name,open_mode from v$pdbs;
NAME OPEN_MODE
-------------------- ------------------------------
PDB$SEED READ ONLY
HBHE READ WRITE
SQL> select force_logging from v$database;
FORCE_LOGGING
--------------------------------------------------------------------------------
NO
SQL> alter database force logging;
Database altered.
SQL> select force_logging from v$database;
FORCE_LOGGING
--------------------------------------------------------------------------------
YES
3 主库启动归档模式
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u01/app/oracle/product/19.3.0/dbhome_1/dbs/arch
Oldest online log sequence 5
Current log sequence 7
SQL> alter system set log_archive_dest_1='location=/archlog/' scope=spfile ;
System altered.
SQL> alter system set log_archive_format='arch_%t_%s_%r.arc' scope=spfile;
System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 2516581456 bytes
Fixed Size 9141328 bytes
Variable Size 654311424 bytes
Database Buffers 1845493760 bytes
Redo Buffers 7634944 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 HBHE MOUNTED
SQL> alter pluggable database hbhe open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 HBHE READ WRITE NO
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /archlog/
Oldest online log sequence 5
Next log sequence to archive 7
Current log sequence 7
4 在主库添加 standby redo logfile
Oracle 19c的多租户环境里,online redo log 和控制文件是保存在CDB中的,PDB中只有运行需要的数据文件,所以我们这里加standby redo log,是在CDB中加。
SQL> select group#, members, bytes from v$log;
GROUP# MEMBERS BYTES
---------- ---------- ----------
1 1 209715200
2 1 209715200
3 1 209715200
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ORCL/redo03.log
/u01/app/oracle/oradata/ORCL/redo02.log
/u01/app/oracle/oradata/ORCL/redo01.log
SQL> alter database add standby logfile '/u01/app/oracle/oradata/ORCL/stdredo01.log' size 200M;
alter database add standby logfile '/u01/app/oracle/oradata/ORCL/stdredo02.log' size 200M;
alter database add standby logfile '/u01/app/oracle/oradata/ORCL/stdredo03.log' size 200M;
alter database add standby logfile '/u01/app/oracle/oradata/ORCL/stdredo04.log' size 200M;
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL> select member from v$logfile;
Database altered.
SQL>
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ORCL/redo03.log
/u01/app/oracle/oradata/ORCL/redo02.log
/u01/app/oracle/oradata/ORCL/redo01.log
/u01/app/oracle/oradata/ORCL/stdredo01.log
/u01/app/oracle/oradata/ORCL/stdredo02.log
/u01/app/oracle/oradata/ORCL/stdredo03.log
/u01/app/oracle/oradata/ORCL/stdredo04.log
7 rows selected.
5 在主库创建pfile 文件并修改pfile 内容
### add for dg
*.db_unique_name='orcl_p'
*.log_archive_config='dg_config=(orcl_p, orcl_s)'
*.log_archive_dest_1='location=/archlog/ valid_for=(all_logfiles,all_roles) db_unique_name=orcl_p'
*.log_archive_dest_2='service=orcl_s lgwr affirm sync valid_for=(online_logfiles,primary_role) db_unique_name=orcl_s'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.standby_file_management='auto'
*.fal_server='orcl_s'
*.log_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl'
*.db_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl'
用新参数重启数据库:
s[oracle@dg01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 15 22:36:20 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> create spfile from pfile;
File created.
SQL> startup
ORACLE instance started.
Total System Global Area 2516581456 bytes
Fixed Size 9141328 bytes
Variable Size 654311424 bytes
Database Buffers 1845493760 bytes
Redo Buffers 7634944 bytes
Database mounted.
Database opened.
6 分别在主备库配置监听并启动
[oracle@dg01 ~]$ cd /u01/app/oracle/product/19.3.0/dbhome_1/network/admin
[oracle@dg01 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg01)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@dg01 admin]$ lsnrctl reload
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 15-SEP-2021 22:41:26
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg01)(PORT=1521)))
The command completed successfully
7 分别在主备库配置tnsnames.ora
[oracle@dg01 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg01)(PORT = 1521))
ORCL_P =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg01)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL_S =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg02)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
[oracle@dg01 admin]$ tnsping ORCL_P
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 15-SEP-2021 22:52:41
Copyright (c) 1997, 2019, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/19.3.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dg01)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))
OK (0 msec)
[oracle@dg01 admin]$ tnsping ORCL_S
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 15-SEP-2021 22:52:43
Copyright (c) 1997, 2019, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/19.3.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dg02)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))
OK (0 msec)
8 将主库的口令文件copy到备库
[oracle@dg01 dbs]$ scp orapworcl dg02:/u01/app/oracle/product/19.3.0/dbhome_1/dbs
9 将主库的参数文件copy到备库并修改
[oracle@dg01 dbs]$ scp initorcl.ora dg02:/u01/app/oracle/product/19.3.0/dbhome_1/dbs
### add for dg
*.db_unique_name='orcl_s'
*.log_archive_config='dg_config=(orcl_p, orcl_s)'
*.log_archive_dest_1='location=/archlog/ valid_for=(all_logfiles,all_roles) db_unique_name=orcl_s'
*.log_archive_dest_2='service=orcl_s lgwr affirm sync valid_for=(online_logfiles,primary_role) db_unique_name=orcl_p'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.standby_file_management='auto'
*.fal_server='orcl_p'
*.log_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl'
*.db_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl'
[oracle@dg02 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 15 23:00:52 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
SQL> create spfile from pfile;
File created.
10 在备库创建必要的目录
根据pfile 文件,将该文件中出现的所有路径全部检查一遍,如果不存在,则创建之。 否在启动备库会报错。
[oracle@dg02 ~]$ mkdir -p /u01/app/oracle/admin/orcl/adump
[oracle@dg02 ~]$ mkdir -p /u01/app/oracle/oradata/ORCL
[oracle@dg02 ~]$ mkdir -p /u01/app/oracle/oradata/orcl
11 用spfile 将备库启动到nomount 状态
SQL> startup nomount
ORACLE instance started.
Total System Global Area 2516581456 bytes
Fixed Size 9141328 bytes
Variable Size 654311424 bytes
Database Buffers 1845493760 bytes
Redo Buffers 7634944 bytes
12 Active duplicate
[oracle@dg02 ~]$ rman target sys/wwwwww@orcl_p auxiliary sys/wwwwww@orcl_s;
Recovery Manager: Release 19.0.0.0.0 - Production on Fri Sep 17 21:45:23 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1611058655)
connected to auxiliary database: ORCL (not mounted)
RMAN> duplicate target database for standby from active database nofilenamecheck dorecover;
Starting Duplicate Db at 2021:09:1721:45:44
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=2728 device type=DISK
current log archived
contents of Memory Script:
{
backup as copy reuse
passwordfile auxiliary format '/u01/app/oracle/product/19.3.0/dbhome_1/dbs/orapworcl' ;
}
executing Memory Script
Starting backup at 2021:09:1721:45:46
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1221 device type=DISK
Finished backup at 2021:09:1721:45:50
contents of Memory Script:
{
restore clone from service 'orcl_p' standby controlfile;
}
executing Memory Script
Starting restore at 2021:09:1721:45:51
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
output file name=/u01/app/oracle/oradata/ORCL/control01.ctl
output file name=/u01/app/oracle/oradata/ORCL/control02.ctl
Finished restore at 2021:09:1721:45:57
contents of Memory Script:
{
sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
RMAN-05158: WARNING: auxiliary (datafile) file name /u01/app/oracle/oradata/ORCL/system01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /u01/app/oracle/oradata/ORCL/sysaux01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /u01/app/oracle/oradata/ORCL/undotbs01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /u01/app/oracle/oradata/ORCL/pdbseed/system01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /u01/app/oracle/oradata/ORCL/pdbseed/sysaux01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /u01/app/oracle/oradata/ORCL/users01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /u01/app/oracle/oradata/ORCL/pdbseed/undotbs01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /u01/app/oracle/oradata/ORCL/hbhe/system01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /u01/app/oracle/oradata/ORCL/hbhe/sysaux01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /u01/app/oracle/oradata/ORCL/hbhe/undotbs01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /u01/app/oracle/oradata/ORCL/hbhe/users01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (tempfile) file name /u01/app/oracle/oradata/ORCL/temp01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (tempfile) file name /u01/app/oracle/oradata/ORCL/pdbseed/temp012021-09-14_22-39-39-264-PM.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (tempfile) file name /u01/app/oracle/oradata/ORCL/hbhe/temp01.dbf conflicts with a file used by the target database
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/ORCL/temp01.dbf";
set newname for tempfile 2 to
"/u01/app/oracle/oradata/ORCL/pdbseed/temp012021-09-14_22-39-39-264-PM.dbf";
set newname for tempfile 3 to
"/u01/app/oracle/oradata/ORCL/hbhe/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/ORCL/system01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/ORCL/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/ORCL/undotbs01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/ORCL/pdbseed/system01.dbf";
set newname for datafile 6 to
"/u01/app/oracle/oradata/ORCL/pdbseed/sysaux01.dbf";
set newname for datafile 7 to
"/u01/app/oracle/oradata/ORCL/users01.dbf";
set newname for datafile 8 to
"/u01/app/oracle/oradata/ORCL/pdbseed/undotbs01.dbf";
set newname for datafile 9 to
"/u01/app/oracle/oradata/ORCL/hbhe/system01.dbf";
set newname for datafile 10 to
"/u01/app/oracle/oradata/ORCL/hbhe/sysaux01.dbf";
set newname for datafile 11 to
"/u01/app/oracle/oradata/ORCL/hbhe/undotbs01.dbf";
set newname for datafile 12 to
"/u01/app/oracle/oradata/ORCL/hbhe/users01.dbf";
restore
from nonsparse from service
'orcl_p' clone database
;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/ORCL/temp01.dbf in control file
renamed tempfile 2 to /u01/app/oracle/oradata/ORCL/pdbseed/temp012021-09-14_22-39-39-264-PM.dbf in control file
renamed tempfile 3 to /u01/app/oracle/oradata/ORCL/hbhe/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
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 2021:09:1721:46:03
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
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/ORCL/system01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:36
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ORCL/sysaux01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ORCL/undotbs01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ORCL/pdbseed/system01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/ORCL/pdbseed/sysaux01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/ORCL/users01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/ORCL/pdbseed/undotbs01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/ORCL/hbhe/system01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/ORCL/hbhe/sysaux01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00011 to /u01/app/oracle/oradata/ORCL/hbhe/undotbs01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/ORCL/hbhe/users01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2021:09:1721:48:37
sql statement: alter system archive log current
current log archived
contents of Memory Script:
{
restore clone force from service 'orcl_p'
archivelog from scn 2324926;
switch clone datafile all;
}
executing Memory Script
Starting restore at 2021:09:1721:48:38
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=11
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=12
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service orcl_p
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=13
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2021:09:1721:48:42
datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=1083534522 file name=/u01/app/oracle/oradata/ORCL/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=1083534522 file name=/u01/app/oracle/oradata/ORCL/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=6 STAMP=1083534522 file name=/u01/app/oracle/oradata/ORCL/undotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=7 STAMP=1083534522 file name=/u01/app/oracle/oradata/ORCL/pdbseed/system01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=8 STAMP=1083534522 file name=/u01/app/oracle/oradata/ORCL/pdbseed/sysaux01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=9 STAMP=1083534522 file name=/u01/app/oracle/oradata/ORCL/users01.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=10 STAMP=1083534522 file name=/u01/app/oracle/oradata/ORCL/pdbseed/undotbs01.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=11 STAMP=1083534522 file name=/u01/app/oracle/oradata/ORCL/hbhe/system01.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=12 STAMP=1083534522 file name=/u01/app/oracle/oradata/ORCL/hbhe/sysaux01.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=13 STAMP=1083534522 file name=/u01/app/oracle/oradata/ORCL/hbhe/undotbs01.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=14 STAMP=1083534522 file name=/u01/app/oracle/oradata/ORCL/hbhe/users01.dbf
contents of Memory Script:
{
set until scn 2325371;
recover
standby
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 2021:09:1721:48:43
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 11 is already on disk as file /archlog/arch_1_11_1083277921.arc
archived log for thread 1 with sequence 12 is already on disk as file /archlog/arch_1_12_1083277921.arc
archived log for thread 1 with sequence 13 is already on disk as file /archlog/arch_1_13_1083277921.arc
archived log file name=/archlog/arch_1_11_1083277921.arc thread=1 sequence=11
archived log file name=/archlog/arch_1_12_1083277921.arc thread=1 sequence=12
archived log file name=/archlog/arch_1_13_1083277921.arc thread=1 sequence=13
media recovery complete, elapsed time: 00:00:01
Finished recover at 2021:09:1721:48:46
contents of Memory Script:
{
delete clone force archivelog all;
}
executing Memory Script
released channel: ORA_DISK_1
released channel: ORA_AUX_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1221 device type=DISK
deleted archived log
archived log file name=/archlog/arch_1_11_1083277921.arc RECID=1 STAMP=1083534518
deleted archived log
archived log file name=/archlog/arch_1_12_1083277921.arc RECID=2 STAMP=1083534520
deleted archived log
archived log file name=/archlog/arch_1_13_1083277921.arc RECID=3 STAMP=1083534521
Deleted 3 objects
Oracle error from auxiliary database: ORA-01275: Operation RENAME is not allowed if standby file management is automatic.
RMAN-05535: warning: All redo log files were not defined properly.
Oracle error from auxiliary database: ORA-01275: Operation RENAME is not allowed if standby file management is automatic.
RMAN-05535: warning: All redo log files were not defined properly.
Oracle error from auxiliary database: ORA-01275: Operation RENAME is not allowed if standby file management is automatic.
RMAN-05535: warning: All redo log files were not defined properly.
Oracle error from auxiliary database: ORA-01275: Operation RENAME is not allowed if standby file management is automatic.
RMAN-05535: warning: All redo log files were not defined properly.
Oracle error from auxiliary database: ORA-01275: Operation RENAME is not allowed if standby file management is automatic.
RMAN-05535: warning: All redo log files were not defined properly.
Oracle error from auxiliary database: ORA-01275: Operation RENAME is not allowed if standby file management is automatic.
RMAN-05535: warning: All redo log files were not defined properly.
Oracle error from auxiliary database: ORA-01275: Operation RENAME is not allowed if standby file management is automatic.
RMAN-05535: warning: All redo log files were not defined properly.
Finished Duplicate Db at 2021:09:1721:48:47
13 打开备库并并启动apply
SQL> select open_mode from v$database;
OPEN_MODE
------------------------------------------------------------
MOUNTED
SQL> alter database open;
Database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 HBHE MOUNTED
SQL> set lines 150
SQL> col log_mode for a15
SQL> col open_mode for a15
SQL> col database_role for a20
SQL> select log_mode,open_mode ,database_role from v$database;
LOG_MODE OPEN_MODE DATABASE_ROLE
--------------- --------------- --------------------
ARCHIVELOG READ ONLY PHYSICAL STANDBY
SQL> select log_mode,open_mode ,database_role from v$database;
LOG_MODE OPEN_MODE DATABASE_ROLE
--------------- --------------- --------------------
ARCHIVELOG READ ONLY PHYSICAL STANDBY
-----启动日志应用
SQL> alter database recover managed standby database disconnect;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
---------------
READ ONLY WITH
APPLY
14 验证DG
SQL> col status for a15
SQL> col error for a20
SQL> select status,error from v$archive_dest where dest_id=2;
STATUS ERROR
--------------- --------------------
VALID
主库执行命令:
SQL> alter system switch logfile;
System altered.
SQL> create table t1 as select * from all_users;
Table created.
在备库查看
SQL> select count(*) from t1;
COUNT(*)
----------
36
版权声明:本文为博主原创文章,未经博主允许不得转载。
Linux,oracle