
我嘗試在 CentOS 上為 Sybase ASE 12.5 設定共享記憶體。我的伺服器有17G內存,我想為sybase提供14G(=17-1-2)。 (1G 用於作業系統,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 最大記憶體設定為 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還不夠嗎?還是需要做更多的事情?
另外,我的輸出不低於 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
如何解決這個問題?
答案1
嘗試分配比shmmax
結果允許的更大的段EINVAL (Invalid argument)
,這不是您得到的。嘗試分配超過提交的記憶體限制會導致ENOSPC (No space left on device)
您得到的結果。
據我記得,限制預設為實體 RAM 的一半加上總交換空間。您可以使用此命令查看當前值grep CommitLimit /proc/meminfo
檔案系統的大小tmpfs
由 mount 選項控制size
,如 所述man mount
。
檔案/dev/shm
系統由呼叫使用shm_open
。這與shmget
源自 Posix 和 SysV 的兩個不同 API無關。