FastNetMon

Friday 18 November 2011

Использование замены UBC в OpenVZ для RHEL/CentOS 6

В версии OpenVZ для 2.6.32 есть два варианта ограничения ресурсов контейнера, старый классический UBC и новый - vSwap.

Для создания VPS с классическими лимитами можно использовать команду:
vzctl create 101 --ostemplate debian-5-x86_64 --config basic --hostname testvps.fastvps.ru

UB параметры контейнера будут иметь следующий вид:
cat /proc/user_beancounters
Version: 2.5
uid resource held maxheld barrier limit failcnt
101: kmemsize 2737572 4407296 14372700 14790164 0
lockedpages 0 0 2048 2048 0
privvmpages 1378 14003 65536 69632 0
shmpages 0 0 21504 21504 0
dummy 0 0 0 0 0
numproc 10 36 240 240 0
physpages 5174 10811 0 9223372036854775807 0
vmguarpages 0 0 33792 9223372036854775807 0
oomguarpages 914 914 26112 9223372036854775807 0
numtcpsock 4 4 360 360 0
numflock 1 4 188 206 0
numpty 0 0 16 16 0
numsiginfo 1 18 256 256 0
tcpsndbuf 69760 69760 1720320 2703360 0
tcprcvbuf 65536 65536 1720320 2703360 0
othersockbuf 6936 8456 1126080 2097152 0
dgramrcvbuf 0 1288 262144 262144 0
numothersock 32 33 360 360 0
dcachesize 1383859 1440285 3409920 3624960 0
numfile 127 245 9312 9312 0
dummy 0 0 0 0 0
dummy 0 0 0 0 0
dummy 0 0 0 0 0
numiptent 20 20 128 128 0

Конфиг контейнера тоже будет выглядить как и раньше:
cat /etc/vz/conf/101.conf
# Copyright (C) 2000-2011, Parallels, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

# UBC parameters (in form of barrier:limit)
KMEMSIZE="14372700:14790164"
LOCKEDPAGES="2048:2048"
PRIVVMPAGES="65536:69632"
SHMPAGES="21504:21504"
NUMPROC="240:240"
PHYSPAGES="0:unlimited"
VMGUARPAGES="33792:unlimited"
OOMGUARPAGES="26112:unlimited"
NUMTCPSOCK="360:360"
NUMFLOCK="188:206"
NUMPTY="16:16"
NUMSIGINFO="256:256"
TCPSNDBUF="1720320:2703360"
TCPRCVBUF="1720320:2703360"
OTHERSOCKBUF="1126080:2097152"
DGRAMRCVBUF="262144:262144"
NUMOTHERSOCK="360:360"
DCACHESIZE="3409920:3624960"
NUMFILE="9312:9312"
AVNUMPROC="180:180"
NUMIPTENT="128:128"

# Disk quota parameters (in form of softlimit:hardlimit)
DISKSPACE="2G:2.2G"
DISKINODES="200000:220000"
QUOTATIME="0"

# CPU fair scheduler parameter
CPUUNITS="1000"
HOSTNAME="testvps.fastvps.ee"
VE_ROOT="/vz/root/$VEID"
VE_PRIVATE="/vz/private/$VEID"
OSTEMPLATE="debian-5.0-x86_64"
ORIGIN_SAMPLE="basic"
IP_ADDRESS="176.9.54.124"


vzctl create 101 --ostemplate debian-5-x86_64 --config vswap-256m --hostname testvps.fastvps.ru

В итоге получим следующий вид параметров BC:
cat /proc/user_beancounters
Version: 2.5
uid resource held maxheld barrier limit failcnt
101: kmemsize 3369468 4431872 121634816 134217728 0
lockedpages 0 0 32768 32768 0
privvmpages 2461 14151 9223372036854775807 9223372036854775807 0
shmpages 18 354 9223372036854775807 9223372036854775807 0
dummy 0 0 0 0 0
numproc 10 33 9223372036854775807 9223372036854775807 0
physpages 5989 10780 0 65536 0
vmguarpages 0 0 0 9223372036854775807 0
oomguarpages 1145 1145 0 9223372036854775807 0
numtcpsock 5 6 9223372036854775807 9223372036854775807 0
numflock 2 4 9223372036854775807 9223372036854775807 0
numpty 0 0 9223372036854775807 9223372036854775807 0
numsiginfo 0 21 9223372036854775807 9223372036854775807 0
tcpsndbuf 87200 104640 9223372036854775807 9223372036854775807 0
tcprcvbuf 81920 98304 9223372036854775807 9223372036854775807 0
othersockbuf 6936 28720 9223372036854775807 9223372036854775807 0
dgramrcvbuf 0 2312 9223372036854775807 9223372036854775807 0
numothersock 32 36 9223372036854775807 9223372036854775807 0
dcachesize 1535996 1595162 60817408 67108864 0
numfile 180 250 9223372036854775807 9223372036854775807 0
dummy 0 0 0 0 0
dummy 0 0 0 0 0
dummy 0 0 0 0 0
numiptent 20 20 9223372036854775807 9223372036854775807 0

И намного более простой конфиг VPS:
cat /etc/vz/conf/101.conf
# Copyright (C) 2000-2011, Parallels, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

# This config is valid for VSwap-enabled kernel (which currently means
# any RHEL6-based kernel, i.e. 042test* or 042stab*).

# UBC parameters (in form of barrier:limit)
PHYSPAGES="0:256M"
SWAPPAGES="0:512M"
KMEMSIZE="116M:128M"
DCACHESIZE="58M:64M"
LOCKEDPAGES="128M"
PRIVVMPAGES="unlimited"
SHMPAGES="unlimited"
NUMPROC="unlimited"
VMGUARPAGES="0:unlimited"
OOMGUARPAGES="0:unlimited"
NUMTCPSOCK="unlimited"
NUMFLOCK="unlimited"
NUMPTY="unlimited"
NUMSIGINFO="unlimited"
TCPSNDBUF="unlimited"
TCPRCVBUF="unlimited"
OTHERSOCKBUF="unlimited"
DGRAMRCVBUF="unlimited"
NUMOTHERSOCK="unlimited"
NUMFILE="unlimited"
NUMIPTENT="unlimited"

# Disk quota parameters (in form of softlimit:hardlimit)
DISKSPACE="2G:2.2G"
DISKINODES="200000:220000"
QUOTATIME="0"

# CPU fair scheduler parameter
CPUUNITS="1000"
HOSTNAME="testvps.fastvps.ru"
VE_ROOT="/vz/root/$VEID"
VE_PRIVATE="/vz/private/$VEID"
OSTEMPLATE="debian-5.0-x86_64"
ORIGIN_SAMPLE="vswap-256m"
IP_ADDRESS="176.9.54.124"
NAMESERVER="213.133.98.98 213.133.100.100 213.133.99.99"

Вот так :)

Больше информации: http://wiki.openvz.org/VSwap

No comments :

Post a Comment

Note: only a member of this blog may post a comment.