简体   繁体   English

Oracle 11g具有幻像连接

[英]Oracle 11g has phantom connection

I have 11g installed locally on my machine (Windows 7 64bit). 我在计算机上本地安装了11g(Windows 7 64位)。

When I have disconnected all my clients from my oracle (ie no sqlplus running, no weblogic running) and then reconnect using sqlplus and I run the following script: 当我从oracle断开所有客户端的连接(即不运行sqlplus,不运行weblogic),然后使用sqlplus重新连接时,我运行以下脚本:

SQL> set linesize 120
SQL> SELECT            s.sid,
  2                    s.serial#,
  3                    s.username,
  4                    s.program
  5    from v$session s
  6    where username is not null;
       SID    SERIAL# USERNAME                       PROGRAM
---------- ---------- ------------------------------ ----------------------------------------------------------------
       134      11274 FOO                         ORACLE.EXE (J000) <-- I want to remove this connection
       139      19140 MYADMIN                        sqlplus.exe       <-- My connection
       155       8941 FOO                         ORACLE.EXE (J001) <-- I want to remove this connection
SQL>

So I am trying to programmatically remove the connections that I have labelled in blue. 因此,我尝试以编程方式删除以蓝色标记的连接。

I am using the following: 我正在使用以下内容:

SQL> ALTER SYSTEM DISCONNECT SESSION  134,11274  IMMEDIATE;
ALTER SYSTEM DISCONNECT SESSION  134,11274  IMMEDIATE
                                 *
ERROR at line 1:
ORA-00026: missing or invalid session ID

Is this not the correct way? 这不是正确的方法吗? I have also tried 我也尝试过

ALTER SYSTEM DISCONNECT SESSION  '134,11274'  IMMEDIATE;

When I try running the above again I will get the error message: 当我再次尝试运行以上命令时,我将收到错误消息:

SQL> ALTER SYSTEM DISCONNECT SESSION  '134,11274'  IMMEDIATE;
ALTER SYSTEM DISCONNECT SESSION  '134,11274'  IMMEDIATE
*
ERROR at line 1:
ORA-00031: session marked for kill

So the connection doesn't seem to really go away. 因此,连接似乎并没有真正消失。

I want to have a script that forces all 'FOO' connections to be terminated so that my build will run properly. 我想要一个脚本来强制终止所有“ FOO”连接,以便我的构建能够正常运行。 But my script is not working. 但是我的脚本不起作用。 Do you have any ideas? 你有什么想法? The only reliable way I can get rid of connections is to reboot. 我摆脱连接的唯一可靠方法是重新启动。 Stopping and starting the service sometimes works - but not always - which is really weird. 停止和启动服务有时是可行的,但并非总是如此,这确实很奇怪。

Here's my PL/SQL script that I ultimately want to be able to run. 这是我最终希望能够运行的PL / SQL脚本。

SET SERVEROUTPUT ON 
SET LINESIZE 120
DECLARE
   theKillCmd VARCHAR2(1000);

   PROCEDURE msg(msg VARCHAR2) AS 
   BEGIN
        DBMS_OUTPUT.PUT_LINE(msg);
   END;


BEGIN

msg(' . ');
msg(' . ');
msg('Killing extraneous sessions.');
msg(' . ');
msg(' . ');

for conn in (SELECT    s.sid,
         s.serial#,
         s.username,
         s.program
  FROM   v$session s
  WHERE s.USERNAME IS NOT NULL) 
loop

  msg( '.     ' || conn.sid || ' ' || conn.serial# || ' ' ||  conn.username || ' ' || conn.program );
  IF (conn.username = 'FOO') THEN
     -- Following asks client process to kill itself
     -- theKillCmd := 'ALTER SYSTEM KILL SESSION ''' ||  conn.sid || ',' || conn.serial# || ''' IMMEDIATE ';
     -- Following tells server to kill process 
     theKillCmd := 'ALTER SYSTEM DISCONNECT SESSION ' ||  conn.sid || ',' || conn.serial# || ' IMMEDIATE ';
     msg( '.           ' || 'Killing connection using command : ' || theKillCmd );
     EXECUTE IMMEDIATE theKillCmd ;
  ELSE
     msg('.           Ignoring .. ');
  END IF;

end loop;


END;
/

-- exit;

So if anyone has any ideas that would be appreciated. 因此,如果有人有任何想法将不胜感激。

I'm wondering if maybe I somehow botched the oracle installation - I don't want to yet go down the path of re-installing - would rather have a script that just kills oracle connections before I run ant oracle. 我想知道是否我可能以某种方式破坏了oracle的安装-我还不想走上重新安装的道路-宁愿有一个脚本可以在运行ant oracle之前终止oracle的连接。

That Jnnn (J000 and J001) syntax indicates it is a "Job Queue Slave Process". Jnnn(J000和J001)语法表明它是“作业队列从属进程”。 If you kill it, the scheduler will probably just restart it. 如果您将其杀死,则调度程序可能只会重新启动它。

Look at the appropriate DBMS_JOB or DBMS_SCHEDULER API. 查看适当的DBMS_JOB或DBMS_SCHEDULER API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM