GDB是GNU项目开发的命令行调试工具,支持多种编程语言(C/C++、Go、Rust等),主要用于分析程序崩溃、逻辑错误和内存问题。它允许开发者在程序运行时检查内部状态(如变量值、调用栈),动态修改执行流程。
在本案例中可用于调整推进数据库的SCN,来处理由于SCN问题无法打开的数据库。不过该方法适用于12C及以上的数据库。
经测试发现,数据库
mount
和
open
状态下都可以通过此方法推进
SCN
。
Session1
:
查询当前
SCN
|
|
SQL>
select
current_scn
from
v$
database
;
|
查询当前
SCN
转成
16
进制后的值
|
|
SQL>
select
to_char(2910718245,
'xxxxxxxxxxxx'
)
from
dual;
|
查询预修改的
SCN
转换成
16
进制后的值
|
|
SQL>
select
to_char(3910718245,
'xxxxxxxxxxxx'
)
from
dual;
|
060017E98
是
SCN BASE
值,我们待会修改的就是他,修改成多少,数据库
SCN
就是多少
AD7E093B
是当前的
SCN
值,可以理解为
060017E98
是一个代号
x
,当前的
x
等于
AD7E093B
Session2:
|
|
[oracle@redhat19c11 ~]$ ps -ef|grep
LOCAL
=YES
oracle 9824 9730 0 Feb22 ? 00:00:01 oracleorcl (DESCRIPTION=(
LOCAL
=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 18621 8636 0 01:18 pts/1 00:00:00 grep
|
本次测试库是
orcl
,因此选
9824
|
|
[oracle@redhat19c11 ~]$ gdb $ORACLE_HOME/bin/oracle 9824
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
Copyright (C) 2013
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-redhat-linux-gnu"
.
For
bug reporting instructions, please see:
。。。。。。(中间省略)
(gdb)
set
*((
int
*) 0x060017E98) = 0xe918d325
|
返回
session1
查询,修改成功:
|
|
SQL>
select
current_scn
from
v$
database
;
|
重启数据库,也正常:
|
|
SQL> shutdown immediate;
Database
closed.
Database
dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System
Global
Area 2466250400 bytes
Fixed
Size
9137824 bytes
Variable
Size
603979776 bytes
Database
Buffers 1845493760 bytes
Redo Buffers 7639040 bytes
Database
mounted.
Database
opened.
SQL>
select
current_scn
from
v$
database
;
|