記錄一次RAC異常的問題和處理

問題的現象和處理  轉載 搜索到的方法

http://www.novell.com/support/kb/doc.php?id=3007194 

轉載

http://hi.baidu.com/edeed/item/fb7ff6c224bd3953ad00efb0

Linux下殭屍進程過多造成用戶無法登陸, 參考解決辦法

平臺: Red Hat Enterprise Linux AS release 4 (Nahant Update 8)

oracle用戶無法登陸, 登錄時提示"Resource temporarily unavailable":


# su - oracle
su: cannot set user id: Resource temporarily unavailable

看來是Oracle用戶不能fork系統進程. 通過top查看竟然有幾千個進程, 且有800多個僵死進程:

# top
...
Tasks: 2079 total,   1 running, 782 sleeping, 432 stopped, 864 zombie
...

defunct進程已經是死掉的了. 除了在kernel進程表裏佔用了記錄以外, 不佔用任何系統資源. 查看僵死進程信息:


# ps auxwwf | grep defunct | grep -v grep | wc -l
864
# ps auxwwf | grep defunct | grep -v grep

查看系統資源限制, oracle用戶的 "soft nproc" 爲2047, 這是按照oracle數據庫官方文檔設置的.

# cat /etc/security/limits.conf
...
oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  1024
oracle              hard    nofile  65536

發生的原因如下:

defunct 進程產生的原因就是父進程先於子進程退出了. 因爲父進程既沒有退出也沒有處理SIGCHLD信號造成的. 如果父進程退出了, 它的子進程將被init收養, init會負責處理SIGCHLD從而消除進程.但是信號機制是不可靠的, SIGCHLD信號丟失的子進程就沒有機會被init處理.

臨時解決辦法是:

1) 修改/etc/security/limits.conf中的oracle soft nproc 2047 爲 3096, 再次嘗試可以登錄系統.
2) 嘗試kill引起殭屍進程的父進程, 從而減少系統總進程數, 再次嘗試可以登錄系統. 我使用的是第二種方法.

終極解決辦法是:

參見kernel的mail list也只是建議reboot來解決這個問題.

嘗試kill引起殭屍進程的父進程, 從而減少系統總進程數:

# ps auxwwf | grep defunct | grep -v grep
...
oracle   16740  0.0  0.0     0    0 ?        Z    10:46   0:00  \_ [test.sh] <defunct>
oracle   23184  0.0  0.0     0    0 ?        Z    11:51   0:00  \_ [test.sh] <defunct>
oracle   25249  0.0  0.0     0    0 ?        Z    12:12   0:00  \_ [test.sh] <defunct>

殭屍進程是無法kill掉的:

# kill 16740 23184 25249
# kill -9 16740 23184 25249

獲取這些進程樹信息, 發現是crontab引起的:

$ ps auxwwf | grep test.sh
...
oracle   16736  0.0  0.0  1912  228 ?        T    10:46   0:00 /orahome/package/test.sh.x ORCL
oracle   16740  0.0  0.0     0    0 ?        Z    10:46   0:00  \_ [test.sh] <defunct>
oracle   23183  0.0  0.0  3200  240 ?        T    11:51   0:00 /orahome/package/test.sh.x ORCL
oracle   23184  0.0  0.0     0    0 ?        Z    11:51   0:00  \_ [test.sh] <defunct>
oracle   25248  0.0  0.0  2792  240 ?        T    12:12   0:00 /orahome/package/test.sh.x ORCL
oracle   25249  0.0  0.0     0    0 ?        Z    12:12   0:00  \_ [test.sh] <defunct>

# pstree -ap | head
init,1                            
|-atd,3359
|-crond,3324
|   |-crond,354
|   |   `-(sh,356)
|   |-crond,360
|   |   `-(sh,362)
|   |-crond,380
|   |   `-(sh,382)
|   |-crond,384

# pstree -ap | grep test.sh | grep -v grep | tail
|-test.sh,32550 ORCL
|   `-(test.sh,32551)
|-test.sh,32637 ORCL
|   `-(test.sh,32641)
|-test.sh,32649 ORCL
|   `-(test.sh,32651)
|-test.sh,32679 ORCL
|   `-(test.sh,32680)
|-test.sh,32750 ORCL
|   `-(test.sh,32753)

# service crond status
crond (pid 32761 32697 32630 32623 32575 32339 32153 32081 31971 31955 31798 31752 31733 31576 31478 31419 31286 31216 31160 31101 30971 30535 30393 30329 30272 30216 30116 29929 29883 29844 29795 29651 29609 29428 29387 29341 29263 29242 29206 29146 29116 29093 29091 29051 28970 28818 28795 28747 28688 28584 28560 28516 28508 28435 28381 28313 28264 28238 28197 28150 28056 28000 27919 27852 27648 27631 27502 27469 27465 27201 27141 27136 27086 27025 26911 26795 26759 26670 26545 26526 26513 26388 26381 26353 26326 26221 26198 26194 26128 26045 25708 25487 25439 25415 25246 25188 25143 25002 24923 24774 24770 24745 24686 24643 24530 24490 24451 24427 24393 24321 24295 24277 24191 24079 24036 23914 23801 23686 23668 23570 23506 23410 23331 23319 23246 23224 23097 22931 22887 22853 22441 22398 22300 22224 22216 22201 22160 22009 21899 21767 21670 21650 21518 21387 21354 21325 21213 21191 21170 21052 20972 20946 20907 20796 20742 20585 20531 20526 20435 20419 20276 20222 20210 20097 19967 19879 19804 19777 19763 19748 19745 19689 19564 19514 19493 19462 19179 19160 19053 18992 18901 18835 18823 18793 18768 18724 18689 18621 18553 18277 18187 18155 18081 18072 17932 17891 17867 17864 17842 17786 17699 17671 17624 17615 17591 17589 17586 17530 17448 17424 17185 17134 16992 16919 16566 16496 16381 16167 16075 16005 15983 15892 15725 15668 15654 15579 15542 15479 15457 15290 15201 15117 15102 14851 14842 14784 14693 14620 14527 14485 14274 14110 14100 14070 13982 13959 13917 13748 13744 13433 13360 13356 13200 13159 13144 13089 12871 12860 12825 12650 12636 12488 12395 12284 12174 12051 11976 11820 11777 11739 11637 11583 11560 11452 11134 11106 11092 11044 10961 10772 10674 10566 10473 10390 10333 10320 10265 10164 10136 10056 10054 9933 9874 9855 9838 9818 9803 9662 9604 9536 9418 9330 9222 9176 9091 9040 9022 9020 8910 8899 8677 8670 8649 8598 8542 8423 8419 8415 8283 8065 8007 8004 7839 7831 7823 7775 7686 7633 7507 7436 7294 7200 7175 7055 6999 6913 6893 6830 6759 6736 6714 6651 6601 6491 6416 6200 6192 6164 6126 6071 6050 5781 5766 5578 5476 5369 5360 5355 5291 5216 5172 5074 4843 4788 4772 4718 4696 4675 4591 4563 4470 4321 4319 4253 4221 4198 4002 3962 3941 3863 3819 3814 3759 3657 3596 3508 3500 3446 3324 3321 3294 3222 3190 2983 2848 2812 2727 2709 2332 2265 2227 2007 1982 1962 1820 1730 1696 1585 1520 1495 1457 1455 1290 1236 1207 1186 1105 1009 918 893 892 845 825 811 809 704 668 633 574 384 380 360 354) is running...

重啓crontab守護進程:

# service crond restart
Stopping crond:                                            [  OK  ]
Starting crond:                                            [  OK  ]
# service crond status
crond (pid 18175) is running...

再top查看一下, 發現總進程數降了不少:

# top
...
Tasks: 1217 total,   1 running, 352 sleeping, 432 stopped, 432 zombie
...

# ps auxwwf | grep defunct | grep -v grep | wc -l
432

# pstree -ap | grep test.sh | grep -v grep | tail
...
|-test.sh,32550 ORCL
|   `-(test.sh,32551)
|-test.sh,32637 ORCL
|   `-(test.sh,32641)
|-test.sh,32649 ORCL
|   `-(test.sh,32651)
|-test.sh,32679 ORCL
|   `-(test.sh,32680)
|-test.sh,32750 ORCL
|   `-(test.sh,32753)

嘗試批量kill掉, 發現不行:

# rm -f ./kill.txt
# for pid in `ps -ef | grep test.sh | grep -v defunct | grep -v grep | awk '{print $2}'`
do
echo "kill -9 $pid" >> ./kill.txt
done
# cat kill.txt

# top
...
Tasks: 1217 total,   1 running, 352 sleeping, 432 stopped, 432 zombie
...

看來只有等下次重啓服務器了.

--End--
 
當時遠程操作對問題沒有截圖,但是查看下來和這篇blog記錄的問題現象都是一樣的,最後重啓了服務器 一切正常,RAC啓動也是正常的。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章