查看oracle的資料庫連接數以及修改串連數__Python

來源:互聯網
上載者:User
 

可能是資料庫上當前的串連數目已經超過了它能夠處理的最大值.

select count(*) from v$process --當前的串連數

select value from v$parameter where name = 'processes' --資料庫允許的最大串連數

修改最大串連數:
alter system set processes = 300 scope = spfile;

重啟資料庫:
shutdown immediate;
startup;

--查看當前有哪些使用者正在使用資料
SELECT osuser, a.username,cpu_time/executions/1000000||'s', sql_fulltext,machine
from v$session a, v$sqlarea b
where a.sql_address =b.address order by cpu_time/executions desc;
select count(*) from v$session   #串連數


select count(*) from v$session where status='ACTIVE' #並發串連數

show parameter processes   #最大串連

alter system set processes = value scope = spfile;重啟資料庫   #修改串連


 

SQL> Select count(*) from v$session where status='ACTIVE' ;

   COUNT(*)
----------
       20

SQL> Select count(*) from v$session;

   COUNT(*)
----------
   187

SQL> show parameter processes;

NAME                               TYPE        VALUE
------------------------------------ ----------- ----------
aq_tm_processes                   integer     0
db_writer_processes                integer     1
gcs_server_processes                 integer     0
job_queue_processes                integer     10
log_archive_max_processes          integer     2
processes                         integer     450
SQL>

並髮指active,I SEE

SQL> select count(*) from v$session   #串連數
SQL> Select count(*) from v$session where status='ACTIVE' #並發串連數
SQL> show parameter processes   #最大串連
SQL> alter system set processes = value scope = spfile;重啟資料庫   #修改串連

unix 1個使用者session 對應一個作業系統 process
而 windows體現線上程

DBA要定時對資料庫的串連情況進行檢查,看與資料庫建立的會話數目是不是正常,如果建立了過多的串連,會消耗資料庫的資源。同時,對一些“掛死”的串連,可能會需要DBA手工進行清理。
以下的SQL語句列出當前資料庫建立的會話情況:
select sid,serial#,username,program,machine,status
from v$session;
輸出結果為:
SID SERIAL# USERNAME PROGRAM MACHINE STATUS
---- ------- ---------- ----------- --------------- --------
1 1 ORACLE.EXE WORK3 ACTIVE
2 1 ORACLE.EXE WORK3 ACTIVE
3 1 ORACLE.EXE WORK3 ACTIVE
4 1 ORACLE.EXE WORK3 ACTIVE
5 3 ORACLE.EXE WORK3 ACTIVE
6 1 ORACLE.EXE WORK3 ACTIVE
7 1 ORACLE.EXE WORK3 ACTIVE
8 27 SYS SQLPLUS.EXE WORKGROUP\\WORK3 ACTIVE
11 5 DBSNMP dbsnmp.exe WORKGROUP\\WORK3 INACTIVE
其中,
SID 會話(session)的ID號;
SERIAL# 會話的序號,和SID一起用來唯一標識一個會話;
USERNAME 建立該會話的使用者名稱;
PROGRAM 這個會話是用什麼工具串連到資料庫的;
STATUS 當前這個會話的狀態,ACTIVE表示會話正在執行某些任務,INACTIVE表示當前會話沒有執行任何操作;
如果DBA要手工斷開某個會話,則執行:
alter system kill session \'SID,SERIAL#\' sql語句 SQL語句如下:

SELECT   username, machine, program, status, COUNT (machine) AS
串連數量
    FROM v$session
GROUP BY username, machine, program, status
ORDER BY machine;

顯示結果(每個人的機器上會不同)

SCHNEIDER|WORKGROUD\WANGZHENG|TOAD.exe|ACTIVE|1
SCHNEIDER|WORKGROUP\597728AA514F49D|sqlplusw.exe|INACTIVE|1
|WWW-Q6ZMR2OIU9V|ORACLE.EXE|ACTIVE|8
PUBLIC|||INACTIVE|0

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.