热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

Oracle10gRAC环境下创建物理DATAGUARD

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

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

为一个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: Release 10.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> }


using target database control file instead of recovery catalog

allocated channel: c1

channel c1: sid=134 instance=rac1 devtype=DISK


allocated channel: c2

channel c2: sid=141 instance=rac2 devtype=DISK


Starting backup at 30-APR-08

current log archived

channel c1: starting archive log backupset

channel c1: specifying archive log(s) in backup set

input archive log thread=1 sequence=80 recid=1 stamp=653247673

input archive log thread=1 sequence=81 recid=4 stamp=653268228

input archive log thread=1 sequence=82 recid=5 stamp=653353066

channel c1: starting piece 1 at 30-APR-08

channel c2: starting archive log backupset

channel c2: specifying archive log(s) in backup set

input archive log thread=1 sequence=85 recid=13 stamp=653409646

input archive log thread=2 sequence=42 recid=2 stamp=653248818

input archive log thread=2 sequence=43 recid=3 stamp=653250118

input archive log thread=2 sequence=46 recid=10 stamp=653353763

input archive log thread=2 sequence=47 recid=11 stamp=653354798

input archive log thread=2 sequence=48 recid=12 stamp=653409644

input archive log thread=2 sequence=49 recid=16 stamp=653410122

channel c2: starting piece 1 at 30-APR-08

channel c2: finished piece 1 at 30-APR-08

piece handle=/soft/backup/02jf4fql_1_1 tag=TAG20080430T144854 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:05

channel c2: deleting archive log(s)

archive log filename=/soft/archivelog/1_85_644085430.arc recid=13 stamp=653409646

archive log filename=/soft/archivelog/2_42_644085430.arc recid=2 stamp=653248818

archive log filename=/soft/archivelog/2_43_644085430.arc recid=3 stamp=653250118

archive log filename=/soft/archivelog/2_46_644085430.arc recid=10 stamp=653353763

archive log filename=/soft/archivelog/2_47_644085430.arc recid=11 stamp=653354798

archive log filename=/soft/archivelog/2_48_644085430.arc recid=12 stamp=653409644

archive log filename=/soft/archivelog/2_49_644085430.arc recid=16 stamp=653410122

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/01jf4fqq_1_1 tag=TAG20080430T144854 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:14

channel c1: deleting archive log(s)

archive log filename=/soft/archivelog/1_80_644085430.arc recid=1 stamp=653247673

archive log filename=/soft/archivelog/1_81_644085430.arc recid=4 stamp=653268228

archive log filename=/soft/archivelog/1_82_644085430.arc recid=5 stamp=653353066

channel c1: starting archive log backupset

channel c1: specifying archive log(s) in backup set

input archive log thread=1 sequence=83 recid=6 stamp=653353068

input archive log thread=1 sequence=84 recid=9 stamp=653353575

input archive log thread=1 sequence=86 recid=14 stamp=653409966

input archive log thread=1 sequence=87 recid=15 stamp=653410123

input archive log thread=2 sequence=44 recid=7 stamp=653353071

input archive log thread=2 sequence=45 recid=8 stamp=653353072

channel c1: starting piece 1 at 30-APR-08

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/03jf4fr9_1_1 tag=TAG20080430T144854 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:02

channel c1: deleting archive log(s)

archive log filename=/soft/archivelog/1_83_644085430.arc recid=6 stamp=653353068

archive log filename=/soft/archivelog/1_84_644085430.arc recid=9 stamp=653353575

archive log filename=/soft/archivelog/1_86_644085430.arc recid=14 stamp=653409966

archive log filename=/soft/archivelog/1_87_644085430.arc recid=15 stamp=653410123

archive log filename=/soft/archivelog/2_44_644085430.arc recid=7 stamp=653353071

archive log filename=/soft/archivelog/2_45_644085430.arc recid=8 stamp=653353072

Finished backup at 30-APR-08


Starting backup at 30-APR-08

channel c1: starting full datafile backupset

channel c1: specifying datafile(s) in backupset

input datafile fno=00001 name=/dev/raw/raw1

input datafile fno=00005 name=/dev/raw/raw7

input datafile fno=00003 name=/dev/raw/raw2

channel c1: starting piece 1 at 30-APR-08

channel c2: starting full datafile backupset

channel c2: specifying datafile(s) in backupset

input datafile fno=00002 name=/dev/raw/raw3

input datafile fno=00004 name=/dev/raw/raw5

channel c2: starting piece 1 at 30-APR-08

channel c2: finished piece 1 at 30-APR-08

piece handle=/soft/backup/05jf4frg_1_1 tag=TAG20080430T144919 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:43

channel c2: starting full datafile backupset

channel c2: specifying datafile(s) in backupset

including current control file in backupset

channel c2: starting piece 1 at 30-APR-08

channel c2: finished piece 1 at 30-APR-08

piece handle=/soft/backup/06jf4ft0_1_1 tag=TAG20080430T144919 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:22

channel c2: starting full datafile backupset

channel c2: specifying datafile(s) in backupset

including current SPFILE in backupset

channel c2: starting piece 1 at 30-APR-08

channel c2: finished piece 1 at 30-APR-08

piece handle=/soft/backup/07jf4ftm_1_1 tag=TAG20080430T144919 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:06

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/04jf4frg_1_1 tag=TAG20080430T144919 comment=NONE

channel c1: backup set complete, elapsed time: 00:01:13

Finished backup at 30-APR-08


Starting backup at 30-APR-08

current log archived

channel c1: starting archive log backupset

channel c1: specifying archive log(s) in backup set

input archive log thread=1 sequence=88 recid=17 stamp=653410237

channel c1: starting piece 1 at 30-APR-08

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/08jf4fv9_1_1 tag=TAG20080430T145120 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:04

channel c1: deleting archive log(s)

archive log filename=/soft/archivelog/1_88_644085430.arc recid=17 stamp=653410237

channel c1: starting archive log backupset

channel c1: specifying archive log(s) in backup set

input archive log thread=2 sequence=50 recid=18 stamp=653410279

channel c1: starting piece 1 at 30-APR-08

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/09jf4fvf_1_1 tag=TAG20080430T145120 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:04

channel c1: deleting archive log(s)

archive log filename=/soft/archivelog/2_50_644085430.arc recid=18 stamp=653410279

Finished backup at 30-APR-08

released channel: c1

released channel: c2


2、生成备库控制文件

RMAN> run

2> {

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

4> backup current controlfile for standby;

5> }


allocated channel: c1

channel c1: sid=131 instance=rac1 devtype=DISK


Starting backup at 30-APR-08

channel c1: starting full datafile backupset

channel c1: specifying datafile(s) in backupset

including standby control file in backupset

channel c1: starting piece 1 at 30-APR-08

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/CON_0ajf4gqi_1_1 tag=TAG20080430T150554 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:12

Finished backup at 30-APR-08

released channel: c1

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

五、备库环境准备


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

linux

推荐阅读
  • Windows服务与数据库交互问题解析
    本文探讨了在Windows 10(64位)环境下开发的Windows服务,旨在定期向本地MS SQL Server (v.11)插入记录。尽管服务已成功安装并运行,但记录并未正确插入。我们将详细分析可能的原因及解决方案。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • PHP 5.2.5 安装与配置指南
    本文详细介绍了 PHP 5.2.5 的安装和配置步骤,帮助开发者解决常见的环境配置问题,特别是上传图片时遇到的错误。通过本教程,您可以顺利搭建并优化 PHP 运行环境。 ... [详细]
  • 深入理解 SQL 视图、存储过程与事务
    本文详细介绍了SQL中的视图、存储过程和事务的概念及应用。视图为用户提供了一种灵活的数据查询方式,存储过程则封装了复杂的SQL逻辑,而事务确保了数据库操作的完整性和一致性。 ... [详细]
  • 构建基于BERT的中文NL2SQL模型:一个简明的基准
    本文探讨了将自然语言转换为SQL语句(NL2SQL)的任务,这是人工智能领域中一项非常实用的研究方向。文章介绍了笔者在公司举办的首届中文NL2SQL挑战赛中的实践,该比赛提供了金融和通用领域的表格数据,并标注了对应的自然语言与SQL语句对,旨在训练准确的NL2SQL模型。 ... [详细]
  • UNP 第9章:主机名与地址转换
    本章探讨了用于在主机名和数值地址之间进行转换的函数,如gethostbyname和gethostbyaddr。此外,还介绍了getservbyname和getservbyport函数,用于在服务器名和端口号之间进行转换。 ... [详细]
  • 本文详细分析了Hive在启动过程中遇到的权限拒绝错误,并提供了多种解决方案,包括调整文件权限、用户组设置以及环境变量配置等。 ... [详细]
  • MySQL缓存机制深度解析
    本文详细探讨了MySQL的缓存机制,包括主从复制、读写分离以及缓存同步策略等内容。通过理解这些概念和技术,读者可以更好地优化数据库性能。 ... [详细]
  • 使用Python在SAE上开发新浪微博应用的初步探索
    最近重新审视了新浪云平台(SAE)提供的服务,发现其已支持Python开发。本文将详细介绍如何利用Django框架构建一个简单的新浪微博应用,并分享开发过程中的关键步骤。 ... [详细]
  • MySQL 数据库迁移指南:从本地到远程及磁盘间迁移
    本文详细介绍了如何在不同场景下进行 MySQL 数据库的迁移,包括从一个硬盘迁移到另一个硬盘、从一台计算机迁移到另一台计算机,以及解决迁移过程中可能遇到的问题。 ... [详细]
  • Hadoop入门与核心组件详解
    本文详细介绍了Hadoop的基础知识及其核心组件,包括HDFS、MapReduce和YARN。通过本文,读者可以全面了解Hadoop的生态系统及应用场景。 ... [详细]
  • 本文详细介绍了如何使用ActionScript 3.0 (AS3) 连接并操作MySQL数据库。通过具体的代码示例和步骤说明,帮助开发者理解并实现这一过程。 ... [详细]
  • 在即将迎来26岁生日之际,作者的人生陷入了低谷。经过近三年的硕士学习后,最终决定退学,并且面临没有工作经验的困境。尽管如此,作者依然坚定地选择为自己的人生负责。 ... [详细]
  • 根据最新发布的《互联网人才趋势报告》,尽管大量IT从业者已转向Python开发,但随着人工智能和大数据领域的迅猛发展,仍存在巨大的人才缺口。本文将详细介绍如何使用Python编写一个简单的爬虫程序,并提供完整的代码示例。 ... [详细]
  • openGauss每日一练:第6天 - 模式的创建、修改与删除
    本篇笔记记录了openGauss数据库中关于模式(Schema)的创建、修改和删除操作。通过这些操作,用户可以更好地管理和控制数据库对象。实验环境为openGauss 2.0.0,并使用由墨天轮提供的线上环境。 ... [详细]
author-avatar
Cockroach小小强
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有