【ORACLE】11g rac+dg

首先感谢群友分享的文档,在这里先感谢哆啦B梦,非常感谢



该文档主要指导如何利用现有的RAC环境搭建一套RAC与单实例的DG的环境


 ============================主机配置信息====================================
|   角色    |   主机名    |     管理IP     |      VIP       |    SCAN-IP     |
| RAC NODE1 | ktabsdb001r | 192.111.12.101 | 192.111.12.103 | 192.111.12.105 |
| RAC NODE2 | ktabsdb002r | 192.111.12.102 | 192.111.12.104 | 192.111.12.105 |
| Single DG | ktabsdb003r | 192.111.12.106 |      无        |       无       |
 ============================================================================


 ===========================数据库配置信息======================================
|   角色    |DB UNIQUE NAME| 数据库版本 |  归档路径  |       数据文件路径       |
|    RAC    |     abs      | 11.2.0.4.8 | /u01/arch/ |          +DATA           |
| DataGuard |    absdg     | 11.2.0.4.8 | /u01/arch/ | /u01/app/oracle/oradata/ |
 ===============================================================================


相关文档信息:
RAC Database Service With Physical Standby Role Option In 11gR2 - New Feature (文档 ID 1129143.1)




具体操作如下:
1.更改源RAC数据库为归档模式,并启用force_logging
SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/product/11.2.0/db_1/dbs/arch
Oldest online log sequence     11
Current log sequence           12


SQL> alter system set log_archive_dest_1='location=/u01/arch' sid='*';      


System altered.


ktabsdb001r:/home/oracle$srvctl stop database -d abs


ktabsdb001r:/home/oracle$export ORACLE_SID=abs1
ktabsdb001r:/home/oracle$sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 29 02:57:04 2016


Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to an idle instance.


SQL> startup mount;
ORACLE instance started.


Total System Global Area 2572144640 bytes
Fixed Size                  2249120 bytes
Variable Size             704646752 bytes
Database Buffers         1845493760 bytes
Redo Buffers               19755008 bytes
Database mounted.


SQL> alter database archivelog;


Database altered.


SQL> alter database force logging;


Database altered.


SQL> alter database open;


Database altered.


ktabsdb001r:/home/oracle$srvctl start instance -i abs2 -d abs


ktabsdb001r:/home/oracle$sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 29 02:59:26 2016


Copyright (c) 1982, 2013, Oracle.  All rights reserved.




Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application absing options


SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/arch
Oldest online log sequence     11
Next log sequence to archive   12
Current log sequence           12


SQL> select open_mode from gv$database;


OPEN_MODE
--------------------
READ WRITE
READ WRITE


SQL> alter system archive log current;


System altered.


2.修改主库的参数文件
SQL> create pfile='/home/oracle/pfile.ora' from spfile;


File created.


SQL> exit


修改主库参数文件
##DataGuard Configuration
alter system set LOG_ARCHIVE_CONFIG = 'DG_CONFIG=(abs,absdg)' scope=spfile sid='*';
alter system set LOG_ARCHIVE_DEST_1 = 'LOCATION=/u01/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=abs' scope=spfile sid='*';
alter system set LOG_ARCHIVE_DEST_2 = 'SERVICE=absdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=absdg' scope=spfile sid='*';
alter system set FAL_SERVER = 'absdg' scope=spfile sid='*'; 
alter system set FAL_CLIENT = 'abs' scope=spfile sid='*';
alter system set STANDBY_FILE_MANAGEMENT='AUTO' scope=spfile sid='*';
alter system set DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/absdg/','+DATA/abs/datafile/','/u01/app/oracle/oradata/absdg/','+DATA/abs/tempfile/' scope=spfile sid='*';
alter system set LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/absdg/','+DATA/abs/onlinelog/' scope=spfile sid='*';


重启数据库
kttestdb001r:/home/oracle$srvctl stop database -d abs
kttestdb001r:/home/oracle$srvctl start database -d abs
3.修改主库的tnsnames.ora(所有节点)
ABS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.111.12.105)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = abs)
    )
  )
  
absdg =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.111.12.106)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = absdg)
    )
  )


4.修改备库的tnsnames.ora和listener.ora
tnsnames.ora内容如下
#192.111.12.105为SCAN-IP
absdg =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.111.12.106)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = absdg)
    )
  )


ABS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.111.12.105)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = abs)
    )
  )
  
listener.ora内容如下
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = kttestdb003r)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )


ADR_BASE_LISTENER = /u01/app/oracle


SID_LIST_LISTENER =
   (SID_LIST =
     (SID_DESC =
      (SID_NAME = absdg)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (GLOBAL_DBNAME = absdg)
     )
    )


5.拷备主库的密码文件,创建备库参数文件
kttestdb001r:/u01/app/oracle/product/11.2.0/db_1/dbs$scp orapwabs1 192.111.12.106:/u01/app/oracle/product/11.2.0/db_1/dbs/orapwabsdg
备库创建相关目录
kttestdb003r:/u01/app/oracle$mkdir -p /u01/app/oracle/admin/absdg/adump
修改后的备库参数文件如下:
*.audit_file_dest='/u01/app/oracle/admin/absdg/adump'#modified
*.audit_trail='NONE'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/absdg/control01.ctl'#modified
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata/absdg/'#modified
*.db_domain=''
*.db_file_name_convert='+DATA/abs/datafile/','/u01/app/oracle/oradata/absdg/','+DATA/abs/tempfile/','/u01/app/oracle/oradata/absdg/'#modified
*.db_name='abs'
*.db_unique_name='absdg'#modified
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=absdgXDB)'#modified
*.fal_client='absdg'#modified
*.fal_server='abs'#modified
*.log_archive_config='DG_CONFIG=(abs,absdg)'
*.log_archive_dest_1='LOCATION=/u01/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=absdg'#modified
*.log_archive_dest_2='SERVICE=abs LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=abs'#modified
*.log_file_name_convert='+DATA/abs/onlinelog/','/u01/app/oracle/oradata/absdg/'#modified
*.open_cursors=300
*.pga_aggregate_target=858783744
*.processes=150
*.remote_login_passwordfile='exclusive'
*.sga_target=2576351232
*.standby_file_management='AUTO'#modified
*.undo_tablespace='UNDOTBS1'#modified


6.启动备库
kttestdb003r:/home/oracle$export ORACLE_SID=absdg
kttestdb003r:/home/oracle$sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 29 17:26:22 2016


Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to an idle instance.


SQL> startup nomount pfile='?/dbs/initabsdg.ora';
ORACLE instance started.


Total System Global Area 2572144640 bytes
Fixed Size                  2249120 bytes
Variable Size             654315104 bytes
Database Buffers         1895825408 bytes
Redo Buffers               19755008 bytes


7.双方互测监听是否正常
主库测备库监听
kttestdb001r:/home/oracle$sqlplus sys/oracle@absdg as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 29 04:27:01 2016


Copyright (c) 1982, 2013, Oracle.  All rights reserved.




Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> exit


备库测主备监听
kttestdb003r:/home/oracle$sqlplus sys/oracle@abs as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 29 17:27:19 2016


Copyright (c) 1982, 2013, Oracle.  All rights reserved.




Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options


SQL> exit


8.将主库duplicate至备库
kttestdb001r:/home/oracle$rman target / auxiliary sys/oracle@absdg nocatalog


Recovery Manager: Release 11.2.0.4.0 - Production on Wed Jun 29 05:02:49 2016


Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.


connected to target database: ABS (DBID=1253241113)
using target database control file instead of recovery catalog
connected to auxiliary database: ABS (not mounted)


RMAN> duplicate target database for standby from active database ;


----------------------日志输出如下-------------------------------
Starting Duplicate Db at 2016-06-29 05:03:07
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=66 device type=DISK


contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwabs1' auxiliary format 
 '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwabsdg'   ;
}
executing Memory Script


Starting backup at 2016-06-29 05:03:08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=196 instance=abs1 device type=DISK
Finished backup at 2016-06-29 05:03:09


contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '/u01/app/oracle/oradata/absdg/control01.ctl';
}
executing Memory Script


Starting backup at 2016-06-29 05:03:09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_abs1.f tag=TAG20160629T050309 RECID=5 STAMP=915771791
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2016-06-29 05:03:11


contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script


sql statement: alter database mount standby database


contents of Memory Script:
{
   set newname for tempfile  1 to 
 "/u01/app/oracle/oradata/absdg/temp.263.915749599";
   switch clone tempfile all;
   set newname for datafile  1 to 
 "/u01/app/oracle/oradata/absdg/system.256.915749509";
   set newname for datafile  2 to 
 "/u01/app/oracle/oradata/absdg/sysaux.257.915749509";
   set newname for datafile  3 to 
 "/u01/app/oracle/oradata/absdg/undotbs1.258.915749509";
   set newname for datafile  4 to 
 "/u01/app/oracle/oradata/absdg/users.259.915749509";
   set newname for datafile  5 to 
 "/u01/app/oracle/oradata/absdg/undotbs2.264.915749683";
   backup as copy reuse
   datafile  1 auxiliary format 
 "/u01/app/oracle/oradata/absdg/system.256.915749509"   datafile 
 2 auxiliary format 
 "/u01/app/oracle/oradata/absdg/sysaux.257.915749509"   datafile 
 3 auxiliary format 
 "/u01/app/oracle/oradata/absdg/undotbs1.258.915749509"   datafile 
 4 auxiliary format 
 "/u01/app/oracle/oradata/absdg/users.259.915749509"   datafile 
 5 auxiliary format 
 "/u01/app/oracle/oradata/absdg/undotbs2.264.915749683"   ;
   sql 'alter system archive log current';
}
executing Memory Script


executing command: SET NEWNAME


renamed tempfile 1 to /u01/app/oracle/oradata/absdg/temp.263.915749599 in control file


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


Starting backup at 2016-06-29 05:03:16
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DATA/abs/datafile/system.256.915749509
output file name=/u01/app/oracle/oradata/absdg/system.256.915749509 tag=TAG20160629T050317
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+DATA/abs/datafile/sysaux.257.915749509
output file name=/u01/app/oracle/oradata/absdg/sysaux.257.915749509 tag=TAG20160629T050317
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+DATA/abs/datafile/undotbs1.258.915749509
output file name=/u01/app/oracle/oradata/absdg/undotbs1.258.915749509 tag=TAG20160629T050317
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/abs/datafile/users.259.915749509
output file name=/u01/app/oracle/oradata/absdg/users.259.915749509 tag=TAG20160629T050317
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:26
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+DATA/abs/datafile/undotbs2.264.915749683
output file name=/u01/app/oracle/oradata/absdg/undotbs2.264.915749683 tag=TAG20160629T050317
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
Finished backup at 2016-06-29 05:05:43


sql statement: alter system archive log current


contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script


datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=915818779 file name=/u01/app/oracle/oradata/absdg/system.256.915749509
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=915818779 file name=/u01/app/oracle/oradata/absdg/sysaux.257.915749509
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=915818779 file name=/u01/app/oracle/oradata/absdg/undotbs1.258.915749509
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=915818779 file name=/u01/app/oracle/oradata/absdg/users.259.915749509
datafile 5 switched to datafile copy
input datafile copy RECID=9 STAMP=915818779 file name=/u01/app/oracle/oradata/absdg/undotbs2.264.915749683
Finished Duplicate Db at 2016-06-29 05:06:02


----------------------日志输出完毕----------------------




9.主库和备库分别添加standby logfile
standby logfile建议比redo logfile多1至2组
主库:
SQL> alter database add standby logfile thread 1 group 7 '+DATA' size 500M,group 8 '+DATA' size 500M,group 9 '+DATA' size 500M,group 13 '+DATA' size 500M;


Database altered.


SQL> alter database add standby logfile thread 2 group 10 '+DATA' size 500M,group 11 '+DATA' size 500M,group 12 '+DATA' size 500M,group 14 '+DATA' size 500M;


Database altered.


SQL>  select group#,thread#,bytes/1024/1024 from v$standby_log;


    GROUP#    THREAD# BYTES/1024/1024
---------- ---------- ---------------
         7          1             500
         8          1             500
         9          1             500
        10          2             500
        11          2             500
        12          2             500
        13          1             500
        14          2             500


8 rows selected.


备库:
SQL> alter database add standby logfile thread 1 group 7 '/u01/app/oracle/oradata/absdg/redo_standby01' size 500M,group 8 '/u01/app/oracle/oradata/absdg/redo_standby02' size 500M,group 9 '/u01/app/oracle/oradata/absdg/redo_standby03' size 500M,group 10 '/u01/app/oracle/oradata/absdg/redo_standby04' size 500M;


Database altered.


SQL> select group#,thread#,bytes/1024/1024 from v$standby_log;


    GROUP#    THREAD# BYTES/1024/1024
---------- ---------- ---------------
         7          1             500
         8          1             500
         9          1             500
        10          1             500
10.备库清除多余的redo日志组(此步不做不受影响)
#因为主库为RAC,备库为单机,所以备库里面有多余的redo日志需要清理。该动作需要备库处于open read write状态才可以操作(即切到primary状态)
SQL> select open_mode, database_role, switchover_status from v$database;


OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS
-------------------- ---------------- --------------------
READ WRITE           PRIMARY          SESSIONS ACTIVE


SQL> select THREAD#,INSTANCE,STATUS, ENABLED from v$thread;


   THREAD# INSTANCE                                                                         STATUS          ENABLED
---------- -------------------------------------------------------------------------------- --------------- --------
         1 absdg                                                                            OPEN            PUBLIC
         2 abs2                                                                             CLOSED          PUBLIC


SQL> alter database disable thread 2;


Database altered.


SQL> select group# from v$log where THREAD#=2;


    GROUP#
----------
         3
         4
         6


SQL> alter database drop logfile group 3;


Database altered.


SQL> alter database drop logfile group 4;


Database altered.


SQL> alter database drop logfile group 6;


Database altered.








10.测试备库的DG是否可用


SQL> alter database open;


Database altered.


SQL> select open_mode from v$database;


OPEN_MODE
--------------------
READ ONLY


SQL> alter database recover managed standby database using current logfile disconnect from session;




11.DG角色切换测试
关闭RAC的实例2
srvctl stop instance -i abs2 -d abs


查看主库实例1的状态
SQL> select switchover_status from v$database;


SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE


执行主库的SWITCHOVER切换操作
SQL> alter database commit to switchover to physical standby with session shutdown;


Database altered.


重新启动主库
SQL> startup mount
ORACLE instance started.


Total System Global Area 2572144640 bytes
Fixed Size                  2249120 bytes
Variable Size             704646752 bytes
Database Buffers         1845493760 bytes
Redo Buffers               19755008 bytes
Database mounted.


SQL> alter database open;


Database altered.


SQL> select switchover_status from v$database;


SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE


查看备库的状态
SQL> select open_mode, database_role, switchover_status from v$database;


OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS
-------------------- ---------------- --------------------
READ ONLY            PHYSICAL STANDBY TO PRIMARY


备库切换至primary的状态
SQL> alter database commit to switchover to primary;


Database altered.


SQL> select open_mode from v$database;


OPEN_MODE
--------------------
MOUNTED


SQL> alter database open;


Database altered.


SQL> select open_mode from v$database;


OPEN_MODE
--------------------
READ WRITE


启动主库实例2
kttestdb002r:/home/oracle$sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 29 07:06:31 2016


Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to an idle instance.


SQL> startup
ORACLE instance started.


Total System Global Area 2572144640 bytes
Fixed Size                  2249120 bytes
Variable Size             704646752 bytes
Database Buffers         1845493760 bytes
Redo Buffers               19755008 bytes
Database mounted.
Database opened.


SQL> select open_mode, database_role, switchover_status from v$database;


OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS
-------------------- ---------------- --------------------
READ ONLY WITH APPLY PHYSICAL STANDBY NOT ALLOWED


再次感谢

你可能感兴趣的:(oracle,DG,RAC,Oracle的错误总结和分析)