关于DG主备切换请跳转https://blog.csdn.net/weixin_42774383/article/details/82682503
1、一台完整可用装有ORACLE数据库的虚拟机作为主库
2、一台干净没有安装ORACLE数据库的虚拟机作为备库,注意是没有安装ORACLE数据库,但是软件要提前安装好
(1)startup mount;
(2)alter database archivelog;
(3)alter database open;
(4)archive log list;
(5)修改归档路径,路径要提前存在
show parameter archive;
alter system set log_archive_dest_1 =’location=/u01/arch’;
alter system set log_archive_format =%t_%s_%r.arc;
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;
注意文件大小要与原日志文件大小差不多。
GROUP# THREAD# SEQUENCE# ARC STATUS
---------- ---------- ---------- --- ----------
4 0 0 YES UNASSIGNED
5 0 0 YES UNASSIGNED
6 0 0 YES UNASSIGNED
7 0 0 YES UNASSIGNED
4 STANDBY /u01/app/oracle/oradata/orcl/s NO 0
tdredo01.log
GROUP# STATUS TYPE MEMBER IS_ CON_ID
---------- ------- ------- ------------------------------ --- ----------
5 STANDBY /u01/app/oracle/oradata/orcl/s NO 0
tdredo02.log
6 STANDBY /u01/app/oracle/oradata/orcl/s NO 0
tdredo03.log
7 STANDBY /u01/app/oracle/oradata/orcl/s NO 0
tdredo04.log
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME =/u01/app/oracle/product/12.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
ADR_BASE_LISTENER = /u01/app/oracle
ORCL_S =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = wyuu)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL_P =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = wyu)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
scp $ORACLE_HOME/dbs/initorcl.ora wyuu:`pwd`
*.db_name='orcl'
*.db_unique_name='orcl_p'
*.log_archive_config='dg_config=(orcl_p,orcl_s)'
*.log_archive_dest_1='location=/u01/arch valid_for=(all_logfiles,all_roles) db_unique_name=orcl_p'
*.log_archive_dest_2='service=orcl_s arch ASYNC 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'
scp $ORACLE_HOME/network/admin/listener.ora wyuu:`pwd`
scp $ORACLE_HOME/network/admin/tnsnames.ora wyuu:`pwd`
*.db_name='orcl'
*.db_unique_name='orcl_s'
*.log_archive_config='dg_config=(orcl_p,orcl_s)'
*.log_archive_dest_1='location=/u01/arch valid_for=(all_logfiles,all_roles) db_unique_name=orcl_s'
*.log_archive_dest_2='service=orcl_p arch ASYNC 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'
scp $ORACLE_HOME/dbs/orapworcl wyuu:`pwd`
目录要与pfile中路径相同
mkdir -p $ORACLE_BASE/admin/orcl/adump
startup nomount
alter database open;
alter database recover managed standby database cancel;(取消日志文件应用,不需做)
LOG_MODE OPEN_MODE DATABASE_ROLE
------------ -------------------- ----------------
ARCHIVELOG READ WRITE PRIMARY
LOG_MODE OPEN_MODE DATABASE_ROLE
------------ -------------------- ----------------
ARCHIVELOG READ ONLY WITH APPLY PHYSICAL STANDBY