分享更有价值
被信任是一种快乐

如何通过操作系统的进程号查看数据库的session

文章页正文上

这篇文章将为大家详细讲解有关如何通过操作系统的进程号查看数据库的session,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。在工作中很多新手会遇到这种问题,就是操作系统显示有个PID占用的CPU很高,导致整个系统运行很慢,同时又不敢轻易的对这个PID进行KILL操作,很是头疼。今天就和大家分享下,怎么通过操作系统的PID查找相应的数据库session和语句。第一步:通过可以通过操作系统的PID查找数据库的v$process进程,语句如下:select * from v$process where SPID=’&PID’第二步:查找相应的SESSION信息SELECT SID,SERIAL#, USERNAME,MACHINE
FROM v$session b 免费主机域名
WHERE b.paddr = (SELECT addr
FROM v$process c
WHERE c.spid = ‘&pid’);第三步:通过第二步查找出来的SID,可以进一步查找正在执行的SQL语句select b.sql_text
from v$session a,v$sqlarea b
where a.sql_hash_value=b.hash_value and a.sid=‘&SID’;另外可以通过下面这条语句查找后台进程的名字SELECT s.SID SID, p.spid threadid, p.program processname, bg.NAME NAME
FROM v$process p, v$session s, v$bgprocess bg
WHERE p.addr = s.paddr
AND p.addr = bg.paddr
AND bg.paddr ’00’;经过一番查询如果发现当前的session有问题,具体怎么判断是否有问题,会继续介绍。操作系统的杀进程的操作很简单,语句如下kill -9 pid附:V$PROCESS和V$SESSION的各字段说明ColumnDatatypeDescriptionADDRRAW(4 | 8)Address of process state objectPIDNUMBEROracle process identifierSPIDVARCHAR2(12)Operating system process identifierUSERNAMEVARCHAR2(15)Operating system process username. Any two-task user coming across the network has “-T” appended to the username.SERIAL#NUMBERProcess serial numberTERMINALVARCHAR2(30)Operating system terminal identifierPROGRAMVARCHAR2(48)Program in progressTRACEIDVARCHAR2(255)Trace file identifierBACKGROUNDVARCHAR2(1)1 for a background process; NULL for a normal processLATCHWAITVARCHAR2(8)Address of latch the process is waiting for; NULL if noneLATCHSPINVARCHAR2(8)Address of the latch the process is spinning on; NULL if nonePGA_USED_MEMNUMBERPGA memory currently used by the processPGA_ALLOC_MEMNUMBERPGA memory currently allocated by the process (including free PGA memory not yet released to the operating system by the server process)PGA_FREEABLE_MEMNUMBERAllocated PGA memory which can be freedPGA_MAX_MEMNUMBERMaximum PGA memory ever allocated by the processColumnDatatypeDescriptionSADDRRAW(4 | 8)Session addressSIDNUMBERSession identifierSERIAL#NUMBERSession serial number. Used to uniquely identify a session’s objects. Guarantees that session-level commands are applied to the correct session objects if the session ends and another session begins with the same session ID.AUDSIDNUMBERAuditing session IDPADDRRAW(4 | 8)Address of the process that owns the sessionUSER#NUMBEROracle user identifierUSERNAMEVARCHAR2(30)Oracle usernameCOMMANDNUMBERCommand in progress (last statement parsed); for a list of values, see Table 7-5. These values also appear in the AUDIT_ACTIONS table.OWNERIDNUMBERThe column contents are invalid if the value is 2147483644. Otherwise, this column contains the identifier of the user who owns the migratable session.For operations using Parallel Slaves, interpret this value as a 4-byte value. The low-order 2 bytes of which represent the session number, and the high-order bytes the instance ID of the query coordinator.TADDRVARCHAR2(8)Address of transaction state objectLOCKWAITVARCHAR2(8)Address of lock waiting for; null if noneSTATUSVARCHAR2(8)Status of the session:ACTIVE – Session currently executing SQLINACTIVEKILLED – Session marked to be killedCACHED – Session temporarily cached for use by Oracle*XASNIPED – Session inactive, waiting on the clientSERVERVARCHAR2(9)Server type (DEDICATED| SHARED| PSEUDO| NONE)SCHEMA#NUMBERSchema user identifierSCHEMANAMEVARCHAR2(30)Schema user nameOSUSERVARCHAR2(30)Operating system client user namePROCESSVARCHAR2(12)Operating system client process IDMACHINEVARCHAR2(64)Operating system machine nameTERMINALVARCHAR2(30)Operating system terminal namePROGRAMVARCHAR2(48)Operating system program nameTYPEVARCHAR2(10)Session typeSQL_ADDRESSRAW(4 | 8)Used with SQL_HASH_VALUE to identify the SQL statement that is currently being executedSQL_HASH_VALUENUMBERUsed with SQL_ADDRESS to identify the SQL statement that is currently being executedSQL_IDVARCHAR2(13)SQL identifier of the SQL statement that is currently being executedSQL_CHILD_NUMBERNUMBERChild number of the SQL statement that is currently being executedPREV_SQL_ADDRRAW(4 | 8)Used with PREV_HASH_VALUE to identify the last SQL statement executedPREV_HASH_VALUENUMBERUsed with SQL_HASH_VALUE to identify the last SQL statement executedPREV_SQL_IDVARCHAR2(13)SQL identifier of the last SQL statement executedPREV_CHILD_NUMBERNUMBERChild number of the last SQL statement executedMODULEVARCHAR2(48)Name of the currently executing module as set by calling theDBMS_APPLICATION_INFO.SET_MODULE procedureMODULE_HASHNUMBERHash value of the above MODULEACTIONVARCHAR2(32)Name of the currently executing action as set by calling theDBMS_APPLICATION_INFO.SET_ACTION procedureACTION_HASHNUMBERHash value of the above action nameCLIENT_INFOVARCHAR2(64)Information set by the DBMS_APPLICATION_INFO.SET_CLIENT_INFO procedureFIXED_TABLE_SEQUENCENUMBERThis contains a number that increases every time the session completes a call to the database and there has been an intervening select from a dynamic performance table. This column can be used by performance monitors to monitor statistics in the database. Each time the performance monitor looks at the database, it only needs to look at sessions that are currently active or have a higher value in this column than the highest value that the performance monitor saw the last time. All the other sessions have been idle since the last time the performance monitor looked at the database.ROW_WAIT_OBJ#NUMBERObject ID for the table containing the row specified in ROW_WAIT_ROW#ROW_WAIT_FILE#NUMBERIdentifier for the datafile containing the row specified in ROW_WAIT_ROW#. This column is valid only if the session is currently waiting for another transaction to commit and the value ofROW_WAIT_OBJ# is not -1.ROW_WAIT_BLOCK#NUMBERIdentifier for the block containing the row specified in ROW_WAIT_ROW#. This column is valid only if the session is currently waiting for another transaction to commit and the value ofROW_WAIT_OBJ# is not -1.ROW_WAIT_ROW#NUMBERCurrent row being locked. This column is valid only if the session is currently waiting for another transaction to commit and the value of ROW_WAIT_OBJ# is not -1.LOGON_TIMEDATETime of logonLAST_CALL_ETNUMBERIf the session STATUS is currently ACTIVE, then the value represents the elapsed time in seconds since the session has become active.If the session STATUS is currently INACTIVE, then the value represents the elapsed time in seconds since the session has become inactive.PDML_ENABLEDVARCHAR2(3)This column has been replaced by column PDML_STATUSFAILOVER_TYPEVARCHAR2(13)Indicates whether and to what extent transparent application failover (TAF) is enabled for the session:NONE – Failover is disabled for this sessionSESSION – Client is able to fail over its session following a disconnectSELECT – Client is able to fail over queries in progress as wellSee Also:Oracle Database Concepts for more information on TAFOracle Database Net Services Administrator’s Guide for information on configuring TAFFAILOVER_METHODVARCHAR2(10)Indicates the transparent application failover method for the session:NONE – Failover is disabled for this sessionBASIC – Client itself reconnects following a disconnectPRECONNECT – Backup instance can support all connections from every instance for which it is backed upFAILED_OVERVARCHAR2(3)Indicates whether the session is running in failover mode and failover has occurred (YES) or not (NO)RESOURCE_CONSUMER_GROUPVARCHAR2(32)Name of the免费主机域名 session’s current resource consumer groupPDML_STATUSVARCHAR2(8)If ENABLED, the session is in a PARALLEL DML enabled mode. If DISABLED, PARALLEL DML enabled mode is not supported for the session. If FORCED, the session has been altered to force PARALLEL DML.PDDL_STATUSVARCHAR2(8)If ENABLED, the session is in a PARALLEL DDL enabled mode. If DISABLED, PARALLEL DDL enabled mode is not supported for the session. If FORCED, the session has been altered to force PARALLEL DDL.PQ_STATUSVARCHAR2(8)If ENABLED, the session is in a PARALLEL QUERY enabled mode. If DISABLED, PARALLEL QUERY enabled mode is not supported for the session. If FORCED, the session has been altered to force PARALLEL QUERY.CURRENT_QUEUE_DURATIONNUMBERIf queued (1), the current amount of time the session has been queued. If not currently queued, the value is 0.CLIENT_IDENTIFIERVARCHAR2(64)Client identifier of the sessionBLOCKING_SESSION_STATUSVARCHAR2(11)Blocking session status:VALIDNO HOLDERGLOBALNOT IN WAITUNKNOWNBLOCKING_INSTANCENUMBERInstance identifier of blocking sessionBLOCKING_SESSIONNUMBERSession identifier of blocking sessionSEQ#NUMBERSequence number that uniquely identifies the wait. Incremented for each wait.EVENT#NUMBEREvent numberEVENTVARCHAR2(64)Resource or event for which the session is waitingSee Also: Appendix C, “Oracle Wait Events”P1TEXTVARCHAR2(64)Description of the first additional parameterP1NUMBERFirst additional parameterP1RAWRAW(4)First additional parameterP2TEXTVARCHAR2(64)Description of the second additional parameterP2NUMBERSecond additional parameterP2RAWRAW(4)Second additional parameterP3TEXTVARCHAR2(64)Description of the third additional parameterP3NUMBERThird additional parameterP3RAWRAW(4)Third additional parameterWAIT_CLASS_IDNUMBERIdentifier of the wait classWAIT_CLASS#NUMBERNumber of the wait classWAIT_CLASSVARCHAR2(64)Name of the wait classWAIT_TIMENUMBERA nonzero value is the session’s last wait time. A zero value means the session is currently waiting.SECONDS_IN_WAITNUMBERIf WAIT_TIME = 0, then SECONDS_IN_WAIT is the seconds spent in the current wait condition. IfWAIT_TIME > 0, then SECONDS_IN_WAIT is the seconds since the start of the last wait, andSECONDS_IN_WAIT – WAIT_TIME / 100 is the active seconds since the last wait ended.STATEVARCHAR2(19)Wait state:0 – WAITING (the session is currently waiting)-2 – WAITED UNKNOWN TIME (duration of last wait is unknown)-1 – WAITED SHORT TIME (last wait >0 – WAITED KNOWN TIME (WAIT_TIME = duration of last wait)SERVICE_NAMEVARCHAR2(64)Service name of the sessionSQL_TRACEVARCHAR2(8)Indicates whether SQL tracing is enabled (ENABLED) or disabled (DISABLED)SQL_TRACE_WAITSVARCHAR2(5)Indicates whether wait tracing is enabled (TRUE) or not (FALSE)SQL_TRACE_BINDSVARCHAR2(5)Indicates whether bind tracing is enabled (TRUE) or not (FALSE)关于“如何通过操作系统的进程号查看数据库的session”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

相关推荐: 如何根据操作系统进程号查看oracle对应的SQL语句内容

这篇文章主要介绍了如何根据操作系统进程号查看oracle对应的SQL语句内容,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。 1、 先用ps -aux查询,发现有个进程占用大量CPU,记录下PID…

文章页内容下
赞(0) 打赏
版权声明:本站采用知识共享、学习交流,不允许用于商业用途;文章由发布者自行承担一切责任,与本站无关。
文章页正文下
文章页评论上

云服务器、web空间可免费试用

宝塔面板主机、支持php,mysql等,SSL部署;安全高速企业专供99.999%稳定,另有高防主机、不限制内容等类型,具体可咨询QQ:360163164,Tel同微信:18905205712

主机选购导航云服务器试用

登录

找回密码

注册