你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle控制文件基本维护

[日期:2012-05-16] 来源:Linux社区  作者:gtlions [字体:大 中 小]
两端创建控制文件的脚本,分别用于2中情况:NORESETLOGS和RESETLOGS,简单来说就是看online log的情况而定,如果online log可用,那么使用前者;否则使用后者,将重置日志文件,一些数据将会丢失。这里我当然使用的是NORESETLOGS选项了,可用将备份的trace文件再次备份然后编辑后直接在sqlplus @执行。
sys@ www.linuxidc.com> @/u01/Oracle/gt9icontrolCREATE.trc
ORACLE instance started.

Total System Global Area  286752136 bytes
Fixed Size             740744 bytes
Variable Size          150994944 bytes
Database Buffers      134217728 bytes
Redo Buffers             798720 bytes

Control file created.

ORA-00283: recovery session canceled due to errors
ORA-00264: no recovery required



Database altered.


Tablespace altered.


Tablespace altered.
ok,这样控制文件就恢复了。
3.1. 二进制文件恢复
同样,模拟下文件的丢失,然后将二进制分别复制到原位置,注意如果有多个控制文件需要多个拷贝并将文件名称修改为原来的名称。
注意在做这个实验之前需要重新执行下二进制的备份操作,因为在上一次二进制备份之后我们执行了trace的恢复操作。
sys@ www.linuxidc.com> alter database backup controlfile to '/u01/oracle/gt9icontrol.ctl';

Database altered.
sys@ www.linuxidc.com> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

sys@ www.linuxidc.com> startup
ORACLE instance started.

[oracle@ www.linuxidc.com gt9i]$  mv control01.ctl c1.ctl;mv control02.ctl c2.ctl ;mv control03.ctl c3.ctl;mv controlTEST.ctl cTEST.ctl
[oracle@ www.linuxidc.com gt9i]$ ll c*
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:03 c1.ctl
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:03 c2.ctl
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:03 c3.ctl
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:03 cTEST.ctl
-rw-r--r--  1 oracle oinstall 20979712  4月 11 17:03 cwmlite01.dbf
sys@ www.linuxidc.com> startup
ORACLE instance started.

Total System Global Area  286752136 bytes
Fixed Size             740744 bytes
Variable Size          150994944 bytes
Database Buffers      134217728 bytes
Redo Buffers             798720 bytes
ORA-00205: error in identifying controlfile, check alert log for more info


sys@ www.linuxidc.com> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.
[oracle@ www.linuxidc.com oracle]$ cp gt9icontrol.ctl 9i/oradata/gt9i/control01.ctl;cp gt9icontrol.ctl 9i/oradata/gt9i/control02.ctl;cp gt9icontrol.ctl 9i/oradata/gt9i/control03.ctl;cp gt9icontrol.ctl 9i/oradata/gt9i/controlTEST.ctl
[oracle@ www.linuxidc.com gt9i]$ ll c*
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:03 c1.ctl
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:03 c2.ctl
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:03 c3.ctl
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:05 control01.ctl
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:05 control02.ctl
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:05 control03.ctl
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:05 controlTEST.ctl
-rw-r-----  1 oracle oinstall  2285568  4月 11 17:03 cTEST.ctl
-rw-r--r--  1 oracle oinstall 20979712  4月 11 17:03 cwmlite01.dbf
sys@ www.linuxidc.com> startup mount;
ORACLE instance started.

Total System Global Area  286752136 bytes
Fixed Size             740744 bytes
Variable Size          150994944 bytes
Database Buffers      134217728 bytes
Redo Buffers             798720 bytes
Database mounted.

sys@ www.linuxidc.com> alter database open resetlogs;

Database altered.
这样就ok了,当然我这是完全不出意外的操作,只是模拟了在关掉数据库的情况下的丢失而已,如果是在其他情况,需要自行recover操作。
-The End-linux
相关资讯       oracle数据库教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款