关于Oracle中重启数据库的一个bug


关于drop database在Oracle中是致命的操作,这个操作自己在测试环境中体验过,会完全删除数据文件,因此这个操作非常敏感但是实用性不强,不过话说过来,这个操作也不是随便就能执行的,除了操作敏感的权限之外,其实还是有一些前提条件的。
 在数据库open状态,是无法运行这个命令的。
SQL> drop database TEST;
drop database TEST
              *
ERROR at line 1:
ORA-00933: SQL command not properly ended

需要重启到mount阶段。
SQL> alter database mount exclusive;
Database altered.

SQL> drop database TEST;
drop database TEST
              *
ERROR at line 1:
ORA-00933: SQL command not properly ended
同时还要保证处于exclustrict模式。
SQL> drop database;--要执行还是不容易的。
drop database
*
ERROR at line 1:
ORA-12719: operation requires database is in RESTRICTED mode
SQL> alter system enable restricted session;
System altered.
SQL> drop database;
Database dropped.

今天网友提供了一个精简的两个命令。就把停库,重启到Mount,设置restrict mode,drop database的步骤都完成了。
 自己在本地的测试库中也尝试了一下,看看能不能启动到restrict模式下.,结果运行的时候报了一个ORA错误就退出了。
idle>  startup force  mount restrict;
ORA-00000: normal, successful completion

其实对于这个问题,oerr的解释感觉有些牵强,至少对于我来说是不可接受的。
$ oerr ora 00000
 00000, 00000, "normal, successful completion"
 // *Cause:  Normal exit.
 // *Action: None.
顺着这个问题在metalink上看了一圈,突然有一个帖子引起了我的注意,就是关于钱包的一个设置。
 关于钱包的设置,可以参考我之前对比MySQL和Oracle无密码登录的案例。http://blog.itpub.net/23718752/viewspace-1659551/
 metalink中相关的文章是Bug 11706168 - ORA-00000 during STARTUP with SQLNET.WALLET_OVERRIDE=TRUE (Doc ID 11706168.8)
由此可见很可能就是我碰到的这个bug.
我们来简单验证和复现一下。
 如果启用钱包的这个override特性,就出出现问题。
sys@TEST11G> startup force
 ORA-00000: normal, successful completion
 sys@TEST11G> !cat sqlnet.ora|grep SQLNET
SQLNET.WALLET_OVERRIDE=true
如果禁用,就会发现能够正常重启了。
idle> startup force
 ORACLE instance started.
 Total System Global Area  435224576 bytes
 Fixed Size                  1337044 bytes
 Variable Size            272632108 bytes
 Database Buffers          155189248 bytes
 Redo Buffers                6066176 bytes
 Database mounted.
 Database opened.
 idle> !cat sqlnet.ora|grep SQLNET
#SQLNET.WALLET_OVERRIDE=true

对于这个问题的测试还没有完,我们可以深究一下,这个问题在什么场景下还会出现。
 其实在同一个session中进行数据库的重启也是会有问题的。
 我们在同一个session内重启,停库
idle> startup
 ORACLE instance started.
 Total System Global Area  435224576 bytes
 Fixed Size                  1337044 bytes
 Variable Size            272632108 bytes
 Database Buffers          155189248 bytes
 Redo Buffers                6066176 bytes
 Database mounted.
 Database opened.
 idle> shutdown immediate
 Database closed.
 Database dismounted.
 ORACLE instance shut down.
当再次重启的时候,就会出现这个问题了,当然这个问题还是和钱包相关的。
idle> startup
 ORA-00000: normal, successful completion

idle> !cat sqlnet.ora|grep SQLNET
 SQLNET.WALLET_OVERRIDE=true


最后亮出那个精简的命令,看看效果。
sys@TEST11G> startup force mount restrict;
 ORACLE instance started.
 Total System Global Area  435224576 bytes
 Fixed Size                  1337044 bytes
 Variable Size            272632108 bytes
 Database Buffers          155189248 bytes
 Redo Buffers                6066176 bytes
 Database mounted.
可以看到数据库可以很快的重启到Mount阶段,然后设置为restrict模式。
 当然,startup force也就是个人本地测试环境玩玩,工作中的环境中一概要撇清关系,因为后果是很严重的,别说破坏性操作,就算新特性的使用都是谨慎又谨慎的,这也是我们DBA存在的一种意义和价值所在。

相关内容

    暂无相关文章