dataguard 11GR2 RAC to RAC配置(一)

数据架构

Primary:
HOSTNAME    DATABASENAME    UNIQUE_DBNAME   INSTANCE_NAME
RAC1                 orclpd                          orclpd                             orclpd1
RAC2                orclpd                          orclpd                             orclpd2

Standby:
HOSTNAME    DATABASENAME    UNIQUE_DBNAME   INSTANCE_NAME
RAC21                 orclpd                          orclst                             orclst1
RAC22                orclpd                          orclst                             orclst2

RAC                          ASM diskgroup(vote) ASM diskgroup(database managefile) ASM diskgroup(recovery manage)
Primary                   DATA                                        DATA1                                                                DATA2
Standby                   DATA                                        DATA1                                                                DATA2

[oracle@rac21 orclst]$ cat /etc/hosts
127.0.0.1 localhost
10.10.23.1 rac1
192.168.1.11 rac1-priv
10.10.23.5 rac1-vip

10.10.23.2 rac2
192.168.1.2 rac2-priv
10.10.23.4 rac2-vip

10.10.23.6 rac21
192.168.1.6 rac21-priv
10.10.23.7 rac21-vip

10.10.23.8 rac22
192.168.1.8 rac22-priv
10.10.23.9 rac22-vip

10.10.23.10 scan2-cluster
10.10.23.3 rac-cluster

1、备库上创建所需目录

oracle用户登录
[oracle@rac21 ~]$ cd $ORACLE_BASE
[oracle@rac21 oracle]$ pwd
/u01/app/oracle
[oracle@rac21 oracle]$ mkdir admin
[oracle@rac21 admin]$ cd admin/
[oracle@rac21 admin]$ mkdir orclst
[oracle@rac21 admin]$ cd orclst/
[oracle@rac21 admin]$ mkdir adump dpdump hdump pfile
PS:备库只需要安装好集群软件和数据库软件就可以了,不需要创建数据库,如果创建数据库也没有问题,就不需要下面创建目录的操作了。

2、主库设为归档模式

RAC1、RAC2
SQL> shutdown immediate;
SQL> startup mount;
RAC1:
SQL> alter database archivelog;
SQL> archive log list;

主库设置为force logging 模式,设置之后数据库将会记录除了临时表空间或临时回滚段外所有的操作
RAC1:
SQL> alter database force logging;
SQL> select force_logging from v$database;
PS:如果没有设置为归档模式,在复制库的时候就会报错。主库设置为forcelogging模式是必须的,这样就会强制记录所有的操作写入redo
alter database force logging是设置数据库级别的force logging,通过select force_logging from v$database可以看到当前数据库强制日志模式的状态。

3、主库创建standby redo log

SQL> alter database add standby logfile thread 1 size 52428800;
or
SQL> alter database add standby logfile thread 1;
SQL> alter database add standby logfile thread 2;
PS:standby logfile:备库角色时用来接收主库redo日志,主备库的角色转换,所以都需要创建standby logfile,主库上创建了,复制主库到备库,备库上也就有了standby logfile。
RAC 环境下有多个实例,每个实例都需要有自己的一套Redo log 文件来记录日志。这套Redo Log 就叫作一个Redo Thread,其实单实例下也是Redo Thread,只是Thread 这个词很少被提及,每个实例一套Redo Thread的设计就是为了避免资源竞争造成性能瓶颈。
Redo Thread有两种,一种是Private 的,创建语法: alter database add logfile .. Thread n;另一种是public,创建语法:alter database add logfile…;
RAC 中每个实例都要设置thread 参数,该参数默认值为0. 如果设置了这个参数,则实例启动时,会使用等于该Thread的Private Redo Thread。如果没有设置这个参数,则使用缺省值0,启动实例后选择使用Public Redo Thread,并且实例会用独占的方式使用该Redo Thread。
RAC 中每个实例都需要一个Redo Thread,每个Redo Log Thread至少需要两个Redo Log Group,
每个Log Group 成员大小应该相等,每组最好有2个以上成员,这些成员应放在不同的磁盘上,以避免单点失败。

4、为主备库创建静态监听

在$GRID_HOME($CRS_HOME)/network/admin/listener.ora,如果使用scan listener,也要同样为其创建静态监听

[oracle@rac2 ~]$ srvctl config listener
Name: LISTENER
Network: 1, Owner: grid
Home: <CRS home>
End points: TCP:1521
[oracle@rac2 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:11521

Standby:RAC21
more listener.ora
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orclst)
(SID_NAME = orclst1)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
)
)

SID_LIST_LISTENER_SCAN1 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orclst)
(SID_NAME = orclst1)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
)
)

Standby:RAC22
more listener.ora
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orclst)
(SID_NAME = orclst2)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
)
)

SID_LIST_LISTENER_SCAN1 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orclst)
(SID_NAME = orclst2)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
)
)

重启监听 RAC21 or RAC21
srvctl stop listener -n RAC21
srvctl start listener -n RAC21
srvctl stop listener -n RAC22
srvctl start listener -n RAC22
srvctl stop scan_listener
srvctl start scan_listener

Primary:RAC1
more listener.ora
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orclpd)
(SID_NAME = orclpd1)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
)
)

SID_LIST_LISTENER_SCAN1 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orclpd)
(SID_NAME = orclpd1)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
)
)
Primary:RAC2
more listener.ora
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orclpd)
(SID_NAME = orclpd2)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
)
)

SID_LIST_LISTENER_SCAN1 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orclpd)
(SID_NAME = orclpd2)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
)
)

重启监听 RAC1 or RAC2
srvctl stop listener -n RAC1
srvctl start listener -n RAC1
srvctl stop listener -n RAC2
srvctl start listener -n RAC2
srvctl stop scan_listener
srvctl start scan_listener

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注