ORACLE10g R2【RAC+ASM→单实例FS】

ORACLE10g R2【RAC+ASM→单实例FS】

10g R2 RAC+ASMà单实例FS的DG,建议禁用OMF.

本演示案例所用环境:


 


primary


standby


OS Hostname


node1,node2


std


OS Version


RHEL5.8


RHEL5.8


DB Version


10.2.0.5


10.2.0.5


db_name


stephen


stephen


db_unique_name


stephen


standby


service_names


stephen


standby


instance_name


stephen1,stephen2


standby

Primary database configure

1.启用primary force logging

SQL> select force_logging from v$database;

SQL> alter database force logging;

2.配置redo传输认证

(1) tnsnames.ora

STEPHEN =

(DESCRIPTION =

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

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

(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = stephen))

)

STANDBY =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = standby)

)

)

 

(2) tnsping命令解析网络服务名,命令须返回OK.

此时,standby端未配置监听,无法解析,可以standby配置后再测试。

$ tnsping standby

 

(3) 密码文件

若无密码文件,则在一个节点创建密码文件并拷贝至其余节点。格式:orapw<ORACLE_SID>

cd $ORACLE_HOME/dbs

orapwd file=orapwstephen1 password=oracle force=y

scp orapwstephen1 node2:$ORACLE_HOME/dbs/orapwstephen2

3.添加standby logfiles

添加standby logfile 的要求:

(1) 确保主和备数据库上的日志文件大小是相同的

(2) 确定备库重做日志文件组的适当数目

Standby logfile数 = (每个线程的logfile数+1)* 线程数

(3) 检查create database时指定的MAXLOGFILES和MAXLOGMEMBERS参数,可以通过trace controlfile出来查看

(4) RAC环境创建standby logfile,指定thread#创建

每个thread的standby logfile数 = 每个thread的logfile数 + 1

检查当前环境的logfile:

set lines 200 pages 300

col member for a60

select a.thread#,a.group#,b.member,b.type,a.bytes/1024/1024 MB from v$log a,v$logfile b where a.group#=b.group#

union all

select a.thread#,a.group#,b.member,b.type,a.bytes/1024/1024 MB from v$standby_log a,v$logfile b where a.group#=b.group#;

根据查询的logfile 信息上文添加standby logfile的要求,添加合理的standby logfile,然后用上面的sql再次查看当前环境的logfile:

alter database add standby logfile thread 1

group 5 ‘+DATA/stephen/onlinelog/standby05.log‘ size 50M,

group 6 ‘+DATA/stephen/onlinelog/standby06.log‘ size 50M,

group 7 ‘+DATA/stephen/onlinelog/standby07.log‘ size 50M;

alter database add standby logfile thread 2

group 8 ‘+DATA/stephen/onlinelog/standby08.log‘ size 50M,

group 9 ‘+DATA/stephen/onlinelog/standby09.log‘ size 50M,

group 10 ‘+DATA/stephen/onlinelog/standby10.log‘ size 50M;

4.修改primary参数文件

备份spfile:

create pfile=‘/tmp/pfile.bak‘ from spfile;

修改以下参数,其中stephen,standby分别为primary,standby的db_unqiue_name/TNS-Alias,详见参数详解部分:

alter system set log_archive_config=‘dg_config=(stephen,standby)‘ sid=‘*‘;

alter system set log_archive_dest_1=‘location=+DATA/stephen/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=stephen‘ sid=‘*‘;

alter system set log_archive_dest_2=‘service=standby lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=standby‘ sid=‘*‘;

alter system set log_archive_max_processes=30 sid=‘*‘; #根据需求调整个数

 

--确认以下参数是否为默认值,如不是则修改:

alter system set remote_login_passwordfile=exclusive scope=spfile sid=‘*‘;

 # remote_login_passwordfile=exclusive/shared

alter system set log_archive_dest_state_1=enable sid=‘*‘;

alter system set log_archive_dest_state_2=enable sid=‘*‘;

--可修改归档日志格式,与datafile作区分:

alter system set log_archive_format=‘%t_%s_%r.arc‘ scope=spfile sid=‘*‘;

--备角色参数:

alter system set fal_server=standby sid=‘*‘;

alter system set fal_client=stephen sid=‘*‘;

alter system set standby_file_management=auto sid=‘*‘;

alter system set db_file_name_convert=‘/oradata/standby‘,‘+DATA/stephen/datafile‘ scope=spfile sid=‘*‘;

alter system set log_file_name_convert=‘/oradata/standby‘,‘+DATA/stephen/onlinelog‘ scope=spfile sid=‘*‘;

#如不采用OMF,可禁用OMF:

alter system reset db_create_file_dest sid=‘*‘;

alter system reset db_create_online_log_dest_n sid=‘*‘; #n为数值变量

alter system reset db_recovery_file_dest sid=‘*‘;

指定spfile修改的参数,重启实例后生效。

5.打开归档模式

首先确认当前数据库是否是归档模式,如果不是,则打开归档模式。

archive log list;

shutdown immediate;

startup mount;

alter database archivelog;

alter database open;

6.备份primary database

rman target / <<EOF

run{allocate channel c1 type disk;

allocate channel c2 type disk;

backup full database format ‘/backup/full_%T_%U.bak‘ plus archivelog;

sql ‘alter system switch logfile‘;

backup current controlfile for standby format ‘/backup/c_%T_%U.bak‘;

release channel c1;

release channel c2;

}

EOF

Standby database configure

1.配置环境变量

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/10.2/db_1

export ORACLE_SID=standby

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib #不同平台变量名不一样

2.配置redo传输认证

(1) listener.ora

配置静态监听:

LISTENER =

(ADDRESS_LIST=

(ADDRESS=(PROTOCOL=tcp)(HOST=std)(PORT=1521))

)

SID_LIST_LISTENER=

(SID_LIST=

(SID_DESC=

(GLOBAL_DBNAME=standby)

(SID_NAME=standby)

(ORACLE_HOME=/u01/app/oracle/product/10.2/db_1)

)

)

 

启用监听:

lsnrctl start

lsnrctl status

 

(2) tnsnames.ora

STEPHEN =

(DESCRIPTION =

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

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = stephen)

)

)

STANDBY =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = standby)

)

)

 

(3) tnsping命令解析网络服务名,命令须返回OK.

$ tnsping stephen

...

OK (0 msec)

 

(4) 密码文件

使用主库的密码文件:

scp node1:$ORACLE_HOME/dbs/orapwstephen1 $ORACLE_HOME/dbs/orapwstandby

3.创建相关目录

mkdir -p $ORACLE_BASE/admin/standby/{adump,bdump,cdump,dpdump,pfile,udump,hdump}

mkdir -p /oradata/{standby,arch}

4.参数文件

用primary的pfile加以修改,以保证某些参数与primary保持一致,注意主备库内存的大小适当的调整内存相关参数。

scp node1:/tmp/pfile.bak $ORACLE_HOME/dbs/initstandby.ora

修改pfile为需要的standby pfile,并创建spfile.特别注意以下事例的参数设定:

*.audit_file_dest=‘/u01/app/oracle/admin/standby/adump‘

*.background_dump_dest=‘/u01/app/oracle/admin/standby/bdump‘

*.core_dump_dest=‘/u01/app/oracle/admin/standby/cdump‘

*.user_dump_dest=‘/u01/app/oracle/admin/standby/udump‘

*.control_files=‘/oradata/standby/control01.ctl‘

*.cluster_database=false

*.instance_number=1

*.local_listener=‘(ADDRESS=(PROTOCOL=tcp)(HOST=std)(PORT=1521))‘

*.thread=1

*.undo_management=‘AUTO‘

*.undo_tablespace=‘UNDOTBS1‘

*.db_name=‘stephen‘

*.db_unique_name=‘standby‘

*.instance_name=‘standby‘

*.service_names=‘standby‘

*.fal_client=‘standby‘

*.fal_server=‘stephen‘

*.log_archive_config=‘dg_config=(standby,stephen)‘

*.log_archive_dest_1=‘location=/oradata/arch valid_for=(all_logfiles,all_roles) db_unique_name=standby‘

*.log_archive_dest_2=‘service=stephen lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=stephen‘

*.log_archive_dest_state_1=‘enable‘

*.log_archive_dest_state_2=‘enable‘

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

*.log_archive_max_processes=30  #根据需求调整个数

*.remote_login_passwordfile=‘exclusive‘ #exclusive/shared

*.standby_file_management=‘AUTO‘

*.db_file_name_convert=‘+DATA/STEPHEN/DATAFILE‘,‘/oradata/standby‘

*.log_file_name_convert=‘+DATA/STEPHEN/ONLINELOG‘,‘/oradata/standby‘

 

取消以下参数设定:

#*.cluster_database_instances

#*.remote_listener

 

#如不采用,可不设置以下参数禁用OMF:

#*.db_create_file_dest

#*.db_create_online_log_dest_n  #n为数值变量

#*.db_recovery_file_dest

创建spfile:

create spfile from pfile;

5.恢复standby controlfile

SQL> startup nomount;

RMAN> restore standby controlfile from ‘/backup/c_2bqlin2h_1_1.bak‘;

6.恢复数据文件

查询primary database的数据文件信息:

set lines 300 pages 300

col name for a60

col member for a60

select file#,name from v$datafile

union all

select file#,name from v$tempfile;

启动standby到mount阶段,恢复数据文件:

RMAN> sql ‘alter database mount standby database‘;

run{

set newname for datafile 1 to ‘/oradata/standby/system01.dbf‘;

set newname for datafile 2 to ‘/oradata/standby/undotbs1.dbf‘;

set newname for datafile 3 to ‘/oradata/standby/sysaux01.dbf‘;

set newname for datafile 4 to ‘/oradata/standby/undotbs2.dbf‘;

set newname for datafile 5 to ‘/oradata/standby/users01.dbf‘;

set newname for tempfile 1 to ‘/oradata/standby/temp01.dbf‘;

restore database;

switch datafile all;

switch tempfile all;

recover database;

}

查看standby database log file:

set lines 200 pages 300

col member for a60

select a.thread#,a.group#,b.member,b.type,a.bytes/1024/1024 MB

from v$log a,v$logfile b where a.group#=b.group#

union all

select a.thread#,a.group#,b.member,b.type,a.bytes/1024/1024 MB

from v$standby_log a,v$logfile b where a.group#=b.group#;

7.应用日志

应用archive log:

recover managed standby database disconnect;

实时应用redo logfile:

recover managed standby database using current logfile disconnect;

取消应用日志:

recover managed standby database cancel;

8.观察日志传输

跟踪primary,standby database的alert log,观察是否有错误发生,也可以看到应用日志的相关信息。

确认standby是否应用日志:

--primary端多切几次日志,观察alert log信息。

alter system switch logfile;

alter system switch logfile;

--观察主备库日志序列号

archive log list;

--primary端查询v$archived_log视图,确认日志是否被应用:

set lines 300 pages 300

col name for a20

select name,dest_id,thread#,sequence#,standby_dest,applied,registrar,completion_time from v$archived_log

where standby_dest=‘YES‘

order by thread#,sequence#;

--primary端查询primary,standby的最大日志序列号是否一致:

select ‘Primary :‘ "DB Role",thread#,max(sequence#)

from v$archived_log

where standby_dest=‘NO‘

group by thread#

union

select ‘Standby :‘ "DB Role",thread#,max(sequence#)

from v$archived_log

where standby_dest=‘YES‘ and applied=‘YES‘

group by thread#

order by thread#;

时间: 2024-10-06 11:04:37

ORACLE10g R2【RAC+ASM→单实例FS】的相关文章

ORACLE11g R2【RAC+ASM→单实例FS】

ORACLE11g R2[RAC+ASM→单实例FS] 11g R2 RAC+ASMà单实例FS的DG,建议禁用OMF. 本演示案例所用环境:   primary standby OS Hostname node1,node2 std OS Version RHEL6.5 RHEL6.5 DB Version 11.2.0.4 11.2.0.4 db_name stephen stephen db_unique_name stephen standby service_names stephen

ORACLE10g R2【单实例 FS→单实例FS】

ORACLE10g R2[单实例FS→单实例FS] 本演示案例所用环境:   primary standby OS Hostname pry std OS Version RHEL5.8 RHEL5.8 DB Version 10.2.0.5 10.2.0.5 db_name stephen stephen db_unique_name stephen standby service_names stephen standby instance_name stephen standby Prim

ORACLE11g R2【单实例 FS→单实例FS】

ORACLE11g R2[单实例 FS→单实例FS] 本演示案例所用环境:   primary standby OS Hostname pry std OS Version RHEL6.5 RHEL6.5 DB Version 11.2.0.4 11.2.0.4 db_name stephen stephen db_unique_name stephen standby service_names stephen standby instance_name stephen standby Pri

Oracle 11g RAC到单实例ASM的物理Standby搭建

一.DG环境配置 此次搭建Standby的主库为:" RedHat 6.5+11G+RAC+ASM安装与配置(三节点)",11g单实例ASM安装使用ASMLib的方式,不在使用UDEV方式,磁盘为本机磁盘,非远程挂载的磁盘.本次搭建包含了11g单实例ASM的详细安装过程. 1. 基本环境 主库: 实例名:racdb1,racdb2,racdb3        DB_NAME:racdb              DB_UNIQUE_NAME:racdb 备库: 实例名:racdg  

Oracle_lhr_CentOS 7.3 ECS上搭建RAC 18c+单实例DG+EMCC+DG

Oracle_lhr_CentOS 7.3 ECS上搭建RAC 18c+单实例DG+EMCC+DG的FSFO快速故障转移配置 [大型连续免费公开课]Oracle 18c rac+dg+13.3的emcc部署配置(2018年最后一次免费公开课) 报名连接:https://ke.qq.com/course/315575 讲师:小麦苗 预计课时:6课时 开课时间:11月9日20点 相关软件下载地址:https://share.weiyun.com/57HUxNi 听课福利: 1.获得讲课文档pdf和课

11g ASM单实例 dbca报错 prcr-1006 crs-0259 prcr-1071

11g ASM dbca报错 prcr-1006 crs-0259  prcr-1071 使用ASM方式创建单实例DB时,在运行DBCA时出现 PRCR-1006 : Failed to add resource ora.orcl.db for orcl PRCR-1071 : Failed to register or update resource ora.orcl.db PRCR-1001 : Resource ora.orcl.db does not exist 查看DBCA日志后,发现

oracle rac与单实例dg 切换测试

rac与单实例dg 切换测试 一.环境概述 1.环境 orace rac&单实例dg os: centos 5.8 64位 oracle: 10.2.0.4 2.dg同步状态 rac1: dg: dg现已同步状态 3.归档情况 rac dg: 二.rac切备,dg切主,切换测试 1.rac1&rac2 手工切归档 rac1: alter system switch logfile;执行两次 两次间隔30s rac2: alter system switch logfile;执行两次 两次间

搭建rac对单实例的MAA

一:实验环境 系统:redhat 4 三台计算机rac1,rac2,dg. --其中rac为主库,单实例为备库 已在虚拟机里搭建好集群环境(rac1,rac2); dg计算机里没有建任何数据库(只安装了Oracle软件). 二:实验步骤 单实例环境部署请参考文档‘Linux下安装Oracle 10g(redhat 4)’. 3.1:enable forced logging --将主库设为强制归档 SQL> select force_logging from v$database; FOR --

Goldengate 部署oracle10g在 rac asm环境,完整教程

前言 Goldengate再rac 环境部署,和单机部署区别还是有点大,主要存在环境上. 环境 oracle10g ,sid=rac 准备工作 1.在rac节点,配置监听动态注册,确保goldengate用户能够连接实例.安装部分分为源端和目标端 节点一配置: [[email protected] admin]$ cat listener.ora # listener.ora.rac1 Network Configuration File: /opt/oracle/102/db_1/networ