This shows you the differences between two versions of the page.
saisp:labs:07:contents:03 [2013/11/11 00:46] 127.0.0.1 external edit |
saisp:labs:07:contents:03 [2014/04/14 11:42] (current) alexandru.carp |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== 03. Lorem ipsum ==== | + | ==== 03. [10p] Spatiul de procese ==== |
- | ... | + | Folositi comanda ''lxc-info'' pentru a afla PID-ul containerului ''ct1''. Acest PID este al procesului ''init'' corespunzator containerului. Restul proceselor din container vor fi copii ai acestui proces ''init''. |
+ | Atasati-va la consola containerului, logati-va, apoi detasati-va de la consola. | ||
+ | Pe **saisp-vm-1**, afisati intreaga ierarhie de procese: | ||
+ | <code bash> | ||
+ | root@saisp-vm-1:~# pstree -p | ||
+ | init(1)─┬─acpid(1542) | ||
+ | ├─atd(1565) | ||
+ | ├─cron(1652) | ||
+ | ├─dbus-daemon(1602) | ||
+ | ├─exim4(1902) | ||
+ | ├─getty(1959) | ||
+ | ├─getty(1960) | ||
+ | ├─getty(1961) | ||
+ | ├─getty(1962) | ||
+ | ├─getty(1963) | ||
+ | ├─getty(1964) | ||
+ | ├─lxc-start(8267)───init(8269)─┬─getty(8508) | ||
+ | │ ├─getty(8510) | ||
+ | │ ├─getty(8511) | ||
+ | │ ├─getty(8512) | ||
+ | │ ├─login(8509)───bash(8751) | ||
+ | │ └─sshd(8478) | ||
+ | ├─rpc.idmapd(1237) | ||
+ | ├─rpc.statd(1223) | ||
+ | ├─rpcbind(1195) | ||
+ | ├─rsyslogd(1480)─┬─{rsyslogd}(1485) | ||
+ | │ ├─{rsyslogd}(1486) | ||
+ | │ └─{rsyslogd}(1487) | ||
+ | ├─sshd(1935)───sshd(1965)───bash(1967)───pstree(8762) | ||
+ | └─udevd(280) | ||
+ | </code> | ||
+ | |||
+ | Observati ca procesul ''init'' corespunzator containerului este copil al procesului ''lxc-start''. | ||
+ | |||
+ | Putem afisa ierarhia de procese pentru un container si folosind comanda ''lxc-ps'': | ||
+ | <code bash> | ||
+ | root@saisp-vm-1:~# lxc-ps -n ct1 --forest | ||
+ | CONTAINER PID TTY TIME CMD | ||
+ | ct1 8269 ? 00:00:00 \_ init | ||
+ | ct1 8478 ? 00:00:00 \_ sshd | ||
+ | ct1 8508 pts/5 00:00:00 \_ getty | ||
+ | ct1 8509 pts/1 00:00:00 \_ login | ||
+ | ct1 8751 pts/1 00:00:00 | \_ bash | ||
+ | ct1 8510 pts/2 00:00:00 \_ getty | ||
+ | ct1 8511 pts/3 00:00:00 \_ getty | ||
+ | ct1 8512 pts/4 00:00:00 \_ getty | ||
+ | </code> | ||
+ | |||
+ | Apoi, conectati-va la consola containerului si afisati procesele din **interiorul** acestuia: | ||
+ | <code bash> | ||
+ | root@ct1:~# ps -ef | ||
+ | UID PID PPID C STIME TTY TIME CMD | ||
+ | root 1 0 0 18:34 ? 00:00:00 init [3] | ||
+ | root 182 1 0 18:34 ? 00:00:00 /usr/sbin/sshd | ||
+ | root 212 1 0 18:34 console 00:00:00 /sbin/getty 38400 console | ||
+ | root 213 1 0 18:34 tty1 00:00:00 /bin/login -- | ||
+ | root 214 1 0 18:34 tty2 00:00:00 /sbin/getty 38400 tty2 linux | ||
+ | root 215 1 0 18:34 tty3 00:00:00 /sbin/getty 38400 tty3 linux | ||
+ | root 216 1 0 18:34 tty4 00:00:00 /sbin/getty 38400 tty4 linux | ||
+ | root 217 213 0 18:53 tty1 00:00:00 -bash | ||
+ | root 228 217 0 19:00 tty1 00:00:00 ps -ef | ||
+ | </code> | ||
+ | |||
+ | Observati ca desi apar aceleasi procese, valorile PID-urilor difera in interiorul containerului si in exteriorul acestuia. Practic, se produce o translatie la nivelul spatiului de procese. |