操作系统版本:IBM aix 6.2
数据库版本:11.2.0.4
软件运行架构:
主库为一个两节点的rac,备库也是一个两节点的rac,但备库只用于接收归档日志,不创建数据文件,不用于数据同步,用于接收来之主库的归档,以供ogg的日志挖取,并且准备在备库上架设一套ogg
ha环境;其中镜像用于存放归档的文件系统为ocfs文件系统;并且用于安装ogg软件;
简要操作步骤:
一、dg环境的搭建;
1、 强制归档:alter database force logging;
2、 创建备份的控制文件;
3、 更改主库初始化参数文件;
*.log_archive_config=‘DG_CONFIG=(shestate,racdg,archnw)‘
*.log_archive_dest_1=‘LOCATION=+ARCHVALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=shestate‘
*.log_archive_dest_2=‘SERVICE=racdgASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdg‘
*.log_archive_dest_3=‘SERVICE=archnw ARCH ASYNCVALID_FOR=(ALL_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=archnw‘
*.log_archive_dest_state_2=‘enable‘
*.log_archive_dest_state_3=‘enable‘
备库初始化参数文件内容:
*.audit_file_dest=‘/u01/app/oracle/admin/shestate/adump‘
*.audit_trail=‘db‘
*.cluster_database=true
*.compatible=‘11.2.0.4.0‘
*.control_files=‘/archnw/archlog/scontrol01.ctl‘,‘/archnw/archlog/scontrol02.ctl‘
*.db_block_size=8192
*.db_create_file_dest=‘/archnw/archlog/‘
*.db_domain=‘‘
*.db_name=‘shestate‘
*.db_unique_name=‘archnw‘
*.diagnostic_dest=‘/u01/app/oracle‘
*.dispatchers=‘(PROTOCOL=TCP)(SERVICE=racXDB)‘
archnw1.instance_number=1
archnw2.instance_number=2
*.log_archive_config=‘DG_CONFIG=(archnw,racdg,shestate)‘
*.log_archive_dest_1=‘LOCATION=/archnw/archlogVALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=archnw‘
*.log_archive_dest_2=‘SERVICE=racdgASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdg‘
*.log_archive_dest_3=‘SERVICE=shestate ARCH ASYNCVALID_FOR=(ALL_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=shestate‘
*.log_archive_dest_state_2=‘enable‘
*.log_archive_dest_state_3=‘enable‘
*.log_archive_format=‘%t_%s_%r.dbf‘
*.open_cursors=300
*.pga_aggregate_target=1284901888
*.processes=500
*.remote_listener=‘logrecv-cluster-scan:1521‘
*.remote_login_passwordfile=‘exclusive‘
*.sga_target=5654705664
archnw2.thread=2
archnw1.thread=1
archnw1.undo_tablespace=‘UNDOTBS1‘
archnw2.undo_tablespace=‘UNDOTBS2‘
4、 创建备库初始化参数文件中的aduit目录:(两节点均执行)
mkdir -p/u01/app/oracle/admin/shestate/adump
5、 更改两节点的oracle的配置文件.profile;
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.
export PATH
if [ -s"$MAIL" ] # This isat Shell startup. In normal
then echo"$MAILMSG" # operation,the Shell checks
fi # periodically.
#---------------------------------------------------
#---------------------------------------------------
# .profile
#---------------------------------------------------
# OS User: oracle
#Application: Oracle Database SoftwareOwner
# Version: Oracle 11g release 2
#---------------------------------------------------
if [ -s"$MAIL" ] # This isat Shell startup. In normal
then echo"$MAILMSG" # operation,the Shell checks
fi # periodically.
#---------------------------------------------------
# ORACLE_SID
#---------------------------------------------------
# Specifies theOracle system identifier (SID) for
# the Oracleinstance running on this node.
# Each RAC nodemust have a unique ORACLE_SID.
# (i.e. rac1,rac2,...)
#---------------------------------------------------
ORACLE_SID=archnw1;export ORACLE_SID
#---------------------------------------------------
# ORACLE_UNQNAME
#---------------------------------------------------
# In previousreleases of Oracle Database, you were
# required toset environment variables for
# ORACLE_HOMEand ORACLE_SID to start, stop, and
# check thestatus of Enterprise Manager. With
# OracleDatabase 11g release 2 (11.2) and later, you
# need to setthe environment variables ORACLE_HOME
# andORACLE_UNQNAME to use Enterprise Manager.
# SetORACLE_UNQNAME equal to the database unique
# name.
#---------------------------------------------------
ORACLE_UNQNAME=archnw;export ORACLE_UNQNAME
#---------------------------------------------------
# ORACLE_BASE
#---------------------------------------------------
# Specifies thebase of the Oracle directory structure
# for OptimalFlexible Architecture (OFA) compliant
# databasesoftware installations.
#---------------------------------------------------
ORACLE_BASE=/u01/app/oracle;export ORACLE_BASE
#---------------------------------------------------
# ORACLE_HOME
#---------------------------------------------------
# Specifies thedirectory containing the Oracle
# Databasesoftware.
#---------------------------------------------------
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1;export ORACLE_HOME
exportGGS_HOME=/archnw/archlog/ggs
#---------------------------------------------------
# ORACLE_TERM
#---------------------------------------------------
# Defines aterminal definition. If not set, it
# defaults tothe value of your TERM environment
# variable. Usedby all character mode products.
#---------------------------------------------------
ORACLE_TERM=xterm;export ORACLE_TERM
#---------------------------------------------------
#NLS_DATE_FORMAT
#---------------------------------------------------
# Specifies thedefault date format to use with the
# TO_CHAR andTO_DATE functions. The default value of
# this parameteris determined by NLS_TERRITORY. The
# value of thisparameter can be any valid date
# format mask,and the value must be surrounded by
# doublequotation marks. For example:
#
# NLS_DATE_FORMAT ="MM/DD/YYYY"
#
#---------------------------------------------------
NLS_DATE_FORMAT="DD-MON-YYYYHH24:MI:SS"; export NLS_DATE_FORMAT
#---------------------------------------------------
# TNS_ADMIN
#---------------------------------------------------
# Specifies thedirectory containing the Oracle Net
# Servicesconfiguration files like listener.ora,
# tnsnames.ora,and sqlnet.ora.
#---------------------------------------------------
TNS_ADMIN=$ORACLE_HOME/network/admin;export TNS_ADMIN
#---------------------------------------------------
# ORA_NLS11
#---------------------------------------------------
# Specifies thedirectory where the language,
# territory,character set, and linguistic definition
# files arestored.
#---------------------------------------------------
ORA_NLS11=$ORACLE_HOME/nls/data;export ORA_NLS11
#---------------------------------------------------
# PATH
#---------------------------------------------------
# Used by theshell to locate executable programs;
# must includethe $ORACLE_HOME/bin directory.
#---------------------------------------------------
PATH=/etc:/usr/sbin:/usr/ucb:$HOME/bin:/sbin:.
PATH=${PATH}:$ORACLE_HOME/bin
PATH=${PATH}:/bin:/usr/bin/X11:/usr/local/bin
PATH=${PATH}:/u01/app/common/oracle/bin
export PATH
#---------------------------------------------------
#LD_LIBRARY_PATH
#---------------------------------------------------
# Specifies thelist of directories that the shared
# library loadersearches to locate shared object
# libraries atruntime.
#---------------------------------------------------
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
exportLD_LIBRARY_PATH
exportORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
#---------------------------------------------------
# CLASSPATH
#---------------------------------------------------
# Specifies thedirectory or list of directories that
# containcompiled Java classes.
#---------------------------------------------------
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
#---------------------------------------------------
# THREADS_FLAG
#---------------------------------------------------
# All the toolsin the JDK use green threads as a
# default. Tospecify that native threads should be
# used, set theTHREADS_FLAG environment variable to
#"native". You can revert to the use of green
# threads bysetting THREADS_FLAG to the value
#"green".
#---------------------------------------------------
THREADS_FLAG=native;export THREADS_FLAG
#---------------------------------------------------
# TEMP, TMP, andTMPDIR
#---------------------------------------------------
# Specify thedefault directories for temporary
# files; if set,tools that create temporary files
# create them inone of these directories.
#---------------------------------------------------
export TEMP=/tmp
exportTMPDIR=/tmp
#---------------------------------------------------
# UMASK
#---------------------------------------------------
# Set the defaultfile mode creation mask
# (umask) to 022to ensure that the user performing
# the Oraclesoftware installation creates files
# with 644permissions.
#---------------------------------------------------
umask 022
exportDSMI_DIR=/usr/tivoli/tsm/client/api/bin64
exportDSMI_CONFIG=/usr/tivoli/tsm/client/api/bin64/dsm.opt.inter
exportDSMI_LOG=/usr/tivoli/tsm/client/log
6、 创建SPFILE;
$ sqlplus ‘/assysdba‘
SQL*Plus:Release 11.2.0.4.0 Production on Thu May 29 11:26:11 2014
Copyright (c)1982, 2013, Oracle. All rights reserved.
Connected to anidle instance.
SQL> createspfile=‘/archnw/archlog/spfilearchnw.ora‘ from pfile=‘/home/oracle/pfile.ora‘;
File created.
7、 恢复控制文件;
$ rman target /
RecoveryManager: Release 11.2.0.4.0 - Production on Thu May 29 11:29:32 2014
Copyright (c)1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected totarget database: SHESTATE (not mounted)
RMAN> restorestandby controlfile from ‘/home/oracle/scontrol.ctl‘;
Starting restoreat 29-MAY-2014 11:30:15
using targetdatabase control file instead of recovery catalog
allocatedchannel: ORA_DISK_1
channelORA_DISK_1: SID=2 instance=archnw1 device type=DISK
channelORA_DISK_1: copied control file copy
output filename=/archnw/archlog/scontrol01.ctl
output file name=/archnw/archlog/scontrol02.ctl
Finished restoreat 29-MAY-2014 11:30:19
8、 mount数据库;
$ sqlplus ‘/assysdba‘
SQL*Plus:Release 11.2.0.4.0 Production on Thu May 29 11:31:10 2014
Copyright (c)1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With thePartitioning, Real Application Clusters, OLAP, Data Mining
and RealApplication Testing options
SQL> selectinstance_name,status from gv$instance;
INSTANCE_NAME STATUS
----------------------------
archnw1 STARTED
SQL> alterdatabase mount;t
Databasealtered.
SQL> selectinstance_name,status from gv$instance;
INSTANCE_NAME STATUS
----------------------------
archnw1 MOUNTED
SQL> selectname,open_mode,database_role from v$database;
NAME OPEN_MODE DATABASE_ROLE
----------------------------- ----------------
SHESTATE MOUNTED PHYSICAL STANDBY
9、 启动第二个节点的实例;
$ sqlplus ‘/assysdba‘
SQL*Plus:Release 11.2.0.4.0 Production on Thu May 29 11:32:56 2014
Copyright (c)1982, 2013, Oracle. All rights reserved.
Connected to anidle instance.
SQL> startupmount;
ORACLE instancestarted.
Total SystemGlobal Area 5645373440 bytes
Fixed Size 2256504 bytes
VariableSize 1291846024 bytes
DatabaseBuffers 4345298944 bytes
RedoBuffers 5971968 bytes
Databasemounted.
10、 再次查看数据库实例状态;
SQL> selectinstance_name,status from gv$instance;
INSTANCE_NAME STATUS
----------------------------
archnw1 MOUNTED
archnw2 MOUNTED
SQL> selectname,open_mode,database_role from v$database;
NAME OPEN_MODE DATABASE_ROLE
----------------------------- ----------------
SHESTATE MOUNTED PHYSICAL STANDBY
11、 将数据库及其对应的实例加入到集群中;
srvctl adddatabase -d archnw -n shestate -r PHYSICAL_STANDBY -s MOUNT -o/u01/app/oracle/product/11.2.0/dbhome_1 -c RAC -p/archnw/archlog/spfilearchnw.ora -y AUTOMATIC
srvctl addinstance -d archnw -i archnw1 -n logrecv1
srvctl addinstance -d archnw -i archnw2 -n logrecv2
12、 查看添加的数据库及其实例资源状态;
$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.ARCHNW.dg ora....up.type ONLINE ONLINE logrecv1
ora.ARCHWW.dg ora....up.type ONLINE ONLINE logrecv1
ora.CRS.dg ora....up.type ONLINE ONLINE logrecv1
ora....ER.lsnrora....er.type ONLINE ONLINE logrecv1
ora....N1.lsnrora....er.type ONLINE ONLINE logrecv2
ora....N2.lsnrora....er.type ONLINE ONLINE logrecv1
ora....N3.lsnrora....er.type ONLINE ONLINE logrecv1
ora.archnw.db ora....se.type OFFLINE OFFLINE
ora.asm ora.asm.type ONLINE ONLINE logrecv1
ora.cvu ora.cvu.type ONLINE ONLINE logrecv1
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....SM1.asmapplication ONLINE ONLINE logrecv1
ora....V1.lsnrapplication ONLINE ONLINE logrecv1
ora....cv1.gsdapplication OFFLINE OFFLINE
ora....cv1.onsapplication ONLINE ONLINE logrecv1
ora....cv1.vipora....t1.type ONLINE ONLINE logrecv1
ora....SM2.asmapplication ONLINE ONLINE logrecv2
ora....V2.lsnrapplication ONLINE ONLINE logrecv2
ora....cv2.gsdapplication OFFLINE OFFLINE
ora....cv2.onsapplication ONLINE ONLINE logrecv2
ora....cv2.vipora....t1.type ONLINE ONLINE logrecv2
ora....networkora....rk.type ONLINE ONLINE logrecv1
ora.oc4j ora.oc4j.type ONLINE ONLINE logrecv1
ora.ons ora.ons.type ONLINE ONLINE logrecv1
ora....ry.acfsora....fs.type ONLINE ONLINE logrecv1
ora.scan1.vip ora....ip.type ONLINE ONLINE logrecv2
ora.scan2.vip ora....ip.type ONLINE ONLINE logrecv1
ora.scan3.vip ora....ip.type ONLINE ONLINE logrecv1
13、 采用集群方式启动数据库;grid用户;
$ srvctl startdatabase -d archnw
$
$
$
$ srvctl statusdatabase -d archnw
Instance archnw1is running on node logrecv1
Instance archnw2is running on node logrecv2
$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.ARCHNW.dg ora....up.type ONLINE ONLINE logrecv1
ora.ARCHWW.dg ora....up.type ONLINE ONLINE logrecv1
ora.CRS.dg ora....up.type ONLINE ONLINE logrecv1
ora....ER.lsnrora....er.type ONLINE ONLINE logrecv1
ora....N1.lsnrora....er.type ONLINE ONLINE logrecv2
ora....N2.lsnrora....er.type ONLINE ONLINE logrecv1
ora....N3.lsnrora....er.type ONLINE ONLINE logrecv1
ora.archnw.db ora....se.type ONLINE ONLINE logrecv1
ora.asm ora.asm.type ONLINE ONLINE logrecv1
ora.cvu ora.cvu.type ONLINE ONLINE logrecv1
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....SM1.asmapplication ONLINE ONLINE logrecv1
ora....V1.lsnrapplication ONLINE ONLINE logrecv1
ora....cv1.gsdapplication OFFLINE OFFLINE
ora....cv1.onsapplication ONLINE ONLINE logrecv1
ora....cv1.vipora....t1.type ONLINE ONLINE logrecv1
ora....SM2.asmapplication ONLINE ONLINE logrecv2
ora....V2.lsnrapplication ONLINE ONLINE logrecv2
ora....cv2.gsdapplication OFFLINE OFFLINE
ora....cv2.onsapplication ONLINE ONLINE logrecv2
ora....cv2.vipora....t1.type ONLINE ONLINE logrecv2
ora....networkora....rk.type ONLINE ONLINE logrecv1
ora.oc4j ora.oc4j.type ONLINE ONLINE logrecv1
ora.ons ora.ons.type ONLINE ONLINE logrecv1
ora....ry.acfsora....fs.type ONLINE ONLINE logrecv1
ora.scan1.vip ora....ip.type ONLINE ONLINE logrecv2
ora.scan2.vip ora....ip.type ONLINE ONLINE logrecv1
ora.scan3.vip ora....ip.type ONLINE ONLINE logrecv1
14、 在内网主库的dns服务网两个节点的dns解析地址中增加日志档案库的解析地址;named.abc.data添加:
logrecv1 IN A 172.16.40.137
logrecv2 IN A 172.16.40.138
logrecv1-priv IN A 192.168.40.137
logrecv2-priv IN A 192.168.40.138
logrecv1-vip IN A 172.16.40.147
logrecv2-vip IN A 172.16.40.148
logrecv-cluster-scan IN A 172.16.40.149
logrecv-cluster-scan IN A 172.16.40.150
logrecv-cluster-scan IN A 172.16.40.151
在日志档案库的dns服务器的解析地址中增加内网集群的解析ip地址;
rac1 IN A 172.16.41.21
rac2 IN A 172.16.41.22
rac1-priv IN A 192.168.0.21
rac2-priv IN A 192.168.0.22
rac1-vip IN A 172.16.41.23
rac2-vip IN A 172.16.41.24
cluster1-scan IN A 172.16.41.121
cluster1-scan IN A 172.16.41.122
cluster1-scan IN A 172.16.41.123
15、 配置主库以及日志档案库上的tnsnames配置文件;
SHESTATE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =cluster1-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = shestate)
)
)
archnw =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =logrecv-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = archnw)
)
)
16、 拷贝主库的密码文件到日志档案库;
scp orapwrac1172.16.40.137:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwarchnw1
17、 在日志档案库里面创建standbylogfile;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 1 (‘/archnw/archlog/sredo1_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 1 (‘/archnw/archlog/sredo2_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 1 (‘/archnw/archlog/sredo3_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 1 (‘/archnw/archlog/sredo4_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 1 (‘/archnw/archlog/sredo5_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 1 (‘/archnw/archlog/sredo6_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 1 (‘/archnw/archlog/sredo7_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 2 (‘/archnw/archlog/sredo8_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 2 (‘/archnw/archlog/sredo9_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 2 (‘/archnw/archlog/sredo10_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 2 (‘/archnw/archlog/sredo11_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 2 (‘/archnw/archlog/sredo12_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 2 (‘/archnw/archlog/sredo13_01.log‘)SIZE 150M;
ALTER DATABASE ADD STANDBYLOGFILE THREAD 2 (‘/archnw/archlog/sredo14_01.log‘)SIZE 150M;
18、 由于镜像库还未启用,故暂时先将日志传输服务禁用;
Alter sysem setlog_archive_dest_state_2=’defer’ scope=both sid=’*’;
本文出自 “一生何求” 博客,请务必保留此出处http://xiexingw.blog.51cto.com/8982314/1420167
RAC对RAC的物理DG的搭建,布布扣,bubuko.com
原文:http://xiexingw.blog.51cto.com/8982314/1420167