一聚教程网:一个值得你收藏的教程网站

热门教程

oracle数据库dataguard 11GR2 RAC to RAC配置

时间:2022-06-29 09:59:25 编辑:袖梨 来源:一聚教程网

数据架构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 logSQL> 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:
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


5、修改tnsnames.ora文件Primary:RAC1 & RAC2

 代码如下 复制代码

more $ORACLE_HOME/network/admin/tnsnames.ora
orclstscan2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = scan2-cluster)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclst)
)
)

orclst =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac21-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac22-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclst)
)
)

orclst1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac21-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclst)
(INSTANCE_NAME = orclst1)
)
)

orclst2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac22-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclst)
(INSTANCE_NAME = orclst2)
)
)

orclpd =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpd)
)
)

orclpd1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpd)
(INSTANCE_NAME = orclpd1)
)
)

orclpd2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpd)
(INSTANCE_NAME = orclpd2)
)
)

Standby:RAC21 & RAC22
more $ORACLE_HOME/network/admin/tnsnames.ora
orclpdrac =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac-cluster)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpd)
)
)

orclst =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac21-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac22-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclst)
)
)

orclst1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac21-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclst)
(INSTANCE_NAME = orclst1)
)
)

orclst2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac22-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclst)
(INSTANCE_NAME = orclst2)
)
)

orclpd =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpd)
)
)

orclpd1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpd)
(INSTANCE_NAME = orclpd1)
)
)

orclpd2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpd)
(INSTANCE_NAME = orclpd2)
)
)

6、Primary 主库修改初始化参数之前,备份pfileSQL> create pfile=’/home/oracle/primaryinitpfile.ora’ from spfile;

7、Primary 主库上修改初始化参数primary rac1:

 代码如下 复制代码
alter system set log_archive_config=’dg_config=(orclpd,orclst)’ scope=both ;
alter system set log_archive_dest_1=’location=+DATA2 valid_for=(all_logfiles,all_roles) db_unique_name=orclpd’ scope=both;
alter system set log_archive_dest_2=’service=orclst LGWR ASYNC NOAFFIRM max_failure=10 max_connections=5 reopen=180 valid_for=(online_logfiles,primary_role) db_unique_name=orclst’ scope=both;
alter system set log_archive_dest_state_2=’defer’ scope=both;
alter system set log_archive_dest_state_1=’enable’ scope=both;
alter system set fal_server=’orclst1′,’orclst2′ scope=both;
alter system set fal_client=’orclpd1′ scope=both sid=’orclpd1′;
alter system set fal_client=’orclpd2′ scope=both sid=’orclpd2′;
alter system set log_archive_max_processes=10 scope=both;
alter system set db_file_name_convert=’+DATA1/orclst’,'+DATA1/orclpd’ scope=spfile;
alter system set log_file_name_convert=’+DATA2/orclst’,'+DATA2/orclpd’,'+DATA1/orclst’,'+DATA1/orclpd’ scope=spfile;
alter system set standby_file_management=’AUTO’ scope=both;

重启数据库,使得修改参数生效

 代码如下 复制代码
srvctl stop database -d orclpd
srvctl start database -d orclpd

PS:单独重启其中一个实例可能会报错
filename convert主备要用不同的路径,否则关闭其中一个数据库相当于关闭系统

8、关于LOCAL_LISTENER建议不要设置LOCAL_LISTENER,因为设置了LOCAL_LISTENER,如果对监听进行修改,则LOCAL_LISTENER不会字段更新,会导致数据库不能连接。
在RAC中,当数据库重启的时候就会动态更新LOCAL_LISTENER的值。

9、Standby 备库确定remote_listener设置为scan name,后面会用到[oracle@rac21 orclst]$ srvctl config scan
SCAN name: scan2-cluster, Network: 1/10.10.23.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /scan2-cluster/10.10.23.10

10、拷贝Primary节点上的密码文件到Standby库的各节点,并根据实例名命名RAC1上的/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapworclpd2
拷贝到RAC21 & RAC22上
rac21上命名为/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapworclst1
rac22上命名为/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapworclst2

11、选择Standby库其中一个节点RAC21:

 代码如下 复制代码
创建/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorclst1.ora
cat initorclst1.ora
db_name=orclst

12、启动数据库到nomount模式RAC21:

 代码如下 复制代码

export ORACLE_SID=orclst1
SQL> startup nomount pfile=’/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorclst1.ora’;
ORACLE instance started.

Total System Global Area 217157632 bytes
Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes

13、在primary主库的一个节点上修改log_archive_dest_state_2的值

 代码如下 复制代码
SQL> alter system set log_archive_dest_state_2=’enable’ SCOPE=both sid=’*';

14、在Primary主库的一个节点上使用rman复制数据到Standby数据库target连接到主库其中的一个实例,auxiliary连接到备库其中的一个实例

 代码如下 复制代码

rman target / auxiliary sys/Salley_2009@orclst1
Recovery Manager: Release 11.2.0.2.0 – Production on Fri Feb 18 15:12:39 2011

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

connected to target database: RAC11G2 (DBID=4063332678)
connected to auxiliary database: RAC11G2S (not mounted)

Primary rac1:
[oracle@rac1 dbs]$ rman target / auxiliary sys/Salley_2009@orclst1
duplicate target database for standby from active database
spfile
parameter_value_convert ‘orclpd’,'orclst’,'ORCLPD’,'ORCLST’
set db_unique_name=’orclst’
set db_file_name_convert=’+DATA1/orclpd’,'+DATA1/orclst’
set log_file_name_convert=’+DATA1/orclpd’,'+DATA1/orclst’,'+DATA2/orclpd’,'+DATA2/orclst’
set control_files=’+DATA1′,’+DATA2′
set instance_number=’1′
set log_archive_max_processes=’5′
set fal_client=’orclst’
set fal_server=’orclpd1′,’orclpd2′
set remote_listener=’scan2-cluster:11521′
reset local_listener
set log_archive_dest_2=’service=orclpd LGWR ASYNC NOAFFIRM max_failure=10 max_connections=5 reopen=180 valid_for=(online_logfiles,primary_role) db_unique_name=orclpd’
set log_archive_dest_1=’location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=orclst’;

PS:如果运行失败,一般需要检查的地方有以下几点:
内存是否足够;
监听是否可以连接;
trname是否配置正确;
primary是否启动到archive模式;
primary是否启动到force logging模式;


15、上面的命令运行成功了之后,就会启动standby上的orclst1实例到mount模式运行以下log应用的命令

 代码如下 复制代码
SQL> alter database recover managed standby database using current logfile disconnect;
Database altered.

下面查看归档日志应用的情况:

 代码如下 复制代码

SQL> select sequence#,thread#,applied from v$archived_log;

SEQUENCE# THREAD# APPLIED
———- ———- ———
18 1 YES
20 1 YES
19 1 YES
22 2 YES
20 2 YES
21 2 YES
23 2 YES
21 1 YES
22 1 YES
24 2 YES
25 2 YES

SEQUENCE# THREAD# APPLIED
———- ———- ———
23 1 YES
24 1 YES
25 1 YES
26 2 YES
26 1 YES
27 2 YES
27 1 YES
28 2 YES
29 2 YES
28 1 YES
30 2 YES

SEQUENCE# THREAD# APPLIED
———- ———- ———
29 1 YES
31 2 YES
30 1 IN-MEMORY

25 rows selected.

16、上面的设置使得DG正常运行了,则下面要设置standby数据库在cluster的控制下首先,Standby:RAC21 创建pfile
SQL> create pfile=’/home/oracle/stdbypfile.ora’ from spfile;

17、修改/home/oracle/stdbypfile.ora文件去掉引用primary库的部分,加上实例orclst2设定的部分
如下:

 代码如下 复制代码
1 orclst1.__db_cache_size=436207616
2 orclst2.__db_cache_size=436207616
3 orclst1.__java_pool_size=16777216
4 orclst2.__java_pool_size=16777216
5 orclst1.__large_pool_size=16777216
6 orclst2.__large_pool_size=16777216
7 orclst1.__oracle_base=’/u01/app/oracle’#ORACLE_BASE set from environment
8 orclst2.__oracle_base=’/u01/app/oracle’#ORACLE_BASE set from environment
9 orclst1.__pga_aggregate_target=520093696
10 orclst2.__pga_aggregate_target=520093696
11 orclst1.__sga_target=754974720
12 orclst2.__sga_target=754974720
13 orclst1.__shared_io_pool_size=0
14 orclst2.__shared_io_pool_size=0
15 orclst1.__shared_pool_size=268435456
16 orclst2.__shared_pool_size=268435456
17 orclst1.__streams_pool_size=0
18 orclst2.__streams_pool_size=0
19 *.audit_file_dest=’/u01/app/oracle/admin/orclst/adump’
20 *.audit_trail=’db’
21 *.cluster_database=true
22 *.compatible=’11.2.0.0.0′
23 *.control_files=’+DATA1/orclst/controlfile/current.278.825782107′,’+DATA2/orclst/controlfile/current.318.825782107′#Set by RMAN
24 *.db_block_size=8192
25 *.db_create_file_dest=’+DATA1′
26 *.db_domain=”
27 *.db_file_name_convert=’+DATA1/orclpd’,'+DATA1/orclst’
28 *.db_name=’orclpd’
29 *.db_recovery_file_dest=’+DATA2′
30 *.db_recovery_file_dest_size=4070572032
31 *.db_unique_name=’orclst’
32 *.diagnostic_dest=’/u01/app/oracle’
33 *.dispatchers=’(PROTOCOL=TCP) (SERVICE=orclstXDB)’
34 orclst1.fal_client=’orclst1′
35 orclst2.fal_client=’orclst2′
36 *.fal_server=’orclpd1′,’orclpd2′
37 orclst1.instance_number=1
38 orclst2.instance_number=2
39 *.log_archive_config=’dg_config=(orclpd,orclst)’
40 *.log_archive_dest_1=’location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=orclst’
41 *.log_archive_dest_2=’service=orclpd LGWR ASYNC NOAFFIRM max_failure=10 max_connections=5 reopen=180 valid_for=(online_logfiles,primary_role) db_unique_name=orclpd ‘
42 *.log_archive_dest_state_1=’enable’
43 *.log_archive_dest_state_2=’enable’
44 *.log_archive_format=’%t_%s_%r.dbf’
45 *.log_archive_max_processes=5
46 *.log_file_name_convert=’+DATA1/orclpd’,'+DATA1/orclst’,'+DATA2/orclpd’,'+DATA2/orclst’
47 *.memory_target=1264582656
48 *.open_cursors=300
49 *.processes=150
50 *.remote_listener=’scan2-cluster:11521′
51 *.remote_login_passwordfile=’exclusive’
52 *.standby_file_management=’AUTO’
53 orclst2.thread=2
54 orclst1.thread=1
55 orclst1.undo_tablespace=’UNDOTBS1′
56 orclst2.undo_tablespace=’UNDOTBS2′

PS:注意这里db_name和primary上是一样的,unique_db_name设置为orclst

18、关闭数据库,使用新的参数启动到mount模式SQL> alter database recover managed standby database cancel;

 代码如下 复制代码
SQL> shutdown immediate;
SQL> startup mount pfile=’/home/oracle/stdbypfile.ora’;
SQL> create spfile=’+DATA1/orclst/spfileorclst.ora’ from pfile=’/home/oracle/stdbypfile.ora’;
SQL> shutdown immediate;

19、在standby的两个节点分别创建参数文件,文件内容一致

 代码如下 复制代码
RAC21:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorclst1.ora
RAC22:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorclst2.ora
vim initorclst1.ora
spfile=’+DATA1/orclst/spfileorclst.ora’

20、设置standby的两个节点上的oracle的环境变量RAC21上ORACLE_SID=orclst1
RAC22上ORACLE_SID=orclst2

21、把新的standby数据库及其实例加入到cluster设置中来

 代码如下 复制代码
srvctl add database -d orclst -o /u01/app/oracle/product/11.2.0/dbhome_1 -p “+DATA1/orclst/spfileorclst.ora” -n orclpd -r physical_standby -s mount
srvctl add instance -d orclst -i orclst1 -n rac21
srvctl add instance -d orclst -i orclst2 -n rac22

PS:注意-s mount设定physical standby默认启动到mount模式

22、启动standby,并测试加入cluster的配置是否正确

 代码如下 复制代码

[oracle@rac21 ~]$ srvctl status database -d orclst
[oracle@rac21 ~]$ srvctl start database -d orclst
Instance orclst1 is running on node rac21
Instance orclst2 is running on node rac22

[grid@rac21 ~]$ crsctl stat res ora.orclst.db -p
NAME=ora.orclst.db
TYPE=ora.database.type
ACL=owner:oracle:rwx,pgrp:oinstall:rwx,other::r–
ACTION_FAILURE_TEMPLATE=
ACTION_SCRIPT=
ACTIVE_PLACEMENT=1
AGENT_FILENAME=%CRS_HOME%/bin/oraagent%CRS_EXE_SUFFIX%
AUTO_START=restore
CARDINALITY=2
CHECK_INTERVAL=1
CHECK_TIMEOUT=600
CLUSTER_DATABASE=true
DB_UNIQUE_NAME=orclst
DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=database) PROPERTY(DB_UNIQUE_NAME= CONCAT(PARSE(%NAME%, ., 2), %USR_ORA_DOMAIN%, .)) ELEMENT(INSTANCE_NAME= %GEN_USR_ORA_INST_NAME%)
DEGREE=1
DESCRIPTION=Oracle Database resource
ENABLED=1
FAILOVER_DELAY=0
FAILURE_INTERVAL=60
FAILURE_THRESHOLD=1
GEN_AUDIT_FILE_DEST=/u01/app/oracle/admin/orclst/adump
GEN_USR_ORA_INST_NAME=
GEN_USR_ORA_INST_NAME@SERVERNAME(rac21)=orclst1
GEN_USR_ORA_INST_NAME@SERVERNAME(rac22)=orclst2
HOSTING_MEMBERS=
INSTANCE_FAILOVER=0
LOAD=1
LOGGING_LEVEL=1
MANAGEMENT_POLICY=AUTOMATIC
NLS_LANG=
NOT_RESTARTING_TEMPLATE=
OFFLINE_CHECK_INTERVAL=0
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
PLACEMENT=restricted
PROFILE_CHANGE_TEMPLATE=
RESTART_ATTEMPTS=2
ROLE=physical_standby
SCRIPT_TIMEOUT=60
SERVER_POOLS=ora.orclst
SPFILE=+DATA1/orclst/spfileorclst.ora
START_DEPENDENCIES=weak(type:ora.listener.type,global:type:ora.scan_listener.type,uniform:ora.ons,uniform:ora.eons)
START_TIMEOUT=600
STATE_CHANGE_TEMPLATE=
STOP_DEPENDENCIES=
STOP_TIMEOUT=600
UPTIME_THRESHOLD=1h
USR_ORA_DB_NAME=orclpd
USR_ORA_DOMAIN=
USR_ORA_ENV=
USR_ORA_FLAGS=
USR_ORA_INST_NAME=
USR_ORA_INST_NAME@SERVERNAME(rac21)=orclst1
USR_ORA_INST_NAME@SERVERNAME(rac22)=orclst2
USR_ORA_OPEN_MODE=mount
USR_ORA_OPI=false
USR_ORA_STOP_MODE=immediate
VERSION=11.2.0.1.0

SQL> show parameter local;

NAME TYPE VALUE
———————————— ———– ——————————
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=rac2
1-vip)(PORT=1521))))
log_archive_local_first boolean TRUE
parallel_force_local boolean FALSE

23、在standby的其中一个实例上启动DG恢复进程SQL> alter database recover managed standby database using current logfile disconnect;
以上就是RAC-RAC DG所有的设置。

24、primary上设置归档日志清除策略

 代码如下 复制代码
SQL> alter system set log_archive_dest_2=’service=orclst LGWR ASYNC NOAFFIRM max_failure=10 max_connections=5 reopen=180 valid_for=(online_logfiles,primary_role) db_unique_name=orclst mandatory’ scope=both sid=’*';

设置rman的归档日志清除策略:(再删除日志前要确认archivelog已经被standby数据库应用

 代码如下 复制代码
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;

热门栏目