2013年9月30日星期一

Oracle ADG 环境搭建

Oracle官方文档

不错的网络文章

《Oracle Data Guard理论知识》 这篇文章对于理解DataGuard如何利用log进行了介绍。
《Data Guard broker系列》《Data Guard Physical Standby Setup in Oracle Database 11g Release 2》 这篇文章有坑(没有提及_DBG, _DGMGRL),但总体顺序不错。
《Four Steps to create a Physical Standby Database》  这篇文章轮廓写得清晰。 上篇文章中没有提及listener.ora文件中的_DGB , _DGMGRL这两个static listener,是绝对的坑。 _DGB是Datagurad Broker用来侦听不同节点心跳的。_DGMGRL是用来保证数据库down的时候能够访问的。

《How to add and remove databases from Oracle cluseter》这篇主要示例了如何使用crvctl。

 

安装中遇到的一些问题&解决:

1)
现象:
SQL>  STARTUP NOMOUNT PFILE=’/tmp/initDB11G_stby.ora’;
ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated
ORA-01262: Stat failed on a file destination directory
Linux-x86_64 Error: 2: No such file or directory
SQL>
解决:
因为在standby上创建的fast_recovery_area时,把一个字母写错了…

2)
现象:
Warning: ORA-16714: the value of property ArchiveLagTarget is inconsistent with the database setting
解决:
先查看那些不一致,然后更正之。
DGMGRL>  show database 'db11g_stby' 'InconsistentProperties';
edit database 'db11g_stby' set property 'ArchiveLagTarget'=0;
可参考官方文档 http://docs.oracle.com/cd/E11882_01/server.112/e17023/cli.htm
3)
现象:
分别进入primary sqlplus , standby sqlplus执行—-》
SQL> select flashback_on from v$database;
SQL> alter database flashback on;
在standby 上
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-01153: an incompatible media recovery is active
SQL>
解决:SQL> STARTUP MOUNT;
ORACLE instance started.
Total System Global Area 2421825536 bytes
Fixed Size 2228880 bytes
Variable Size 1358957936 bytes
Database Buffers 1040187392 bytes
Redo Buffers 20451328 bytes
Database mounted.
SQL> alter database flashback on;
Database altered.
4)
现象:switchover失败
DGMGRL> switchover to db11g_stby;
Performing switchover NOW, please wait…
Error: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Error: ORA-16625: cannot reach database “db11g_stby”
Failed.
Unable to switchover, primary database is still “db11g”
DGMGRL> show configuration;
Configuration – myconfigProtection Mode: MaxAvailability
Databases:
db11g      – Primary database
db11g_stby – Physical standby databaseFast-Start Failover: DISABLED
Configuration Status:
ORA-16623: database detected role change
ORA-16625: cannot reach database “db11g”
DGM-17017: unable to determine configuration status
DGMGRL>
解决:查看一下stby数据库broker参数,发现staticConnectorIdentifier默认使用1521端口。而我用的stby数据库是1522端口。
DGMGRL> show database  verbose ‘db11g_stby’;
RecvQEntries                    = ‘(monitor)’
SidName                         = ‘DB11G’
StaticConnectIdentifier         = ‘(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slc01bme)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=DB11G_STBY_DGMGRL.us.oracle.com)(INSTANCE_NAME=DB11G)(SERVER=DEDICATED)))’
StandbyArchiveLocation          = ‘USE_DB_RECOVERY_FILE_DEST’
可以通过一下命令之一修改之:
//通过dgmgrl:
edit database db11g_stby set property StaticConnectIdentifier='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slc01bme)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=DB11G_STBY_DGMGRL.us.oracle.com)(INSTANCE_NAME=DB11G)(SERVER=DEDICATED)))';
 或者 sqlplus:
alter system set StaticConnectIdentifier='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slc01bme)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=DB11G_STBY_DGMGRL.us.oracle.com)(INSTANCE_NAME=DB11G)(SERVER=DEDICATED)))' scope=both;
参考:
《解决Oracle DataGuard Broker出现的TNS-12514错误》《Four steps to create a Physical Standby Database》 这篇文章里,是在添加了_DBG, _DGMGRL两个服务名之后,执行诸如如下的命令来确保提供合适的conenction给DG broker。下面的命令因为使用服务名而优于前文的链接字符串。
edit database db11g set property staticConnectidentifier=’DB11G’;
edit database db11g_DG1 set property staticConnectidentifier=’DB11G_DG1′;
5)
现象:-bash-3.2$ srvctl add ons
PRCR-1063 : Failed to create context
PRKH-1010 : Unable to communicate with CRS services.
PRKH-1000 : Unable to load the SRVM HAS shared library
PRKN-1008 : Unable to load the shared library “libsrvmhas11.so”
or a dependent library, from
LD_LIBRARY_PATH=”/scratch/dahyuan/app/oracle/product/11.2.0/grid/lib”
[java.lang.UnsatisfiedLinkError: /scratch/dahyuan/app/oracle/product/11.2.0/grid/lib/libsrvmhas11.so: libasmclnt11.so: cannot open shared object file: No such file or directory]
解决:
一种是你的server上真的缺少一些开发包,需要你编译安装。但我这里是因为LD_LIBRARY_PATH的问题,当时libary path没有/usr/lib和/usr/local/lib这两个目录。加上之后再运行root.sh就好了。 LD_LIBRARY_PATH应该至少包括/scratch/dahyuan/app/oracle/product/11.2.0/grid/lib:/usr/lib:/usr/local/lib。
参考:
《Oracle 安装 clusterware时遇到的问题》
6)
现象:-bash-3.2$ srvctl start ons
#
# An unexpected error has been detected by HotSpot Virtual Machine:
# SIGSEGV (0xb) at pc=0x00002ada0b2b3a84, pid=2082, tid=47115974751584
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.5.0_24-rev-b08 mixed mode)
# Problematic frame:
# V [libjvm.so+0x3afa84]
#
# An error report file with more information is saved as hs_err_pid2082.log
#
# If you would like to submit a bug report, please visit:
#
/scratch/dahyuan/app/oracle/product/11.2.0/dbhome_1/bin/srvctl: line 240: 2082 Aborted $JRE $JRE_OPTIONS -DORACLE_HOME=$ORACLE_HOME -classpath $CLASSPATH $SRVM_PROPERTY_DEFS oracle.ops.opsctl.OPSCTLDriver “$@”
解决:
这个是因为使用了Database_HOME里的srvctl。应该使用grid_HOME/bin里的srvctl。
参考:
《SRVCTL文档》  To manage Oracle ASM on Oracle Database 11g release 2 (11.2) installations, use the SRVCTL binary in the Oracle Grid Infrastructure home for a cluster (Grid home). If you have Oracle RAC or Oracle Database installed, then you cannot use the SRVCTL binary in the database home to manage Oracle ASM.

7)
现象:
DGMGRL>  ENABLE FAST_START FAILOVER;
Error: ORA-16651: requirements not met for enabling fast-start failover
解决:
在primary 和 standby上用sqlplus 都执行,  alter database flashback on;


8)
现象:
DGMGRL> show database  verbose 'db11g_stby';
出现以下警告,
  Database Warning(s):

    ORA-16826: apply service state is inconsistent with the DelayMins property
解决:
在DGMGRL里执行,disable configuration;    再执行 enable configuration;  就可以解决。