[20171110]_allow_read_only_corruption参数.txt

--//昨天在修改查询隐含参数脚本时发现一个参数_allow_read_only_corruption,感觉应该可以在异常关闭的情况下以read only打开.
--//自己测试看看.

1.环境:

SYS@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SYS@book> @ &r/hide _allow_read_only_corruption
NAME                        DESCRIPTION                                      DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
--------------------------- ------------------------------------------------ ------------- ------------- ------------
_allow_read_only_corruption allow read-only open even if database is corrupt TRUE          FALSE         FALSE

2.测试前准备:

SYS@book> create pfile='/tmp/init@.ora' from spfile ;
File created.

--//修改 /tmp/initbook.ora文件,加入如下内容:
*._allow_read_only_corruption=true

--//做一个异常关闭数据库.
SYS@book> shutdown abort ;
ORACLE instance shut down.

SYS@book> startup mount pfile='/tmp/init@.ora'
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.

SYS@book> show parameter allow
NAME                        TYPE    VALUE
--------------------------- ------- ------
_allow_read_only_corruption boolean TRUE

--//说明只要配置了参数在参数文件中,隐含参数实际上也可以使用show parameter.但是像前面带2个下划线参数,show parameter还是无
--//法查询.比如:
SYS@book> show parameter __java_pool_size
SYS@book> @ &r/hide __java_pool_size
NAME              DESCRIPTION                       DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
----------------- --------------------------------- ------------- ------------- ------------
__java_pool_size  Actual size in bytes of java pool FALSE         4194304       4194304

SYS@book> alter database open read only;
alter database open read only
*
ERROR at line 1:
ORA-16005: database requires recovery

--//可以发现不行.也许需要_allow_resetlogs_corruption参数配合.

3.继续测试:
--//修改 /tmp/initbook.ora文件,加入如下内容:
*._allow_resetlogs_corruption=true

SYS@book> @ &r/logfile
GROUP# STATUS     TYPE       MEMBER                           IS_ GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARC STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ---------- ---------- -------------------------------- --- ------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ -------------------
     1            ONLINE     /mnt/ramdisk/book/redo01.log     NO       1       1       728    52428800       512       1 NO  CURRENT      13277659048 2017-11-09 16:18:09 2.814750E+14
     2            ONLINE     /mnt/ramdisk/book/redo02.log     NO       2       1       726    52428800       512       1 YES INACTIVE     13277630208 2017-11-09 09:54:47  13277632611 2017-11-09 10:18:14
     3            ONLINE     /mnt/ramdisk/book/redo03.log     NO       3       1       727    52428800       512       1 YES INACTIVE     13277632611 2017-11-09 10:18:14  13277659048 2017-11-09 16:18:09
     4            STANDBY    /mnt/ramdisk/book/redostb01.log  NO
     5            STANDBY    /mnt/ramdisk/book/redostb02.log  NO
     6            STANDBY    /mnt/ramdisk/book/redostb03.log  NO
     7            STANDBY    /mnt/ramdisk/book/redostb04.log  NO
7 rows selected.

$ mv /mnt/ramdisk/book/redo01.log /mnt/ramdisk/book/redo01.log_xxx

--//这样避免找到redo文件.或者假象redo01.log文件损坏了.
SYS@book> shutdown abort ;
ORACLE instance shut down.

SYS@book> startup mount pfile='/tmp/init@.ora'
ORACLE instance started.
Total System Global Area    634732544 bytes
Fixed Size                    2255792 bytes
Variable Size               197133392 bytes
Database Buffers            427819008 bytes
Redo Buffers                  7524352 bytes
Database mounted.

SYS@book> @ &r/hide allow_r%corrupt%
NAME                        DESCRIPTION                                      DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
--------------------------- ------------------------------------------------ ------------- ------------- ------------
_allow_read_only_corruption allow read-only open even if database is corrupt FALSE         TRUE          TRUE
_allow_resetlogs_corruption allow resetlogs even if it will cause corruption FALSE         TRUE          TRUE

SYS@book> alter database open read only;
alter database open read only
*
ERROR at line 1:
ORA-16005: database requires recovery

$ oerr ora 16005
16005, 00000, "database requires recovery"
// *Cause:  The database requires recovery, and therefore cannot be opened for
//          read-only access by this instance.
// *Action: Perform the necessary recovery and reopen for read-only access.
//

--//视乎与_allow_resetlogs_corruption无关,取消*._allow_resetlogs_corruption=true设置,重来..

SYS@book> shutdown abort ;
ORACLE instance shut down.
SYS@book> startup mount pfile='/tmp/init@.ora'
ORACLE instance started.
Total System Global Area    634732544 bytes
Fixed Size                    2255792 bytes
Variable Size               197133392 bytes
Database Buffers            427819008 bytes
Redo Buffers                  7524352 bytes
Database mounted.
SYS@book> @ &r/hide allow_r%corrupt%
old  10:  and lower(a.ksppinm) like lower('%&1%')
new  10:  and lower(a.ksppinm) like lower('%allow_r%corrupt%%')
NAME                        DESCRIPTION                                      DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
--------------------------- ------------------------------------------------ ------------- ------------- -------------
_allow_read_only_corruption allow read-only open even if database is corrupt FALSE         TRUE          TRUE
_allow_resetlogs_corruption allow resetlogs even if it will cause corruption TRUE          FALSE         FALSE

SYS@book> recover database until cancel;
ORA-00279: change 13277663682 generated at 11/10/2017 09:14:12 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/archivelog/book/1_728_896605872.dbf
ORA-00280: change 13277663682 for thread 1 is in sequence #728
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log '/u01/app/oracle/archivelog/book/1_728_896605872.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3

ORA-00308: cannot open archived log '/u01/app/oracle/archivelog/book/1_728_896605872.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/mnt/ramdisk/book/system01.dbf'

SYS@book> alter database open read only;
alter database open read only
*
ERROR at line 1:
ORA-16005: database requires recovery

--//依旧不行.失望!!

4.看看正常关闭数据库丢失某个redo的情况呢?
$ mv /mnt/ramdisk/book/redo01.log_xxx /mnt/ramdisk/book/redo01.log

--//先恢复到正常状态.
SYS@book> shutdown abort ;
ORACLE instance shut down.
SYS@book> startup mount
ORACLE instance started.
Total System Global Area    634732544 bytes
Fixed Size                    2255792 bytes
Variable Size               197133392 bytes
Database Buffers            427819008 bytes
Redo Buffers                  7524352 bytes
Database mounted.

SYS@book> @ &r/hide allow_r%corrupt%
NAME                        DESCRIPTION                                      DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
--------------------------- ------------------------------------------------ ------------- ------------- ------------
_allow_read_only_corruption allow read-only open even if database is corrupt FALSE         TRUE          TRUE
_allow_resetlogs_corruption allow resetlogs even if it will cause corruption TRUE          FALSE         FALSE

SYS@book> recover database until cancel;
ORA-00279: change 13277663682 generated at 11/10/2017 09:14:12 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/archivelog/book/1_728_896605872.dbf
ORA-00280: change 13277663682 for thread 1 is in sequence #728
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/mnt/ramdisk/book/redo01.log
Log applied.
Media recovery complete.

SYS@book> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SYS@book> alter database open NORESETLOGS;
Database altered.

--//这种情况下是可以NORESETLOGS打开的,因为redo文件设置回来了.

SYS@book> select open_mode from v$database ;
OPEN_MODE
-----------
READ WRITE

SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

SYS@book> startup mount pfile='/tmp/init@.ora'
ORACLE instance started.
Total System Global Area    634732544 bytes
Fixed Size                    2255792 bytes
Variable Size               197133392 bytes
Database Buffers            427819008 bytes
Redo Buffers                  7524352 bytes
Database mounted.
SYS@book> @ &r/logfile
GROUP# STATUS TYPE       MEMBER                           IS_ GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARC STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ------ ---------- -------------------------------- --- ------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ -------------------
     1        ONLINE     /mnt/ramdisk/book/redo01.log     NO       1       1       728    52428800       512       1 YES INACTIVE     13277659048 2017-11-09 16:18:09  13277684336 2017-11-10 09:54:02
     2        ONLINE     /mnt/ramdisk/book/redo02.log     NO       2       1       729    52428800       512       1 NO  CURRENT      13277684336 2017-11-10 09:54:02 2.814750E+14
     3        ONLINE     /mnt/ramdisk/book/redo03.log     NO       3       1       727    52428800       512       1 YES INACTIVE     13277632611 2017-11-09 10:18:14  13277659048 2017-11-09 16:18:09
     4        STANDBY    /mnt/ramdisk/book/redostb01.log  NO
     5        STANDBY    /mnt/ramdisk/book/redostb02.log  NO
     6        STANDBY    /mnt/ramdisk/book/redostb03.log  NO
     7        STANDBY    /mnt/ramdisk/book/redostb04.log  NO
7 rows selected.

--//当前是/mnt/ramdisk/book/redo02.log.
$ mv /mnt/ramdisk/book/redo02.log /mnt/ramdisk/book/redo02.log_xxx

SYS@book> alter database open read only ;
Database altered.

SYS@book> @ &r/hide allow_r%corrupt%
NAME                        DESCRIPTION                                      DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
--------------------------- ------------------------------------------------ ------------- ------------- ------------
_allow_read_only_corruption allow read-only open even if database is corrupt FALSE         TRUE          TRUE
_allow_resetlogs_corruption allow resetlogs even if it will cause corruption TRUE          FALSE         FALSE

--//^_^,这个参数意义不大,要在正常关闭的情况下,redo文件损坏的情况下,可以使用它打开数据库.

5.看看使用正常参数启动情况如何?
SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

SYS@book> startup
ORACLE instance started.
Total System Global Area    634732544 bytes
Fixed Size                    2255792 bytes
Variable Size               197133392 bytes
Database Buffers            427819008 bytes
Redo Buffers                  7524352 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 18301
Session ID: 274 Serial number: 3

--//因为/mnt/ramdisk/book/redo02.log文件无法找到,启动失败.修改回来:

$ mv /mnt/ramdisk/book/redo02.log_xxx /mnt/ramdisk/book/redo02.log

SYS@book> startup
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.
Database opened.

SYS@book> @ &r/hide allow_r%corrupt%
old  10:  and lower(a.ksppinm) like lower('%&1%')
new  10:  and lower(a.ksppinm) like lower('%allow_r%corrupt%%')
NAME                        DESCRIPTION                                      DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
--------------------------- ------------------------------------------------ ------------- ------------- ------------
_allow_read_only_corruption allow read-only open even if database is corrupt TRUE          FALSE         FALSE
_allow_resetlogs_corruption allow resetlogs even if it will cause corruption TRUE          FALSE         FALSE

总结:
1._allow_read_only_corruption参数意义不大,要在正常关闭的情况下,某个redo文件不存在或者损坏的情况下临时open read only打开.
2.一旦数据库文件头与控制文件当前scn不一致,需要恢复是无法使用它,read only打开的,怪不得很少见人提到这个参数.

--//补充测试redo损坏不是current的情况.
SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

SYS@book> startup mount pfile='/tmp/init@.ora'
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.

SYS@book> @ &r/logfile
GROUP# STATUS     TYPE       MEMBER                          IS_ GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARC STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ---------- ---------- ------------------------------- --- ------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ -------------------
     1            ONLINE     /mnt/ramdisk/book/redo01.log    NO       1       1       728    52428800       512       1 YES INACTIVE     13277659048 2017-11-09 16:18:09  13277684336 2017-11-10 09:54:02
     2            ONLINE     /mnt/ramdisk/book/redo02.log    NO       2       1       729    52428800       512       1 NO  CURRENT      13277684336 2017-11-10 09:54:02 2.814750E+14
     3            ONLINE     /mnt/ramdisk/book/redo03.log    NO       3       1       727    52428800       512       1 YES INACTIVE     13277632611 2017-11-09 10:18:14  13277659048 2017-11-09 16:18:09
     4            STANDBY    /mnt/ramdisk/book/redostb01.log NO
     5            STANDBY    /mnt/ramdisk/book/redostb02.log NO
     6            STANDBY    /mnt/ramdisk/book/redostb03.log NO
     7            STANDBY    /mnt/ramdisk/book/redostb04.log NO
7 rows selected.

$ mv /mnt/ramdisk/book/redo03.log /mnt/ramdisk/book/redo03.log_xxx

SYS@book> alter database open ;
alter database open
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 18497
Session ID: 274 Serial number: 3

--//无法打开数据库.

SYS@book> startup mount pfile='/tmp/init@.ora'
ORACLE instance started.

Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.

SYS@book> alter database open read only ;
Database altered.

--//还原现场:

SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

$ mv /mnt/ramdisk/book/redo03.log_xxx /mnt/ramdisk/book/redo03.log

SYS@book> startup
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.
Database opened.

[20171110]_allow_read_only_corruption参数.txt的更多相关文章

  1. [20180123]测试SQLNET.EXPIRE_TIME参数.txt

    [20180123]测试SQLNET.EXPIRE_TIME参数.txt --//曾经写过一篇linux内核网络参数测试tcp_keepalive,链接http://blog.itpub.net/26 ...

  2. [20170927]hugepages与内核参数nr_overcommit_hugepages.txt

    [20170927]hugepages与内核参数nr_overcommit_hugepages.txt /proc/sys/vm/nr_overcommit_hugepages specifies h ...

  3. Revit通过API创建共享参数

    Revit共享参数是通过创建一个.txt类型的文件来保存相关信息,一旦与项目保存完毕之后,共享参数也就变成了项目参数(项目参数无法通过API创建),项目参数是保存在Revit项目里面的,所以此时这个. ...

  4. [20181109]12cR2 的pre_page_sga参数

    [20181109]12cR2 的pre_page_sga参数.txt --//12CR2改变了参数pre_page_sga设置为True.设置为true有好处也有缺点.--//先看看官方的定义:ht ...

  5. [20170927]关于hugepages.txt

    [20170927]关于hugepages.txt --//今天测试hugepages与内核参数nr_overcommit_hugepages,才发现HugePages_Surp表示什么? --// ...

  6. jmeter压测--从文本中读取参数

    由于之前从数据库获取查询结果作为请求的入参(使用场景:测试一个接口并发处理数据的能力,并且每次请求传入的参数都要不同.),会一定程度上造成对数据库的压测,在没有完全搞清楚多线程之间参数的传递之前,我们 ...

  7. [20191220]关于共享内存段相关问题.txt

    [20191220]关于共享内存段相关问题.txt --//我一直很好奇如果设置内核参数kernel.shmmax = 68719476736足够大,为什么我的测试实例还是建立3个共享内存段.--// ...

  8. (一)在Windows下编译扩展OpenCV 3.1.0 + opencv_contrib 及一些问题

    一.准备工作: 1.下载OpenCV安装包:https://github.com/opencv/opencv 安装过程实际上就是解压过程,安装完成后得到(这里修改了文件名): 2.下载opencv_c ...

  9. AS3和js相互通信要点分析

    目标:在html页面里可以使用事件来影响到swf文件的内容,swf文件也可以影响html里js代码的内容 一.新建flash文件,用Flash CC试用版新建一个TextArea.fla的源文件,不添 ...

随机推荐

  1. vue中子组件通过$parent操作父组件的参数或者方法

    先看一个简单的demo: 父组件添加一个弹框,弹框的内容是另外导入的一个子组件: <Modal v-model="accountDetailsModal" class=&qu ...

  2. hdu 6127---Hard challenge(思维)

    题目链接 Problem Description There are n points on the plane, and the ith points has a value vali, and i ...

  3. 快速排序——Quick Sort

    基本思想:(分治) 先从数列中取出一个数作为key值: 将比这个数小的数全部放在它的左边,大于或等于它的数全部放在它的右边: 对左右两个小数列重复第二步,直至各区间只有1个数. 辅助理解:挖坑填数 初 ...

  4. Android_学习系列(33)--App应用之提交到各大市场渠道

    本文同步更新在http://hmu140482.chinaw3.com/?p=315.    Android的终端碎片化问题,是一个很讨厌的问题.    而对于国内开发者来说,Android的市场“碎 ...

  5. JAVA基础--重新整理(1)后版

    比较喜欢用demo来讲解. 变量: public static void main(String[] args) { int age;//变量声明 age = 16;//变量的初始化,第一次赋值 ag ...

  6. Spring Boot + Spring Cloud 构建微服务系统(一):服务注册和发现(Consul)

    使用Consul提供注册和发现服务 什么是 Consul Consul 是 HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置.与其它分布式服务注册与发现的方案,Consul ...

  7. 模型评估——ROC、KS

    无论是利用模型对信用申请人进行违约识别,还是对授信申请人进行逾期识别……在各种各样的统计建模中,永远必不可少的一步是对模型的评价,这样我们就可以根据模型评价指标的取值高低,来决定选取哪个模型.本篇主要 ...

  8. xhr.withCredentials发送跨域请求凭证

    一.前言 今天遇到一个坑,浏览器请求数据的时候gg了.浏览器报错如下图: 因为请求头部设置了credentis mode is 'include', 从上面可以看出是Access-Control-Al ...

  9. [JZOJ5837] Omeed

    Description Solution 有两种做法 一种是线段树维护一次方程系数,一种是线段树维护矩阵 准备都写一写 维护系数 首先把式子推出来 \[CS=B\times \sum\limits_{ ...

  10. SpringBoot之Mybatis操作中使用Redis做缓存

    上一博客学习了SpringBoot集成Redis,今天这篇博客学习下Mybatis操作中使用Redis做缓存.这里其实主要学习几个注解:@CachePut.@Cacheable.@CacheEvict ...