跳至主要内容

DG主备库切换

连不上主库,查看bdump下的日志,发觉链接不上。而备库的bdump下同样显示的disconnect,无奈重启主库,发觉仍旧不能连上,查看dmesg网卡坏了。。。。不过刚好,给我个主备库切换的机会。
因为主库的网卡以坏,同时也没有其他的生产用机连接,因为是测试机^ ^所以开始切换。根据piner在书中提到的switchover脚本,开始进行切换。基于以上原因我就没有修改备库IP。

$ more switchprimary.sh
#!/bin/sh ORACLE_BASE=/SERVER/ora9;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/9.2;export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH;export PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib; LD_LIBRARY_PATH
ORACLE_SID=ora9i; export ORACLE_SID
ORACLE_NLS=$ORACLE_HOME/ocommon/nls/admin/data; export ORACLE_NLS
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK; export NLS_LANG NLS_DATE_FORMAT='yyyy-mm-dd
hh24:mi:ss';export NLS_DATE_FORMAT

$ORACLE_HOME/bin/sqlplus /nolog <

startup pfile=?/dbs/initora9i.ora_pri
exit
EOF
lsnrctl stop
listenerdb lsnrctl start

但是服务器由此出来的提示是ora-01153错误,然后我做了下查看
[oracle@ora9-2 oracle]$ oerr ora 01153
01153, 00000, "an incompatible media recovery is active"
// *Cause: Attempted to start an incompatible media recovery or open
resetlogs
// during media recovery or
RMAN backup . Media recovery sessions
// are incompatible if they
attempt to recover the same data file.
// Incomplete media
recovery or open resetlogs is incompatible with
// any media recovery.
Backup or restore by RMAN is incompatible
// with open
resetlogs
// *Action: Complete or cancel the other media recovery session or RMAN
backup

所以根据提示我有做了以下动作
[oracle@ora9-2 oracle]$recover managed standby database cancel;
[oracle@ora9-2 oracle]$ shutdown immediate;

但是似乎很不性,我shutdown了以后起来的时候用pfile启动到nomount但是alterdatabase到mount下是提示的这是备库的controlfile。如下错误:
ORA-01666: controlfile is for a standby database
之后又做了一次后提示ORA-01012: not logged on 。。 然后就开始飚血~~~~~~~~~~~
麻烦了,之后重启了机器,重启后就OK了,但是还是提示好了还是如此。我继续shutdown然后重新启动到原来的备库状态。。
startup nomount pfile = initora9i.ora_std
alter database mount standby database

这样就启动到了备库的状态了。那么余下的就是如何切换了,没有用piner提供的脚本而是google了下,这次我做
alter database commit to switchover to primary;

的时候提示
[oracle@ora9-2 oracle]$ oerr ora 16139
16139, 00000, "media recovery required"
// *Cause: The database has not been recovered through the end of log
stream.
// Graceful
switchover is not possible.
// *Action: Ensure that the entire log stream has been applied. If
appropriate,
// reissue the
graceful switchover command.

所以根据GOOGLE的经验,需进行以下操作
结束备库的管理恢复
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
如果报错,则执行
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH SKIP STANDBY
LOGFILE;
切换备库到主库
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
SQL> shutdown immediate
SQL> startup mount
SQL> startup

至此切换成功
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PRIMARY

很好,很强大
还需要增加三个REDO,和一个临时表空间

评论

此博客中的热门博文

Python学习笔记20100117

映射list   Dictionary 是用{}. list 是一那个[]. turple是用() 当你定义过dictionary后,你可以使用d.keys(), d.values(),d.items()将定义后的时候分别显示出来 当然可以将list里的值加减乘除,也可以如一般的定义直接重新复制这个list. 链接与分割字符串的 li=";", join(li) 则显示的就是 分隔符为;的数 如果使用li=li.split(";")则将刚刚;的分隔符删除,而split里也可定义域,如li.split(";",1)   自省 <---这是啥 之前在使用的时候发觉有些书本上的模块不能调用,很多是py脚本定义过的函数。 下载该脚本s,然后上传至指定位置。 >>>import sys >>>sys.path >>>sys.path.append("绝对位置")然后就能调用这些脚本和参数了。 删除 >>>sys.path.pop() 定义一个参数是 def info(test, test1=10.test2=12): info是函数名,test是必备参数,因为没有定义值,test1和test2是可选参数,定义了初始值   以上是外部函数的调用,下面转到内部函数 内部函数有type,str,dir及其他   ---type 返回任意字符的类型,模块也可以。types模块 >>> type(1) <type 'int'> >>> li=[] >>> type(li) <type 'list'> >>> import odbchelper >>> type(odbchelper) <type 'module'> >>> type(sys) <type 'module'> >>> import types ...

Setagaya park

  We visited Setagaya Park (世田谷区) yesterday. This park reminds us when we in Europe, which has a fancy fountain in the middle, and free entrance. People just laid down on the grass, enjoy the day time they can waste. people who have kids together,  play all different kinds of sports. you really can't image whether you are in Europe or  Japan. I would prefer to use a Bus instead of the metro, the metro is fast, but you only can see the dark, light, people sit or stand as Sardine, without any emotion. but on the bus, you can see the traffic, the shop, everything on the road. When we on our way to the park, we stop by a good chocolate shop named " craft chocolate works ",  this is a very good place to have ice cream, you probably can choose half & half, you can enjoy the feeling when you smell the chocolate smell and eat with it.  or you can enjoy beer or cake in "globe antiques (ザ グローブアン ティ ークス) .   also, we checked the Blue Bottle Coffee Sangenjaya ...