ITPub博客

首页 > 数据库 > Oracle > oracle 11g RAC 环境下配单实例DG

oracle 11g RAC 环境下配单实例DG

原创 Oracle 作者:woods_su 时间:2016-03-26 16:00:11 0 删除 编辑


1. 前期准备

1.1 规划

 

RAC

DG

oracle版本

11.2.0.4.8

11.2.0.4.0

主机名

rac1

rac2

dg

db_name

orcl

orcl

orcl

db_unique_name

orcl

orcl

dg

instance_name

orcl1

orcl1

dg

ip

192.168.1.201

192.168.1.202

192.168.1.203

RACDG两端的/etc/hosts一样,如下:

#public IP

192.168.1.201     rac1.oracle.com         rac1.  rac1

192.168.1.202     rac2.oracle.com         rac2.  rac2

#private IP

10.10.10.1      rac1-priv.oracle.com    rac1-priv

10.10.10.2      rac2-priv.oracle.com    rac2-priv

#virtual IP

192.168.1.101   rac1-vip.oracle.com     rac1-vip

192.168.1.102   rac2-vip.oracle.com     rac2-vip

#scan IP

192.168.1.10    rac-scan.oracle.com     rac-scan

 

192.168.1.203   dg

 

1.2 确认集群状态

 [grid@rac1 ~]$  crsctl stat res -t

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

NAME           TARGET  STATE        SERVER                   STATE_DETAILS      

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

Local Resources

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

ora.DATA01.dg

               ONLINE  ONLINE       rac1                                        

               ONLINE  ONLINE       rac2                                         

ora.FRA.dg

               ONLINE  ONLINE       rac1                                                                                

。。。。。。。    

1.3 确认RAC是归档模式

1.3.1 当前归档模式

SQL> archive log list;

Database log mode              No Archive Mode

Automatic archival             Disabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     10

Current log sequence           11

1.3.2 修改归档路径

归档日志改成在本地,两个节点都修改一下

节点1mkdir -p /u01/app/oracle/orcl1_arch

alter system set log_archive_dest_1 = 'LOCATION=/u01/app/oracle/orcl1_arch' scope=both sid='orcl1';

节点2mkdir -p /u01/app/oracle/orcl2_arch

alter system set log_archive_dest_1 = 'LOCATION=/u01/app/oracle/orcl2_arch' scope=both sid='orcl2';

 1.3.3 切换归档模式:

alter system set cluster_database=false scope=spfile sid='orcl1';

alter system set cluster_database=false scope=spfile sid='orcl2';

关闭两个节点

启动一个节点实例到mount状态

alter database archivelog;

alter system set cluster_database=true scope=spfile sid='orcl1';

alter system set cluster_database=true scope=spfile sid='orcl2';

shutdown ammediate;

重新打开两个节点的实例

1.3.4 验证归档模式:

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u01/app/oracle/orcl1_arch

Oldest online log sequence     13

Next log sequence to archive   14

Current log sequence           14

 

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u01/app/oracle/orcl2_arch

Oldest online log sequence     8

Next log sequence to archive   9

Current log sequence           9

1.4 RAC端添加网络配置

1.4.1 listener.ora

[grid@rac2 admin]$ cat /u01/app/11.2.0/grid/network/admin/listener.ora

添加下面这些内容:

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME=orcl_dgmgrl)

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

      (sid_name=orcl2)

     )

   )

节点1也要添加相同内容,最后面改成sid_name=orcl1即可

1.4.2 tnsnames.ora

RAC的两个节点和DG,总共三个节点都一样即可

[oracle@rac1 admin]$ cat /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

内容:

ORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

ORCL2 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

      (INSTANCE_NAME = orcl2)

    )

  )

ORCL1 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

      (INSTANCE_NAME = orcl1)

    )

  )

DG =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dg)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = dg)

    )

  )

1.5 DG端准备

1.5.1 安装软件

安装好软件,不需要建库

1.5.2 基础配置

根据/etc/hosts里的配置,修改主机名和IP

tnsnames.ora内容和上面一样即可

listener.ora(可以用netmgr配置)内容如下:

[oracle@dg admin]$ cat /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = dg)

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

      (SID_NAME = dg)

    )

  )

LISTENER =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dg)(PORT = 1521))

  )

 

ADR_BASE_LISTENER = /u01/app/oracle

2. 修改RAC的参数

2.1 修改一些参数

alter system set standby_file_management=auto;

alter system set log_archive_config='DG_CONFIG=(orcl,dg)';

alter system set LOG_ARCHIVE_DEST_2='SERVICE=dg async VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg';

alter system set fal_server=dg;

alter system set fal_client=orcl;

alter system set db_file_name_convert='/u01/app/oracle/oradata/dg/datafile/','+DATA01/orcl/datafile/','/u01/app/oracle/oradata/dg/tempfile/','+DATA01/orcl/tempfile/' scope=spfile;

alter system set log_file_name_convert='/u01/app/oracle/oradata/dg/log1/','+DATA01/orcl/onlinelog/','/u01/app/oracle/oradata/dg/log2/','+FRA/orcl/onlinelog/' scope=spfile;

2.2 创建pfile文件

主要指定一些pfile的路径,不要直接create pfile from spfile

create pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/tmp.ora' from spfile;

2.3添加standby redo log file

添加的standby 日志要比online日志多一组

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

   THREAD#     GROUP# BYTES/1024/1024

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

         1          1              50

         1          2              50

         2          3              50

         2          4              50

SQL> alter database add standby logfile thread 1 group 5 size 50m;

SQL> alter database add standby logfile thread 1 group 6 size 50m;

SQL> alter database add standby logfile thread 1 group 7 size 50m;

SQL>  alter database add standby logfile thread 2 group 8 size 50m;

SQL> alter database add standby logfile thread 2 group 9 size 50m;

SQL> alter database add standby logfile thread 2 group 10 size 50m;

2.4 开启FORCE LOGGING;

ALTER DATABASE FORCE LOGGING;

2.5 传输文件到DG

密码文件和初始化参数文件:

scp orapworcl1 oracle@dg:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwdg

scp tmp.ora oracle@dg:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initdg.ora

3. RMAN备份数据库

3.1 修改参数文件

相应路径要记得创建

修改完的内容如下:

[oracle@dg dbs]$ cat /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initdg.ora

*.audit_file_dest='/u01/app/oracle/admin/dg/adump'

*.audit_trail='db'

*.compatible='11.2.0.4.0'

*.control_files='/u01/app/oracle/oradata/dg/control01.ctl'

*.db_block_size=8192

*.db_create_file_dest='/u01/app/oracle/oradata/dg/'

*.db_domain=''

*.db_file_name_convert='+DATA01/orcl/datafile/','/u01/app/oracle/oradata/dg/datafile/','+DATA01/orcl/tempfile/','/u01/app/oracle/oradata/dg/tempfile/'

*.db_name='orcl'

*.db_unique_name='dg'

*.db_recovery_file_dest='/u01/app/oracle/flsh_recovery_area'

*.db_recovery_file_dest_size=4589617152

*.diagnostic_dest='/u01/app/oracle'

*.fal_client='ORCL'

*.fal_server='DG'

*.log_archive_config='DG_CONFIG=(orcl,dg)'

*.log_archive_dest_1='LOCATION=/u01/app/oracle/archdg'

*.log_archive_dest_2='SERVICE=orcl1 async VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl'

*.log_file_name_convert='+DATA01/orcl/onlinelog/','/u01/app/oracle/oradata/dg/log1/','+FRA/orcl/onlinelog/','/u01/app/oracle/oradata/dg/log2/'

*.memory_target=1053818880

*.open_cursors=300

*.processes=150

*.remote_listener='rac-scan:1521'

*.remote_login_passwordfile='exclusive'

*.standby_file_management='AUTO'

*.undo_tablespace='UNDOTBS1'

3.2 dg端启动到nomount

sqlplus / as sysdba;

create spfile from pfile;

startup nomount;

3.3 duplicate复制数据库

RAC端开始拷贝数据库到DG端:

rman target sys/oracle@orcl auxiliary sys/oracle@dg

duplicate target database for standby from active database

3.4打开备库并启动redo应用

alter database open;

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

alter database recover managed standby database using current logfile disconnect from session;(启动实时应用)

如果要取消应用可以用:

alter database recover managed standby database cancel;

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

 

PROTECTION_MODE      DATABASE_ROLE    OPEN_MODE

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

MAXIMUM PERFORMANCE  PHYSICAL STANDBY READ ONLY WITH APPLY

4. 配置broker

4.1 启动DMON进程

RACDG两边都要启动

alter system set dg_broker_start=true;

4.2 设置RAC端的broker配置文件位置

备库用默认的位置

ASMCMD> mkdir +DATA01/orcl/brokerconfig/

ASMCMD> mkdir +FRA/orcl/brokerconfig/

RAC的两个节点分别执行:

SQL> alter system set dg_broker_config_file1='+DATA01/orcl/brokerconfig/dr1orcl.dat' scope=both sid='orcl1';

SQL> alter system set dg_broker_config_file2='+FRA/orcl/brokerconfig/dr2orcl.dat' scope=both sid='orcl1';

 

SQL> alter system set dg_broker_config_file1='+DATA01/orcl/brokerconfig/dr1orcl.dat' scope=both sid='orcl2';

SQL> alter system set dg_broker_config_file2='+FRA/orcl/brokerconfig/dr2orcl.dat' scope=both sid='orcl2';

4.3 开始配置

[oracle@dg dbs]$ dgmgrl sys/oracle@orcl

DGMGRL>  CREATE CONFIGURATION qqq as  PRIMARY DATABASE IS orcl CONNECT IDENTIFIER IS orcl;

DGMGRL> ADD DATABASE dg AS CONNECT IDENTIFIER IS  dg MAINTAINED AS PHYSICAL;

DGMGRL> enable configuration;

4.4 验证

DGMGRL> show configuration;

Configuration - qqq

  Protection Mode: MaxPerformance

  Databases:

    orcl - Primary database

    dg   - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS

分别看下两个库的状态

DGMGRL> show database orcl;

Database - orcl

  Role:            PRIMARY

  Intended State:  TRANSPORT-ON

  Instance(s):

    orcl1

    orcl2

Database Status:

SUCCESS

 

DGMGRL> show database dg;

Database - dg

  Role:            PHYSICAL STANDBY

  Intended State:  APPLY-ON

  Transport Lag:   0 seconds (computed 0 seconds ago)

  Apply Lag:       0 seconds (computed 0 seconds ago)

  Apply Rate:      0 Byte/s

  Real Time Query: ON

  Instance(s):

    dg

Database Status:

SUCCESS

配置过程中遇到这样的错误:

Database Status:

DGM-17016: failed to retrieve status for database "dg"

ORA-16603: Data Guard broker detected a mismatch in configuration ID

ORA-16625: cannot reach database "dg"

就删掉broker配置文件,重新搭建broker

5. switchover

进行切换

DGMGRL> SWITCHOVER TO dg;

Performing switchover NOW, please wait...

Operation requires a connection to instance "dg" on database "dg"

Connecting to instance "dg"...

Connected.

New primary database "dg" is opening...

Operation requires startup of instance "orcl2" on database "orcl"

Starting instance "orcl2"...

ORACLE instance started.

Database mounted.

Database opened.

Switchover succeeded, new primary is "dg"

 

再看下现在的状态:

DGMGRL> show configuration;

Configuration - qqq

  Protection Mode: MaxPerformance

  Databases:

    dg   - Primary database

    orcl - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS

 

看一下orcl库的状态:

DGMGRL> show database orcl;

Database - orcl

  Role:            PHYSICAL STANDBY

  Intended State:  APPLY-ON

  Transport Lag:   0 seconds (computed 1 second ago)

  Apply Lag:       0 seconds (computed 0 seconds ago)

  Apply Rate:      9.00 KByte/s

  Real Time Query: ON

  Instance(s):

    orcl1

    orcl2 (apply instance)

Database Status:

SUCCESS

最后去看下集群的状态,能看到一个库是mount,另一个是read only

ora.orcl.db

      1        ONLINE  INTERMEDIATE rac1                 Mounted (Closed)   

      2        ONLINE  ONLINE       rac2                   Open,Readonly

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30935525/viewspace-2064290/,如需转载,请注明出处,否则将追究法律责任。

上一篇: linux 基础
请登录后发表评论 登录
全部评论

注册时间:2016-02-29

  • 博文量
    41
  • 访问量
    63803