zoukankan      html  css  js  c++  java
  • 【Linux/Oracle】ORA-00031:标记要终止的会话 解决

    在PL/SQL操作了一条delete语句用于删除这张1.4亿条数据的表,执行了12个小时还没删完

    (经DB指导,量级大的需要使用truncate table table_name 进行删除)

    --查询当前进程 
    SELECT l.session_id sid, s.serial#, l.locked_mode 锁模式, l.oracle_username 登录用户, l.os_user_name 登录机器用户名, s.machine 机器名, s.terminal 终端用户名, o.object_name 被锁对象名, s.logon_time 登录数据库时间 FROM v$locked_object l, all_objects o, v$session s WHERE l.object_id = o.object_id AND l.session_id = s.sid ORDER BY sid, s.serial#;

     查询发下 SID为962的对象被锁了

    尝试使用   alter system kill session 'SID,SERTAL';   杀掉会话进程

    alter system kill session '962,23413';

    提示了 ORA-00031: 标记要终止的会话

    经查 :如果出现题目的错误,则说明在数据库级不能杀掉该死锁进程,需要到操作系统级来处理了。如下图所示:

    ①可以通过下列语句查询: 
    select a.spid,b.sid,b.serial#,b.username 
    from v$process a,v$session b 
    where a.addr=b.paddr 
    and b.status='KILLED';
     
    ②如果利用上面的命令杀死一个进程后,进程状态被置为"killed",但是锁定的资源很长时间没有被释放,那么可以在OS级再杀死相应的进程(线程),首先执行下面的语句获得进程(线程)号: 
    select b.spid,a.osuser,b.program 
      from v$session a,v$process b 
     where a.paddr=b.addr 
       and a.sid=962    --962就是上面的sid
     
    [root@crb-db1 ~]# su - oracle            --切换到oracle 用户
    Last login: Thu Jun 10 10:59:03 CST 2021 on pts/0
    [oracle@crb-db1 ~]$ ps -ef | grep  smon     --SMON(system monitor process)系统监控后台进程

                                                                          --ps命令将某个进程显示出来

                                                     --grep命令是查找

                        --中间的|是管道命令 是指ps命令与grep同时执行

                        --grep命令是查找,是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。

                       --grep全称是Global Regular Expression Print,表示全局正则表达式版本,它的使用权限是所有用户。

                       --select  *  from   v$session  where  sid=962;     根据sid查addr  

                       --select  *  from  v$process where  addr='0000000508DF6488'    查pid

    UID      :程序被该 UID 所拥有

    PID      :就是这个程序的 ID 

    PPID    :则是其上级父程序的ID

    C          :CPU使用的资源百分比

    STIME :系统启动时间

    TTY     :登入者的终端机位置

    TIME   :使用掉的CPU时间。

     

    CMD   :所下达的是什么指令

    UID            PID       PPID   C  STIME    TTY        TIME                          CMD
    oracle    1819  1779  0 12:59 pts/1    00:00:00 grep --color=auto smon
    oracle   10125     1  0  2020 ?        00:15:06 ora_smon_orcl
    [oracle@crb-db1 ~]$ ps -ef | grep  55754    --55754 即第②步根据SID查询出的spid
    oracle    1821  1779  0 12:59 pts/1    00:00:00 grep --color=auto 55754
    oracle   55754     1  1 Jun09 ?        00:16:26 oracleorcl (LOCAL=NO)
    [oracle@crb-db1 ~]$ kill -9  55754
    [oracle@crb-db1 ~]$ 
    [oracle@crb-db1 ~]$ ^C
    [oracle@crb-db1 ~]$ timed out waiting for input: auto-logout
    [root@crb-db1 ~]# timed out waiting for input: auto-logout
    Connection closing...Socket close.
    
    Connection closed by foreign host.
    
    成功解决
  • 相关阅读:
    window.clipboardData(转载)
    动态添加样式(转载)
    IE6 IE7 FF的CSS Hack总结(转载)
    [轉貼] linux解壓 tar 命令
    [轉]用 snprintf / asprintf 取代不安全的 sprintf
    寫一個函數計算當參數為 n(n很大) 時的值 12+34+56+7……+n
    [轉]vi 與 vim 的指令整理
    MySQL和php採用UTF8的方法
    [轉]printf 引數說明
    [C] warning: ISO C90 forbids mixed declarations and code
  • 原文地址:https://www.cnblogs.com/Williamls/p/14871592.html
Copyright © 2011-2022 走看看