swap메모리는 주 메모리가 부족할 때 하드디스크와 같은 공간을 메모리로 사용하기 위한 가상메모리이다.(윈도우에선 가상메모리라 함)
그런데, 오늘은 주 메모리는 남아도는데 swap메모리가 부족한 어처구니없는 상황이 벌어졌으니….
머 이번 포스팅은 이런 현상의 원인이 아니라 걍 swap메모리 늘리기니깐 상황분석은 생략..(실은 잘 몰라서..-ㅅ-;;)
swap영역을 확보하기 위해서는 2가지 방법이 있다고 한다.
1. swap 파티션 구성
2. swap 파일 생성
위 2가지 중 swap 파일을 생성하는 것이 상대적으로 용이하기 때문에 swap파일을 생성, 설정, 활성화 하는 것을 이용하였다.
1. swap파일의 생성 – root(/)에 512MB의 swapfile_temp라는 것을 만든다.
# dd if=/dev/zero of=/swapfile_temp bs=1024 count=524288
(참고 : 4G 로 생성할 경우 count=4000000)
2. swap파일 설정 - v1옵션은 new스타일, v0옵션은 old스타일이다.
# mkswap –v1 /swapfile_temp
3. swap파일 활성화
# swapon /swapfile_temp
이 후 top 또는 free명령을 통해 늘어난 swap공간을 확인할 수 있다.
* 활성화된 swap공간을 삭제하기 위해선 swapoff명령을 사용한 후 해당 파일을 삭제하면 끝~
* 리부팅시 swap 용량이 전상태로 돌아가므로 /etc/rc.d/rc.local 에 맨 마지막 명령어(swapon /swapfile_temp)를 추가해 준다.
20140711
20131020
Kill Process based on Start Time (STIME)
One of the server that I am working with has some infinitely running PHP process. Due to incorrect way of cron setup by the development team, it has caused the process hanging and not ended properly. According to them, these processes can be killed if still hang after 12 hours.
Any process which run in server will have start time (STIME). You can check this by using ps command. In this case, following result will appear:
|
If you see the STIME value mostly has started long time ago but it is still inside the process list. To kill all the older process which more that 24 hours, I use following command:
$ kill -9 `ps aux | grep php | grep sync2server | awk '$9 !~ /[0-9]:[0-9]/' | awk '{print $2}'`
|
Explanation:
Using ps command, we grep anything related to “php” and “sync2server” which is the specific process that we want to kill. The 4th argument is checking whether column no 9 (STIME) column has value which NOT in “number:number” format. Process which starts for more than 24 hours, STIME value will contains word for example “Jun23″ or “2010″. The 5th argument is actually print the value of column no 2 which is the PID to be killed.
Using ps command, we grep anything related to “php” and “sync2server” which is the specific process that we want to kill. The 4th argument is checking whether column no 9 (STIME) column has value which NOT in “number:number” format. Process which starts for more than 24 hours, STIME value will contains word for example “Jun23″ or “2010″. The 5th argument is actually print the value of column no 2 which is the PID to be killed.
To kill process which less than 24 hours, you can use following script:
|
Above scripts will try to find any PHP process which executed more than 12 hours and will kill it one by one. You can get the script to run as cron twice per day so it will automate your administration job.
Lets share if you have better idea. Cheers!
피드 구독하기:
글 (Atom)
Articles
-
요즘 회사 내부에서 쇼핑 관련 추천이나 여러가지 고민을 해보던중에... 발견한 내용...ㅋㅋㅋ 울 회사는 외부 연구기관에다가 의뢰하여 개별 시나리오를 작성하여 상품 수명 등 여러가지를 해봤는데... 이미 이런 추천 내용이 있어... 다시 고민...
-
Load Balance Mysql Slaves Using MySQLProxy I am sure you all have read about MySQL replication, like Master-Master, Single Master - ...
-
아래 기술한 5가지는 해 놓으시면 좋습니다. 차후에 관련해서 큰 고민을 덜어놓을수 있으니까요. 1. 과학기술인공제회 가입 2. 한이음 멘토 신청 3. 산업통상자원부 전문가 풀 등록 4. 감리원 교육 신청 5. Skill up of an E...
-
百度搜索网站登录口:http://www.baidu.com/search/url_submit.html Google网站登录口:http://www.google.com/intl/zh-CN/add_url.html 孙悟空网站登录口:http://www.sunwuk...
-
webman21님의 블로그 | webman21 http://blog.naver.com/webman21/17890936 인덱스를 선택하는 것은 많은 SQL Server DBA와 개발자에게 신비로운 대상이다. 물론 우리는 인...
-
1. Virtual Columns MariaDB 5.2부터 지원되는 Virtual Columns은 가상의 칼럼을 둬서 수식과 조건문을 사용해 데이터의 가공 결과를 저장하는 것을 말한다. 사용 시 PERSISTENT(stored)와 VIRTUAL...
-
Overview “ 트위터의 새로운 분산 관리 라이브러리 Gizzard를 소개합니다. “를 알아보던 당시 부사수 “임창선”님과 진행했던 또 다른 해외 사례 “Tumblr”를 정리해보았습니다. Tumblr 는 국내에서는 사용자가 많지는 않지만,...
-
I’m happy to post today there is now support for a generic push notifications plugin for PhoneGap Build . The new plugin is called PushP...
-
눈도 고치고, 코도 고치고, 입도 고치고, 여기 저기 성형 수술한 사람을 얼마전 TV에서 보았다. 다들 놀랐다. 그렇게 많은 돈을 들여서 수술했음에도 우리가 생각했던 그런 미인은 아니였다. 이상하게 보이기까지 했다. 눈도 크고, 코도 오똑하고, 입...
-
나는 Python이 좋다. 하지만 Python은 느리다 뭐가 느리냐 하면 지명적인 것이지만 사칙연산이 느리다. 하지만 동적으로 형이 정의되는 다른 스크립트 언어(Perl, Ruby, Javascript)도 C, Java처럼 컴파일을 하는 정적형...