11g RAC+DG(Oracle Maximum Availability Architecture)

 

操作环境

 

Clusterware

11.2.0.3 Grid Infrastructure

11.2.0.3 Grid Infrastructure

Cluster Nodes

Node1,node2(2-Nodes)

bdspoc_st

SCAN

node-scan

NA

SCAN listener Host/port

SCAN VIP(1521)

GI (1521)

HOSTNAME

Node1,node2

bdspoc_st

DB_UNIQUE_NAME

bdspocpy

bdspocst

DB_NAME

bdspoc

bdspoc

DB Instances

bdspoc

bdspoc

DB Storage

ASM

ASM

File Management

OMF

OMF

ASM DiskGroup for CRS

CRS

CRS

ASM DiskGroup for DB Files

DATA

SDATA

11gR2 RAC Version

11.2.0.3.7

11.2.0.3.7

OS

RHEL 5.7 (x86_64)

RHEL 5.7 (x86_64)

 

DataGuard配置前准备工作

Primary Database

安装和配置好2节点的Grid Infrastructure (11.2.0.3)

安装和配置好2节点的RAC Database

创建SYSDG,DATADG,FRADG ASM Diskgroup

配置数据库"zwc"在ASM上使用OMF

配置数据库参数LOCAL_LISTENER,REMOTE_LISTENER

Standby Database

安装和配置好单节点的Grid Infrastructure (11.2.0.3)

安装 Database Software

创建CRS,SDATA ASM Diskgroup

NOTE:由于我主库打上了11.2.0.3.7的PSU,所以相应的也需要在standby上安装psu,如果没有建立相应的DB instance。Psu只能给GRID_HOME打上,RDBMS不能自动的打上11.2.3.7的PSU。安装完实例后,可以删除相应的数据文件及日志文件。

配置Primary RAC database

Enable Force Logging

SQL> alter database force logging;

Database altered.

SQL> select inst_id,name,db_unique_name,force_logging,platform_name from gv$database order by 1;

   INST_ID NAME     DB_UNIQUE_NAME FORCE_LOGGING PLATFORM_NAME

---------- --------- ---------- ------------- -----------------

1 BDSPOC    bdspocpy   YES           Linux x86 64-bit

2 BDSPOC    bdspocpy   YES           Linux x86 64-bit

修改初始化参数

create pfile='/u01/app/oracle/init1.ora' from spfile;

*.db_name='BDSPOC'

*.service_names='BDSPOC'

*.DB_UNIQUE_NAME='BDSPOCPY'

*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(BDSPOCPY,BDSPOCST)'

*.LOG_ARCHIVE_DEST_1='LOCATION=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) *.DB_UNIQUE_NAME=BDSPOCPY'

*.LOG_ARCHIVE_DEST_2='SERVICE=BDSPOCST  ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=BDSPOCST'

*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'

*.LOG_ARCHIVE_MAX_PROCESSES=10

*.fal_client='BDSPOCPY'

*.fal_server='BDSPOCST'

*.DB_FILE_NAME_CONVERT=’+SDATA’,’+DATA’

*.LOG_FILE_NAME_CONVERT=’+SDATA’,’+DATA’

*.STANDBY_FILE_MANAGEMENT='AUTO'

 

SQL> create spfile='+data/bdspoc/spfilebdspoc.ora' from pfile='/u01/app/oracle/init1.ora';

 

 

创建备份目录,使用RMAN备份Primary DatabaseStandby Controlfile

[oracle@node1 ~]mkdir /u01/app/oracle/rman

[oracle@node1 ~]rman target /

run{ 

allocate channel c1 device type disk; 

allocate channel c2 device type disk; 

allocate channel c3 device type disk; 

allocate channel c4 device type disk; 

backup as compressed backupset 

format='/u01/app/oracle/rman/full_%d_%U' tag='full' 

database plus archivelog delete input; 

backup format='/u01/app/oracle/rman/bkctl.ctl' tag='ctl' 

current controlfile; 

release channel c1; 

release channel c2; 

release channel c3; 

release channel c4; 

 } 

 

primary的备份拷贝到standby/u01/app/oracle/rman/

复制hosts文件

bdspoc_st的主机解析地址加入到node1hosts中,/etc/hosts复制到node2bdspoc_st上。

复制tnsname.ora文件

加入bdspoc_pybdspoc_st的解析连接串写入到该文件中。复制到primarystandby上。

复制密码文件

node1的密码文件复制到bdspoc_st上。修改成standby上的密码文件名。

 

配置standby GI databse

Standby上创建相应的目录:

[oracle@bdspoc_st oracle]$ mkdir -p /u01/app/oracle/admin/bdspoc_st/adump

[oracle@bdspoc_st oracle]$ chmod 775 /u01/app/oracle/admin/bdspoc_st/adump/

[oracle@bdspoc_st rdbms]$ mkdir -p /u01/app/oracle/diag/rdbms/bdspoc_st/bdspoc

[oracle@bdspoc_st rdbms]$ cd /u01/app/oracle/diag/rdbms/bdspoc_st/bdspoc/

[oracle@bdspoc_st bdspoc]$ mkdir trace cdump

 

 

配置standby静态监听

[grid@bdspoc_st admin]$ vim listener.ora

LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))))

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

    )

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = bdspoc_st.bdstar.com)(PORT = 1521))

    )

  )

 

SID_LIST_LISTENER =

 (SID_LIST =

   (SID_DESC =

     (GLOBAL_DBNAME = bdspoc)

     (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1/)

     (SID_NAME = bdspoc)

   )

 )

ADR_BASE_LISTENER = /u01/app/11.2.0/

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON

SUBSCRIBE_FOR_NODE_DOWN_EVENT_LISTENER = OFF   #解决一个报错问题

 

GI模式下的listenersrvctl控制,

[grid@bdspoc_st admin]$ srvctl stop listener

[grid@bdspoc_st admin]$ srvctl start listener

[grid@bdspoc_st admin]$ srvctl add listener  -l listener    --若果没有listener服务可以添加该服务

添加DB服务

 

[oracle@bdspoc_st ~]$ cd /u01/app/11.2.0/grid/bin/

[oracle@bdspoc_st bin]$ ./srvctl add database -d bdspocst  -n bdspoc -o /u01/app/oracle/product/11.2.0/dbhome_1/

 

使用RMANDUPLICATE DATABASE还原数据库

[oracle@bdspoc_st ~]sqlplus sys/****@bdspocst  as  sysdba

SQL> startup nomount

ORACLE instance started.

Total System Global Area 7549435904 bytes

Fixed Size              2243072 bytes

Variable Size              1258292736 bytes

Database Buffers    6274678784 bytes

Redo Buffers                14221312 bytes

[oracle@bdspoc_st ~]$ rman target sys/paladin@bdspocpy auxiliary sys/paladin@bdspocst

 

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Sep 28 20:35:07 2013

 

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

 

connected to target database: BDSPOC (DBID=2907827626)

connected to auxiliary database: BDSPOC (not mounted)

 

 

RMAN > duplicate target database for standby nofilenamecheck;

 

Starting Duplicate Db at 28-SEP-13

using channel ORA_AUX_DISK_1

 

contents of Memory Script:

{

   restore clone standby controlfile;

}

executing Memory Script

 

Starting restore at 28-SEP-13

……….

Finished Duplicate Db at 29-SEP-13

 

查看listen状态

[grid@bdspoc_st admin]$ lsnrctl status

 

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 29-SEP-2013 07:55:54

 

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production

Start Date                28-SEP-2013 17:55:55

Uptime                    0 days 13 hr. 59 min. 59 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/11.2.0/grid/network/admin/listener.ora

Listener Log File         /u01/app/11.2.0/diag/tnslsnr/bdspoc_st/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bdspoc_st.bdstar.com)(PORT=1521)))

Services Summary...

Service "+ASM" has 1 instance(s).

  Instance "+ASM", status READY, has 1 handler(s) for this service...

Service "bdspoc" has 2 instance(s).

  Instance "bdspoc", status UNKNOWN, has 1 handler(s) for this service...

  Instance "bdspoc", status READY, has 1 handler(s) for this service...

Service "bdspocst" has 1 instance(s).

  Instance "bdspoc", status READY, has 1 handler(s) for this service...

 

创建添加Standby log

primary主库添加:

SQL> alter database add standby logfile thread 1 group 13 '+DATA/bdspoc/onlinelog/standby13.log' size 500M;

SQL> alter database add standby logfile thread 2 group 20 '+DATA/bdspoc/onlinelog/standby20.log' size 500M;

 

Standby从库添加相应的standby log文件

 

注意:standby log要与logfile大小一致,且每个实例要相应的多一组

启动Managed Recovery进程

此时standby会默认到达mounted状态

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

观察standby 状态

--启动read only mode

SQL> select status from v$instance;

 

STATUS

------------

MOUNTED

 

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

 

Database altered.

SQL> alter database open;

Database altered.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;     –实时在线应用

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

Database altered.  

SQL> SELECT open_mode FROM V$DATABASE;

OPEN_MODE

--------------------

READ ONLY WITH APPLY

alter system archive log current;   --归档当前的日志文件

 

[grid@bdspoc_st ~]$ crs_stat -t

Name           Type           Target    State     Host       

------------------------------------------------------------

ora.CRS.dg     ora....up.type ONLINE    ONLINE    bdspoc_st  

ora....ER.lsnr ora....er.type ONLINE    ONLINE    bdspoc_st  

ora.SDATA.dg   ora....up.type ONLINE    ONLINE    bdspoc_st  

ora.asm        ora.asm.type   ONLINE    ONLINE    bdspoc_st  

ora....ocst.db ora....se.type ONLINE    ONLINE    bdspoc_st  

ora.cssd       ora.cssd.type  ONLINE    ONLINE    bdspoc_st  

ora.diskmon    ora....on.type OFFLINE   OFFLINE              

ora.evmd       ora.evm.type   ONLINE    ONLINE    bdspoc_st  

ora.ons        ora.ons.type   OFFLINE   OFFLINE  

 

添加standby的临时文件

以只读形式打开数据库进行 redo apply的时候会出现如下错误:

Errors in file /u01/app/oracle/diag/rdbms/hainan/bdspoc/trace/bdspoc_dbw0_22527.trc:

ORA-01157: cannot identify/lock data file 201 - see DBWR trace file

ORA-01110: data file 201: '/u01/app/oracle/oradata/bdspoc/temp.263.816281829'

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

 

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;  --取消恢复

 

 

alter database tempfile '/u01/app/oracle/oradata/bdspoc/temp.263.816281829' drop;  --删除原有的temp文件

alter tablespace temp add  tempfile '/u01/app/oracle/oradata/bdspoc/temp01.dbf' size 300m;  --新增temp文件

 

Task 5: Verify Data Guard Configuration

  1. On the physical standby database, query the V$ARCHIVED_LOG view to identify existing files in the archived redo log. For example:

    SQL> select sequence#, first_time, next_time
    from v$archived_log order by sequence#;

  1. On the primary database, issue the following SQL statement to force a log switch and archive the current online redo log file group:

    SQL> alter system archive log current; 

  1. On the physical standby database, query the V$ARCHIVED_LOG view to verify that the redo data was received and archived on the standby database:

    SQL> select sequence#, first_time, next_time
    from v$archived_log order by sequence#;

 

其他

1、关闭注意事项

关闭MAA时,先关闭primary,再standby。启动MAA时,开启standby后,启动primary

重启Primary   Databasemount模式:

 

[grid@bdspoc_st ~]$ srvctl stop database -d bdspoc

[grid@bdspoc_st ~]$srvctl stop database -d bdspoc -o mount

[grid@bdspoc_st ~]$ Srvctl stop instance  -d bdspoc –I bdspoc2

 

2、RAC+DG的卸载

如果单纯的替换参数文件,将会导致如下问题。

SQL> startup

ORACLE instance started.

 

Total System Global Area 7549435904 bytes

Fixed Size              2243072 bytes

Variable Size              1308624384 bytes

Database Buffers    6224347136 bytes

Redo Buffers                14221312 bytes

Database mounted.

ORA-03113: end-of-file on communication channel

Process ID: 569

Session ID: 101 Serial number: 3

参看alert日志,有如下错误。

...

LGWR: Primary database is in MAXIMUM AVAILABILITY mode

LGWR: Destination LOG_ARCHIVE_DEST_1 is not serviced by LGWR

LGWR: Minimum of 1 LGWR standby database required

Errors in file /u01/app/oracle/diag/rdbms/bdspoc/bdspoc1/trace/bdspoc1_lgwr_756.trc:

ORA-16072: a minimum of one standby database destination is required

...

 

删除在参数文件中的DG相关参数,启动到mount阶段,alter database noarchivelog;重启数据库。

 

3、切换保护模式:(primary数据上做)
  ALTER DATABASE SET STANDBY TO MAXIMIZE PERFORMANCE;
  ALTER DATABASE SET STANDBY TO MAXIMIZE AVAILABILITY;
  ALTER DATABASE SET STANDBY TO MAXIMIZE PROTECTION; 

 

 

你可能感兴趣的:(11g RAC+DG(Oracle Maximum Availability Architecture))