oracle中使用者串連相關

來源:互聯網
上載者:User

查看使用者串連

斷掉某一串連

查看串連ip

oracle中查看使用者串連
select username,sid,serial#,status from v$session where username <>'1';
select sid,ses.serial#,ses.username,pro.username,pro.spid,status
from v$session ses,v$process pro
where ses.username='PRODUCT' and ses.paddr=pro.addr;
select ses.username,pro.* from v$process pro,v$session ses where ses.paddr=pro.addr and ses.username<>'1';
從上面的sql中可以獲得串連的使用者、oracle sid以及os的進程號等資訊
利用上述資訊,可以停掉串連
alter system kill session 'sid,serial#';或者根據os的進程號直接kill
上述sql無法獲得串連的client的ip,不知道有沒有現成的view能提供呢?
要擷取ip
方法1:$ORACLE_HOME/network/log/listener_orarac1.log
方法2:需要建立logon的trigger
create table session_history。。。

CREATE OR REPLACE TRIGGER logon_history
AFTER LOGON ON database
BEGIN
insert into session_history
select username,SYSDATE,SYS_CONTEXT('USERENV','IP_ADDRESS') from v$session where audsid = userenv( 'sessionid' ) ;
commit;
END;

方法3:netstat -anp |grep 1521
tcp 0 0 192.168.1.52:1521 192.168.2.101:45877 ESTABLISHED 5582/oracleorcl1
tcp 0 0 192.168.1.52:1521 192.168.2.101:37343 ESTABLISHED 5588/oracleorcl1
tcp 0 0 192.168.1.52:1521 192.168.2.101:50172 ESTABLISHED 24184/oracleorcl1
tcp 0 0 192.168.1.52:1521 192.168.2.101:59023 ESTABLISHED 5584/oracleorcl1
tcp 0 0 192.168.1.52:1521 192.168.10.23:1992 ESTABLISHED 29055/oracleorcl1
tcp 0 0 192.168.1.52:1521 192.168.2.101:51121 ESTABLISHED 5586/oracleorcl1
tcp 0 0 192.168.1.52:1521 192.168.2.102:44376 ESTABLISHED 18104/oracleorcl1
tcp 0 0 192.168.1.52:1521 192.168.2.102:51209 ESTABLISHED 27165/oracleorcl1
tcp 0 0 192.168.1.52:1521 192.168.2.102:59845 ESTABLISHED 18102/oracleorcl1
tcp 0 0 192.168.1.52:1521 192.168.2.102:41867 ESTABLISHED 22780/oracleorcl1
其中5582/oracleorcl1中的5582就是os的進程號

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.