标签:
本文根据一个实践操作的记录,详细介绍利用rman热备来创建dataguard物理Active备库;这种方式主库只需要重启一次即可,使主库具有更高的可用性!1:主库上开启Forced Logging
alter database force logging;
scp /home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/orapwahqy 192.168.100.118:/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/orapwahqy
select member from v$logfile; du -h /home/oracle/oradata/ahqy/redo01.log sqlplus / as sysdba mkdir standby alter database add standby logfile group 4 '/home/oracle/oradata/ahqy/standby/standby04.log' size 200M; alter database add standby logfile group 5 '/home/oracle/oradata/ahqy/standby/standby05.log' size 200M; alter database add standby logfile group 6 '/home/oracle/oradata/ahqy/standby/standby06.log' size 200M;
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(ahqy,standby)'; alter system set log_archive_dest_1='LOCATION=/home/oracle/arch valid_for=(all_logfiles,all_roles) db_unique_name=ahqy' scope=spfile; alter system set log_archive_dest_2='service=standby lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=standby' scope=spfile; alter system set log_archive_dest_state_1=enable; alter system set log_archive_dest_state_2=enable; alter system set log_archive_format='%t_%s_%r.arc' scope=spfile; show parameter remote_login; alter system set log_archive_max_processes=30; alter system set fal_server=standby; alter system set fal_client=ahqy; alter system set standby_file_management=auto; shutdown immediate; startup;
cat /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin//tnsnames.ora # tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. LISTENER_AHQY = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.117)(PORT = 1521)) AHQY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.117)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ahqy) ) ) STANDBY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.118)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = standby) ) )
mkdir -p /home/oracle/backup/ create pfile='/home/oracle/backup/initahqy.ora' from spfile; rman target / backup tag 'dg_20141226' format '/home/oracle/backup/dg_%U' incremental level 0 database plus archivelog; backup format '/home/oracle/backup/controlfile_%U' current controlfile for standby;
echo $ORACLE_SID scp /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora oracle@192.168.100.118:/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
mkdir -p /home/oracle/backup/ scp -rp oracle@192.168.100.117:/home/oracle/backup/* /home/oracle/backup/ cp /home/oracle/backup/initahqy.ora $ORACLE_HOME/dbs grep 'fal_' $ORACLE_HOME/dbs/initahqy.ora *.fal_client='STANDBY' *.fal_server='AHQY' grep 'log_archive_dest_' $ORACLE_HOME/dbs/initahqy.ora *.log_archive_dest_1='LOCATION=/home/oracle/arch valid_for=(all_logfiles,all_roles) db_unique_name=standby' *.log_archive_dest_2='service=ahqy lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=ahqy' *.log_archive_dest_state_1='ENABLE' *.log_archive_dest_state_2='ENABLE' *.db_unique_name='standby' ----------------------------这一句漏了,导致默认成了AHQY,一定要加上 *.LOG_ARCHIVE_CONFIG='DG_CONFIG=(standby,ahqy)' --主备库切换用,否则切换会有问题 ---alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(standby,ahqy)'; mkdir -p /home/oracle/arch/ahqy mkdir -p /home/oracle/app/oracle/admin/ahqy/{adump,bdump,cdump,dpdump,udump,pfile} --有几个文件夹可能用不到 mkdir -p /home/oracle/oradata/ahqy mkdir -p /u01/app/oracle/flash_recover_area/ORCL --未找到 --(将相应的主库文件直接移到了备库上,如:/home/oracle/arch/、/home/oracle/oradata/、/home/oracle/oradiag_oracle) mkdir -p /home/oracle/app/oracle/diag/rdbms/ahqy/ahqy/{alert,cdump,hm,incident,incpkg,ir,lck,metadata,stage,sweep,trace} 考虑到可能有文件夹没有建,所以我这里将几个主要文件夹直接从主库拷贝到备库相应的目录中去。
sqlplus / as sysdba startup nomount;
rman target sys/ORACLE@AHQY auxiliary / duplicate target database for standby nofilenamecheck;
sqlplus / as sysdba archive log list; alter database recover managed standby database disconnect from session; select SEQUENCE#,FIRST_TIME,NEXT_TIME,APPLIED from v$archived_log; select member from v$logfile; 可以在主库上进行日志切换,加快备库应用日志的速度! sqlplus / as sysdba alter system switch logfile; archive log list; 备库上再次查询: select SEQUENCE#,FIRST_TIME,NEXT_TIME,APPLIED from v$archived_log; select name,database_role from v$database;
select name,database_role from v$database; create tablespace ahqy datafile '/home/oracle/oradata/ahqy/ahqy.dbf' size 10M autoextend on; create table dg01 as select * from dba_source; alter system switch logfile;
alter database recover managed standby database cancel; alter database open read only; select type from dg01;
sqlplus / as sysdba shutdown immediate; startup nomount; alter database mount standby database; alter database recover managed standby database disconnect from session;
select open_mode,database_role,db_unique_name from v$database;
alter database recover managed standby database cancel;
alter database open; select open_mode from v$database; alter database recover managed standby database using current logfile disconnect; select open_mode,database_role,db_unique_name from v$database;
alter database commit to switchover to physical standby with session shutdown; shutdown immediate startup mount alter database recover managed standby database disconnect from session;
shutdown immediate startup mount alter database commit to switchover to primary; alter database open;
[oracle@118 admin]$ cat listener.ora # listener.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.118)(PORT = 1521)) ) ) SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1) (PROGRAM = extproc) ) (SID_DESC = (SID_NAME = ahqy) (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1) (GLOBAL_DBNAME = standby) ) ) ADR_BASE_LISTENER = /home/oracle/app/oracle [oracle@117 admin]$ cat listener.ora # listener.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.117)(PORT = 1521)) ) ) SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1) (PROGRAM = extproc) ) (SID_DESC = (SID_NAME = ahqy) (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1) (GLOBAL_DBNAME = ahqy) ) ) ADR_BASE_LISTENER = /home/oracle/app/oracle
[oracle@117 admin]$ cat tnsnames.ora # tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. LISTENER_AHQY = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.117)(PORT = 1521)) AHQY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.117)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ahqy) ) ) standby = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.118)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = standby) ) ) [oracle@118 admin]$ cat tnsnames.ora # tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. LISTENER_AHQY = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.117)(PORT = 1521)) AHQY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.117)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ahqy) ) ) STANDBY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.118)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = standby) ) )
标签:
原文地址:http://blog.csdn.net/nisjlvhudy/article/details/42198499