Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=tcloud)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) The listener supports no services The command completed successfully
重启之后变为:
1 2 3 4 5 6 7
Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=tcloud)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "ora19cl" has 1 instance(s). Instance "ora19cl", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully
rman<<_EOF connect target sys/password123@primarytns connect auxiliary sys/password123@standbytns run { allocate channel c1 type disk; allocate channel c2 type disk; allocate auxiliary channel s1 type disk; allocate auxiliary channel s2 type disk; duplicate target database for standby from active database nofilenamecheck dorecover spfile parameter_value_convert 'ora19cl','ora19cdg' set db_name='ora19cl' set db_unique_name='ora19cdg' set fal_server='primarytns' set sga_target='2G' set sga_max_size='2G' set remote_listener='' set local_listener='' set standby_file_management='AUTO' set audit_file_dest= '/data/app/oracle/admin/ora19cl/adump' set log_archive_config='dg_config=(ora19cl,ora19cdg)' set log_archive_dest_1='location=/data/archivelog/ valid_for=(all_logfiles,all_roles) db_unique_name=ora19cdg' set log_archive_dest_2='SERVICE=primarytns lgwr async VALID_FOr=(ONLINE_LOGFILES,primary_role) DB_UNIQUE_NAME=ora19cl' set log_archive_dest_state_2='enable' ; sql channel c1 "alter system archive log current"; sql channel s1 "alter database open"; sql channel s1 "alter database recover managed standby database using current logfile disconnect"; } _EOF
1 2 3 4
ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/path/to/standby/controlfile.ctl'; alter database recover managed standby database cancel; alter database recover managed standby database using current logfile disconnect
Recovery Manager: Release 19.0.0.0.0 - Production on Sun Dec 31 10:12:27 2023 Version 19.18.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
RMAN> connected to target database: ORA19CL (DBID=742043361)
RMAN> PL/SQL package SYS.DBMS_BACKUP_RESTORE version 19.03.00.00 in AUXILIARY database is not current PL/SQL package SYS.DBMS_RCVMAN version 19.03.00.00 in AUXILIARY database is not current connected to auxiliary database: ORA19CL (not mounted)
Starting Duplicate Db at 2023-12-31 10:12:44 current log archived
contents of Memory Script: { backup as copy reuse passwordfile auxiliary format '/data/app/oracle/product/19.3.0.0/dbhome_1/dbs/orapwora19cl' ; restore clone from service 'primarytns' spfile to '/data/app/oracle/product/19.3.0.0/dbhome_1/dbs/spfileora19cl.ora'; sql clone"alter system set spfile= ''/data/app/oracle/product/19.3.0.0/dbhome_1/dbs/spfileora19cl.ora''"; } executing Memory Script
Starting backup at 2023-12-31 10:12:46 Finished backup at 2023-12-31 10:12:49
Starting restore at 2023-12-31 10:12:49
channel s1: starting datafile backup set restore channel s1: using network backup set from service primarytns channel s1: restoring SPFILE output file name=/data/app/oracle/product/19.3.0.0/dbhome_1/dbs/spfileora19cl.ora channel s1: restore complete, elapsed time: 00:00:02 Finished restore at 2023-12-31 10:12:55
sql statement: alter system set spfile= ''/data/app/oracle/product/19.3.0.0/dbhome_1/dbs/spfileora19cl.ora''
contents of Memory Script: { sql clone"alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=ora19cdgXDB)'' comment= '''' scope=spfile"; sql clone"alter system set db_name = ''ora19cl'' comment= '''' scope=spfile"; sql clone"alter system set db_unique_name = ''ora19cdg'' comment= '''' scope=spfile"; sql clone"alter system set fal_server = ''primarytns'' comment= '''' scope=spfile"; sql clone"alter system set sga_target = 2G comment= '''' scope=spfile"; sql clone"alter system set sga_max_size = 2G comment= '''' scope=spfile"; sql clone"alter system set remote_listener = '''' comment= '''' scope=spfile"; sql clone"alter system set local_listener = '''' comment= '''' scope=spfile"; sql clone"alter system set standby_file_management = ''AUTO'' comment= '''' scope=spfile"; sql clone"alter system set audit_file_dest = ''/data/app/oracle/admin/ora19cl/adump'' comment= '''' scope=spfile"; sql clone"alter system set log_archive_config = ''dg_config=(ora19cl,ora19cdg)'' comment= '''' scope=spfile"; sql clone"alter system set log_archive_dest_1 = ''location=/data/archivelog/ valid_for=(all_logfiles,all_roles) db_unique_name=ora19cdg'' comment= '''' scope=spfile"; sql clone"alter system set log_archive_dest_2 = ''SERVICE=primarytns lgwr async VALID_FOr=(ONLINE_LOGFILES,primary_role) DB_UNIQUE_NAME=ora19cl'' comment= '''' scope=spfile"; sql clone"alter system set log_archive_dest_state_2 = ''enable'' comment= '''' scope=spfile"; shutdown clone immediate; startup clone nomount; } executing Memory Script
sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=ora19cdgXDB)'' comment= '''' scope=spfile
sql statement: alter system set db_name = ''ora19cl'' comment= '''' scope=spfile
sql statement: alter system set db_unique_name = ''ora19cdg'' comment= '''' scope=spfile
sql statement: alter system set fal_server = ''primarytns'' comment= '''' scope=spfile
sql statement: alter system set sga_target = 2G comment= '''' scope=spfile
sql statement: alter system set sga_max_size = 2G comment= '''' scope=spfile
sql statement: alter system set remote_listener = '''' comment= '''' scope=spfile
sql statement: alter system set local_listener = '''' comment= '''' scope=spfile
sql statement: alter system set standby_file_management = ''AUTO'' comment= '''' scope=spfile
sql statement: alter system set audit_file_dest = ''/data/app/oracle/admin/ora19cl/adump'' comment= '''' scope=spfile
sql statement: alter system set log_archive_config = ''dg_config=(ora19cl,ora19cdg)'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_1 = ''location=/data/archivelog/ valid_for=(all_logfiles,all_roles) db_unique_name=ora19cdg'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_2 = ''SERVICE=primarytns lgwr async VALID_FOr=(ONLINE_LOGFILES,primary_role) DB_UNIQUE_NAME=ora19cl'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_state_2 = ''enable'' comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started) Oracle instance started
contents of Memory Script: { restore clone from service 'primarytns' standby controlfile; } executing Memory Script
Starting restore at 2023-12-31 10:13:38
channel s1: starting datafile backup set restore channel s1: using network backup set from service primarytns channel s1: restoring control file channel s1: restore complete, elapsed time: 00:00:16 output file name=/data/oradata/ORA19CL/control01.ctl output file name=/data/oradata/ORA19CL/control02.ctl Finished restore at 2023-12-31 10:13:58
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 forclone tempfile 1 to new; switch clone tempfile all; set newname forclone datafile 1 to new; set newname forclone datafile 2 to new; set newname forclone datafile 3 to new; set newname forclone datafile 4 to new; set newname forclone datafile 5 to new; set newname forclone datafile 7 to new; set newname forclone datafile 8 to new; set newname forclone datafile 9 to new; set newname forclone datafile 10 to new; restore from nonsparse from service 'primarytns'clone database ; sql 'alter system archive log current'; } executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /data/oradata/ORA19CDG/datafile/o1_mf_temp_%u_.tmp 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
Starting restore at 2023-12-31 10:14:07
channel s1: starting datafile backup set restore channel s1: using network backup set from service primarytns channel s1: specifying datafile(s) to restore from backup set channel s1: restoring datafile 00001 to /data/oradata/ORA19CDG/datafile/o1_mf_system_%u_.dbf channel s2: starting datafile backup set restore channel s2: using network backup set from service primarytns channel s2: specifying datafile(s) to restore from backup set channel s2: restoring datafile 00002 to /data/oradata/ORA19CDG/datafile/o1_mf_userb_in_%u_.dbf channel s2: restore complete, elapsed time: 00:00:55 channel s2: starting datafile backup set restore channel s2: using network backup set from service primarytns channel s2: specifying datafile(s) to restore from backup set channel s2: restoring datafile 00003 to /data/oradata/ORA19CDG/datafile/o1_mf_sysaux_%u_.dbf channel s1: restore complete, elapsed time: 00:22:42 channel s1: starting datafile backup set restore channel s1: using network backup set from service primarytns channel s1: specifying datafile(s) to restore from backup set channel s1: restoring datafile 00004 to /data/oradata/ORA19CDG/datafile/o1_mf_undotbs1_%u_.dbf channel s1: restore complete, elapsed time: 00:00:26 channel s1: starting datafile backup set restore channel s1: using network backup set from service primarytns channel s1: specifying datafile(s) to restore from backup set channel s1: restoring datafile 00005 to /data/oradata/ORA19CDG/datafile/o1_mf_userb_da_%u_.dbf channel s1: restore complete, elapsed time: 00:02:46 channel s1: starting datafile backup set restore channel s1: using network backup set from service primarytns channel s1: specifying datafile(s) to restore from backup set channel s1: restoring datafile 00007 to /data/oradata/ORA19CDG/datafile/o1_mf_users_%u_.dbf channel s2: restore complete, elapsed time: 00:40:24 channel s2: starting datafile backup set restore channel s2: using network backup set from service primarytns channel s2: specifying datafile(s) to restore from backup set channel s2: restoring datafile 00008 to /data/oradata/ORA19CDG/datafile/o1_mf_archive_%u_.dbf channel s1: restore complete, elapsed time: 00:16:22 channel s1: starting datafile backup set restore channel s1: using network backup set from service primarytns channel s1: specifying datafile(s) to restore from backup set channel s1: restoring datafile 00009 to /data/oradata/ORA19CDG/datafile/o1_mf_archive_%u_.dbf channel s2: restore complete, elapsed time: 00:00:57 channel s2: starting datafile backup set restore channel s2: using network backup set from service primarytns channel s2: specifying datafile(s) to restore from backup set channel s2: restoring datafile 00010 to /data/oradata/ORA19CDG/datafile/o1_mf_mestbs_%u_.dbf channel s1: restore complete, elapsed time: 00:00:02 channel s2: restore complete, elapsed time: 00:00:56 Finished restore at 2023-12-31 10:57:23
sql statement: alter system archive log current current log archived
contents of Memory Script: { restore clone force from service 'primarytns' archivelog from scn 7554812; switch clone datafile all; } executing Memory Script
Starting restore at 2023-12-31 10:57:24
channel s1: starting archived log restore to default destination channel s1: using network backup set from service primarytns channel s1: restoring archived log archived log thread=1 sequence=159 channel s2: starting archived log restore to default destination channel s2: using network backup set from service primarytns channel s2: restoring archived log archived log thread=1 sequence=160 channel s1: restore complete, elapsed time: 00:00:04 channel s2: restore complete, elapsed time: 00:00:08 Finished restore at 2023-12-31 10:57:34
contents of Memory Script: { set until scn 7561622; recover standby clone database delete archivelog ; } executing Memory Script
executing command: SET until clause
Starting recover at 2023-12-31 10:57:37
starting media recovery
archived logfor thread 1 with sequence 159 is already on disk as file /data/archivelog/1_159_1151325793.dbf archived logfor thread 1 with sequence 160 is already on disk as file /data/archivelog/1_160_1151325793.dbf released channel: c1 released channel: c2 released channel: s1 released channel: s2 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of Duplicate Db command at 12/31/2023 10:57:44 RMAN-05501: aborting duplication of target database RMAN-03015: error occurred in stored script Memory Script RMAN-10015: error compiling PL/SQL program RMAN-10014: PL/SQL error 0 on line 425 column 10: Statement ignored RMAN-10014: PL/SQL error 306 on line 426 column 14: wrong number or types of arguments in call to 'GETDFINFO'
RMAN>
Recovery Manager complete.
查看DG数据同步详情
查看脚本为 /home/oracle/dginfo.sh,内容如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/env sh sqlplus / as sysdba <<EOF set lines 123 set pages 200 col CTIME format a20 col NAME format a20 col VALUE format a20 col DATUM_TIME format a20 select open_mode, DATABASE_ROLE from v\$database; SELECT TO_NUMBER( SUBSTR ( (SUBSTR (VALUE, 5)), 0, 2) * 3600 + SUBSTR ( (SUBSTR (VALUE, 5)), 4, 2) * 60 + SUBSTR ( (SUBSTR (VALUE, 5)), 7, 2)) dgbehind, TO_CHAR (SYSDATE, 'yyyymmdd hh24:mi:ss' ) CTIME, NAME, VALUE,DATUM_TIME FROM V\$DATAGUARD_STATS WHERE NAME ='apply lag'; select process,block#,blocks ,status ,sequence# from v\$managed_standby; exit EOF