这个…不知道是镜像问题还是配置上有问题,docker版的oracle 11g在上次部署完之后已经出现了多次无法访问的情况(就是 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g这个镜像),最后一次修复已经将连接数从150(默认)提升到8000,这次无法访问肯定不是连接数已满的问题。
遇事不要慌,先通过docker exec进入容器内部连接一下oracle数据库,看到的是
ora-01034: oracle not available
这…难道是之前为了修改连接数直接关机导致日志无法归档么?
上网查了些资料,最终通过如下步骤解决的:
- 先用sqlplus使用sysdba权限访问连接数据库
[oracle@e156e1b777f5 -]$ sqlplus / as sysdba sql*plus: release 11.2.0.1.0 production on sun nov 14 13:36:28 2021 d88尊龙官网手机app copyright (c) 1982, 2009, oracle. all rights reserved. connected to an idle instance.
- 查询v$log看看能否正常查询到日志信息
sql> select * from v$log; select × from v$log error at line 1: ora-01034: oracle not available process id: 0 session id: 0 serial number: 0
- 在发现报ora-01034: oracle not available错误后,我们再试试操作resetlogs
sql> alter database open resetlogs; alter database open resetlogs * error at line 1: ora-01034: oracle not available process id: o session id: 0 serial number: 0
要注意,这里使用resetlogs方式打开数据库对oracle进行恢复是存在风险的,如果日志文件没有损坏的情况下可以直接恢复就可以了,这次的情况比较麻烦,所以才想用这种方式进行。
- 既然所有操作都报错了,就先关闭实例
sql> shutdown immediate; ora-01034: oracle not available ora-27101: shared memory realm does not exist linux-x86 64 error: 2: no such file or directory
- 重新挂载启动
sql> startup mount; oracle instance started. total system global area 1603411968 bytes fixed size 2213776 bytes variable size 1342179440 bytes database buffers 251658240 bytes redo buffers 7360512 bytes database mounted.
- 重启之后再尝试使用resetlogs打开数据库
sql> alter database open resetlogs; alter database open resetlogs error at line 1: ora-01139: resetlogs option only valid after an incomplete database recovery
这里又是一个error,先不要管它继续下一步操作
- 这时我们又再查一次v$log
如上图所示,通过v$log得知日志只记录到昨天(11月13日),还好不是生产环境的一天的时间还能够接受。
- 通过recover database命令进行数据恢复
sql> recover database until time '2021-11-13 00:00:00' ora-10879: error signaled in parallel recovery slave 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: '/home/oracle/app/oracle/oradata/helowin/systeml.dbf'
嗯…没有头绪还是先“重启”吧
sol> shutdown; ora-01109: database not open database dismounted. oracle instance shut down. sol> startup oracle instance started. total system global area 1603411968 bytes fixed size 2213776 bytes variable size 1342179440 bytes database buffers 251658240 bytes redo buffers 7360512 bytes database mounted. ora-01589: must use resetlogs or noresetlogs option for database open
这次连启动也报错,真是“一波未平一波又起”。
- sqlplus再查询一次l日志
既然这样就手动redo一次吧。
- 执行recover database
执行完了之后再open resetlogs就可以了
sql> alter database open resetlogs; database altered.
为了使操作完全生效决定重启了一下oracle
sql> shutdown immedate; sp2-0717: illegal shutdown option sql> shutdown immediate; database closed. database dismounted. oracle instance shut down. sol> startup; oracle instance started. total system global area 1603411968 bytes fixed size 2213776 bytes variable size 1342179440 bytes database buffers 251658240 bytes redo buffers 7360512 bytes database mounted. database opened.
这样就搞定了。
总结