Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2796724
  • 博文数量: 389
  • 博客积分: 4177
  • 博客等级: 上校
  • 技术积分: 4773
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-16 23:29
文章分类

全部博文(389)

分类: Oracle

2014-08-08 11:24:45

                        搭建ORACLE 12C RAC到单实例的DATAGUARD

      很多组织都部署了RAC,为了实现灾备,同时实现了DATAGUARD(简称DG),由于
另外使用一套RAC来做DG备库成本过高,于是使用普通的单实例成了很多公司的首选.
从11G开始DG实现了只读查询,可以节约一定的成本.

    本文就是实现一个ORACLE RAC两节点到单实例的操作过程.RAC在之前已经部署完成

环境: ORACLE 12C RAC两个节点,使用ASM存储,OS RHEL 5.5
      ORACLE 12C单节点 ,使用文件系统存储;OS RHEL 5.5(oracle软件已安装好),
IP:192.168.233.102


oracle RAC 12修改归档不需要更改cluster_database=false

[oracle@rac1 ~]$ srvctl start database -db tt -o mount

SQL> alter database archivelog;

Database altered.

在RAC的两个节点上增加到dg库的tns信息.修改$ORACLE_HOME/network/admin/tnsnames.ora

dgtt =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.233.102)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = tt)
    )
  )


在dg备库上增加到rac主库和备库的tns,且本机的实例使用静态listener注册

tnsnames.ora增加如下内容

TT =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.233.42)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = tt)
    )
  )


dgtt =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.233.102)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = tt)
    )
  )

listener增加如下内容

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = tt)
      (ORACLE_HOME = /u01/app/oracle/product/12.1/db_1)
      (SID_NAME = tt)
    )
  )

在RAC上实现force logging,修改参数cluster_database=false
SQL> alter database force logging;

Database altered.

SQL> alter system set cluster_database=false scope=spfile;

System altered.

关闭rac数据库,只启动其中一个节点

[oracle@rac2 dbs]$ srvctl stop database -db tt

[oracle@rac2 dbs]$ srvctl start instance -db tt -node rac1

 

拷贝oracle rac的密码文件到dg备库上或是手动新建也可以(密码需要和rac上的sys密码相同).在dg备库上

[oracle@dg2 dbs]$ orapwd file=orapwtt password=sys

 

在dg备库主机写参数文件,所有数据文件都存放在 /u01/app/oracle/oradata/tt目录中.在备库还需要准备好其他目录.

compatible=12.1.0.0.0
db_name='tt'
control_files='/u01/app/oracle/oradata/tt/control01.ctl'


在dg备库上以nomount方式启动实例
[oracle@dg2 ~]$ export ORACLE_SID=tt
[oracle@dg2 ~]$ sqlplus /nolog

SQL*Plus: Release 12.1.0.1.0 Production on Wed Aug 28 22:02:19 2013

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

SQL> conn / as sysdba;
Connected to an idle instance.
SQL> startup nomount pfile='/home/oracle/tmp.ora';
ORACLE instance started.

Total System Global Area  217157632 bytes
Fixed Size                  2286656 bytes
Variable Size             159386560 bytes
Database Buffers           50331648 bytes
Redo Buffers                5152768 bytes

 

在dg备库以rman的方式构建备库

[oracle@dg2 dbs]$ $ORACLE_HOME/bin/rman nocatalog

RMAN> connect target sys/"sys"@tt;

connected to target database: TT (DBID=2330091929)
using target database control file instead of recovery catalog

RMAN> connect auxiliary sys/"sys"@dgtt;

connected to auxiliary database: TT (not mounted)

 


RMAN> run
2> {
3> allocate channel c1  device type disk ;
4> allocate auxiliary channel  ac2  device type disk;
5> duplicate target database for standby
6> from active database
7> spfile
8> parameter_value_convert 'tt','dgtt'
9> set control_files='/u01/app/oracle/oradata/tt/control01.ctl'
10> set db_create_file_dest='/u01/app/oracle/oradata/tt'
11> set db_create_online_log_dest_1='/u01/app/oracle/oradata'
12> set log_file_name_convert='+DATA','/u01/app/oracle/oradata/tt'
13> set 'db_unique_name'='dgtt'
14> set log_archive_dest_1='location=/u01/app/oracle/oradata/arch valid_for=(all_logfiles,all_roles) db_unique_name=dgtt'
15> set log_archive_dest_2='service=tt valid_for=(online_logfiles,primary_role) db_unique_name=tt'
16> set log_archive_config='DG_CONFIG=(tt,dgtt)'
17> set fal_server='tt'
18> set fal_client='dgtt'
19> nofilenamecheck;
20> sql channel c1 "alter system set log_archive_dest_2=''service=dgtt valid_for=(online_logfiles,primary_role) db_unique_name=dgtt'' sid=''*''";
21> sql channel c1 "alter system set log_archive_config=''DG_CONFIG=(tt,dgtt)'' sid=''*''";
22> sql channel c1 "alter system set fal_server=''dgtt''";
23> sql channel c1 "alter system set fal_client=''tt''";
24>  allocate auxiliary channel c3 device type disk;
25>    sql channel c3 "alter database add standby logfile ''/u01/app/oracle/oradata/tt/stredo01.log'' size 500M";
26>    sql channel c3 "alter database add standby logfile ''/u01/app/oracle/oradata/tt/stredo02.log'' size 500M";
27>    sql channel c3 "alter database add standby logfile ''/u01/app/oracle/oradata/tt/stredo03.log'' size 500M";
28>    sql channel c3 "alter database add standby logfile ''/u01/app/oracle/oradata/tt/stredo04.log'' size 500M";
29>    sql channel c3 "alter database add standby logfile ''/u01/app/oracle/oradata/tt/stredo05.log'' size 500M";
30>  release channel c1;
31> release channel c3;
32> }

......................

改回cluster_database=true,然后重启rac数据库

SQL> alter system set cluster_database=true scope=spfile;

System altered.

 

[oracle@rac2 dbs]$ srvctl start database -db tt

[oracle@rac2 dbs]$ srvctl start database -db tt


重启dg备库,

SQL> startup nomount force;
ORACLE instance started.

Total System Global Area  626327552 bytes
Fixed Size                  2291472 bytes
Variable Size             276826352 bytes
Database Buffers          339738624 bytes
Redo Buffers                7471104 bytes

SQL> alter database mount standby database;

Database altered.

SQL> alter database recover managed standby database disconnect from session;

Database altered.


检是rac的日志是否在dg备库上开始应用了.

SQL> select process,client_process,sequence#,thread# from v$managed_standby;

PROCESS   CLIENT_P  SEQUENCE#    THREAD#
--------- -------- ---------- ----------
ARCH      ARCH             66          1
ARCH      ARCH             64          1
ARCH      ARCH              0          0
ARCH      ARCH             28          2
RFS       UNKNOWN           0          0
RFS       ARCH              0          0
RFS       LGWR             29          2
RFS       UNKNOWN           0          0
RFS       LGWR             68          1
RFS       ARCH              0          0
RFS       UNKNOWN           0          0

PROCESS   CLIENT_P  SEQUENCE#    THREAD#
--------- -------- ---------- ----------
RFS       UNKNOWN           0          0
MRP0      N/A              29          2

数据库角色.

SQL> select database_role from v$database;

DATABASE_ROLE
----------------
PHYSICAL STANDBY

 

 

阅读(7365) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

efits2016-10-13 17:41:38

你好,关于listener配置,是在grid用户下还是在oracle用户下?
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = tt)
      (ORACLE_HOME = /u01/app/oracle/product/12.1/db_1)
      (SID_NAME = tt)
    )
  )