1. 首页
  2. IT资讯

linux共享内存段研究

linux共享内存段研究

无论是在unix或者是linux都有命令查看主机共享内存段的使用情况,以下研究来自linux平台。一、查看Oracle用户共享内存段使用情况

引用
[oracle@capaa ~]$ ipcs—— Shared Memory Segments ——–key shmid owner perms bytes nattch status0x00000000 917504 oracle 600 196608 2 dest0x00000000 950273 oracle 600 196608 2 dest0x00000000 983042 oracle 600 196608 2 dest0x00000000 1015811 oracle 600 196608 2 dest0x00000000 1081349 oracle 600 196608 2 dest0x00000000 1179656 oracle 600 196608 2 dest0x4cd26024 524300 oracle 640 562044928 550×00000000 1900559 oracle 600 12288 2 dest0x00000506 1802260 oracle 666 16384 00×00000000 1835029 oracle 600 196608 2 dest—— Semaphore Arrays ——–key semid owner perms nsems0xc7ef5bb0 98304 oracle 640 1520xc7ef5bb1 131073 oracle 640 1520xc7ef5bb2 163842 oracle 640 152—— Message Queues ——–key msqid owner perms used-bytes messages

简单说明:shmid:表示共享内存段idowner:表示共享内存段属于哪个用户,需要注意的是默认情况下600表示除root用户外不允许其他用户查看bytes:表示共享内存段大小nattch:表示连接到共享内存段的进程数status:表示共享内存段的状态,dest表示该内存段被标记为destroyed状态。二、查看共享内存段进程连接信息1、指定shmid,查看进程连接信息查看shmid为524300的具体信息,可用如下命令

引用
[oracle@capaa ~]$ ipcs -m -i 524300Shared memory Segment shmid=524300uid=505 gid=505 cuid=505 cgid=505mode=0640 access_perms=0640bytes=562044928 lpid=15216 cpid=16790 nattch=55att_time=Wed Dec 9 13:44:45 2009det_time=Wed Dec 9 13:44:45 2009change_time=Fri Nov 27 15:58:44 2009

2、查看所有共享内存段,进程连接信息

引用
[oracle@capaa ~]$ ipcs -pm—— Shared Memory Creator/Last-op ——–shmid owner cpid lpid917504 oracle 30438 30967950273 oracle 30440 1286983042 oracle 31234 309671015811 oracle 31236 309671081349 oracle 31708 12751179656 oracle 31661 30967524300 oracle 16790 154101900559 oracle 1315 299591802260 oracle 1286 01835029 oracle 1315 29959

简单说明:cpid表示创建共享内存段进程的idlpid表示上一次访问该共享内存的进程id三、查看Oracle使用共享内存段使用情况1、使用Oracle小工具查看共享内存段使用情况Oracle软件装好之后自带一个工具(sysresv),可以清晰的看到每个实例的内存使用情况,默认安装在$ORACLE_HOME/bin目录下,以下是sysresv的输出情况

引用
[oracle@capaa ~]$ sysresvIPC Resources for ORACLE_SID “xe” :Shared Memory:ID KEY524300 0x4cd26024Semaphores:ID KEY98304 0xc7ef5bb0131073 0xc7ef5bb1163842 0xc7ef5bb2Oracle Instance alive for sid “xe”

可以看到SID为xe的实例使用了shmid为524300的共享内存段2、使用oradebug命令行查看共享内存段使用情况1)连接到需要查看的数据库中2)取得连接的os pid

引用
[oracle@capaa ~]$ ps -ef|grep LOCAL=YESoracle 16497 16496 0 13:57 ? 00:00:00 oraclexe (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))3)根据os pid利用oradebug产生跟踪文件SQL> oradebug setospid 16497Statement processed.SQL> oradebug ipcInformation written to trace file.SQL> oradebug tracefile_name/var/oracle/admin/xe/udump/xe_ora_16497.trc

4)打开跟踪文件可以看到该实例共享内存使用情况,其中shmid为524300

引用
[oracle@capaa ~]$ cat /var/oracle/admin/xe/udump/xe_ora_16497.trc/var/oracle/admin/xe/udump/xe_ora_16497.trcOracle Database 10g Enterprise Edition Release 10.2.0.1.0 – 64bit ProductionWith the Partitioning, OLAP and Data Mining optionsORACLE_HOME = /var/oracle/product/10.2.0/db_1System name: LinuxNode name: capaaRelease: 2.6.18-53.el5xenVersion: #1 SMP Mon Nov 12 02:46:57 EST 2007Machine: x86_64Instance name: xeRedo thread mounted by this instance: 1Oracle process number: 55Unix process pid: 16497, image: oracle@capaa (TNS V1-V3)*** 2009-12-09 14:02:27.230*** SERVICE NAME:(SYS$USERS) 2009-12-09 14:02:27.171*** SESSION ID:(262.2351) 2009-12-09 14:02:27.171Dump of unix-generic skgm contextareaflags 000000a7realmflags 0000000fmapsize 00001000protectsize 00001000lcmsize 00001000seglen 00001000largestsize 0000001000000000smallestsize 0000000000400000stacklimit 0x7fff2207dac0stackdir -1mode 640magic acc01adeHandle: 0x185252d0 `/var/oracle/product/10.2.0/db_1xe’Dump of unix-generic realm handle `/var/oracle/product/10.2.0/db_1xe’, flags = 00000000Area #0 `Fixed Size’ containing Subareas 0-0 Total size 00000000001edba8 Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Addr 0 0 524300 0x00000060000000 0x00000060000000 Subarea size Segment size 00000000001ee000 0000000021802000Area #1 `Variable Size’ containing Subareas 2-2 Total size 0000000021000000 Minimum Subarea size 00400000 Area Subarea Shmid Stable Addr Actual Addr 1 2 524300 0x00000060800000 0x00000060800000 Subarea size Segment size 0000000021000000 0000000021802000Area #2 `Redo Buffers’ containing Subareas 1-1 Total size 0000000000612000 Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Addr 2 1 524300 0x000000601ee000 0x000000601ee000 Subarea size Segment size 0000000000612000 0000000021802000Area #3 `skgm overhead’ containing Subareas 3-3 Total size 0000000000002000 Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Addr 3 3 524300 0x00000081800000 0x00000081800000 Subarea size Segment size 0000000000002000 0000000021802000Dump of Solaris-specific skgm contextsharedmmu 00000000shareddec 0used region 0: start 0000000040000000 length 000000007fff80000000Maximum processes: = 300Number of semaphores per set: = 152Semaphores key overhead per set: = 4User Semaphores per set: = 148Number of semaphore sets: = 3Semaphore identifiers: = 3Semaphore List=98304————– system semaphore information ——————- Shared Memory Segments ——–key shmid owner perms bytes nattch status0x00000000 917504 oracle 600 196608 2 dest0x00000000 950273 oracle 600 196608 2 dest0x00000000 983042 oracle 600 196608 2 dest0x00000000 1015811 oracle 600 196608 2 dest0x00000000 1081349 oracle 600 196608 2 dest0x00000000 1179656 oracle 600 196608 2 dest0x4cd26024 524300 oracle 640 562044928 550×00000000 1900559 oracle 600 12288 2 dest0x00000506 1802260 oracle 666 16384 00×00000000 1835029 oracle 600 196608 2 dest—— Semaphore Arrays ——–key semid owner perms nsems0xc7ef5bb0 98304 oracle 640 1520xc7ef5bb1 131073 oracle 640 1520xc7ef5bb2 163842 oracle 640 152—— Message Queues ——–key msqid owner perms used-bytes messages四、进一步研究通过以上命令可以查看创建Oracle实例的初始进程[oracle@capaa ~]$ ipcs -mi 524300Shared memory Segment shmid=524300uid=505 gid=505 cuid=505 cgid=505mode=0640 access_perms=0640bytes=562044928 lpid=19796 cpid=16790 nattch=54att_time=Wed Dec 9 14:10:26 2009det_time=Wed Dec 9 14:10:35 2009change_time=Fri Nov 27 15:58:44 2009

通过cpid=16790 可以知道pid为16790启动了Oracle实例,该进程只负责启动Oracle实例,启动完成后通过“自杀”结束进程,可以从两方面得到验证1)启动日志

引用
PMON started with pid=2, OS id=30345PSP0 started with pid=3, OS id=30347MMAN started with pid=4, OS id=30349DBW0 started with pid=5, OS id=30351LGWR started with pid=6, OS id=30353CKPT started with pid=7, OS id=30355SMON started with pid=8, OS id=30357RECO started with pid=9, OS id=30359CJQ0 started with pid=10, OS id=30361MMON started with pid=11, OS id=30363

2)从v$process表中查相关信息

引用
SQL> select addr,program from v$process where pid=1;ADDR PROGRAM—————- ————————————————00000000817DA930 PSEUDO

PSEUDO表示该进程已被killed

转自http://itspace.**.com/blog/544723

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27042095/viewspace-744776/,如需转载,请注明出处,否则将追究法律责任。

主题测试文章,只做测试使用。发布者:布吉卡,转转请注明出处:http://www.cxybcw.com/196056.html

联系我们

13687733322

在线咨询:点击这里给我发消息

邮件:1877088071@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

QR code