在前面的单实例数据库迁移至rac环境配置过程中,介绍了使用standby技术构建单实例主库对应rac物理备库的data guard模型,本节中将介绍rac主库对应单实例物理备库的data guard模型构建;在MAA架构中,ASM提供了存储方面的网格,RAC提供了数据库层面上的网格计算,data guard则着重强调在数据的备份和容灾方面,更多MAA方面的知识,参考下面的链接!
http://www.oracle.com/technetwork/database/features/availability/maa-090890.html
一:主备库的环境介绍
主库:
数据库版本:10.2.0.5
OS版本:centos4.8 64位
数据库名:rac(两个实例)
实例名:rac1,rac2
IP地址:192.168.1.41/24,192.168.1.42/24
db_unique_name: rac
服务名:rac.yang.com
监听器端口:1521
存储类型:OMF+ASM磁盘组,+DATA,+FRA
备库:
数据库版本:10.2.0.5
OS版本:rhel5.4 64位
数据库名:rac (单实例)
实例名:orcl
IP地址:192.168.1.49/24
db_unique_name: orcl
服务名:orcl.yang.com
监听器端口:1521
存储类型:文件系统+OMF
在开始前确保主库rac环境正常,备库只需要安装数据库软件即可,不需要建库
[oracle@rac1 ~]$ crs_stat -t -v Name Type R/RA F/FT Target State Host ---------------------------------------------------------------------- ora.rac.db application 0/0 0/1 ONLINE ONLINE rac1 ora....c1.inst application 0/5 0/0 ONLINE ONLINE rac1 ora....c2.inst application 0/5 0/0 ONLINE ONLINE rac2 ora....SM1.asm application 0/5 0/0 ONLINE ONLINE rac1 ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1 ora.rac1.gsd application 0/5 0/0 ONLINE ONLINE rac1 ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1 ora.rac1.vip application 0/0 0/0 ONLINE ONLINE rac1 ora....SM2.asm application 0/5 0/0 ONLINE ONLINE rac2 ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2 ora.rac2.gsd application 0/5 0/0 ONLINE ONLINE rac2 ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2 ora.rac2.vip application 0/0 0/0 ONLINE ONLINE rac2 |
[oracle@rac1 ~]$ cat $ORACLE_HOME/network/admin/listener.ora SID_LIST_LISTENER_RAC1 = [oracle@rac1 ~]$ sqlplus sys/[email protected]:1521/rac_DGMGRL.yang.com as sysdba Connected to: [oracle@rac1 ~]$ cat $ORACLE_HOME/admin/tnsnames.ora LISTENER_RAC1 = LISTENER_RAC2 = RAC = RAC1 = RAC2 = ORCL = |
[oracle@server49 ~]$ cat /u01/app/oracle/product/10.2.0/db1/network/admin/listener.ora SID_LIST_LISTENER_ORCL = [oracle@server49 ~]$ cat /u01/app/oracle/product/10.2.0/db1/network/admin/tnsnames.ora RAC = RAC1 = RAC2 = ORCL = |
[oracle@rac1 ~]$ sqlplus /nolog SQL> alter database force logging; SQL> alter system set log_file_name_convert='+FLASH/rac','/u01/app/oracle/flash_recover_area/orcl','+DATA/rac','/u01/app/oracle/oradata/orcl' scope=spfile; SQL> alter system set db_file_name_convert='+DATA/rac','/u01/app/oracle/oradata/orcl' scope=spfile; SQL> alter system set dg_broker_config_file1='+DATA/rac/dgbroker/dg_config_file1.dat'; SQL> alter system set dg_broker_config_file2='+FRA/rac/dgbroker/dg_config_file2.dat'; SQL> alter system set fal_client='rac1' sid='rac1'; SQL> alter system set fal_client='rac2' sid='rac2'; SQL> alter system set fal_server='orcl'; SQL> alter system set local_listener='LISTENER_RAC1' sid='rac1'; SQL> alter system set local_listener='LISTENER_RAC2' sid='rac2'; SQL> alter system set log_archive_config='DG_CONFIG=(rac,orcl)'; SQL> alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ONLINE_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=rac'; SQL> alter system set log_archive_dest_state_2='defer'; SQL> alter system set log_archive_dest_2='SERVICE=orcl LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl'; SQL> alter system set log_archive_dest_3='LOCATION=+FRA/rac/standbylog/ VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=rac'; SQL> alter system set log_archive_dest_state_1=enable; SQL> alter system set log_archive_dest_state_3=enable; SQL> alter system set log_archive_max_processes=5; SQL> alter system set remote_listener='LISTENERS_RAC'; SQL> alter system set remote_login_passwordfile='EXCLUSIVE' scope=spfile; SQL> alter system set standby_archive_dest='+FRA/rac/standbylog'; SQL> alter system set standby_file_management='auto'; |
SQL> create pfile='/home/oracle/backup/initrac.ora' from spfile; SQL> select thread#,group# from v$log; THREAD# GROUP# SQL> alter database add standby logfile thread 1 group 11 size 50M,group 12 size 50M,group 13 size 50M; SQL> alter database add standby logfile thread 2 group 14 size 50M,group 15 size 50M,group 16 size 50M; SQL> select thread#,group# from v$standby_log; THREAD# GROUP# |
[oracle@rac1 ~]$ rman target / RMAN> run { RMAN> backup current controlfile for standby format '/home/oracle/backup/control01.ctl'; |
[oracle@server49 orcl]$ env |grep ORA [oracle@server49 orcl]$ pwd [oracle@server49 ~]$ orapwd file=$ORACLE_HOME/dbs/orapworcl password=123456 [oracle@server49 ~]$ sqlplus /nolog SQL> conn /as sysdba Total System Global Area 213909504 bytes SQL> create spfile from pfile='/home/oracle/backup/initrac.ora'; [oracle@server49 ~]$ rman target sys/123456@rac auxiliary / connected to target database: RAC (DBID=2360349352) RMAN> duplicate target database for standby;
RMAN> report schema; using target database control file instead of recovery catalog List of Permanent Datafiles |
SQL> show parameter name; NAME TYPE VALUE NAME TYPE VALUE SQL> archive log list; RMAN> restore archivelog all; [oracle@server49 ~]$ ls /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_01_12/
GROUP# MEMBER SQL> alter system set standby_file_management=manual; SQL> alter database rename file '+FRA/rac/onlinelog/group_2.306.772367347' to '/u01/app/oracle/oradata/ORCL/onlinelog/group_2.306.772367347'; SQL> select member from v$logfile; MEMBER SQL> alter system set standby_file_management=auto; |
SQL> select name,database_role from v$database; NAME DATABASE_ROLE SQL> alter database recover managed standby database using current logfile disconnect from session; [oracle@server49 ~]$ tail -f /u01/app/oracle/admin/orcl/bdump/alert_orcl.log SQL> select first_time,next_time,sequence#,applied,thread# from v$archived_log order by 5,3; FIRST_TIME NEXT_TIME SEQUENCE# APP THREAD# FIRST_TIME NEXT_TIME SEQUENCE# APP THREAD# FIRST_TIME NEXT_TIME SEQUENCE# APP THREAD# |
[oracle@rac1 ~]$ sqlplus sys/123456@rac as sysdba Connected to: SQL> create tablespace maa datafile size 100M; SQL> create table hr.maa_test tablespace maa as select * from dba_source; SQL> alter system archive log current; SQL> alter system set log_archive_dest_state_2=enable; SQL> alter system archive log current; SQL> select first_time,next_time,sequence#,applied,thread# from v$archived_log where sequence# >10 order by 5,3; FIRST_TIME NEXT_TIME SEQUENCE# APP THREAD# 节点1: 节点2: SQL> alter database recover managed standby database cancel; SQL> alter database open read only; SQL> select tablespace_name from dba_tablespaces; TABLESPACE_NAME SQL> select count(*) from hr.maa_test; COUNT(*) SQL> alter database recover managed standby database using current logfile disconnect from session; SQL> select * from v$archive_gap; SQL> select process, client_process, sequence#, status from v$managed_standby; PROCESS CLIENT_P SEQUENCE# STATUS PROCESS CLIENT_P SEQUENCE# STATUS SQL> select thread#, max (sequence#) from v$log_history group by thread#; THREAD# MAX(SEQUENCE#) 备库上相关的文件如下: [oracle@server49 ~]$ ls /u01/app/oracle/oradata/ORCL/controlfile/ |
参考文档:http://www.oracledba.org/10g/dr/10gR2_dataguard_RAC_to_RAC.html,感谢作者分享!
本文出自 “斩月” 博客,谢绝转载!