ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RAC环境下创建物理DATAGUARD

RAC环境下创建物理DATAGUARD

原创 Linux操作系统 作者:zwc1083 时间:2009-02-24 09:28:51 0 删除 编辑

为一个RAC搭建standby和单节点搭建方法基本一致,我们可以把RAC看成是一个单节点的数据库,只需要保证所有节点的日志能传送到备库即可。

 

一、在备库服务器安装ORACLE软件

      只安装软件,不要创建数据库。ORACLE软件版本和主库保持一致。

 

二、修改主库参数

节点1执行:

SQL> show parameter spfile

 

NAME                                TYPE       VALUE

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

spfile                              string     /dev/raw/raw14

 

节点2执行:

SQL> show parameter spfile

 

NAME                                TYPE       VALUE

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

spfile                              string     /dev/raw/raw14

 

可见,在本例中,RAC各节点共用一个spfile,所以,我们修改参数时,可以只需在一个节点下修改就可以了。

 

--强制数据库LOGGING

SQL> ALTER DATABASE FORCE LOGGING;

 

Database altered.

 

 

--修改DATAGUARD相关参数

SQL> ALTER SYSTEM SET DB_UNIQUE_NAME=primary scope=spfile;

 

System altered.

 

SQL> ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(primary,standby)' scope=spfile;

 

System altered.

 

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=/soft/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=primary' scope=spfile;

 

System altered.

 

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby' scope=spfile;

 

System altered.

 

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=spfile;

 

System altered.

 

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=spfile;

 

System altered.

 

SQL> ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE scope=spfile;

 

System altered.

 

SQL> ALTER SYSTEM SET LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' scope=spfile;

 

System altered.

 

SQL> ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=4 scope=spfile;

 

System altered.

 

 

SQL> ALTER SYSTEM SET COMPATIBLE = '10.2.0.3' scope=spfile;

 

System altered.

 

--以下几个参数是为了SWITCH OVER用的,是可选参数。

--但是为了以后可能发生的SWITCH OVER更方便,应该养成设置这些参数的习惯

SQL> ALTER SYSTEM SET FAL_CLIENT = PRIMARY SCOPE=SPFILE;

 

System altered.

 

SQL> ALTER SYSTEM SET FAL_SERVER = STANDBY SCOPE=SPFILE;

 

System altered.

 

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT =AUTO SCOPE=SPFILE;

 

System altered.

 

SQL> ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/soft/oradata/rac/','/dev/raw/' SCOPE=SPFILE;

 

System altered.

 

SQL> ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/soft/oradata/rac/','/dev/raw/' SCOPE=SPFILE;

 

System altered.

 

--在本文测试环境下,由于主库和备库路径不一致,所以要设置路径转换参数。

 

三、修改主库为归档模式

1--关闭所有实例

--注意:修改以上参数后,必须把所有实例都关闭。否则在启动实例的时候可能会导致错误:

--ORA-00600: internal error code, arguments: [kccsbck_first], [2], [2241198041],

[], [], [], [], []

 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

 

2、修改为归档模式

--关闭所有节点

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

--在其中一个节点启用归档

SQL> startup mount

ORACLE instance started.

 

Total System Global Area 159383552 bytes

Fixed Size                 1260672 bytes

Variable Size             79692672 bytes

Database Buffers          75497472 bytes

Redo Buffers               2932736 bytes

Database mounted.

SQL> alter database archivelog;

 

Database altered.

 

SQL> alter database open;

 

 

Database altered.

 

10GR2以前,在RAC环境下修改归档必须先把设置参数cluster_database=false,把数据库设置为归档后再把该参数设置为true,但这个步骤在10GR2可以省略。

 

 

四、备份数据库

1、备份数据库

备份操作在节点1(rac1)上执行。

由于归档在不同的节点下,故要连接所有节点进行备份:

[oracle@rac1 ~]$ $ORACLE_HOME/bin/rman target /                 

 

Recovery Manager: Release10.2.0.3.0 - Production on Wed Apr 30 14:48:23 2008

 

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

 

connected to target database: RAC (DBID=2232067446)

 

RMAN> run

2> {

3> allocate channel c1 device type disk format '/soft/backup/%U' connect sys/test@rac1;

4> allocate channel c2 device type disk format '/soft/backup/%U' connect sys/test@rac2;

5> backup database plus archivelog delete all input;

6> }

 

 

2、生成备库控制文件

RMAN> run                                   

2> {

3> allocate channel c1 device type disk format '/soft/backup/CON_%U';

4> backup current controlfile for standby;

5> }

 

五、备库环境准备

 

1、在备库添加指向主库的tnsnames

      在备库的tnsnames.ora添加如下内容:

primary =

 (DESCRIPTION =

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

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

   (LOAD_BALANCE = yes)

   (CONNECT_DATA =

     (SERVER = DEDICATED)

     (SERVICE_NAME = primary)

     (FAILOVER_MODE =

       (TYPE = SELECT)

       (METHOD = BASIC)

       (RETRIES = 180)

       (DELAY = 5)

     )

   )

 )2、在备库创建相关目录

      包括adump,bdump,cdump,udump及数据文件目录等。

3、拷贝主库的密码文件到备库上

--拷贝rac1的密码文件到备库的$ORACLE_HOME/dbs下,并把该密码文件修改为orapwd。这里我的sid就用rac1,所以,不用改名。

[oracle@rac1 dbs]$ scp orapwrac1 172.25.0.35:`pwd`

orapwrac1                                                                                        100% 1536    1.5KB/s  00:00   

 

4、配置备库的监听

[oracle@standby admin]$ more listener.ora

 

SID_LIST_LISTENER =

 (SID_LIST =

   (SID_DESC =

     (GLOBAL_DBNAME = standby)

     (ORACLE_HOME = /opt/oracle/product/10.2/database)

     (SID_NAME = rac1)

   )

 )

 

LISTENER =

 (DESCRIPTION_LIST =

   (DESCRIPTION =

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

   )

   (DESCRIPTION =

     (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))

   )

 )

 

启动备库监听:lsnrctl start

 

5、设置备库参数文件

      从主库rac1上根据spfile创建一个pfile文件,并传到备库上。

      SQL> create pfile from spfile;

 

File created.

 

SQL> exit

Disconnected from Oracle Database10gEnterpriseEdition Release10.2.0.3.0 - Production

With the Partitioning, Real Application Clusters and Data Mining options

[oracle@rac1 ~]$ cd $ORACLE_HOME/dbs

[oracle@rac1 dbs]$ scp initrac1.ora 172.25.0.35:`pwd`

initrac1.ora        

 

在备库上修改参数文件:

 

Ø        删除所有非”*”打头的参数设置及rac相关参数

Ø        设置dataguard参数

 

修改后参数如下:

[oracle@standby dbs]$ more initrac1.ora

*.audit_file_dest='/opt/oracle/admin/rac/adump'

*.background_dump_dest='/opt/oracle/admin/rac/bdump'

*.compatible='10.2.0.3'

*.control_files='/soft/oradata/rac/control01.ctl','/soft/oradata/rac/control02.ctl','/soft/oradata/rac/control03.ctl'

*.core_dump_dest='/opt/oracle/admin/rac/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_file_name_convert='/DEV/RAW/','/SOFT/ORADATA/RAC/'

*.db_name='rac'

*.db_unique_name='STANDBY'

*.fal_client='STANDBY'

*.fal_server='PRIMARY'

*.job_queue_processes=10

*.log_archive_config='DG_CONFIG=(primary,standby)'

*.log_archive_dest_1='LOCATION= /soft/oradata/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'

*.log_archive_dest_2='SERVICE=primary LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=primary'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='ENABLE'

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

*.log_archive_max_processes=4

*.log_file_name_convert='/DEV/RAW/','/SOFT/ORADATA/RAC/'

*.open_cursors=300

*.pga_aggregate_target=16777216

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_max_size=157286400

*.sga_target=157286400

*.standby_file_management='AUTO'

*.undo_management='AUTO'

undo_tablespace='UNDOTBS1'

*.user_dump_dest='/opt/oracle/admin/rac/udump'

以上有些参数非必须设置的,但是为了switchover更方便,建议都修改上。

Undo表空间保留其中一个就可以。

路径转换相关参数要设置对,否则会报错。

 

6、把备库启动到nomount状态

[oracle@standby ~]$ sqlplus "/as sysdba"

 

SQL*Plus: Release10.2.0.3.0 - Production on Wed Apr 30 18:42:39 2008

 

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

 

Connected to an idle instance.

 

SQL> startup nomount

ORACLE instance started.

 

Total System Global Area 159383552 bytes

Fixed Size                 1260672 bytes

Variable Size             62915456 bytes

Database Buffers          92274688 bytes

Redo Buffers               2932736 bytes

 

7、从主库拷贝备份到备库上

      之前备份的所有文件都拷贝到备库上,路径要和主库备份路径保持一致。如果不一致,linux下可以用ln的方式解决。

      注意:两个节点都有归档的备份,要把这些备份都拷贝到备库上。

      RAC1

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

请登录后发表评论 登录
全部评论

注册时间:2009-02-16

  • 博文量
    91
  • 访问量
    45029