联系:手机/微信(+86 17813235971) QQ(107644445)
标题:使用rman from service 搭建dataguard
作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]
从oracle 12c开始提供了rman通过from service方式搭建dg,使用12c长期支持版19c(并打上最新的patch)
配置dataguard相关参数
alter system set db_unique_name='XIFENFEI' scope=spfile; alter system set service_names='XIFENFEI'; alter system set log_archive_config='dg_config=(XIFENFEI,XIFENFEIDG)'; alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=XIFENFEI'; alter system set log_archive_dest_2='service=XIFENFEIDG lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=XIFENFEIDG'; alter system set standby_file_management=auto; alter system set db_file_name_convert='/u01/app/oracle/oradata/XIFENFEI/','/u01/app/oracle/oradata/XIFENFEI/' scope=spfile; alter system set log_file_name_convert='/u01/app/oracle/oradata/XIFENFEI/','/u01/app/oracle/oradata/XIFENFEI/' scope=spfile; alter system set fal_server=XIFENFEIDG;
配置tnsnames.ora
XIFENFEI = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.238)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = XIFENFEI) ) ) XIFENFEIDG = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.124)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = XIFENFEI) ) )
拷贝主库密码文件到备库
[oracle@primary ~]$ scp $ORACLE_HOME/dbs/orapwXIFENFEI 192.168.0.124:$ORACLE_HOME/dbs/ The authenticity of host '192.168.0.124 (192.168.0.124)' can't be established. ECDSA key fingerprint is SHA256:NI2952z4Bqc3M/B+AK7EJRiJNauROIyluvu1l4NSTX0. ECDSA key fingerprint is MD5:1d:64:dd:ef:1c:ad:ed:cf:70:22:2d:4d:7c:90:5e:5e. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.0.124' (ECDSA) to the list of known hosts. oracle@192.168.0.124's password: orapwXIFENFEI 100% 2048 6.6MB/s 00:00 [oracle@primary ~]$
备库启动到nomount状态
[oracle@standby ~]$ sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 13 20:32:34 2021 Version 19.10.0.0.0 Copyright (c) 1982, 2020, Oracle. All rights reserved. Connected to an idle instance. SQL> create spfile from pfile='/tmp/pfile'; File created. SQL> startup nomount pfile='/tmp/pfile' ORACLE instance started. Total System Global Area 4294963264 bytes Fixed Size 8904768 bytes Variable Size 805306368 bytes Database Buffers 3472883712 bytes Redo Buffers 7868416 bytes SQL> exit Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.10.0.0.0
rman from service方式创建standby ctl和还原数据文件
[oracle@standby ~]$ rman target / Recovery Manager: Release 19.0.0.0.0 - Production on Sat Mar 13 20:34:37 2021 Version 19.10.0.0.0 Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved. connected to target database: XIFENFEI (not mounted) RMAN> restore standby controlfile from service XIFENFEI; Starting restore at 13-MAR-21 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=9 device type=DISK channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service XIFENFEI channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 output file name=/u01/app/oracle/oradata/XIFENFEI/control01.ctl output file name=/u01/app/oracle/fast_recovery_area/XIFENFEI/control02.ctl Finished restore at 13-MAR-21 RMAN> alter database mount; released channel: ORA_DISK_1 Statement processed RMAN> restore database from service XIFENFEI; Starting restore at 13-MAR-21 Starting implicit crosscheck backup at 13-MAR-21 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=12 device type=DISK Finished implicit crosscheck backup at 13-MAR-21 Starting implicit crosscheck copy at 13-MAR-21 using channel ORA_DISK_1 Finished implicit crosscheck copy at 13-MAR-21 searching for all files in the recovery area cataloging files... no files cataloged using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service XIFENFEI channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/XIFENFEI/system01.dbf channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service XIFENFEI channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/XIFENFEI/sysaux01.dbf channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service XIFENFEI channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/XIFENFEI/undotbs01.dbf channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service XIFENFEI channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/XIFENFEI/users01.dbf channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 13-MAR-21 [/sehll] 备库启动mrp进程 1 1 2021-03-13T20:54:08.075418+08:00 Attempt to start background Managed Standby Recovery process (XIFENFEI) Starting background process MRP0 2021-03-13T20:54:08.086269+08:00 MRP0 started with pid=56, OS id=8182 2021-03-13T20:54:08.087276+08:00 Background Managed Standby Recovery process started (XIFENFEI) 2021-03-13T20:54:13.104757+08:00 Started logmerger process 2021-03-13T20:54:13.112058+08:00 IM on ADG: Start of Empty Journal IM on ADG: End of Empty Journal PR00 (PID:8188): Managed Standby Recovery starting Real Time Apply 2021-03-13T20:54:13.205668+08:00 Parallel Media Recovery started with 4 slaves 2021-03-13T20:54:13.216576+08:00 Stopping change tracking PR00 (PID:8188): Media Recovery Waiting for T-1.S-25 (in transit) 2021-03-13T20:54:13.269138+08:00 Recovery of Online Redo Log: Thread 1 Group 12 Seq 25 Reading mem 0 Mem# 0: /u01/app/oracle/oradata/XIFENFEI/s_redo12.log
至此dataguard基本上搭建完成