connect target sys/Password123@orcl connect auxiliary sys/Password123@orcldg1 run { allocate channel c1 type disk; allocate channel c2 type disk; allocate channel c3 type disk; allocate channel c4 type disk; allocate auxiliary channel s1 type disk; allocate auxiliary channel s2 type disk; allocate auxiliary channel s3 type disk; allocate auxiliary channel s4 type disk; duplicate target database for standby from active database nofilenamecheck dorecover spfile parameter_value_convert 'orcl','orcl' set db_unique_name='orcldg1' set cluster_database='false' set fal_server='orcl' set remote_listener='' set local_listener='' set standby_file_management='AUTO' set log_archive_config='dg_config=(orcl,orcldg1)' set log_archive_dest_1='location=/data/oracle/arch valid_for=(all_logfiles,all_roles) db_unique_name=orcldg1' set log_archive_dest_2='SERVICE=orcl lgwr async VALID_FOr=(ONLINE_LOGFILES,primary_role) DB_UNIQUE_NAME=orcl' 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"; }
查看DG数据同步详情
查看脚本为 /home/oracle/dginfo.sh,内容如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/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 show parameter service_name 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