시스템 사양에 맞는 세마포어 값 계산해주는 스크립트



 

스템 사양에 맞는 세마포어 값 계산해주는 스크립트

shmmax, shmall 계산

DB를 설치하고 사용 할 때, 많이 수정하는 OS 커널 파라미터 입니다.

postgresql 이나, mysql의 max_connections 값을 조정하거나 오라클을 설치할 때도 기본적으로 수정을 합니다.

 

shmsetup.sh

#!/bin/bash
# http://archives.postgresql.org/pgsql-admin/2010-05/msg00285.php
# Output lines suitable for sysctl configuration based
# on total amount of RAM on the system.  The output
# will allow up to 50% of physical memory to be allocated
# into shared memory.

# On Linux, you can use it as follows (as root):
#
# ./shmsetup >> /etc/sysctl.conf
# sysctl -p

# Early FreeBSD versions do not support the sysconf interface
# used here.  The exact version where this works hasn't
# been confirmed yet.

page_size=`getconf PAGE_SIZE`
phys_pages=`getconf _PHYS_PAGES`

if [ -z "$page_size" ]; then
  echo Error:  cannot determine page size
  exit 1
fi

if [ -z "$phys_pages" ]; then
  echo Error:  cannot determine number of memory pages
  exit 2
fi

shmall=`expr $phys_pages / 2`
shmmax=`expr $shmall \* $page_size`

echo \# Maximum shared segment size in bytes
echo kernel.shmmax = $shmmax
echo \# Maximum number of shared memory segments in pages
echo kernel.shmall = $shmall

출처: https://gist.github.com/redterror/6732387



You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *