热门标签 | 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

推荐阅读
  • 探讨如何真正掌握Java EE,包括所需技能、工具和实践经验。资深软件教学总监李刚分享了对毕业生简历中常见问题的看法,并提供了详尽的标准。 ... [详细]
  • 作者:守望者1028链接:https:www.nowcoder.comdiscuss55353来源:牛客网面试高频题:校招过程中参考过牛客诸位大佬的面经,但是具体哪一块是参考谁的我 ... [详细]
  • PostgreSQL 10 离线安装指南
    本文详细介绍了如何在无法联网的服务器上进行 PostgreSQL 10 的离线安装,并涵盖了从下载安装包到配置远程访问的完整步骤。 ... [详细]
  • 本文探讨了在Windows Server 2008环境下配置Tomcat使用80端口时遇到的问题,包括端口被占用、多项目访问失败等,并提供详细的解决方法和配置建议。 ... [详细]
  • 通过Web界面管理Linux日志的解决方案
    本指南介绍了一种利用rsyslog、MariaDB和LogAnalyzer搭建集中式日志管理平台的方法,使用户可以通过Web界面查看和分析Linux系统的日志记录。此方案不仅适用于服务器环境,还提供了详细的步骤来确保系统的稳定性和安全性。 ... [详细]
  • 本文详细探讨了HTML表单中GET和POST请求的区别,包括它们的工作原理、数据传输方式、安全性及适用场景。同时,通过实例展示了如何在Servlet中处理这两种请求。 ... [详细]
  • 在现代Web应用中,当用户滚动到页面底部时,自动加载更多内容的功能变得越来越普遍。这种无刷新加载技术不仅提升了用户体验,还优化了页面性能。本文将探讨如何实现这一功能,并介绍一些实际应用案例。 ... [详细]
  • 探讨如何从数据库中按分组获取最大N条记录的方法,并分享新年祝福。本文提供多种解决方案,适用于不同数据库系统,如MySQL、Oracle等。 ... [详细]
  • 本文介绍如何在SQL Server中对Name列进行排序,使特定值(如Default Deliverable Submission Notification)显示在结果集的顶部。 ... [详细]
  • 在尝试用另一台电脑的MySQL文件替换本地D:\xampp\mysql目录后,MySQL服务无法启动。错误提示显示MySQL意外关闭,可能是由于端口冲突、依赖缺失、权限问题或崩溃等原因引起。 ... [详细]
  • SQL查询指定时间段内票数总和并按降序排列
    本文介绍如何使用SQL语句查询特定时间段内的票数总和,并按照票数从高到低进行排序。通过实际案例和详细解释,帮助读者理解SQL查询的实现方法。 ... [详细]
  • 20100423:Fixes:更新批处理,以兼容WIN7。第一次系统地玩QT,于是诞生了此预备式:【QT版本4.6.0&#x ... [详细]
  • 本文介绍了如何在C#应用程序中有效隐藏SQLCMD命令行窗口,确保程序运行时不会弹出黑色命令提示符窗口。 ... [详细]
  • 本题探讨了在一个有向图中,如何根据特定规则将城市划分为若干个区域,使得每个区域内的城市之间能够相互到达,并且划分的区域数量最少。题目提供了时间限制和内存限制,要求在给定的城市和道路信息下,计算出最少需要划分的区域数量。 ... [详细]
  • 本文介绍如何在华为CE交换机上配置M-LAG(多链路聚合组),以实现CE1和CE2设备作为VLAN 10网关的高可用性。通过详细的配置步骤,确保网络冗余和稳定性。 ... [详细]
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社区 版权所有