最近经常出现连接到oracle服务器非常的慢,就算是用sqlplus / as sysdba这产的登录方式都很慢。
解决问题的过程:
1)查看服务器CPU使用情况
输入top
会发现排在前面的都是oracle的进程,而且CPU占用率都是50以上。
$ top
top - 16:28:41 up 4 days, 22:35, 1 user, load average: 21.49, 22.14, 22.05 Tasks: 299 total, 31 running, 268 sleeping, 0 stopped, 0 zombie Cpu(s): 79.2%us, 1.5%sy, 0.0%ni, 18.4%id, 0.8%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 7793040k total, 7659492k used, 133548k free, 165424k buffers Swap: 10223608k total, 763068k used, 9460540k free, 4435980k cachedPID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
29533 oracle 17 0 3291m 36m 26m R 98.9 0.5 98:36.33 oracle 7825 oracle 17 0 3285m 30m 25m R 97.0 0.4 267:59.25 oracle13527 oracle 17 0 3291m 36m 26m R 97.0 0.5 362:08.86 oracle32000 oracle 17 0 3291m 36m 26m R 95.1 0.5 198:58.18 oracle查出进程的作用
ps -ef|grep 712
oracle 712 1 4 Sep02 ? 01:38:25 oracleuidorcl (LOCAL=NO) root 2223 2171 0 16:36 pts/3 00:00:00 grep 712 oracle 17712 1 9 Aug31 ? 07:14:20 oracleuidorcl (LOCAL=NO) oracle 27120 1 0 15:47 ? 00:00:01 oracleuidorcl (LOCAL=NO) # ps -ef|grep 32000 root 2259 2171 0 16:37 pts/3 00:00:00 grep 32000 oracle 32000 1 5 Sep01 ? 03:19:37 oracleuidorcl (LOCAL=NO) # ps -ef|grep 16447 root 2283 2171 0 16:37 pts/3 00:00:00 grep 16447 oracle 16447 1 9 Aug31 ? 07:15:57 oracleuidorcl (LOCAL=NO) 是用来做oracle连接的。 2)查出导致慢的原因查进程执行的是什么语句
sqlplus / as sysdba
SELECT
sql_text FROM v$sqltext a WHERE (a.hash_value, a.address) IN (SELECT DECODE(sql_hash_value, 0, prev_hash_value, sql_hash_value), DECODE(sql_hash_value, 0, prev_sql_addr, sql_address) FROM v$session b WHERE b.paddr = (SELECT addr FROM v$process c WHERE c.spid = '&pid')) ORDER BY piece ASC输入上面的进程ID:29533
SELECT TO_CHAR(current_timestamp AT TIME ZONE 'GMT', 'YYYY-MM-DD
HH24:MI:SS TZD') AS curr_timestamp, COUNT(db_user) AS failed_co unt FROM sys.dba_common_audit_trail WHERE action BETWEEN 100 AND 102 AND returncode != 0 AND TO_CHAR(extended_timestamp, 'YYYY-M M-DD HH24:MI:SS') >= TO_CHAR(current_timestamp - TO_DSINTERVAL(' 0 0:30:00'), 'YYYY-MM-DD HH24:MI:SS')发现,每个进程ID都是执行这条语句
后面群上面问了一下,说是建议把审计功能关闭
3)关闭oracle审计,解决问题
查看audit模式
show parameter audit;
shutdown abort;
startup nomount;
alter ystem set audit_trail=none scope=spfile;
shutdown abort;
startup;
删除签权数据,oracle用户登录到数据库服务器:
truncate table SYS.AUD$;附在群上讨论内容
陈建伟(66472309) 17:06:55 大家好 我oracle开久了之后,oracle进程占用率高,而且每秒都有新的进程执行下面的语句。 SELECT TO_CHAR(current_timestamp AT TIME ZONE 'GMT', 'YYYY-MM-DD HH24:MI:SS TZD') AS curr_timestamp, COUNT(db_user) AS failed_co unt FROM sys.dba_common_audit_trail WHERE action BETWEEN 100 AND 102 AND returncode != 0 AND TO_CHAR(extended_timestamp, 'YYYY-M M-DD HH24:MI:SS') >= TO_CHAR(current_timestamp - TO_DSINTERVAL(' 0 0:30:00'), 'YYYY-MM-DD HH24:MI:SS') 陈建伟(66472309) 17:07:01 不知道是什么原因? 萧雨(76232399) 17:09:27 这个好像是审计的,可以关掉的吧 陈建伟(66472309) 17:09:40 是吗? 萧雨(76232399) 17:09:50 不清楚 蝈蝈(52093188) 17:12:25 你是oracle11g的版本吧 陈建伟(66472309) 17:12:34 嗯 陈建伟(66472309) 17:12:39 你很聪明,猜对了。 蝈蝈(52093188) 17:12:55 还用猜啊,搞笑 陈建伟(66472309) 17:13:06 呵呵 陈建伟(66472309) 17:13:09 那要怎么解决? ▓冷云轩★ゞ(53847854) 17:13:41 关掉 蝈蝈(52093188) 17:14:57 嘿嘿,还专门调过参数啊 陈建伟(66472309) 17:15:17 是啊 蝈蝈(52093188) 17:15:21 为啥啊 萧雨(76232399) 17:15:33 是呀,为啥呀 YINBL(290731945) 17:17:21 scope=spfile 陈建伟(66472309) 17:17:51 哦。 陈建伟(66472309) 17:17:52 好的