rename datafile 做了什么

今天在做数据库恢复重建的时候,对datafile rename突然有点迷惑,下班回来就做了下面的实验。先放上结论,这个结论是我结合10046 trace文件内容与自己的推测得出来了,推测的部分还有待证实。

结论:1:oracle在mount的过程中,只检查了控制文件的完整性,并没有去验证控制文件中记录的信心是否正确无缺;或者说oracle验证了,但是即使检测到错误也没有给出提示。 mount后,在控制文件中做了标记锁定,其他实例不能再mount此控制文件。

             2:rename可以在mount状态进行操作,在rename过程中,oracle仅修改了控制文件对应内容,并没有其他文件被修改。结合第一步的结论,在mount状态下,我们可以按我们想要的任意修改控制文件,只要在oracle  open阶段可以验证通过即可。

第一部分实验:验证结论1.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ cd /home/oracle/app/oracle/oradata/orcl2
[oracle@localhost orcl2]$ ls
control01.ctl  example01.dbf  redo01.log  redo02.log  redo03.log  sysaux01.dbf  system01.dbf  temp01.dbf  temp02.dbf  temp03.dbf  undotbs01.dbf  users01.dbf  users02.dbf  users03.dbf
[oracle@localhost orcl2]$ mv users03.dbf users04.dbf
[oracle@localhost orcl2]$ ls -l
total 15397428
-rw-r-----. 1 oracle oinstall   10108928 Jul 19 03:02 control01.ctl
-rw-r-----. 1 oracle oinstall  355213312 Jul 19 03:02 example01.dbf
-rw-r-----. 1 oracle oinstall   52429312 Jul 19 03:00 redo01.log
-rw-r-----. 1 oracle oinstall   52429312 Jul 19 03:00 redo02.log
-rw-r-----. 1 oracle oinstall   52429312 Jul 19 03:02 redo03.log
-rw-r-----. 1 oracle oinstall  713039872 Jul 19 03:02 sysaux01.dbf
-rw-r-----. 1 oracle oinstall  922755072 Jul 19 03:02 system01.dbf
-rw-r-----. 1 oracle oinstall 9279905792 Jul 19 03:00 temp01.dbf
-rw-r-----. 1 oracle oinstall   10493952 Dec 14  2015 temp02.dbf
-rw-r-----. 1 oracle oinstall   10493952 Dec 14  2015 temp03.dbf
-rw-r-----. 1 oracle oinstall 2768248832 Jul 19 03:02 undotbs01.dbf
-rw-r-----. 1 oracle oinstall 1566318592 Jul 19 03:02 users01.dbf
-rw-r-----. 1 oracle oinstall   20979712 Jul 19 03:02 users02.dbf
-rw-r-----. 1 oracle oinstall   10493952 Jul 19 03:02 users04.dbf
[oracle@localhost orcl2]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Jul 19 03:03:25 2016
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup mount   
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.
Total System Global Area  267227136 bytes
Fixed Size                  2252384 bytes
Variable Size             184549792 bytes
Database Buffers           75497472 bytes
Redo Buffers                4927488 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/home/oracle/app/oracle/oradata/orcl2/users03.dbf'  --在这里看到,控制文件记录的和实际的数据文件不一致,oracle可以mount但是不能open;

下面开始验证第二个结论:

SQL> conn / as sysdba                                                                    
Connected.
SQL> @$HOME/gettrcname
VALUE
----------------------------------------------------------------------------------------------------
/home/oracle/app/oracle/diag/rdbms/orcl2/orcl2/trace/orcl2_ora_19853.trc
SQL> alter session set events '10046 trace name context forever ,level 12';
Session altered.
SQL> alter database rename file '/home/oracle/app/oracle/oradata/orcl2/users03.dbf' to '/home/oracle/app/oracle/oradata/orcl2/users04.dbf';
Database altered.
SQL> alter session set events '10046 trace name context off';
Session altered.
SQL> alter database open;
Database altered.



下面是trace文件内容

WAIT #140605645297032: nam='SQL*Net message from client' ela= 34535079 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1468868829795450

CLOSE #140605645297032:c=0,e=6,dep=0,type=1,tim=1468868829795531
XCTEND rlbk=0, rd_only=1, tim=1468868829795778
=====================
PARSING IN CURSOR #140605645291984 len=133 dep=0 uid=0 oct=35 lid=0 tim=1468868829795953 hv=4254119963 ad='6f858d68' sqlid='23bkm7myt1f0v'
alter database rename file '/home/oracle/app/oracle/oradata/orcl2/users03.dbf' to '/home/oracle/app/oracle/oradata/orcl2/users04.dbf'
END OF STMT

PARSE #140605645291984:c=1031,e=401,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,plh=0,tim=1468868829795952  --语句解析,cpu time1031 ,Elapsed time 401 这几个时间单位是us。物理读0,一致性读0,当前读0这几个读单位是buffer数量。 硬解析一次,0行被处理,深度0,优化目标all_rows,最后一个是时间戳

WAIT #140605645291984: nam='rdbms ipc reply' ela= 422 from_process=14 timeout=21474836 p3=0 obj#=-1 tim=1468868829796731
WAIT #140605645291984: nam='Disk file operations I/O' ela= 24 FileOperation=2 fileno=0 filetype=1 obj#=-1 tim=1468868829796860
WAIT #140605645291984: nam='Disk file operations I/O' ela= 9 FileOperation=2 fileno=1 filetype=1 obj#=-1 tim=1468868829796885 --FileOperation=2文件读操作,fileno=1、fileno=0:1号、0号文件,filetype=1:文件类型,控制文件。合起来就是读取了0号1号控制文件。
WAIT #140605645291984: nam='control file sequential read' ela= 11 file#=0 block#=1 blocks=1 obj#=-1 tim=1468868829796904
WAIT #140605645291984: nam='control file sequential read' ela= 5 file#=1 block#=1 blocks=1 obj#=-1 tim=1468868829796928
WAIT #140605645291984: nam='control file sequential read' ela= 4 file#=0 block#=15 blocks=1 obj#=-1 tim=1468868829796941
WAIT #140605645291984: nam='control file sequential read' ela= 3 file#=0 block#=17 blocks=1 obj#=-1 tim=1468868829796949
WAIT #140605645291984: nam='control file sequential read' ela= 5 file#=0 block#=31 blocks=1 obj#=-1 tim=1468868829796972

WAIT #140605645291984: nam='control file sequential read' ela= 7 file#=0 block#=24 blocks=1 obj#=-1 tim=1468868829797092  --控制文件连续读


WAIT #140605645291984: nam='Disk file operations I/O' ela= 34 FileOperation=2 fileno=0 filetype=2 obj#=-1 tim=1468868829797234  --0号数据文件,我们从sys.file$视图可以看到文件编号是从1开始的,我推测这里是从0开始编号,所以这里的0号文件应该对应sys.file$的1号文件,即system01.dbf。打开system01.dbf数据文件。
WAIT #140605645291984: nam='control file parallel write' ela= 1297 files=2 block#=32 requests=2 obj#=-1 tim=1468868829798579  --控制文件并行写,同时写0和1号两个控制文件的32号块。
WAIT #140605645291984: nam='control file sequential read' ela= 15 file#=0 block#=269 blocks=1 obj#=-1 tim=1468868829798626  --控制文件连续读,block269一个块。
WAIT #140605645291984: nam='Disk file operations I/O' ela= 9 FileOperation=5 fileno=0 filetype=2 obj#=-1 tim=1468868829798647 --关闭system01.dbf数据文件
WAIT #140605645291984: nam='control file parallel write' ela= 1153 files=2 block#=270 requests=2 obj#=-1 tim=1468868829799809 --下面都是对控制文件的读写
WAIT #140605645291984: nam='control file parallel write' ela= 1002 files=2 block#=18 requests=2 obj#=-1 tim=1468868829800843
WAIT #140605645291984: nam='control file parallel write' ela= 954 files=2 block#=16 requests=2 obj#=-1 tim=1468868829801823
WAIT #140605645291984: nam='control file parallel write' ela= 935 files=2 block#=1 requests=2 obj#=-1 tim=1468868829802781
WAIT #140605645291984: nam='control file sequential read' ela= 7 file#=0 block#=1 blocks=1 obj#=-1 tim=1468868829802894
WAIT #140605645291984: nam='control file sequential read' ela= 4 file#=0 block#=16 blocks=1 obj#=-1 tim=1468868829802909
WAIT #140605645291984: nam='control file sequential read' ela= 2 file#=0 block#=18 blocks=1 obj#=-1 tim=1468868829802917
XCTEND rlbk=0, rd_only=1, tim=1468868829803110  事务标识,无回滚,只读
EXEC #140605645291984:c=2075,e=7153,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=0,tim=1468868829803142

WAIT #140605645291984: nam='SQL*Net message to client' ela= 2 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1468868829803307

以上,不十分了解为何要打开关闭system01.dbf文件。但除此之外,可以看到rename datafile操作只修改了controlfile的。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值