顯示具有 Memory 標籤的文章。 顯示所有文章
顯示具有 Memory 標籤的文章。 顯示所有文章

2017年12月14日 星期四

ORACLE ORA-01034 and ORA-27101


AIX: 5300-07
oslevel -r

Oracle: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
select * from v$version



我們有一個ORACLE 資料庫,作業系統是AIX,運行已經有好幾年了。最近發生JBOSS AP在啟動建立資料庫連線的時候報錯,但不全然都會這樣,有些連線建立成功,因此這狀況就變成時有時無。在AP主機重啟時,就會報這錯,但AP還算能登入使用,只是有時候會反應有些功能沒有作業成功而報錯,錯誤訊息依然是以下這個。

WARN  [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
IBM AIX RISC System/6000 Error: 2: No such file or directory)

get a new connection: null
Could not create connection 
一般來說是無法連到DB主機

ORA-01034, ORA-27101: 網路上很多人說,這是資料庫沒有啟動好,或配置不良,應該是泛指剛剛建立完成的資料庫,但我們的已經運行好幾年了,應該不可能。

剛開始,就是拼命地把AP主機重新啟動,觀察AP主機上的執行環境是否有異常蠕蟲或病毒,甚至想要分散一台AP主機的負載量來測試,但方向都不正確。

觀察DB 主機的使用情況,使用ORACLE 身分登入主機
參考這篇文章 http://intermediatesql.com/aix/how-oracle-uses-memory-on-aix-part-1-processes/
$ ps -elf |
egrep " oracle${ORACLE_SID} | ora_.*_${ORACLE_SID} " |
grep -v egrep | awk '{sum += $10} END {print sum/1024}'
53688.7

$ sysresv

IPC Resources for ORACLE_SID "xxxxxxxx" :
Shared Memory:
ID              KEY
1048577         0x6598f430
Oracle Instance alive for sid "xxxxxxxx"

$ ipcs -bm|grep 1048577
m   1048577 0x6598f430 --rw-r-----   oracle      dba 524296192 <--500mb p="">

總共使用的記憶體: 53 GB + 500 MB =53.5 GB

ps -ef|grep oracle${ORACLE_SID}|grep -v grep |wc -l 
540

select * from v$version
161
從資料庫裡查看SESSION 大約是161
很明顯兩邊的數量差很多,可能是程序已經離開,但ORACLE認為還在用沒放開,導致資源消耗。

關閉所有AP連線行為,將ORACLE DB 重新啟動
shutdown immediate  等待約莫10分鐘,還是沒有shutdown

改用
shutdown abort 等待約莫3分鐘

觀察主機ORACLE 的程序數量
ps -ef|grep oracle${ORACLE_SID}|grep -v grep |wc -l 
0

啟動資料庫
Startup

重新啟動AP主機服務,AP 啟動建立資料庫連線的時候,沒有在報錯

說實在的,AIX上的記憶體還真的是不太會看,以下列一些相關指令,參考看看
$ vmstat -v
              2035712 memory pages
              1957164 lruable pages
                 2663 free pages
                    1 memory pools
               472236 pinned pages
                 80.0 maxpin percentage
                 10.0 minperm percentage
                 20.0 maxperm percentage
                 11.0 numperm percentage
               215325 file pages
                  0.0 compressed percentage
                    0 compressed pages
                 11.0 numclient percentage
                 20.0 maxclient percentage
               215323 client pages
                    0 remote pageouts scheduled
                  483 pending disk I/Os blocked with no pbuf
                60078 paging space I/Os blocked with no psbuf
                 2484 filesystem I/Os blocked with no fsbuf
                    0 client filesystem I/Os blocked with no fsbuf
               211963 external pager filesystem I/Os blocked with no fsbuf
                    0 Virtualized Partition Memory Page Faults
                 0.00 Time resolving virtualized partition memory page faults

$ vmstat

System configuration: lcpu=4 mem=7952MB

kthr    memory              page                            faults                    cpu
-----  ---------------- ------------------------ -----------------  -----------
 r   b   avm          fre      re  pi  po  fr     sr         cy  in  sy      cs    us  sy  id  wa
 1  2   1977424  2671   0   0   0     192 1610   0    76 2486 480  8   1   89  1


$ df -k
Filesystem    1024-blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4           524288    257492   51%     8417    13% /
/dev/hd2          6291456   1376552   79%    95241    24% /usr
/dev/hd9var        524288         0  100%     2921    61% /var
/dev/hd3          1048576    508024   52%     2081     2% /tmp
/dev/fwdump        524288    523536    1%        5     1% /var/adm/ras/platform
/dev/hd1           524288    249000   53%      524     1% /home
/proc                   -         -    -         -     -  /proc
/dev/hd10opt      1048576    532384   50%     8599     7% /opt
/dev/lv00          524288    507776    4%       18     1% /var/adm/csd
/dev/fslv00      10485760   4881856   54%     5167     1% /source
/dev/fslv01      94371840  21525676   78%    98843     3% /oradata

2013年3月11日 星期一

JBOSS 4.2.2.GA 管理

查看Memory 情況
JBoss Management > JMX Console > jboss.system> type=ServerInfo > java.lang.String listMemoryPools() > Invoke 按鈕



如果我需要同時間在主機上執行兩個以上的 JBoss AP Server,那應該要改動哪些檔案內的 port number 設定?

環境:JBoss AP Server 4.2.3
$JBOSS_HOME 安裝資料夾 (例如: /usr/local/jBoss/Base)
Service
PACH
Base
Base1
Base2
Base3

$JBoss_home/server/default/deploy/ejb3.deployer/META-INF/jboss-service.xml
3873
10000
10100
10200
webserver
$JBoss_home/server/default/deploy/jboss-web.deployer/server.xml 
8080
10001
10101
10201
ajp13
$JBoss_home/server/default/deploy/jboss-web.deployer/server.xml 
8009
10002
10102
10202
ssl
$JBoss_home/server/default/deploy/jboss-web.deployer/server.xml 
8443
10003
10103
10203
WebService
$JBoss_home/server/default/conf/jboss-service.xml 
8083
10004
10104
10204
NamingService
$JBoss_home/server/default/conf/jboss-service.xml 
1098
10005
10105
10205
NamingService
$JBoss_home/server/default/conf/jboss-service.xml 
1099
10006
10106
10206
RMIObjectPort
$JBoss_home/server/default/conf/jboss-service.xml 
4444
10007
10107
10207
ServerBindPort
$JBoss_home/server/default/conf/jboss-service.xml 
4445
10008
10108
10208

$JBoss_home/server/default/conf/jboss-service.xml 
4446
10009
10109
10209
NamingService
$JBoss_home/server/default/conf/jboss-minimal.xml 
1099
10006
10106
10206
UILServerILService
$JBoss_home/server/default/deploy/jms/uil2-service.xml 
8093
10010
10110
10210
標記區表示為相戶呼應的設定


JBOSS 設定Connect Pool 數量跟用量
可用 以此字串進行詢找  jdbc/c0030,service=ManagedConnectionPool
名詞解釋:
BlockingTimeoutMillis :拋出異常前最大的等待連線時間
IdleTimeoutMinutes :關閉連接前連接空閒的最大時間。即連接創建後由該專案規定的時間內未使用則釋放連接,即系統創建的連接!
InUseConnectionCount 表示表示用戶正在使用的連接!
ConnectionCount 這個專案代表在服務開啟後,總共使用的連接數!
ConnectionCreatedCount 表示jboss應用伺服器自己創建的連接!
ConnectionDestroyedCount 表示jboss釋放的連接,包括使用者釋放的和系統自己釋放的!
IdleTimeoutMinutes 表示閒置釋放時間,即連接創建後由該專案規定的時間內未使用則釋放連接,即系統創建的連接!
InUseConnectionCount 表示表示用戶正在使用的連接!
MaxConnectionsInUseCount 表示用戶正在使用連接的峰值!
InUseConnectionCount越少越好! ConnectionCreatedCount 越大越好! 這兩項是關鍵!!
 AvailableConnectionCount為可用的連接數! 如果你的頁面刷新AvailableConnectionCount的值沒有變得話,說明你的頁面創建的連接都關閉了,如果他的值減少了, 那麼減少了多少,表示你有多少連接沒有釋放!!如果有可能的話,最好每個頁面都測試一下,是否完全釋放!

 MaxConnectionsInUseCount 的值剛好和 AvailableConnectionCount相對應: 前者減少了多少,後者就增加多少!!!
 MaxSize = MaxConnectionsInUseCount + AvailableConnectionCount 它們存在著這種關係!!
可以這樣說InUseConnectionCount 就是未釋放的連接數!!! 而MaxConnectionsInUseCount 則是未釋放連接數的峰值
在具體應用中可以通過servlet 及計時器實現對連接池的即時監控。