Re: Re: [vserver] how to limit the cpu and memory of the vps?

From: songjun435 <songjun435_at_gmail.com>
Date: Thu 01 Mar 2012 - 01:48:50 GMT
Message-ID: <201203010948400930071@gmail.com>

Thank you!
my kernel is 2.6.18.5-vs2.1.1.3,It does not support cgroup.
Seemingly,the cgroup is supported after 2.6.26version.

I user yum to install libcgroup in my OS like this:
yum install libcgroup
but there is no avaliable package.

so can I use cgroup in the 2.6.18.5 kernel?
If yes,what should I do?
Thank you very much!




3NMedia
宋军

From: Claus Herwig
Date: 2012-03-01 08:16
To: vserver
Subject: Re: [vserver] how to limit the cpu and memory of the vps?

>
>> does anyont know how to limit the cpu and memory of the vps?
>
> http://wiki.linux-vserver.org/util-vserver:Cgroups

as I learned just yesterday on IRC, that page isn't really uptodate
regarding memory...

Short version for memory cgroup:

Grab a not too old kernel with the necessary kernel config parameters
set, and a recent util-vserver.
For me (Debian squeeze) kernel 2.6.36.4-vs2.3.0.36.39-beng and
util-vserver 0.30.216-pre3000, both from repo.psand.net, did work out of
the box.

Type "mount" to verify that /dev/cgroup is mounted and has the necessary
mount options. You'll want rw,cpuset,cpu,cpuacct,memory at least. And
you don't want the ns option. (With mentioned versions the util-vserver
init script did all that on system startup.)

Make sure your vserver config tree has cgroup directories.
mkdir -p /etc/vservers/.defaults/cgroup
mkdir -p /etc/vservers/<vsname>/cgroup

See what memory limits you have on your running vserver:
cat /dev/cgroup/<vsname>/memory.limit_in_bytes
cat /dev/cgroup/<vsname>/memory.memsw.limit_in_bytes

memory.limit_in_bytes is the physical RSS hard limit (what the rss.hard
rlimit was in earlier days)
memory.memsw.limit_in_bytes is the limit for physical RAM + Swap
together (I think this was rss.soft in earlier days)

Set some sensible limits for the running vserver:
echo "2G" >/dev/cgroup/<vsname>/memory.limit_in_bytes
echo "3G" >/dev/cgroup/<vsname>/memory.memsw.limit_in_bytes

Make the limits permanent:
echo "2G" >/etc/vservers/<vsname>/memory.limit_in_bytes
echo "3G" >/etc/vservers/<vsname>/memory.memsw.limit_in_bytes

Treat your vserver to a realistic memory display:
echo "VIRT_MEM" >>/etc/vservers/<vsname>/flags

Done.

Greets,
  Claus


--
CHECON EDV-Consulting und Redaktion
         Claus Herwig * Barer Straße 70 * 80799 München
         +49 89 27826981 * Fax 27826982 * c.herwig@checon.de
Received on Thu Mar 1 01:49:08 2012

[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Thu 01 Mar 2012 - 01:49:08 GMT by hypermail 2.1.8