[Linuxtrent] Re: Libvirt LXC cgroup on Ubuntu 18.04
- From: azazel <azazel@xxxxxxxxxxxxxxx>
- To: linuxtrent@xxxxxxxxxxxxx
- Date: Sat, 26 May 2018 01:15:50 +0200
"Guido" == Guido Brugnara <gdo@xxxxxxxxx> writes:
Guido> Ho installato libvirt-daemon-system ed lxc ma il container
Guido> vede lo spazio di memoria del server fisico anziché quello
Guido> assegnato al container. Ho provato ad installate anche
Guido> cgroup-bin e cgroup-lite ma non cambia nulla.
Guido> Suggerimenti?
mnon sono un esperto di libvirt o lxc (libvirt trovo abbia una
documentazione troppo sparsa e lxc è poco significativo per me) e quindi
non posso offrirti molto aiuto, ma non credo che facciano uso di binari
per configurare il control group, ma potrei sbagliarmi...
Non capisco cosa tu intenda con "vede lo spazio di memoria del
server". Se intendi che un'esecuzione di "free" mostra la memoria totale
del sistema credo che sia una cosa normale, però se imponi dei limiti
negli esecutori di container che uso io questi vengono rispettati, un
paio di esempi con un limite a 100 MB:
Docker:
$ docker run -ti -m 100M --rm debian:jessie-slim bash
# free
total used free shared buffers cached
Mem: 7848024 7189508 658516 1026956 191932 1716904
-/+ buffers/cache: 5280672 2567352
Swap: 0 0 0
8 GB,il totale che ho sulla macchina.
# ps ax
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 bash
77 ? R+ 0:00 ps ax
# apt-get update && apt-get install stress
[...]
# stress -m 1 -vm-bytes 100M
stress: info: [78] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
stress: FAIL: [78] (416) <-- worker 79 got signal 9
stress: WARN: [78] (418) now reaping child worker processes
stress: FAIL: [78] (452) failed run completed in 0s
... è intervenuto l'oom-killer
# stress -m 1 --vm-bytes 95M
stress: info: [84] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
^C
questo va.
Con systemd-nspawn è simile:
# systemd-nspawn -M jessie -x --property=MemoryMax=100M /bin/bash
Spawning container jessie on
/var/lib/machines/.#machine.jessiee62bb759be6209bb.
Press ^] three times within 1s to kill container.
# free
total used free shared buffers cached
Mem: 7848024 7521552 326472 1093052 667028 1696312
-/+ buffers/cache: 5158212 2689812
Swap: 0 0 0
# ps ax
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 /bin/bash
3 ? R+ 0:00 ps ax
# apt-get install stress
[...]
# stress -m 1 --vm-bytes 100M
stress: info: [30] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
stress: FAIL: [30] (416) <-- worker 31 got signal 9
stress: WARN: [30] (418) now reaping child worker processes
stress: FAIL: [30] (452) failed run completed in 0s
oom-killer strikes again..
# stress -m 1 --vm-bytes 95M
stress: info: [32] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
^C
magari con i security context si può ottenere che "free" mostri solo
100MB? Non saprei
Per curiosità, come mai hai scelto la soluzione libvirt+lxc?
ciao
--
Per iscriversi (o disiscriversi), basta spedire un messaggio con OGGETTO
"subscribe" (o "unsubscribe") a
mailto:linuxtrent-request@xxxxxxxxxxxxx
Other related posts: