实战11g active data guard on rac

环境描述:
    OS:CentOS release 5.8(64bit)
    DB:Oracle 11.2.0.3(64bit)
    Storage:ASM
    本次试验涉及三个节点racnode1和racnode2(作为主库),dgnode1(备库),双节点rac已部署完毕,接下来的步骤都是演示如何在现有环境下添加一个单实例的standby database。

操作步骤:(步骤中没有明确说明的地方都是在备库上进行操作)
1.rac双节点已配置成功

2.配置standby dg
2.1配置内核参数
kernel.shmall = 4294967296
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1054472192
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
net.ipv4.tcp_wmem = 262144 262144 262144
net.ipv4.tcp_rmem = 4194304 4194304 4194304

2.2配置limit限制
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536

2.3创建目录
mkdir -p /u01/oracle
chown -R oracle:oinstall /u01/oracle
chmod -R 775 /u01/oracle
mkdir -p /u01/grid
mkdir -p /u01/11.2.0/grid
chown -R grid:oinstall /u01/grid
chmod -R 775 /u01/grid
chown -R grid:oinstall /u01/11.2.0/grid
chmod -R 775 /u01/11.2.0/grid
chown -R grid:oinstall oraInventory/
chmod -R 775 oraInventory/

2.4检查软件包
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
ksh \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
sysstat \
unixODBC \
unixODBC-devel

2.5规划asm磁盘
ocr+voting disk(1G)
data(6G)
flash(3G)

2.6安装配置asmlib并创建asm disk
操作省略,和rac上配置一致

2.7安装grid软件
这里需要注意的是在安装选项时选择standalone server

2.8安装oracle软件
在安装数据库类型时选择single instance database

2.9为创建standby database准备主库环境
2.9.1Enable Forced Logging
ALTER DATABASE FORCE LOGGING; 

2.9.2Configure Redo Transport Authentication
确保rac所有节点的密码文件中的密码一致并传输到standby端(文件名根据具体的sid做修改)

2.9.3Configure the Primary Database to Receive Redo Data(这步操作可选,主要是为了以后角色切换时起作用)
我这里暂时没配置

2.9.4Set Primary Database Initialization Parameters
Primary Role Initialization Parameters
DB_NAME=opdb
DB_UNIQUE_NAME=opdb
LOG_ARCHIVE_CONFIG='DG_CONFIG=(opdb,dgdb)'
LOG_ARCHIVE_DEST_2=
'SERVICE=dgdb ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=dgdb'
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc

Standby Role Initialization Parameters
FAL_SERVER=dgdb
DB_FILE_NAME_CONVERT='+DATA/dgdb','+DATA/opdb'
LOG_FILE_NAME_CONVERT='+DATA/dgdb','+DATA/opdb'
STANDBY_FILE_MANAGEMENT=AUTO

2.9.5Enable Archiving
srvctl stop database -d opdb
srvctl start database -d opdb -o mount
alter database archivelog
alter database open

3.Step-by-Step Instructions for Creating a Physical Standby Database
3.1创建primary database的全库备份集
run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
backup database format '/u01/oracle/stage/full_%U' plus archivelog format '/u01/oracle/stage/arch_%U';
release channel c1;
release channel c2;
release channel c3;
}

3.2Create a Control File for the Standby Database
ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/u01/oracle/stage/dgdb.ctl';

3.3Create a Parameter File for the Standby Database
3.3.1Create a parameter file (PFILE) from the server parameter file (SPFILE)
CREATE PFILE='/u01/oracle/stage/initdgdb.ora' FROM SPFILE;
3.3.2Modify the parameter values in the parameter file
DB_UNIQUE_NAME=dgdb
control_files='+DATA/dgdb/controlfile/dbdg.ctl'
DB_FILE_NAME_CONVERT='+DATA/opdb','+DATA/dgdb'
LOG_FILE_NAME_CONVERT='+DATA/opdb','+DATA/dgdb'
LOG_ARCHIVE_DEST_2=
'SERVICE=opdb ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=opdb'
FAL_SERVER=opdb

3.4Copy Files from the Primary System to the Standby System(pfile,backupset,controlfile)
scp * 10.1.101.168:/u01/oracle/stage

3.5Set Up the Environment to Support the Standby Database
3.5.1Copy the remote login password file to Standby Database system

3.5.2Configure listeners for the primary and standby databases(automatic on 11gr2)

3.5.3Create Oracle Net service names
 
3.5.4Create a server parameter file for the standby database
create spfile from pfile='/u01/oracle/stage/initdgdb.ora';

3.6Start the Physical Standby Database
3.6.1Start the physical standby database
startup mount

3.6.2Create an Online Redo Log on the Standby Database
alter database add standby logfile thread 1
    group 5 size 50M,
    group 6 size 50M,
    group 7 size 50M;
alter database add standby logfile thread 2
    group 5 size 50M,
    group 6 size 50M,
    group 7 size 50M;

3.6.3Restore standby database from backupset
restore database;

3.6.4Start Redo Apply.
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

3.7Verify the Physical Standby Database Is Performing Properly
3.7.1Identify the existing archived redo log files
SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SEQUENCE# FIRST_TIM NEXT_TIME
---------- --------- ---------
       228 21-MAR-13 21-MAR-13
       229 21-MAR-13 21-MAR-13
       230 21-MAR-13 21-MAR-13

3.7.2Force a log switch to archive the current online redo log file(主库操作)
ALTER SYSTEM SWITCH LOGFILE;

3.7.3Verify the new redo data was archived on the standby database
SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SEQUENCE# FIRST_TIM NEXT_TIME
---------- --------- ---------
       228 21-MAR-13 21-MAR-13
       229 21-MAR-13 21-MAR-13
       230 21-MAR-13 21-MAR-13
       231 21-MAR-13 21-MAR-13

3.7.4Verify that received redo has been applied
SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

 SEQUENCE# APPLIED
---------- ---------
       228 YES
       229 YES
       230 YES
       231 IN-MEMORY

3.8测试11g active data特性
3.8.1停止日志应用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

3.8.2打开物理备库
ALTER DATABASE OPEN;

3.8.3开启日志实时应用(此时数据库为open状态)
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;

3.8.4查询数据库当前状态
 select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY WITH APPLY 

3.8.5创建测试表并插入测试数据(主库)
create table tl(id int);

 begin
     for i in 1..1000 loop
     insert into tl values(i);
     end loop;
     commit;
     end;
    /
|
 select count(*) from tl;

  COUNT(*)
----------
      1000

3.8.6在备库验证数据
select count(*) from tl;

  COUNT(*)
----------
      1000

实验过程中在备库启动到mount状态时遇到了如下错误:
ERROR: asm_version error. err: driver/agent not installed rc:2
ORA-15183: ASMLIB initialization error [driver/agent not installed]
根据错误提示查询系统的内核版本和asmlib的版本是一致的,google后发现一篇类似帖子,解决方案就是修改oracle二进制程序的属组为asmadmin并保留其原有权限后问题解决,帖子的url为http://space.itpub.net/38267/viewspace-742110,在这里感谢这位哥们,呵呵!

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

转载于:http://blog.itpub.net/20801486/viewspace-756728/

你可能感兴趣的:(实战11g active data guard on rac)