主备 修改/etc/hosts 127.0.0.1 ? localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 ? ? ? ? localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.31.24 nccorcldb1 192.168.31.25 nccorcldb2
主: 修改listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/network/admin/listener.ora # Generated by Oracle configuration tools.
LISTENER = ? (DESCRIPTION_LIST = ? ? (DESCRIPTION = ? ? ? (ADDRESS = (PROTOCOL = TCP)(HOST = nccorcldb1)(PORT = 1521)) ? ? ? (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ? ? ) ? ) SID_LIST_LISTENER = ? ? ? ? (SID_LIST= ? ? ? ? ?(SID_DESC = ? ? ? ? ? (GLOBAL_DBNAME = orcl) ? ? ? ? ? ?(SID_NAME = orcl) ? ? ? ? ?) ? ? ? ? )
ADR_BASE_LISTENER = /u01/app/oracle
备: 修改listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/network/admin/listener.ora # Generated by Oracle configuration tools.
LISTENER = ? (DESCRIPTION_LIST = ? ? (DESCRIPTION = ? ? ? (ADDRESS = (PROTOCOL = TCP)(HOST = nccorcldb2)(PORT = 1521)) ? ? ? (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ? ? ) ? ) SID_LIST_LISTENER = ? ? ? ? (SID_LIST= ? ? ? ? ?(SID_DESC = ? ? ? ? ? (GLOBAL_DBNAME = orcldg) ? ? ? ? ? ?(SID_NAME = orcl) ? ? ? ? ?) ? ? ? ? )
ADR_BASE_LISTENER = /u01/app/oracle
主:修改tnsnames.ora orcl = ? (DESCRIPTION = ? ? (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.24)(PORT = 1521)) ? ? (CONNECT_DATA = ? ? ? (SERVER = DEDICATED) ? ? ? (SERVICE_NAME = orcl) ? ? ) ? )
orcldg = ? (DESCRIPTION = ? ? (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.25)(PORT = 1521)) ? ? (CONNECT_DATA = ? ? ? (SERVER = DEDICATED) ? ? ? (SERVICE_NAME = orcldg) ? ? ) ? ) ~ ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ?主:添加logfile; ??? ?alter database add standby logfile group 4 '/u01/app/oracle/oradata/orcl/redo04.log' size 50M; ?? ?alter database add standby logfile group 5 '/u01/app/oracle/oradata/orcl/redo05.log' size 50M; ?? ?alter database add standby logfile group 6 '/u01/app/oracle/oradata/orcl/redo06.log' size 50M; ?? ?alter database add standby logfile group 7 '/u01/app/oracle/oradata/orcl/redo07.log' size 50M;
?主:生成PFILE和密码文件传输至备 ?主:rman target / ?CROSSCHECK ARCHIVELOG ALL; backup archivelog all format '/u01/arch_casc_%s_%t_%p.bak'; 传输至备;
备: 修改pfile文件 orcl.__db_cache_size=1509949440 orcl.__java_pool_size=16777216 orcl.__large_pool_size=33554432 orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment orcl.__pga_aggregate_target=1325400064 orcl.__sga_target=1962934272 orcl.__shared_io_pool_size=0 orcl.__shared_pool_size=369098752 orcl.__streams_pool_size=0 *.audit_file_dest='/u01/app/oracle/admin/orcl/adump' *.audit_trail='db' *.compatible='11.2.0.4.0' *.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/fast_recovery_area/orcl/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='orcl' *.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area' *.db_recovery_file_dest_size=4385144832 *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.memory_target=3279945728 *.open_cursors=300 *.processes=1500 *.remote_login_passwordfile='EXCLUSIVE' *.sessions=1655 *.undo_tablespace='UNDOTBS1'
*.db_unique_name='orcldg' *.log_archive_config='dg_config=(orcl,orcldg)' *.log_archive_dest_1='location=/u01/app/oracle/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=orcldg' *.log_archive_dest_2='service=orcl ?lgwr sync affirm valid_for=(online_logfiles,primary_role) ?db_unique_name=orcl' *.log_archive_dest_state_1=enable *.log_archive_dest_state_2=enable *.log_archive_max_processes=10 *.fal_server=orcl *.fal_client=orcldg *.standby_file_management=auto 备: sqlplus / as sysdba startup nomount pfile='/u01/app/oracle/product/11.2.0/dbs/initorcl.ora'
主: rman target sys/sys_202111 auxiliary sys/sys_202111@orcldg
duplicate target database for standby from active database NOFILENAMECHECK;
备:rman target / crosscheck backup; restore archivelog all; ??
主: show parameter dest_ log_archive_dest_2?? ??? ? ? ? string?? ? SERVICE=orcldg LGWR ASYNC VALI ?? ??? ??? ??? ??? ??? ? D_FOR=(ONLINE_LOGFILES,PRIMARY ?? ??? ??? ??? ??? ??? ? _ROLE) DB_UNIQUE_NAME=orcldg 备:
show parameter dest_ log_archive_dest_1?? ??? ? ? ? string?? ? location=/u01/app/oracle/archi ?? ??? ??? ??? ??? ??? ? velog valid_for=(all_logfiles, ?? ??? ??? ??? ??? ??? ? all_roles) db_unique_name=orcl ?? ??? ??? ??? ??? ??? ? dg log_archive_dest_2?? ??? ? ? ? string?? ? service=orcl ?lgwr sync affirm ?? ??? ??? ??? ??? ??? ? ?valid_for=(online_logfiles,pr ?? ??? ??? ??? ??? ??? ? imary_role) ?db_unique_name=or ?? ??? ??? ??? ??? ??? ? cl 备: show parameter fal fal_client?? ??? ??? ? ? ? string?? ? orcldg fal_server?? ??? ??? ? ? ? string?? ? orcl
主备: show parameter LOG_ARCHIVE_CONFIG log_archive_config?? ??? ? ? ? string?? ? DG_CONFIG=(orcl,orcldg)
主: ?alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(orcl,orcldg)' scope=both;
备: shutdown immediate; startup; alter database recover managed standby database disconnect from session;
常用查询:
alter system switch logfile; ?select * from v$log; ?select * from v$logfile; select status,error from v$archive_dest; select switchover_status,open_mode from v$database; select process,pid,client_process,thread#,sequence#,status from v$managed_standby; select NAME ,VALUE from v$dataguard_stats;
|