RSS구독하기:SUBSCRIBE TO RSS FEED
즐겨찾기추가:ADD FAVORITE
글쓰기:POST
관리자:ADMINISTRATOR
'2012/01'에 해당되는 글 2
요즘 서버들의 물리메모리를 보면 참 대단하다.
특히나 가상화가 추세이다보니 예전에는 상상도 할 수없을 만큼의 물리메모리를 장착한다.
그럼 이렇게 몇 백기가 단위의 물리 메모리 일때 swap은 어떻게 줘야하는가?

기본적으로 리눅스하는 사람은 swap 공식은 물리메모리에 2배수, 8G 이상은 1배수 정도로 생각하고 있었다.(나만 그런가?!)
하지만 만약 128G의 물리메모리를 가진 서버라면? 1배수라 하여도 128G의 하드디스크의 128G를 써야하는가? 요즘 서버는 메모리는
커지는 반면, internal disk의 용량은 줄어들고있는 추세라는걸 감안하면 엄청난 disk 낭비이기도 하다.

뭐 상황별로 다르긴하겠지만, RHEL 5, 6버전별 권장 스왑용량은 아래와 같다.

Considering that

  1. At installation time when configuring the swap space there is no easy way to predetermine the memory a workload will require, and
  2. The more RAM a system has the less swap space it typically needs, a better swap space requirements rule for Red Hat Enterprise Linux 5 is:
    • Systems with 4 GB of ram or less require a minimum of 2 GB of swap space
    • Systems with 4 GB to 16 GB of ram require a minimum of 4 GB of swap space
    • Systems with 16 GB to 64 GB of ram require a minimum of 8 GB of swap space
    • Systems with 64 GB to 256 GB of ram require a minimum of 16 GB of swap space
  3. And, a better swap space requirements for Red Hat Enterprise Linux 6 is:
    • Systems with 2 GB of ram or less require a minimum of 2*ram of swap space
    • Systems with 2 GB to 8 GB of ram require a minimum of ram size of swap space
    • Systems with 8 GB to 64 GB of ram require a minimum of ram/2 of swap space
    • Systems with 64 GB of ram or more require a minimum of 4 GB of swap space.

Also the following points influence the decison if SWAP should be allocated and how much:

  • Do specific application requirements exist? In the past applications were written and vendors made specific recommendations how much SWAP should be used when the application is run. If this is the case the SWAP has to be sized accordingly to run the application in a supported environment.
  • Do other requirements exist? Workstations and laptops might be hibernated with storing the RAM contents in the SWAP area.
  • Cost/usage tradeoff Swap is stored on harddisks which cause costs, for initial purchase as well as for maintenance. If the system uses internal harddisks which contain the RHEL then it is likely that there is unused discspace - this can be used for swap without additional costs. The cost/usage trafeoff has changed in the last years with changing prices for RAM/harddiscs.
  • Assigning swap as 'last effort' While the blockdevices hosting SWAP are mostly many scales slower than RAM, in the case of an application requesting more and more ram it is useful to have swap as an additional layer before the OOMkiller strikes in.
  • Special system requirements due to much hardware If many cpu cores (i.e. >140) are available on the system or much memory is installed (i.e. >3TB) then this imposes also a requirement for swap. Such systems should be setup with atleast 100GB of swap.


Trackback
Reply
/dev/shm이란?
If an application is POSIX compliant or it uses GLIBC (2.2 and above) on a Red Hat Enterprise Linux system, it will usually use the /dev/shm for shared memory (shm_open, shm_unlink). /dev/shm is a temporary filesystem (tmpfs) which is mounted from /etc/fstab. Hence the standard options like "size" supported for tmpfs can be used to increase or decrease the size of tmpfs on /dev/shm (by default it is half of available system RAM). 

이다.... ( - _-);

더욱 자세한 것은 http://www.kernel.org/pub/linux/kernel/people/marcelo/linux-2.4/Documentation/filesystems/tmpfs.txt 를 참조하자.

하지만 기본적으로 설치 시 물리메모리의 반으로 설정이 되어 있는데, 이것을 resize하는 방법을 정리해 본다.

기본적으로 아래와 같이 설정이 되어 있다.
# /etc/fstab
 none     /dev/shm       tmpfs   defaults        0 0

이것을 하기와 같이 수정한다.(1G로 설정해 본다)
 none      /dev/shm        tmpfs   defaults,size=1024M        0 0

이 후 리마운트만 하면 적용 끝!
# mount -o remount /dev/shm
확인은 df -h 로 가능하다.

여기에서 한 가지 의문점은, 그럼 물리 메모리보다 크게 잡을 경우에는 어떤 문제가 생길것인가?
결론부터 말하자면, 문제가 없다가 정답니다.

/dev/shm은 물리메모리 뿐만 아니라, 필요시에는 swap 영역까지 사용이 가능하다. 하지만 swap을 사용하지 않게 하기
위해서 기본적으로 물리메모리의 반이 설정 되어 있으며, 설정이 되어 있더라고 해도 처음부터 해당 메모리를 선점하지 않고
필요 시마다 메모리를 늘려가는 방식이기 때문에 크게 걱정하지 않아도 된다.


 
Trackback
Reply
우주곰:지구곰이 아닙니다.
지구곰이 아닙니다.
Categories (190)
Information (5)
About uzoogom (5)
My Advanced Linux (73)
Learning Linux (96)
OperatingSystem (5)
Databases (4)
OpenSource (1)
Tips! (1)
«   2012/01   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31