Chinaunix首页 | 论坛 | 博客
  • 博客访问: 99993
  • 博文数量: 64
  • 博客积分: 2570
  • 博客等级: 少校
  • 技术积分: 605
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-24 11:00
文章分类

全部博文(64)

文章存档

2011年(1)

2010年(25)

2009年(38)

我的朋友

分类: LINUX

2009-12-07 09:46:48

shm means posix shared memory.It's added in kernel since 2.4.x.
From Documentation/filesystems/tmpfs:
glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for POSIX shared memory (shm_open, shm_unlink). Adding the following line to /etc/fstab should take care of this:

         tmpfs   /dev/shm        tmpfs   defaults        0 0

Remember to create the directory that you intend to mount tmpfs on if necessary (/dev/shm is automagically created if you use devfs).This mount is _not_ needed for SYSV shared memory. 
The internal mount is used for that. (In the 2.3 kernel versions it was necessary to mount the predecessor of tmpfs (shm fs) to use SYSV shared memory)
Red Hat adds the appropriate fstab entry for you (although they use"none" for the first field, which I think is a bit more correct).

[Chinese]
linux系统中独有的/dev/shm,与swap分区不同,shm使用的文件系统是tmpfs,另有一些linux发行版本(例如REHL3)使用的是rawfs文件系统(一种内存文件系统)。
/dev/shm通常在物理内存足够时,会在内存中进行数据交换,如果物理内存缺乏时,会用swap进行数据交换. 支持动态在线调整.在需要时可以增加或缩减它的大小.(rawfs不支持存储在swap分区)

mount -o remount,size=3G /dev/shm

通过实验验证shm存储在内存时(摘自《/dev/shm 一点知识》

mkdir -p /dev/shm/a
cp 10201_clusterware_linux32.zip /dev/shm/a
root@dbtest u01]# free -m
total used free shared buffers cached
Mem: 1519 1511 7 0 106 940
rm /dev/shm/a/10201_clusterware_linux32.zip
root@dbtest a]# free -m
total used free shared buffers cached
Mem: 1519 1294 224 0 106 722

关于应用(摘自《linux下/dev/shm是什么?》):

   mkdir /dev/shm/tmp
  chmod 1777 /dev/shm/tmp
  mount --bind /dev/shm/tmp /tmp(--bind )

在使用mount --bind olderdir newerdir命令来挂载一个目录到另一个目录后,newerdir的权限和所有者等所有信息会发生变化。挂载后的目录继承了被挂载目录的所有属性,除了名称。
阅读(351) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~