作者介绍:老苏,10余年DBA工作运维经验,擅长Oracle、MySQL、PG数据库运维(如安装迁移,性能优化、故障应急处理等)
公众号:老苏畅谈运维
欢迎关注本人公众号,更多精彩与您分享。
前面介绍了两种推进SCN方法
(1)event 10015 来增加 scn 的值
(2)隐含参数_minimum_giga_scn 来增加 scn 的值
现在来说一下oracle推进SCN方法3:gdb/dbx 来直接修改内存中的值
linux下通过gdb调整scn更方便,适合oracle各种版本,数据库mount和open状态下都可以通过此方法推进SCN。
PS:请不要在生产库测试操作,如果需要,请先进行备份。
1、安装gdb工具
在使用gdb工具前,如果没有安装的话需要预先安装此工具
yum install gdb -y
2、查看当前SCN值
SQL> select current_scn,to_char(current_scn,'xxxxxxxxx') from v$database;
CURRENT_SCN TO_CHAR(CU
----------- ----------
1791638 1b5696
SQL> oradebug setmypid
Statement processed.
SQL> oradebug dumpvar sga kcsgscn
kcslf kcsgscn_ [06001FBB0, 06001FBE0) = 001B590D 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 6001F6B0 00000000
06001FBB0是SCN BASE内存地址,我们待会修改的地方就是它,修改成多少,数据库SCN就是多少
001B590D是当前的SCN值,可以理解为06001FBB0是一个代号x,当前x的值等于001B590D
假设要将当前scn值增加1000000
SQL> select current_scn+1000000,to_char(current_scn+1000000,'xxxxxxxxx') from v$database;
CURRENT_SCN+1000000 TO_CHAR(CU
------------------- ----------
2792220 2a9b1c
3、gdb修改SCN值
$ ps -ef|grep LOCAL=YES
oracle 20610 19297 0 16:26 ? 00:00:00 oracleora121 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 22376 22346 0 16:48 pts/1 00:00:00 grep --color=auto LOCAL=YES
##查看当前数据库进程号为20610
[oracle@ora121:~]$ gdb $ORACLE_HOME/bin/oracle 20610
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.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:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /u01/app/oracle/product/12.1.0/db/bin/oracle...(no debugging symbols found)...done.
Attaching to program: /u01/app/oracle/product/12.1.0/db/bin/oracle, process 20610
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libodm12.so...(no debugging symbols found)...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libodm12.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libcell12.so...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libcell12.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libskgxp12.so...(no debugging symbols found)...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libskgxp12.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libskjcx12.so...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libskjcx12.so
Reading symbols from /lib64/librt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/librt.so.1
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libmql1.so...(no debugging symbols found)...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libmql1.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libipc1.so...(no debugging symbols found)...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libipc1.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libclsra12.so...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libclsra12.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libdbcfg12.so...(no debugging symbols found)...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libdbcfg12.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libhasgen12.so...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libhasgen12.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libskgxn2.so...(no debugging symbols found)...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libskgxn2.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libocr12.so...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libocr12.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libocrb12.so...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libocrb12.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libocrutl12.so...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libocrutl12.so
Reading symbols from /lib64/libaio.so.1...Reading symbols from /lib64/libaio.so.1...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libaio.so.1
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libons.so...(no debugging symbols found)...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libons.so
Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libdl.so.2
Reading symbols from /lib64/libm.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libm.so.6
Reading symbols from /lib64/libpthread.so.0...(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Loaded symbols for /lib64/libpthread.so.0
Reading symbols from /lib64/libnsl.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libnsl.so.1
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from /lib64/libnss_files.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libnss_files.so.2
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libnque12.so...(no debugging symbols found)...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libnque12.so
Reading symbols from /u01/app/oracle/product/12.1.0/db/lib/libshpkavx12.so...(no debugging symbols found)...done.
Loaded symbols for /u01/app/oracle/product/12.1.0/db/lib/libshpkavx12.so
0x00007f3afd1aa740 in __read_nocancel () from /lib64/libpthread.so.0
Missing separate debuginfos, use: debuginfo-install glibc-2.17-326.el7_9.x86_64 libaio-0.3.109-13.el7.x86_64
(gdb) set *((int *) 0x06001FBB0) = 0x2a9b1c
(gdb) quit
A debugging session is active.
Inferior 1 [process 20610] will be detached.
Quit anyway? (y or n) y
Detaching from program: /u01/app/oracle/product/12.1.0/db/bin/oracle, process 20610
[Inferior 1 (process 20610) detached]
###注意上面的set *((int *) 0x06001FBB0) = 0x2a9b1c --->将SCN BASE修改为要增大的值
4、查看修改后的SCN
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
2792272 <<<已由原来的1791638增加到2792272,增加了约1000000
重启数据库,也可以正常打开数据库:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 3707764736 bytes
Fixed Size 2930944 bytes
Variable Size 855639808 bytes
Database Buffers 2835349504 bytes
Redo Buffers 13844480 bytes
Database mounted.
Database opened.
链接:
史上最全,呕心沥血总结oracle推进SCN方法(一)
史上最全,呕心沥血总结oracle推进SCN方法(二)