跳至主要内容

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 ...

Python学习笔记20100128

methodList = [method for method in dir(object) if callable(getattr(object, method))] ###插一句, ifconfig pcn0 unplumb 去禁solaris的网卡plumb起网卡   and, or  已经and-or一起用。 and 两者为真,print第二个数,一个为假一个为真返回假,三者为真返回最后一个真。 or 两个为真,返回第一个, 一个为假一个为真返回真,三者为假返回最后一个假   lambda可快速定义最小值函数   g = lambda x:x*2 g(3) 6 (lambda x:x*2)(3)   doc string print getattr(object,mothod).__doc__   ljust ljust 用空格填充字符串以符合指定的长度。info 函数使用它生成了两列输出并将所有在第二列的 doc string 纵向对齐。 如果小于的话不会从中截断   -----面向对象 首先导入,你可以选择import module or from module import module 如果你要经常访问模块的属性和方法,且不想一遍又一遍地敲入模块名,使用 from module import。 如果你想要有选择地导入某些属性和方法,而不想要其它的,使用 from module import。 如果模块包含的属性和方法与你的某个模块同名,你必须使用 import module 来避免名字冲突   -----类的定义 class Lofs    pass   这个类的名字是 Loaf,它没有从其它类继承。 类名通常是第一个字母大写,如:EachWordLikeThis,但这只是一个习惯,不是一个必要条件。   这个类没有定义任何方法或属性,但是从语法上,需要在定义中有些东西,所以你使用 pass。这是一个 Python 保留字,仅仅表示 “向前走,不要往这看”。它是一条什么都不做的语句,当你删空函数或类时,它是一个很好的占位符。   你可能猜...

Back to Blog again

     My last blog was almost 6 years again.  lots of things happening those years. like marriage, and move to another country, simply relocation, something is very big in my life.      Back to now,  I guess it is a very good time to start with the blog again. no matter daily life or the tech parts.      These blog may or will contains various languages, Chinese, English or Few Japanese. The first thing, I change the profile to Kamata life, Kamata is Japanese words. "鎌田"  as Kanji. why this change happened, due to we will move from Tamagawa "玉川" to Kamata very soon. I hope I can start to write this not daily, but I hope I can do this continuously.