ITPub博客

首页 > 数据库 > Oracle > RAC集群构建dataguard高可用(单机非ASM)

RAC集群构建dataguard高可用(单机非ASM)

Oracle 作者:ycl_jacky 时间:2012-02-09 20:28:31 0 删除 编辑

不使用ASM的Dataguard
本篇我们介绍给已经有的RAC集群架设单实例的Dataguard高可用,为了防止ASM问题扩散,单实例上不采用ASM技术。在本文的实验环境中,RAC集群的数据库名称为AUTHSERV,两个实例的名称分别为AUTHSERV1、AUTHSERV2,搭建的备份库的实例名为AUTHSERV,ASM磁盘组的名称为DATA1。
1.1 基本系统安装准备
请参见另外的文档安装(RAC构建文档)做好以下几件事情:
1. 安装rhel4操作系统
2. 配置oracle用户与操作系统参数调整
3. 配置好共享存储设备(在有共享存储的情况下)
4. 安装oracle10g database软件,并打上10.2.0.4补丁

1.2 启用数据库的force logging特性
在RAC集群的一个节点上执行下面操作:

停止集群数据库(后面配置dataguard过程中保持RAC为单例模式):
[oracle@rhel4n1 ~]$ srvctl stop database -d AUTHSERV

启动单实例并修改为force logging:
[oracle@rhel4n1 ~]$ sqlplus / as sysdba
SQL> startup
SQL> alter database force logging;

1.3 归档模式与flashback配置
由于修改归档模式要求只有一个实例并且只能把数据库启动到mount状态,首先停止集群数据库:
[oracle@rhel4n2 ~]$ srvctl stop database -d AUTHSERV
其中:
AUTHSERV为数据库名称。

在一个节点上启动数据库到mount状态:、
[oracle@rhel4n2 ~]$ sqlplus / as sysdba
SQL> startup mount

配置归档:
SQL> alter database archivelog;
SQL> alter system set log_archive_dest_1='location=+DATA1/AUTHSERV/ARCHIVELOG/allnodes' sid='AUTHSERV1';
SQL> alter system set log_archive_dest_1='location=+DATA1/AUTHSERV/ARCHIVELOG/allnodes ' sid='AUTHSERV2';
其中:
DATA1为ASM磁盘组名称, 归档文件名已经带了thread号,放到同目录就可以,方便管理。
AUTHSERV1、AUTHSERV2分别为两个实例名。

配置flashback:
SQL> alter database flashback on;
SQL> alter system set db_flashback_retention_target=120;

建立ASM中相应目录(在一个新SHELL窗口执行):
[oracle@rhel4n2 ~]$ export ORACLE_SID=+ASM1
[oracle@rhel4n2 ~]$ asmcmd –p
ASMCMD [+] > cd DATA1/AUTHSERV/
ASMCMD [+DATA1/AUTHSERV] > mkdir ARCHIVELOG
ASMCMD [+DATA1/AUTHSERV] > cd ARCHIVELOG
ASMCMD [+DATA1/AUTHSERV/ARCHIVELOG] > mkdir allnodes

重启数据库(单节点):
[oracle@rhel4n2 ~]$ srvctl stop database -d AUTHSERV
[oracle@rhel4n2 ~]$ sqlplus / as sysdba
SQL> startup mount

1.5 备机上建立相应目录
由于备机并没有创建实例,我们需要手工增加相应目录:
cd $ORACLE_BASE
mkdir -p oradata/AUTHSERV
mkdir -p flash_recovery_area

mkdir archivelog_for_AUTHSERV
mkdir standby_onlinelog_for_AUTHSERV
mkdir -p rman/backup
mkdir -p admin/AUTHSERV/bdump
mkdir admin/AUTHSERV/udump
mkdir admin/AUTHSERV/adump
mkdir admin/AUTHSERV/cdump


1.6 备机上配置listener
以oracle身份登录备机的图形界面,通过下面的命令来启动网络配置:
[oracle@rhel4std ~]$ netca

指定为listener配置:

RAC集群构建dataguard高可用(单机非ASM)

添加:


RAC集群构建dataguard高可用(单机非ASM)

并根据提示完成添加。

1.7 配置tnsname.ora
[oracle@rhel4n1 ~]$ cd /usr/oracle/product/10.2.0/db_1/network/admin/
vi tnsname.ora文件,根据RAC与备机的配置信息,确保三台机器上都有下面内容:
AUTHSERV_RAC =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.19)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.20)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVICE_NAME = AUTHSERV)
    )
  )

AUTHSERV_SINGLE =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.8)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = AUTHSERV)
    )
  )

1.8 修改主机配置参数
操作本步骤前,最好使用create pfile='/usr/oracle/pfile_bak.ora' from spfile;命令备份一下spfile。

先把RAC启动到单节点:
[oracle@ysdbrac1 ~]$ srvctl stop database -d AUTHSERV
[oracle@ysdbrac1 ~]$ sqlplus / as sysdba
SQL> startup

以sysdba身份登录oracle,执行下面SQL命令:

ALTER SYSTEM SET DB_UNIQUE_NAME=AUTHSERV_RAC scope=spfile;
alter system set service_names='AUTHSERV','AUTHSERV_RAC';
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(AUTHSERV_RAC, AUTHSERV_SINGLE)' scope=spfile;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=+DATA1/AUTHSERV /ARCHIVELOG/allnodes VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=AUTHSERV_RAC' scope=spfile;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2=' SERVICE=AUTHSERV_SINGLE LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=AUTHSERV_SINGLE';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=spfile;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=spfile;
ALTER SYSTEM SET FAL_CLIENT = AUTHSERV_RAC SCOPE=SPFILE;
ALTER SYSTEM SET FAL_SERVER = AUTHSERV_SINGLE SCOPE=SPFILE;
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT =AUTO SCOPE=SPFILE;
alter system set db_file_name_convert='/usr/oracle/oradata/AUTHSERV','+DATA1/AUTHSERV' SCOPE=SPFILE;
alter system set log_file_name_convert='/usr/oracle/oradata/AUTHSERV','+DATA1/AUTHSERV' SCOPE=SPFILE;
alter system set standby_file_management=’AUTO’;

重启主机数据库实例:
SQL> shutdown immediate
SQL> startup


1.9 主机上创建备份文件并拷贝到备机
主机建立rman备份目录:
cd $ORACLE_BASE
mkdir -p rman/backup
准备pfile文件:
SQL> create pfile='/usr/oracle/rman/backup/initAUTHSERV_SINGLE.ora' from spfile;

进入RMAN
[oracle@rhel4n1 admin]$ rman target /

准备数据库备份:
RMAN> backup database FORMAT '/usr/oracle/rman/backup/bk_%d_%T_%s';

准备归档日志备份:
RMAN> sql 'alter system switch logfile';
RMAN> sql 'alter system switch logfile';
RMAN> sql 'alter system switch logfile';
RMAN> backup archivelog all FORMAT '/usr/oracle/rman/backup/arc_%d_%T_%s';

准备控制文件:
RMAN> backup current controlfile for standby format '/usr/oracle/rman/backup/control_std.ctl';

把所有备份的文件拷贝至备机相同目录下。
1.10 备机上做standby准备
拷贝pfile到相应目录并重命名(备机的数据库名和实例名都为AUTHSERV):
[oracle@rhel4std backup]$ cd $ORACLE_HOME/dbs
[oracle@rhel4std dbs]$ cp /usr/oracle/rman/backup/initAUTHSERV_SINGLE.ora ./initAUTHSERV.ora

编辑initAUTHSERV.ora文件,删除以下集群相关的行:
AUTHSERV2.__db_cache_size=281018368
AUTHSERV1.__db_cache_size=281018368
AUTHSERV2.__java_pool_size=4194304
AUTHSERV1.__java_pool_size=4194304
AUTHSERV2.__large_pool_size=4194304
AUTHSERV1.__large_pool_size=4194304
AUTHSERV2.__shared_pool_size=155189248
AUTHSERV1.__shared_pool_size=155189248
AUTHSERV2.__streams_pool_size=0
AUTHSERV1.__streams_pool_size=0
*.cluster_database_instances=2
*.cluster_database=true
AUTHSERV2.instance_number=2
AUTHSERV1.instance_number=1
AUTHSERV1.log_archive_dest_1='location=+DATA1/AUTHSERV/ARCHIVELOG/allnodes'
AUTHSERV2.log_archive_dest_1='location=+DATA1/AUTHSERV/ARCHIVELOG/allnodes '
AUTHSERV2.thread=2
AUTHSERV1.thread=1
AUTHSERV1.undo_tablespace='UNDOTBS1'
AUTHSERV2.undo_tablespace='UNDOTBS2'
*.remote_listener='LISTENERS_AUTHSERV'

加上下面的行:
*.db_cache_size=281018368
*.java_pool_size=4194304
*.large_pool_size=4194304
*.shared_pool_size=155189248
*.streams_pool_size=0
*.undo_tablespace='UNDOTBS1'
*.db_file_name_convert='+DATA1/AUTHSERV/datafile','/usr/oracle/oradata/AUTHSERV', '+DATA1/AUTHSERV/tempfile','/usr/oracle/oradata/AUTHSERV'
*.log_file_name_convert='+DATA1/AUTHSERV/onlinelog','/usr/oracle/oradata/AUTHSERV'
*.standby_file_management='AUTO'
修改下面的行(主备机配置反过来):
*.service_names='AUTHSERV',’AUTHSERV_SINGLE’;
*.control_files='/usr/oracle/oradata/AUTHSERV/control01.ctl','/usr/oracle/oradata/AUTHSERV/control02.ctl'
*.db_create_file_dest='/usr/oracle/oradata/AUTHSERV'
*.db_recovery_file_dest='/usr/oracle/flash_recovery_area'
*.db_unique_name='AUTHSERV_SINGLE'
*.fal_client='AUTHSERV_SINGLE'
*.fal_server='AUTHSERV_RAC'
*.log_archive_dest_1='LOCATION=/usr/oracle/archivelog_for_AUTHSERV VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=AUTHSERV_SINGLE'
*.log_archive_dest_2='SERVICE=AUTHSERV_RAC LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=AUTHSERV_RAC'


创建密码文件:
cd $ORACLE_HOME/dbs
orapwd file=orapwAUTHSERV password=kingdee entries=4

创建spfile文件:
[oracle@rhel4std dbs]$ sqlplus / as sysdba
SQL> create spfile from pfile;

启动到nomount状态:
SQL> startup nomount

恢复备份的控制文件:
rman target /
RMAN> restore controlfile from '/usr/oracle/rman/backup/control_std.ctl';

启动数据库到mount状态:
RMAN> alter database mount;
1.11 配置备机的standby
还原数据库文件:
RMAN> restore database;

恢复数据库:
RMAN> recover database;
最后会报错找不到一个归档文件,因为该归档文件在备份时还没有产生,忽略该信息。

创建standbylog:
SQL> alter database add standby logfile group 11 ('/usr/oracle/standby_onlinelog_for_AUTHSERV/standby11.log') size 50m;
SQL> alter database add standby logfile group 12 ('/usr/oracle/standby_onlinelog_for_AUTHSERV/standby12.log') size 50m;
SQL> alter database add standby logfile group 13 ('/usr/oracle/standby_onlinelog_for_AUTHSERV/standby13.log') size 50m;
SQL> alter database add standby logfile group 14 ('/usr/oracle/standby_onlinelog_for_AUTHSERV/standby14.log') size 50m;
SQL> alter database add standby logfile group 15 ('/usr/oracle/standby_onlinelog_for_AUTHSERV/standby15.log') size 50m;
SQL> alter database add standby logfile group 16 ('/usr/oracle/standby_onlinelog_for_AUTHSERV/standby16.log') size 50m;

最后通过参数“using current logfile”来启动物理standby的实时应用:
alter database recover managed standby database using current logfile disconnect from session;

1.12 switchover测试
Switchover必须在RAC只启动一个节点的情况下进行。
首先在主节点进行下面操作:
SQL> alter database commit to switchover to physical standby with session shutdown;
SQL> shutdown immediate
SQL> startup mount

然后在备机上进行下面操作:
SQL> alter database commit to switchover to primary;
SQL> shutdown immediate
SQL> startup

在RAC第一次切换为备机时需要先建立standby logfile:
export ORACLE_SID=+ASM1
ASMCMD [+] > mkdir DATA1/authserv/standbylog

export ORACLE_SID=AUTHSERV1
[oracle@ysdbrac1 ~]$ sqlplus / as sysdba
SQL> alter database add standby logfile group 11 ('+DATA1/authserv/standbylog/standby11.log') size 50m;
SQL> alter database add standby logfile group 12 ('+DATA1/authserv/standbylog/standby12.log') size 50m;
SQL> alter database add standby logfile group 13 ('+DATA1/authserv/standbylog/standby13.log') size 50m;
SQL> alter database add standby logfile group 14 ('+DATA1/authserv/standbylog/standby14.log') size 50m;
SQL> alter database add standby logfile group 15 ('+DATA1/authserv/standbylog/standby15.log') size 50m;
SQL> alter database add standby logfile group 16 ('+DATA1/authserv/standbylog/standby16.log') size 50m;

最后在备机上启动重做日志应用:
SQL> alter database recover managed standby database using current logfile disconnect from session;

 

<!-- 正文结束 -->

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

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2009-09-16