系列文章目录
ORACLE问题解决
前言
服务器环境windows server 2012 R2,单机oracle 11.2.0.4(64位)
问题产生:
SQL> conn / as sysdba
Connected.
SQL> update user$ set name='SYSA' where user#=0;
1 row updated.
SQL> commit;
Commit complete.
SQL> alter system checkpoint;
System altered.
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 972898304 bytes
Fixed Size 2259160 bytes
Variable Size 629147432 bytes
Database Buffers 335544320 bytes
Redo Buffers 5947392 bytes
Database mounted.
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00600: internal error code, arguments: [kokasgi1], [], [], [], [], [], [],
解决方式:
windows环境安装mingw64环境,并使gdb调试工具能够使用
安装方式可自行搜索
打开三个console来修复 DB
console1: 启动DB到mount状态
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on 星期五 8月 27 15:19:49 2021
Copyright (c) 1982, 2013, Oracle. All rights reserved.
已连接到空闲例程。
SQL> startup mount
ORACLE 例程已经启动。
Total System Global Area 1.8239E+10 bytes
Fixed Size 2288760 bytes
Variable Size 5368710024 bytes
Database Buffers 1.2818E+10 bytes
Redo Buffers 50126848 bytes
数据库装载完毕。
SQL>
console2: 找到oracle服务的进程pid,使用gdb调试oracle在windows服务中的进程,并在kokasgi函数上设置断点
C:\Users\Administrator>gdb D:\app\Administrator\product\11.2.0\dbhome_1\BIN\orac
le.exe 4832
GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from D:\app\Administrator\product\11.2.0\dbhome_1\BIN\oracle.exe
...(no debugging symbols found)...done.
Attaching to program `D:\app\Administrator\product\11.2.0\dbhome_1\BIN\oracle.ex
e', process 4832
[New Thread 4832.0x1390]
[New Thread 4832.0x11b4]
[New Thread 4832.0x10b4]
[New Thread 4832.0xf5c]
[New Thread 4832.0x1058]
[New Thread 4832.0xd94]
[New Thread 4832.0x122c]
[New Thread 4832.0x1028]
[New Thread 4832.0xe3c]
[New Thread 4832.0x1330]
[New Thread 4832.0x9b4]
[New Thread 4832.0x1204]
[New Thread 4832.0x10e8]
[New Thread 4832.0x12c8]
[New Thread 4832.0x1288]
[New Thread 4832.0x1134]
[New Thread 4832.0x58c]
[New Thread 4832.0x1070]
[New Thread 4832.0xcc8]
[New Thread 4832.0xf38]
[New Thread 4832.0x11c0]
[New Thread 4832.0x150]
[New Thread 4832.0x1110]
[New Thread 4832.0x127c]
[New Thread 4832.0x1160]
[New Thread 4832.0x290]
(gdb) break kokasgi
Function "kokasgi" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (kokasgi) pending.
(gdb) c
Continuing.
[Thread 4832.0x290 exited with code 0]
console1: 回console1执行 alter database open,此时这个session会 hang 住
console2: gdb中抛出异常
Breakpoint 1 (kokasgi) pending.
(gdb) c
Continuing.
[Thread 4832.0x290 exited with code 0]
[Thread 4832.0x127c exited with code 0]
[Thread 4832.0x1160 exited with code 0]
[Thread 4832.0xd94 exited with code 0]
[New Thread 4832.0xb2c]
[New Thread 4832.0x988]
[New Thread 4832.0x1270]
[New Thread 4832.0xeb0]
[New Thread 4832.0x1064]
[New Thread 4832.0x28c]
[New Thread 4832.0x13c4]
[New Thread 4832.0x11a0]
[New Thread 4832.0x137c]
[New Thread 4832.0x10ac]
[New Thread 4832.0x1034]
[New Thread 4832.0xeec]
[New Thread 4832.0xe58]
[New Thread 4832.0x1220]
[New Thread 4832.0xe70]
Thread 23 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 4832.0x1110]
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb)
console3: 使用sqlplus登录数据库并执行脚本修改sys用户为原始用户名称(此时session也会hang住)
C:\Users\Administrator>sqlplus / as sysdba @a.sql
SQL*Plus: Release 11.2.0.4.0 Production on 星期五 8月 27 15:30:24 2021
Copyright (c) 1982, 2013, Oracle. All rights reserved.
(a.sql内容为:
update user$ set name=‘SYS’ where user#=0;
commit;
alter system checkpoint;)
console2: 在gdb中按c键,使调试程序向后推进直至console3中a.sql中内容全部执行成功
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
[New Thread 4832.0x1238]
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
[Thread 4832.0xeac exited with code 0]
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
[New Thread 4832.0xf4c]
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
[Thread 4832.0x1238 exited with code 0]
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f89e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
Thread 25 received signal SIGSEGV, Segmentation fault.
0x000000000148f87e in slacc_check ()
from d:\app\administrator\product\11.2.0\dbhome_1\bin\orageneric11.dll
(gdb) c
Continuing.
[Thread 4832.0x13d0 exited with code 0]
[New Thread 4832.0x814]
[Thread 4832.0x814 exited with code 0]
[Thread 4832.0xf4c exited with code 1]
[Thread 4832.0x1134 exited with code 0]
[Thread 4832.0x58c exited with code 0]
[Thread 4832.0x1070 exited with code 0]
[Thread 4832.0xcc8 exited with code 0]
[Thread 4832.0xf38 exited with code 0]
[Thread 4832.0x11c0 exited with code 0]
[Thread 4832.0x150 exited with code 0]
[Thread 4832.0xb2c exited with code 0]
[Thread 4832.0x988 exited with code 0]
[Thread 4832.0x1270 exited with code 0]
[Thread 4832.0xeb0 exited with code 0]
[Thread 4832.0x1064 exited with code 0]
[Thread 4832.0x28c exited with code 0]
[Thread 4832.0x13c4 exited with code 0]
[Thread 4832.0x11a0 exited with code 0]
[Thread 4832.0x1398 exited with code 0]
[Thread 4832.0xb94 exited with code 0]
[Thread 4832.0xefc exited with code 0]
[Thread 4832.0xec0 exited with code 0]
[Thread 4832.0x10bc exited with code 0]
[Thread 4832.0x12f8 exited with code 0]
[Thread 4832.0xf64 exited with code 0]
[Thread 4832.0x114c exited with code 0]
[Thread 4832.0x13b0 exited with code 0]
[Thread 4832.0xb50 exited with code 0]
[Thread 4832.0x1210 exited with code 0]
[Thread 4832.0x11dc exited with code 0]
[Thread 4832.0x13fc exited with code 0]
[Thread 4832.0xfec exited with code 0]
[Thread 4832.0x13bc exited with code 0]
[Thread 4832.0x960 exited with code 0]
[Thread 4832.0x125c exited with code 0]
[Thread 4832.0x1178 exited with code 0]
[New Thread 4832.0xbf0]
console2: 同时console2显示成功执行修改用户脚本
C:\Users\Administrator>sqlplus / as sysdba @a.sql
SQL*Plus: Release 11.2.0.4.0 Production on 星期五 8月 27 15:37:08 2021
Copyright (c) 1982, 2013, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已更新 1 行。
提交完成。
系统已更改。
SQL>
console1: 同时console1数据库启动报错已弹出(不用管)
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00600: internal error code, arguments: [kokasgi1], [], [], [], [], [], [],
[], [], [], [], []
进程 ID: 4472
会话 ID: 66 序列号: 3
console2: 关闭gdb
[New Thread 4832.0xbf0]
[Thread 4832.0x624 exited with code 0]
[Thread 4832.0xbf0 exited with code 0]
[New Thread 4832.0x102c]
[New Thread 4832.0xc64]
[Thread 4832.0xc64 exited with code 0]
[Thread 4832.0x102c exited with code 0]
[New Thread 4832.0x128c]
Thread 48 received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 4832.0x128c]
0x00007ff8bc8f2241 in ntdll!DbgBreakPoint ()
from C:\Windows\SYSTEM32\ntdll.dll
(gdb) quit
A debugging session is active.
Inferior 1 [process 4832] will be detached.
Quit anyway? (y or n) y
Detaching from program: D:\app\Administrator\product\11.2.0\dbhome_1\BIN\oracle.
exe, Pid 4832
C:\Users\Administrator>
console1: 重新启动数据库服务,成功打开
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on 星期五 8月 27 15:43:19 2021
Copyright (c) 1982, 2013, Oracle. All rights reserved.
已连接到空闲例程。
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 1.8239E+10 bytes
Fixed Size 2288760 bytes
Variable Size 5368710024 bytes
Database Buffers 1.2818E+10 bytes
Redo Buffers 50126848 bytes
数据库装载完毕。
数据库已经打开。
SQL>
到此修复完成。
总结
使用gdb调试oracle启动主线程,在oracle启动过程中报错函数前加断点使启动暂停;
执行还原sys用户名脚本,后逐行调试程序,直至脚本执行完成;
此时oracle启动主线程还是会报错退出,但是脚本已完成sys用户名修改,再次启动oracle成功。