Centos 7 - cgroups 를 사용 하여 프로 세 스 자원 을 제한 합 니 다.
1788 단어 cgroup프로 세 스 자원 제한
제어 그룹 (cgroups) 은 Liux 커 널 특성 으로 커 널 이 프로 세 스 그룹 에 어떻게 특정한 자원 을 배분 해 야 하 는 지 지정 할 수 있 습 니 다.한 그룹 에 있 는 프로 세 스 가 cpu 시간, 시스템 메모리, 네트워크 대역 폭 또는 이 자원 의 조합 을 얼마나 사용 하 는 지 cgroups 로 지정 할 수 있 습 니 다.
(마 고 교육 에서 뽑 은 위 챗 공식 플랫폼)
cgroups 사용
# cpu ,mathomatic ,
wget http://mathomatic.orgserve.de/mathomatic-16.0.5.tar.bz2
tar xf mathomatic-16.0.5.tar.bz2
cd mathomatic-16.0.5/primes/
make && make install #
# centos7 libcgroup-tools , cgroup
yum install -y libcgroup-tools.x86_64
# cpu
cgcreate -g cpu:/large # cgcreate -h
cgcreate -g cpu:/small
# cpu.shares cpu ,
# /sys/fs/cgroup/cpu , 1024, , cpu
cgset -r cpu.shares=512 small
# cgexec cgroup
matho-primes 0 999999999 > /dev/null & # 0 999999999
cgexec -g cpu:small /usr/local/bin/matho-primes 0 999999999 > /dev/null & #
# top cpu 100% , , cpu
# cgroups cpu
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6726 root 20 0 9208 2540 488 R 99.9 0.0 0:34.47 matho-primes
cgexec -g cpu:large /usr/local/bin/matho-primes 0 9999999999 > /dev/null
cgexec -g cpu:small /usr/local/bin/matho-primes 0 9999999999 > /dev/null
cgexec -g cpu:small /usr/local/bin/matho-primes 0 9999999999 > /dev/null
# small matho-primes , top cpu
# small matho-primes cpu,large cpu
다음 에는 cgroups 를 우리 의 컴 퓨 팅 메모리 일체 기 에 적용 하여 glusterfs 프로 세 스 와 nova - compute 를 제한 하고 저장 서비스 와 컴 퓨 팅 서비스 가 cpu 등 자원 을 선점 하지 않도록 할 계획 입 니 다.
cgroups gluster 프로 세 스 제한 예:http://www.andrewklau.com/controlling-glusterfsd-cpu-outbreaks-with-cgroups/