ITPub博客

首页 > 数据库 > Oracle > 11R2--配置RAC+DG

11R2--配置RAC+DG

原创 Oracle 作者:oracle_mao 时间:2014-01-20 16:50:04 0 删除 编辑

主题:RAC+DG
DB版本:11.1.0.6
OS版本:HPUX
磁盘管理:ASM,Filesystem
第一部分:准备环境
1. 搭建RAC,并在第一个RAC节点备份数据库
 RMAN> copy current controlfile to '/csedb/rmanbak/ctl0120.ctl'; ---将备份文件scp到备库服务器
 RMAN> backup database format '/csedb/rmanbak/full0120%U'; ---全库备份,将备份文件scp到备库服务器
2. 构造备库环境(安装rdbms),恢复备库数据 
2.1 启动nomount状态
2.2 创建控制文件
$ rman target /
RMAN> startup nomount
RMAN> restore controlfile from '/home/orazkf/ctl0120.ctl';
RMAN> alter database mount;
SQL> select name from v$datafile;
     FILE# NAME
---------- --------------------------------------------------
         1 +DATA/ORACLEDB/datafile/system.320.822409785
         2 +DATA/ORACLEDB/datafile/sysaux.319.822409785
         3 +DATA/ORACLEDB/datafile/undotbs1.318.822409883
         4 +DATA/ORACLEDB/datafile/undotbs2.315.822410011
         5 +DATA/ORACLEDB/datafile/users.317.822409885
         6 +DATA/ORACLEDB/datafile/undotbs1.316.822410009
6 rows selected.
备注:现在的数据文件都还是像asm磁盘组那种显示,一会需要将其转化为本地文件系统。
2.3 恢复数据文件
RMAN> catalog start with '/home/orazkf/'; ---将备份信息重新注册到控制文件中
RMAN> run {
 allocate channel 'dev_0' type disk;
 set newname for datafile  1 to '/u01/oradata/ZKFP1/system.345.760169914';
 set newname for datafile 2 to '/u01/oradata/ZKFP1/sysaux.564.760187953';
 set newname for datafile 3 to '/u01/oradata/ZKFP1/undotbs1.124.760889985';
 set newname for datafile 4 to '/u01/oradata/ZKFP1/undotbs2.456.760990001';
 set newname for datafile 5 to '/u01/oradata/ZKFP1/users.167.760190409';
 set newname for datafile 6 to '/u01/oradata/ZKFP1/undotbs1.316.822410009';
 restore database;
 switch datafile all;
 release channel 'dev_0' ;
}
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/oradata/ZKFP1/system.345.760169914
/u01/oradata/ZKFP1/sysaux.564.760187953
/u01/oradata/ZKFP1/undotbs1.124.760889985
/u01/oradata/ZKFP1/undotbs2.456.760990001
/u01/oradata/ZKFP1/users.167.760190409
/u01/oradata/ZKFP1/undotbs1.316.822410009
6 rows selected.
2.4 recover database
SQL> select inst_id,name,to_char(completion_time,'yyyymmdd hh24:mi:ss') from gv$archived_log order by completion_time;
   INST_ID NAME                                                                             TO_CHAR(COMPLETIO
---------- -------------------------------------------------------------------------------- -----------------
         1 +DATA/ORACLEDB/archivelog/2014_01_16/thread_2_seq_1.626.836996499            20140116 11:01:38
         2 +DATA/ORACLEDB/archivelog/2014_01_16/thread_2_seq_1.626.836996499            20140116 11:01:38
         2 +DATA/ORACLEDB/archivelog/2014_01_16/thread_2_seq_3.605.836996531            20140116 11:02:11
         1 +DATA/ORACLEDB/archivelog/2014_01_16/thread_2_seq_2.622.836996531            20140116 11:02:11
         1 +DATA/ORACLEDB/archivelog/2014_01_16/thread_2_seq_3.605.836996531            20140116 11:02:11
         2 +DATA/ORACLEDB/archivelog/2014_01_16/thread_2_seq_2.622.836996531            20140116 11:02:11
         2 +DATA/ORACLEDB/archivelog/2014_01_16/thread_1_seq_1.599.836996531            20140116 11:02:12
         1 +DATA/ORACLEDB/archivelog/2014_01_16/thread_1_seq_1.599.836996531            20140116 11:02:12
8 rows selected.

第二部分:搭建DG
3 配置DG
3.1 主库force logging
3.2 配置监听
 请见:http://blog.itpub.net/24500180/viewspace-1073177/
3.3 配置参数文件
不同的地方(主库):
*.db_unique_name='zkf_pri'
*.service_names='zkf_pri'
*.log_archive_config='DG_CONFIG=(zkf_pri,zkf_stb)'
*.log_archive_dest_1='LOCATION=+DATA/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES)  DB_UNIQUE_NAME=zkf_pri'
*.LOG_ARCHIVE_DEST_2='SERVICE=zkf_stb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLES)  DB_UNIQUE_NAME=zkf_stb'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.FAL_SERVER=zkf_stb
*.FAL_CLIENT=zkf_pri
*.STANDBY_FILE_MANAGEMENT=AUTO
不同的地方(物理备库):
*.db_unique_name='zkf_stb'
*.service_names='zkf_stb'
*.log_archive_config='DG_CONFIG=(zkf_stb,zkf_pri)'
*.log_archive_dest_1='LOCATION=/u01/oradata/ZKFP1/arch/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES)  DB_UNIQUE_NAME=zkf_stb'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.FAL_SERVER=zkf_pri
*.FAL_CLIENT=zkf_stb
*.STANDBY_FILE_MANAGEMENT=AUTO
备注:在主库可以用alter system的方式修改,所以不需要重启主库。
3.4 主库创建备库控制文件
SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/home/orazkf/zkfstb.ctl';
$ scp /home/orazkf/zkfstb.ctl 192.168.160.233:/u01/oradata/ZKFP1/data1/control01.dbf
3.5 备库使用新的控制文件启动
SQL> shutdown immediate----此时备库刚restore完,所以直接关闭即可。
SQL> startup mount
SQL> select name,database_role,open_mode,protection_mode,GUARD_STATUS from v$database;

NAME      DATABASE_ROLE    OPEN_MODE  PROTECTION_MODE      GUARD_S
--------- ---------------- ---------- -------------------- -------
ORACLEDB  PHYSICAL STANDBY MOUNTED    MAXIMUM PERFORMANCE  NONE
3.6 备库修改数据文件到新目录
SQL>  alter database rename  file  '+DATA/ORACLEDB/datafile/system.320.822409785' to '/u01/oradata/ZKFP1/system.345.760169914';
 alter database rename  file  '+DATA/ORACLEDB/datafile/system.320.822409785' to '/u01/oradata/ZKFP1/system.345.760169914'
*
ERROR at line 1:
ORA-01511: error in renaming log/data files
ORA-01275: Operation RENAME is not allowed if standby file management is automatic.
SQL> show parameters standby
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
standby_archive_dest                 string      ?/dbs/arch
standby_file_management              string      AUTO
SQL> alter system set standby_file_management=manual;
SQL> alter database rename  file  '+DATA/ORACLEDB/datafile/system.320.822409785' to '/u01/oradata/ZKFP1/system.345.760169914';
SQL> alter database rename file '+DATA/ORACLEDB/datafile/sysaux.319.822409785' to '/u01/oradata/ZKFP1/sysaux.564.760187953';
SQL> alter database rename file '+DATA/ORACLEDB/datafile/undotbs1.318.822409883' to '/u01/oradata/ZKFP1/undotbs1.124.760889985';
SQL> alter database rename file '+DATA/ORACLEDB/datafile/undotbs2.315.822410011' to '/u01/oradata/ZKFP1/undotbs2.456.760990001';
SQL> alter database rename file '+DATA/ORACLEDB/datafile/users.317.822409885' to '/u01/oradata/ZKFP1/users.167.760190409';
SQL> alter database rename file '+DATA/ORACLEDB/datafile/undotbs1.316.822410009' to '/u01/oradata/ZKFP1/undotbs1.316.822410009';
SQL> select name,bytes from v$datafile;
NAME                                                                                  BYTES
-------------------------------------------------------------------------------- ----------
/u01/oradata/ZKFP1/system.345.760169914                                        1073741824
/u01/oradata/ZKFP1/sysaux.564.760187953                                        1073741824
/u01/oradata/ZKFP1/undotbs1.124.760889985                                      4434427904
/u01/oradata/ZKFP1/undotbs2.456.760990001                                       209715200
/u01/oradata/ZKFP1/users.167.760190409                                           52428800
/u01/oradata/ZKFP1/undotbs1.316.822410009                                      6840909824
6 rows selected.
3.7 备库创建standby日志:
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+DATA/ORACLEDB/onlinelog/group_7.632.836996491
+DATA/ORACLEDB/onlinelog/group_7.631.836996495
+DATA/ORACLEDB/onlinelog/group_3.669.836996485
+DATA/ORACLEDB/onlinelog/group_3.652.836996489
+DATA/ORACLEDB/onlinelog/group_2.620.836996479
+DATA/ORACLEDB/onlinelog/group_2.674.836996483
+DATA/ORACLEDB/onlinelog/group_1.630.836996469
+DATA/ORACLEDB/onlinelog/group_1.625.836996475
+DATA/ORACLEDB/onlinelog/group_4.596.836996467
+DATA/ORACLEDB/onlinelog/group_4.600.836996467
+DATA/ORACLEDB/onlinelog/group_5.663.836996469
+DATA/ORACLEDB/onlinelog/group_5.643.836996469
12 rows selected.
SQL> alter database add standby logfile group 8 ('/u01/oradata/ZKFP1/std_redo09.log') SIZE 600M;
SQL> alter database add standby logfile group 9 ('/u01/oradata/ZKFP1/std_redo09.log') SIZE 600M;
SQL> alter database add standby logfile group 10 ('/u01/oradata/ZKFP1/std_redo10.log') SIZE 600M;
SQL> alter database add standby logfile group 11 ('/u01/oradata/ZKFP1/std_redo11.log') SIZE 600M;
备注:接下来可以尝试将带有磁盘组信息的日志组删除,再重建。
3.8  备库应用redo
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

第三部分:测试
SQL> select PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS from v$managed_standby;

PROCESS   STATUS          THREAD#  SEQUENCE#     BLOCK#     BLOCKS
--------- ------------ ---------- ---------- ---------- ----------
ARCH      CLOSING               1         11          1         21
ARCH      CONNECTED             0          0          0          0
ARCH      CONNECTED             0          0          0          0
ARCH      CLOSING               1         10       4097         67
MRP0      WAIT_FOR_LOG          2         12          0          0
RFS       IDLE                  0          0          0          0
RFS       IDLE                  0          0          0          0
RFS       IDLE                  1         12         38          1
8 rows selected.
切换RAC第一个节点日志,查看备库日志应用情况,切换RAC第二个节点日志,再查看备库应用日志情况。
SQL> select inst_id,name,to_char(completion_time,'yyyymmdd hh24:mi:ss'),applied from gv$archived_log order by completion_time desc;
   INST_ID NAME                                                                             TO_CHAR(COMPLETIO APP
---------- -------------------------------------------------------------------------------- ----------------- ---
         1 /u01/oradata/ZKFP1/arch/ZKFP1_2_20_836996466.dbf                               20140120 15:53:08 NO
         1 /u01/oradata/ZKFP1/arch/ZKFP1_1_19_836996466.dbf                               20140120 15:53:03 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_1_18_836996466.dbf                               20140120 15:52:38 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_1_17_836996466.dbf                               20140120 15:51:39 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_2_19_836996466.dbf                               20140120 15:51:39 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_2_18_836996466.dbf                               20140120 15:50:34 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_2_17_836996466.dbf                               20140120 15:50:00 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_1_16_836996466.dbf                               20140120 15:48:48 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_2_16_836996466.dbf                               20140120 15:48:47 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_2_15_836996466.dbf                               20140120 15:48:24 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_2_14_836996466.dbf                               20140120 15:47:38 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_1_15_836996466.dbf                               20140120 15:37:27 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_1_14_836996466.dbf                               20140120 15:36:03 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_2_13_836996466.dbf                               20140120 15:34:45 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_1_13_836996466.dbf                               20140120 15:33:47 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_2_12_836996466.dbf                               20140120 15:33:20 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_1_12_836996466.dbf                               20140120 15:33:14 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_1_11_836996466.dbf                               20140120 15:01:25 YES
         1 /u01/oradata/ZKFP1/arch/ZKFP1_1_10_836996466.dbf                               20140120 15:00:27 YES
19 rows selected.
备注:ZKFP1_1开头的为RAC第一个节点产生的日志再备库的应用。ZKFP1_2为RAC第二个节点产生的日志再备库的应用。

第四部分:总结
 对于单实例DG,配置方法很简单,如果数据量不大的话,基本1小时i就可以完成。因为如果是生产环境的dg的话,一般的目录都都是一样的,这样不仅管理起来方便,而且在配置过程中也相当省事。但如果是RAC+DG的话,相对就没有那么简单了,其实原理都是一样的,配置Dg的前提就是监听,首先需要配置RAC每个节点和备库可以通过监听通信。这样的话,RAC每个节点所产生的归档就都可以传递到备库了。其他的,如果备库也是rac或者也使用asm管理,那大多数目录都不需要变化。剩下其他的,原理都和单实例配置DG是一样的。

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24500180/viewspace-1073179/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-03-28

  • 博文量
    94
  • 访问量
    752879