lsof:一个功能强大的命令 lsof命令的原始功能是列出打开的文件的进程,但LINUX下,所有的设备都是以文件的行式存在的,所以,lsof的功能很强大! lsof输出各列信息的意义如下: COMMAND:进程的名称 PID:进程标识符 USER:进程所有者 FD:文件描述符,应用程序通过文件描述符识别该文件。如cwd、txt等 TYPE:文件类型,如DIR、REG等 DEVICE:指定磁盘的名称 SIZE:文件的大小 NODE:索引节点(文件在磁盘上的标识) NAME:打开文件的确切名称 系统检测进程 (SMON) SMON负责系统的清楚任务。这些任务包括: *在实例启动时执行实例恢复。 *由于文件或者表空间离线的错误,有些事务在实例恢复中被忽略了,当文件和表空间在线 的时候,SMON恢复中断的事务 *清楚无用的临时表空间段。 *合并字典表空间中连续的空闲的区(extent) [root@june ~]# lsof | grep redo oracle 2294 oracle 19u REG 8,3 52429312 10289162 /oradata/june/redo01.log oracle 2294 oracle 20u REG 8,3 52429312 10289167 /oradata/june/redo02.log oracle 2294 oracle 21u REG 8,3 52429312 10289164 /oradata/june/redo03.log oracle 2294 oracle 22u REG 8,3 52429312 10289172 /oradata/june/redo04.dbf [root@june ~]# ps -ef | grep 2294 oracle 2294 1 0 Oct05 ? 00:00:07 ora_lgwr_june root 31000 30928 0 00:44 pts/1 00:00:00 grep 2294 操作控制文件的进程有dbwn lgwr ckpt 还有server process [root@june ~]# lsof | grep control oracle 2292 oracle 16u REG 8,3 7356416 10289159 /oradata/june/control01.ctl oracle 2292 oracle 17u REG 8,3 7356416 10289160 /oradata/june/control02.ctl oracle 2292 oracle 18u REG 8,3 7356416 10289161 /oradata/june/control03.ctl oracle 2294 oracle 16u REG 8,3 7356416 10289159 /oradata/june/control01.ctl oracle 2294 oracle 17u REG 8,3 7356416 10289160 /oradata/june/control02.ctl oracle 2294 oracle 18u REG 8,3 7356416 10289161 /oradata/june/control03.ctl oracle 2296 oracle 16uW REG 8,3 7356416 10289159 /oradata/june/control01.ctl oracle 2296 oracle 17uW REG 8,3 7356416 10289160 /oradata/june/control02.ctl oracle 2296 oracle 18uW REG 8,3 7356416 10289161 /oradata/june/control03.ctl oracle 31011 oracle 13u REG 8,3 7356416 10289159 /oradata/june/control01.ctl oracle 31011 oracle 14u REG 8,3 7356416 10289160 /oradata/june/control02.ctl oracle 31011 oracle 15u REG 8,3 7356416 10289161 /oradata/june/control03.ctl [root@june ~]# ps -ef | grep 2292 oracle 2292 1 0 Oct05 ? 00:00:06 ora_dbw0_june root 31005 30928 0 00:44 pts/1 00:00:00 grep 2292 [root@june ~]# ps -ef | grep 2294 oracle 2294 1 0 Oct05 ? 00:00:07 ora_lgwr_june root 31007 30928 0 00:44 pts/1 00:00:00 grep 2294 [root@june ~]# ps -ef | grep 2296 oracle 2296 1 0 Oct05 ? 00:01:24 ora_ckpt_june root 31009 30928 0 00:44 pts/1 00:00:00 grep 2296 [root@june ~]# ps -ef | grep 31011 oracle 31011 31010 7 00:45 ? 00:00:04 oraclejune (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))) 当增加、重命名、删除一个数据文件或者一个联机日志文件时,Oracle服务器进程(Server Process)会立即更新控制文件以反映数据库结构的这种变化。所以,Oracle总是告诫我们,在数据库的结构发生变化后,要备份控制文件。日志写进程LGWR负责把当前日志序列号记录到控制文件中。校验点进程CKPT负责把校验点的信息记录到控制文件中。归档进程负责把归档日志的信息记录到控制文件中。 操作日志文件的进程是lgwr [root@june ~]# lsof | grep redo oracle 2294 oracle 19u REG 8,3 52429312 10289162 /oradata/june/redo01.log oracle 2294 oracle 20u REG 8,3 52429312 10289167 /oradata/june/redo02.log oracle 2294 oracle 21u REG 8,3 52429312 10289164 /oradata/june/redo03.log oracle 2294 oracle 22u REG 8,3 52429312 10289172 /oradata/june/redo04.dbf [root@june ~]# ps -ef | grep 2294 oracle 2294 1 0 Oct05 ? 00:00:07 ora_lgwr_june root 31072 30928 0 00:50 pts/1 00:00:00 grep 2294 操作数据文件的进程 [root@june ~]# ps -ef | grep 2292 oracle 2292 1 0 Oct05 ? 00:00:07 ora_dbw0_june root 31083 30928 0 00:55 pts/1 00:00:00 grep 2292 [root@june ~]# ps -ef | grep 2294 oracle 2294 1 0 Oct05 ? 00:00:07 ora_lgwr_june root 31085 30928 0 00:55 pts/1 00:00:00 grep 2294 [root@june ~]# ps -ef | grep 2298 oracle 2298 1 0 Oct05 ? 00:00:17 ora_smon_june root 31087 30928 0 00:55 pts/1 00:00:00 grep 2298 [root@june ~]# ps -ef | grep 31011 oracle 31011 31010 0 00:45 ? 00:00:04 oraclejune (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))) root 31089 30928 0 00:55 pts/1 00:00:00 grep 31011 操作unod文件的进程: [root@june ~]# lsof /oradata/june/undotbs02.dbf COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME oracle 2292 oracle 25uW REG 8,3 1056768 10289168 /oradata/june/undotbs02.dbf oracle 2294 oracle 29u REG 8,3 1056768 10289168 /oradata/june/undotbs02.dbf oracle 2298 oracle 22u REG 8,3 1056768 10289168 /oradata/june/undotbs02.dbf oracle 2304 oracle 21u REG 8,3 1056768 10289168 /oradata/june/undotbs02.dbf oracle 31011 oracle 18u REG 8,3 1056768 10289168 /oradata/june/undotbs02.dbf [root@june ~]# ps -ef | grep 31011 操作temp文件的进程: [root@june ~]# lsof /oradata/june/temp01.dbf COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME oracle 2292 oracle 30uW REG 8,3 31465472 10289165 /oradata/june/temp01.dbf oracle 2294 oracle 34u REG 8,3 31465472 10289165 /oradata/june/temp01.dbf oracle 2298 oracle 27u REG 8,3 31465472 10289165 /oradata/june/temp01.dbf select * from v$sga_dynamic_components 第二个脚本是pga_by_session.sql,用来监控session所使用的PGA和UGA的大小: select a.name, b.value from v$statname a, v$sesstat b where a.statistic# = b.statistic# and b.sid = &sid and a.name like '%ga %' order by a.name / 第三个脚本监控进程所使用的PGA的大小,pga_by_process.sql : SELECT a.pga_used_mem "PGA Used", a.pga_alloc_mem "PGA Alloc", a.pga_max_mem "PGA Max" FROM v$process a,v$session b where a.addr = b.paddr and b.sid= &sid 会话是在连接建立的基础之上 [root@june ~]# ipcs -m | grep oracle 0x276f145c 98305 oracle 640 209715200 17 [root@june ~]# ipcrm -m 98305 [root@june ~]# ipcs -m | grep oracle 0x00000000 98305 oracle 640 209715200 17 dest [root@june ~]# ipcs -m | grep oracle 0x00000000 98305 oracle 640 209715200 17 dest [root@june ~]# ipcs -m | grep oracle 0x00000000 98305 oracle 640 209715200 17 dest