sqlplus命令無響應,cpu佔用率很高的問題處理

regonly1發表於2017-02-16
今天準備連線一臺測試伺服器的資料庫,但是遲遲未能連上。直接登入主機,用sqlplus連,一直沒反應。殺掉程式也無法連線sqlplus。
實在搞不清楚為什麼,抱著試試看的心情搜尋了一下,卻發現這是普遍現象。
下面是一篇文章:

根據文中所說的幾個條件,我查了一下本地的情況,伺服器啟動剛剛199天(uptime):
[oracle@DB ~]$ uptime
 10:35:46 up 199 days, 53 min,  3 users,  load average: 0.05, 0.05, 0.31
文中說從198天起剛好會出現該問題。
資料庫版本是10.2.0.1,又吻合。
然後用strace命令跟蹤了一下:
fcntl64(6, F_SETFD, FD_CLOEXEC)         = 0
lseek(6, 0, SEEK_SET)                   = 0
read(6, "\25\23\"\1\23\3\t\t\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 256) = 256
lseek(6, 512, SEEK_SET)                 = 512
read(6, "\337y\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 512) = 512
lseek(6, 1024, SEEK_SET)                = 1024
read(6, "\25\7'\0072\7>\7j\7\276\17$'\6K5S\24TfT\307T(VsV\222V\6W"..., 86) = 86
times(NULL)                             = 2148613639
times(NULL)                             = 2148613639
times(NULL)                             = 2148613639
times(NULL)                             = 2148613639
times(NULL)                             = 2148613639
times(NULL)                             = 2148613639
times(NULL)                             = 2148613639
基本確定是bug引起:
事實上只要 x86主機執行天數是是24.8的倍數都有可能引發該bug,因為time()函式值為null,造成無限死迴圈,從而耗盡cpu。

解決辦法有三種:
1、重啟伺服器(治標不治本);
2、資料庫版本升級(比較耗時);
3、打patch;

以下是patch過程:
[oracle@DB packages]$ unzip p4612267_10201_LINUX32bit_198days.zip 
Archive:  p4612267_10201_LINUX32bit_198days.zip
   creating: 4612267/
   creating: 4612267/files/
   creating: 4612267/files/lib/
   creating: 4612267/files/lib/libcore10.a/
  inflating: 4612267/files/lib/libcore10.a/sltrg.o  
   creating: 4612267/etc/
   creating: 4612267/etc/config/
  inflating: 4612267/etc/config/inventory  
  inflating: 4612267/etc/config/actions  
   creating: 4612267/etc/xml/
  inflating: 4612267/etc/xml/GenericActions.xml  
  inflating: 4612267/etc/xml/ShiphomeDirectoryStructure.xml  
  inflating: 4612267/README.txt      
[oracle@DB packages]$ ls
4612267  bbed  cx_Oracle-5.1.2  p4612267_10201_LINUX32bit_198days.zip  p4612267_10201_Linux-x86-64.zip
[oracle@DB packages]$ cd 4612267/
[oracle@DB 4612267]$ ls
etc  files  README.txt
[oracle@DB 4612267]$ $ORACLE_HOME/OPatch/opatch apply
Invoking OPatch 10.2.0.1.0


Oracle interim Patch Installer version 10.2.0.1.0
Copyright (c) 2005, Oracle Corporation.  All rights reserved..




Oracle Home       : /home/oracle/db/product/10.2.0/db_1
Central Inventory : /home/oracle/oraInventory
   from           : /home/oracle/db/product/10.2.0/db_1/oraInst.loc
OPatch version    : 10.2.0.1.0
OUI version       : 10.2.0.1.0
OUI location      : /home/oracle/db/product/10.2.0/db_1/oui
Log file location : /home/oracle/db/product/10.2.0/db_1/cfgtoollogs/opatch/opatch-2017_Feb_16_10-52-33-CST_Thu.log


ApplySession applying interim patch '4612267' to OH '/home/oracle/db/product/10.2.0/db_1'
Invoking fuser to check for active processes.
Invoking fuser on "/home/oracle/db/product/10.2.0/db_1/bin/oracle"


OPatch detected non-cluster Oracle Home from the inventory and will patch the local system only.




Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/home/oracle/db/product/10.2.0/db_1')


Is the local system ready for patching?


Do you want to proceed? [y|n]
y
User Responded with: Y
Backing up files and inventory (not for auto-rollback) for the Oracle Home
Backing up files affected by the patch '4612267' for restore. This might take a while...
Backing up files affected by the patch '4612267' for rollback. This might take a while...


Patching component oracle.oracore.rsf, 10.2.0.1.0...
Updating archive file "/home/oracle/db/product/10.2.0/db_1/lib/libcore10.a"  with "lib/libcore10.a/sltrg.o"


Patching component oracle.rdbms, 10.2.0.1.0...
Updating archive file "/home/oracle/db/product/10.2.0/db_1/lib/libcore10.a"  with "lib/libcore10.a/sltrg.o"
Running make for target client_sharedlib
Running make for target client_sharedlib
Running make for target ioracle
ApplySession adding interim patch '4612267' to inventory


The local system has been patched and can be restarted.




OPatch succeeded.
[oracle@DB 4612267]$ 


然後啟動sqlplus,正常啟動,問題解決。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12932950/viewspace-2133633/,如需轉載,請註明出處,否則將追究法律責任。

相關文章