我尝试在CentOS上为Sybase ASE 12.5设置共享内存。 我的服务器有17G内存,我想让14G(= 17-1-2)可用于sybase。 (1G用于os,2G用于ramdisk 14 = 17-1-2)。
这里是信息:
[sybase@myserver ASE-12_5]$ free -g total used free shared buffers cached Mem: 17 7 9 0 0 7 -/+ buffers/cache: 0 17 Swap: 3 0 3
有2G ramdisk设置。
[sybase@myserver ASE-12_5]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 12G 2.6G 8.8G 23% / /dev/sda1 251M 19M 220M 8% /boot none 8.7G 0 8.7G 0% /dev/shm ---what's this? is it related kernel.shmmax? /dev/sdb1 30G 8.4G 20G 30% /home tmpfs 2.1G 20M 2.1G 1% /db/tempdb -----this is ramdisk, what 's the difference between this and /dev/shm???
那么我修改/ect/sysctl.conf为:
[sybase@myserver ASE-12_5]$ cat /etc/sysctl.conf # Kernel sysctl configuration file for Red Hat Linux # # For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and # sysctl.conf(5) for more details. # Controls IP packet forwarding net.ipv4.ip_forward = 0 # Controls source route verification net.ipv4.conf.default.rp_filter = 1 # Do not accept source routing net.ipv4.conf.default.accept_source_route = 0 # Controls the System Request debugging functionality of the kernel kernel.sysrq = 1 # Controls whether core dumps will append the PID to the core filename. # Useful for debugging multi-threaded applications. kernel.core_uses_pid = 1 # kernel.shmmax = 10737418240 kernel.shmmax= 14738890752 ------modify this to 13.7G kernel.shmmni = 4096 kernel.shmall = 2097152
然后运行:
echo "kernel.shmmax=14738890752" >> /etc/sysctl.conf
然后重新启动CentOS。
然后我尝试将sybase max memory设置为7196724(2K),但我可以启动sybase并出现错误:
00:00000:00000:2014/04/02 16:50:26.92 kernel os_create_region: shmget(0xf402f74d): No space left on device 00:00000:00000:2014/04/02 16:50:26.92 kernel kbcreate: couldn't create kernel region. 00:00000:00000:2014/04/02 16:50:26.92 kernel kistartup: could not create shared memory
只允许我将最大内存设置为40000009(2k)= 7.6G
不知道为什么。 所以在CentOS上设置共享内存,只改变/etc/sysctl.conf中的kernel.shmmax是不够的? 还是需要做更多?
另外,我df -h
2行输出df -h
:
none 8.7G 0 8.7G 0% /dev/shm ---what's this? is it related kernel.shmmax tmpfs 2.1G 20M 2.1G 1% /db/tempdb -----this is ramdisk
如何解决这个问题?
试图分配比shmmax
允许的更大的段导致EINVAL (Invalid argument)
,这不是你所得到的。 试图在ENOSPC (No space left on device)
情况下分配超过已提交的内存限制的结果,这就是你所得到的。
据我所知,限制默认为物理RAM加总交换空间的一半。 你可以用这个命令grep CommitLimit /proc/meminfo
来查看你当前的值
tmpfs
文件系统的size
由man mount
说明来控制。
/dev/shm
文件系统由shm_open
调用使用。 这与shmget
无关,这些是来自Posix和SysV的两种不同的API。