记一次数据库参数compatible降级[转]
转:http://dbzone.iteye.com/blog/1042455
众所周知,Oracle参数compatible 主要用于启用Oracle针对某一版本的新特性。但此参数设置时,只能往上调,设置好之后不能往下降。
The default value for the COMPATIBLE parameter is the release number of the most recent major release.
Note:For Oracle Database 10g Release 2 (10.2), the default value of the COMPATIBLE parameter is 10.2.0. The minimum value is 9.2.0. If you create an Oracle Database using the default value, you can immediately use all the new features in this release, and you can never downgrade the database.
比如可以将参数compatible从10.2.0.1.0设置成10.2.0.2.0,重启数据库后生效。
System altered.
重启数据库后alert日志会有如下显示,从alert日志中可以明显的看出,compatible升级之后,Oracle会修改控制文件和redolog
alter database mount
Fri May 13 11:59:15 2011
ALERT: Compatibility of the database is changed from 10.2.0.0.0 to 10.2.0.2.0.
Setting recovery target incarnation to 1
Fri May 13 11:59:15 2011
Successful mount of redo thread 1, with mount id 200680975
Fri May 13 11:59:15 2011
Database mounted in Exclusive Mode
Completed: alter database mount
Fri May 13 11:59:32 2011
alter database open
Fri May 13 11:59:32 2011
Switching redo format version from 10.2.0.0.0 to 10.2.0.2.0 at change 803371
Fri May 13 11:59:32 2011
Thread 1 opened at log sequence 10
Current log# 1 seq# 10 mem# 0: /oradata/mynewdb/redo01.log
Successful open of redo thread 1
其实,Oracle还会修改数据文件头,从数据文件头的dump信息中可以看出存在compatible信息
V10 STYLE FILE HEADER:
Compatibility Vsn = 169869568=0xa200100
Db ID=2596133541=0x9abddaa5, Db Name='XE'
Activation ID=0=0x0
Control Seq=198940=0x3091c, File size=142080=0x22b00
File Number=1, Blksiz=8192, File Type=3 DATA
经过以上分析,要实现手工实现compatible降级,必须修改3个地方,即控制文件,数据文件头,redolog。
修改步骤如下,摸索着艰难前进,注意以下操作,除非特殊情况下,严禁在生产库操作:
1、在参数文件中将compatible重设为10.2.0.1.0,重启数据后出现参数文件和控制文件不匹配
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1262716 bytes
Variable Size 159386500 bytes
Database Buffers 356515840 bytes
Redo Buffers 7122944 bytes
ORA-00201: control file version 10.2.0.2.0 incompatible with ORACLE version
10.2.0.1.0
ORA-00202: control file: '/oradata/mynewdb/control01.ctl'
于是尝试修改控制文件,由于控制文件compatible设置是从参数文件获取的,可以通过重建控制文件的方法,将compatible从10.2.0.2.0降为10.2.0.1.0。
重建控制文件分为noresetlogs和resetlogs两种。
如果采用noresetlogs方法重建时,需要扫描redolog文件头,由于redolog文件头compatible为10.2.0.2.0,和参数文件compatible版本号不一致。由于控制文件采用resetlogs选项重建时,并不会扫描redolog头,于是我们采用resetlogs选项重建控制文件。
但是无论采用noresetlogs或者resetlogs选项重建控制文件,重建时都会进行数据文件头匹配,由于数据文件头compatible为10.2.0.2.0
所以重建控制文件时会出现以下错误:
CREATE CONTROLFILE REUSE DATABASE "MYNEWDB" RESETLOGS NOARCHIVELOG
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oradata/mynewdb/redo01.log' SIZE 100M,
GROUP 2 '/oradata/mynewdb/redo02.log' SIZE 100M,
GROUP 3 '/oradata/mynewdb/redo03.log' SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'/oradata/mynewdb/system01.dbf',
'/oradata/mynewdb/undotbs01.dbf',
'/oradata/mynewdb/sysaux01.dbf'
CHARACTER SET ZHS16GBK
;
--ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1262716 bytes
Variable Size 167775108 bytes
Database Buffers 348127232 bytes
Redo Buffers 7122944 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "MYNEWDB" RESETLOGS NOARCHIVELOG
*
ERROR at line 1:
ORA-01503: CREATE CONTROLFILE failed
ORA-01130: database file version 10.2.0.2.0 incompatible with ORACLE version
10.2.0.1.0
ORA-01110: data file 1: '/oradata/mynewdb/system01.dbf'
至此,我们只能通过修改数据文件头的compatible来达到降级的目的了
File: /oradata/mynewdb/system01.dbf (1)
Block: 1 Offsets: 24 to 535 Dba:0x00400001
------------------------------------------------------------------------
0002200a e28bcb0b 4d594e45 57444200 6a000000 80a20000 00200000 01000300
BBED> modify 0x0001200a
File: /oradata/mynewdb/system01.dbf (1)
Block: 1 Offsets: 24 to 535 Dba:0x00400001
------------------------------------------------------------------------
0001200a e28bcb0b 4d594e45 57444200 6a000000 80a20000 00200000 01000300
BBED> sum apply
Check value for File 1, Block 1:
current = 0xf4ba, required = 0xf4ba
修改完所有数据文件之后,用noresetlog重建控制文件,日志文件头和参数文件不匹配如期而至。
CREATE CONTROLFILE REUSE DATABASE "MYNEWDB" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oradata/mynewdb/redo01.log' SIZE 100M,
GROUP 2 '/oradata/mynewdb/redo02.log' SIZE 100M,
GROUP 3 '/oradata/mynewdb/redo03.log' SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'/oradata/mynewdb/system01.dbf',
'/oradata/mynewdb/undotbs01.dbf',
'/oradata/mynewdb/sysaux01.dbf'
CHARACTER SET ZHS16GBK
;ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1262716 bytes
Variable Size 176163716 bytes
Database Buffers 339738624 bytes
Redo Buffers 7122944 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "MYNEWDB" NORESETLOGS NOARCHIVELOG
*
ERROR at line 1:
ORA-01503: CREATE CONTROLFILE failed
ORA-00331: log version 0.0.0.0.0 incompatible with ORACLE version 10.2.0.1.0
ORA-01517: log member: '/oradata/mynewdb/redo01.log'
于是我们采用reselogs选项重建控制文件,终于成功
2 MAXLOGFILES 5
3 MAXLOGMEMBERS 5
4 MAXDATAFILES 100
5 MAXINSTANCES 1
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/oradata/mynewdb/redo01.log' SIZE 100M,
9 GROUP 2 '/oradata/mynewdb/redo02.log' SIZE 100M,
10 GROUP 3 '/oradata/mynewdb/redo03.log' SIZE 100M
11 -- STANDBY LOGFILE
12 DATAFILE
13 '/oradata/mynewdb/system01.dbf',
14 '/oradata/mynewdb/undotbs01.dbf',
15 '/oradata/mynewdb/sysaux01.dbf'
16 CHARACTER SET ZHS16GBK
17 ;
Control file created.
重建好控制文件后,在open resetlogs时提示需要recover,redolog文件头的版本号依然为10.2.0.2.0,于是recover出现了问题
alter database open resetlogs
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/oradata/mynewdb/system01.dbf'
SQL> recover database using backup controlfile;
ORA-00279: change 823455 generated at 05/13/2011 12:05:45 needed for thread 1
ORA-00289: suggestion :
/ora10g/oracle/product/10.2.0/db_1/dbs/arch1_11_748203362.dbf
ORA-00280: change 823455 for thread 1 is in sequence #11
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/oradata/mynewdb/redo01.log
ORA-00331: log version 10.2.0.2.0 incompatible with ORACLE version 10.2.0.1.0
ORA-00334: archived log: '/oradata/mynewdb/redo01.log'
出现这个错误之后,其实修复也很简单,只要再次通过bbed修复redolog文件头即可。
File: /oradata/mynewdb/redo01.log (0)
Block: 1 Offsets: 0 to 511 Dba:0x00000000
------------------------------------------------------------------------
01220000 01000000 0a000000 00809db0 00000000 0002200a e28bcb0b 4d594e45
BBED> find 0x0002200a
File: /oradata/mynewdb/redo01.log (0)
Block: 1 Offsets: 20 to 511 Dba:0x00000000
------------------------------------------------------------------------
0002200a e28bcb0b 4d594e45 57444200 69000000 00200300 00020000 01000200
但由于bbed工具不会再次计算redolog的checksum值,所以修改之后该日志文件头也处于了checksum error状态
Check value for File 0, Block 1:
current = 0x0000, required = 0x0000
SQL> recover database using backup controlfile;
ORA-00279: change 823455 generated at 05/13/2011 12:05:45 needed for thread 1
ORA-00289: suggestion :
/ora10g/oracle/product/10.2.0/db_1/dbs/arch1_11_748203362.dbf
ORA-00280: change 823455 for thread 1 is in sequence #11
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/oradata/mynewdb/redo01.log
ORA-00367: checksum error in log file header
ORA-00334: archived log: '/oradata/mynewdb/redo01.log'
其实Oracle 对checkvalue值的计算只是各个字节相对简单的与或运算,由于手头没有现成脚本,于是打算放弃使用该redolog,强制启用Oracle。
启用隐含参数_allow_resetlogs_corruption
System altered.
SQL> startup force mount
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1262716 bytes
Variable Size 180358020 bytes
Database Buffers 335544320 bytes
Redo Buffers 7122944 bytes
Database mounted.
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 823455 generated at 05/13/2011 12:05:45 needed for thread 1
ORA-00289: suggestion : /ora10g/oracle/product/10.2.0/db_1/dbs/arch1_11_748203362.dbf
ORA-00280: change 823455 for thread 1 is in sequence #11
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
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: '/oradata/mynewdb/system01.dbf'
ORA-01112: media recovery not started
用reselogs选项打开Oracle。
alter database open resetlogs
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
实例异常终止,打开后台alert日志一看,2662错误如期而至
Errors in file /ora10g/oracle/product/10.2.0/db_1/rdbms/log/mynewdb_ora_22033.trc:
ORA-00600: internal error code, arguments: [2662], [0], [823461], [0], [823504], [4194313], [], []
Fri May 13 12:29:01 2011
Errors in file /ora10g/oracle/product/10.2.0/db_1/rdbms/log/mynewdb_ora_22033.trc:
ORA-00600: internal error code, arguments: [2662], [0], [823461], [0], [823504], [4194313], [], []
Fri May 13 12:29:01 2011
Error 600 happened during db open, shutting down database
USER: terminating instance due to error 600
Instance terminated by USER, pid = 22033
ORA-1092 signalled during: alter database open resetlogs..
ORA-600 [2662]主要是由于Oracle内部block的scn大于当前打开数据库的scn而引起的,主要有5个参数:
ORA-600 [2662] [a] [b] [c] [d] [e]
VERSIONS:
versions 6.0 to 10.1
DESCRIPTION:
A data block SCN is ahead of the current SCN.
The ORA-600 [2662] occurs when an SCN is compared to the dependent SCN
stored in a UGA variable.
If the SCN is less than the dependent SCN then we signal the ORA-600 [2662]
internal error.
ARGUMENTS:
Arg [a] Current SCN WRAP
Arg [b] Current SCN BASE
Arg [c] dependent SCN WRAP
Arg [d] dependent SCN BASE
Arg [e] Where present this is the DBA where the dependent SCN came from.
一般情况下,产生ora-600 [2662],可以通过设置event 10015事件,手工递增scn,即数据库open时的scn。
event 10015事件设置需要针对每个场景计算出level 1,通过2662几个参数根据一定的规则可以计算出我们需要的level。
计算规则如下:
Arg [c]*4得出一个数值,假设为V_Wrap
如果Arg [d]=0,则V_Wrap值为需要的level
Arg [d] < 1073741824,V_Wrap+1为需要的level
Arg [d] < 2147483648,V_Wrap+2为需要的level
Arg [d] < 3221225472,V_Wrap+3为需要的level
本案例中[c]=0,所以level为0*4+1=1,即在数据mount状态下,设置如下参数即可
Session altered.
但Oracle并不识别此event的设置,即并不递增scn值,在打开时,数据库依然报错
SMON: enabling cache recovery
Fri May 13 12:45:09 2011
Errors in file /ora10g/oracle/product/10.2.0/db_1/rdbms/log/mynewdb_ora_25610.trc:
ORA-00600: internal error code, arguments: [2662], [0], [823467], [0], [823504], [4194313], [], []
Fri May 13 12:45:09 2011
Errors in file /ora10g/oracle/product/10.2.0/db_1/rdbms/log/mynewdb_ora_25610.trc:
ORA-00600: internal error code, arguments: [2662], [0], [823467], [0], [823504], [4194313], [], []
Fri May 13 12:45:09 2011
也是尝试采用隐含参数_minimum_giga_scn,其取值方法和10015 event相同
System altered.
再次尝试打开数据终于成功
ORA-00279: change 823463 generated at 05/13/2011 12:45:09 needed for thread 1
ORA-00289: suggestion :
/ora10g/oracle/product/10.2.0/db_1/dbs/arch1_1_751034707.dbf
ORA-00280: change 823463 for thread 1 is in sequence #1
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
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: '/oradata/mynewdb/system01.dbf'
ORA-01112: media recovery not started
SQL> alter database open resetlogs;
Database altered.
后台alert日志显示,scn已经递增成功。
alter database open resetlogs
Fri May 13 12:47:37 2011
RESETLOGS is being done without consistancy checks. This may result
in a corrupted database. The database should be recreated.
RESETLOGS after incomplete recovery UNTIL CHANGE 823463
Resetting resetlogs activation ID 200680610 (0xbf624a2)
Online log /oradata/mynewdb/redo01.log: Thread 1 Group 1 was previously cleared
Online log /oradata/mynewdb/redo02.log: Thread 1 Group 2 was previously cleared
Fri May 13 12:47:39 2011
Setting recovery target incarnation to 6
Fri May 13 12:47:39 2011
Fri May 13 12:47:39 2011
Assigning activation ID 200679734 (0xbf62136)
Thread 1 opened at log sequence 1
Current log# 3 seq# 1 mem# 0: /oradata/mynewdb/redo03.log
Successful open of redo thread 1
Fri May 13 12:47:39 2011
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Fri May 13 12:47:39 2011
SMON: enabling cache recovery
Fri May 13 12:47:39 2011
Successfully onlined Undo Tablespace 1.
Dictionary check beginning
Tablespace 'TEMPTS1' #3 found in data dictionary,
but not in the controlfile. Adding to controlfile.
Dictionary check complete
Fri May 13 12:47:39 2011
SMON: enabling tx recovery
Fri May 13 12:47:39 2011
*********************************************************************
WARNING: The following temporary tablespaces contain no files.
This condition can occur when a backup controlfile has
been restored. It may be necessary to add files to these
tablespaces. That can be done using the SQL statement:
ALTER TABLESPACE <tablespace_name> ADD TEMPFILE
Alternatively, if these temporary tablespaces are no longer
needed, then they can be dropped.
Empty temporary tablespace: TEMPTS1
*********************************************************************
Database Characterset is ZHS16GBK
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
QMNC started with pid=16, OS id=401
Fri May 13 12:47:39 2011
LOGSTDBY: Validating controlfile with logical metadata
Fri May 13 12:47:39 2011
LOGSTDBY: Validation complete
Completed: alter database open resetlogs
可以看到数据库已经成功降级
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
compatible string 10.2.0.1.0
记一次数据库参数compatible降级[转]的更多相关文章
- Android之数据库升级onUpgrade降级onDowngrade
借用API文档解释: public abstract void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) 当数据库需要升 ...
- SQL Server 字段类型 decimal(18,6)小数点前是几位?记一次数据库SP的BUG处理
原文:SQL Server 字段类型 decimal(18,6)小数点前是几位?记一次数据库SP的BUG处理 SQL Server 字段类型 decimal(18,6)小数点前是几位? 不可否认,这是 ...
- Android之sqlite数据库版本升级和降级的处理(onUpgrade和onDowngrade)
一.SQLite升级和降级需要考虑的细节 ① SQLite升级: v3.0数据库版本 [onUpgrade 情况:n-1,onCreate 情况:1] ...
- Android数据库升级、降级、创建(onCreate() onUpgrade() onDowngrade())的注意点
以下内容可以作为面试官在面试的时候的问题,感觉比较好,是比较常用的知识点,可以用来考察基础是否扎实. 也可以程序猿学习.开发中的注意点.因为稍微不注意,就有可能导致数据库不能用. DBAdapter. ...
- 记一次数据库调优过程(IIS发过来SQLSERVER 的FETCH API_CURSOR语句是神马?)
记一次数据库调优过程(IIS发过来SQLSERVER 的FETCH API_CURSOR语句是神马?) 前几天帮客户优化一个数据库,那个数据库的大小是6G 这麽小的数据库按道理不会有太大的性能问题的, ...
- 用WIN7系统IIS的提示:数据库连接出错,请检查Conn.asp文件中的数据库参数设置
我用科讯的从4.0开始,去年开始很少用科讯做新站了,今天拿来做一下,结果悲剧了,数据库路径老是不对,百度一番又一番的,,最后终于给度娘解决了.分享出来给遇到同样的问题的人. 用WIN7系统IIS的注意 ...
- Sybase配置数据库参数
Sybase配置数据库参数参数配置的两种方法:sp_configure ‘参数名称’,参数值修改参数文件(如:Sybase主机上的 %SYBASE%\servername.cfg) 配置Sybase数 ...
- 金蝶KIS&K3助记码SQL数据库批量刷新
金蝶KIS&K3助记码SQL数据库批量刷新 用的次数不多,就没有写入存储过程或者触发里面了,可以自行实现. 第一步选择对应账套的数据库,执行下面的命令,这个是一个函数. go if exist ...
- MySQL数据库参数
数据库参数 MYSQL数据库的参数配置一般在my.ini配置文件中修改/添加(部分参数也可以用set global 参数名=值 做临时调整,重启后失效),配置完后需要重启数据库才生效. 参数1:inn ...
随机推荐
- [转] HTML5利用WebRTC的getUserMedia获取摄像头信息模拟拍照及视频(完整示例)
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...
- Ubuntu 安装 OpenMPI
1. 下载OpenMPI 在官网上下载最新版本的安装包,如:openmpi-1.8.4.tar.gz 2. 解压并进行配置 tar -zxvf openmpi-3.0.0.tar.gz cd open ...
- python全栈开发day16-正则表达式和re模块
1.昨日内容回顾 2.正则表达式(re模块是python中和正则表达式相关的模块) 1.作用 1).输入字符串是否符合匹配条件 2).从大段文字中匹配出符合条件的内容 2.字符组 [0-9a-zA-Z ...
- 【Java】 剑指offer(63) 股票的最大利润
本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集 题目 假设把某股票的价格按照时间先后顺序存储在数组中,请问买卖交易该 ...
- Solution for unable to create "dead-letter-exchange" in RabbitMQ
在参考 Dead-Letter-Exchange 进行Dead-letter-exchange的理解, 在本地时,想要创建 Dead-letter-exchange 时,一直报错,错误如下: Unha ...
- 汇合confluence
Confluence是一个专业的企业知识管理与协同软件,也可以用于构建企业wiki.使用简单,但它强大的编辑和站点管理特征能够帮助团队成员之间共享信息.文档协作.集体讨论,信息推送. 空间 空间是页面 ...
- BZOJ.4892.[TJOI2017]DNA(后缀自动机/后缀数组)
题目链接 \(Description\) 给出两个串\(S,T\),求\(T\)在\(S\)中出现了多少次.出现是指.可以有\(3\)次(\(3\)个字符)不匹配(修改使其匹配). \(Solutio ...
- COGS.1317.数列操作c(分块 区间加 区间求和)
题目链接 #include<cmath> #include<cstdio> #include<cctype> #include<algorithm> u ...
- Python 爬取bangumi网页信息
1.数据库连接池 #######db.py########## import time import pymysql import threading from DBUtils.PooledDB im ...
- 常用类及 LeetCode 每日一题
1 日期时间类 在 Java 语言中,是通过时间戳来表示时间的.所谓的时间戳,在 Java 中就是指当前时间距离历元(1970-01-01 00:00:00)的时间间隔,单位是毫秒,所以 Java 中 ...