赞
踩
图1-1说明了虚拟机、Linux 容器 (LXC) 或操作系统级容器以及应用程序级容器在主机操作系统中的组织方式的差异。
年
|
技术
|
首次在操作系统中引入
|
---|---|---|
1982年
| Chroot |
类 Unix 操作系统
|
2000年
| Jail |
FreeBSD
|
2000年
|
Virtuozzo 容器
|
Linux、Windows(Parallels Inc. 版本)
|
2001年
| Linux VServer |
Linux, 视窗
|
2004年
|
Solaris 容器(zones
)
|
Sun Solaris,Open
Solaris
|
2005年
|
OpenVZ
|
Linux(开源版 Virtuozzo)
|
2008年
|
LXC
|
Linux
|
2013年
|
Docker
|
Linux、FreeBSD、Windows
|
列出 Cgroup
- stylesen@harshu:∼$ ls -alh /sys/fs/cgroup
- total 0
- drwxr-xr-x 12 root root 320 Mar 24 20:40 .
- drwxr-xr-x 8 root root 0 Mar 24 20:40 ..
- dr-xr-xr-x 6 root root 0 Mar 24 20:40 blkio
- lrwxrwxrwx 1 root root 11 Mar 24 20:40 cpu -> cpu,cpuacct
- lrwxrwxrwx 1 root root 11 Mar 24 20:40 cpuacct -> cpu,cpuacct
- dr-xr-xr-x 6 root root 0 Mar 24 20:40 cpu,cpuacct
- dr-xr-xr-x 3 root root 0 Mar 24 20:40 cpuset
- dr-xr-xr-x 6 root root 0 Mar 24 20:40 devices
- dr-xr-xr-x 4 root root 0 Mar 24 20:40 freezer
- dr-xr-xr-x 7 root root 0 Mar 24 20:40 memory
- lrwxrwxrwx 1 root root 16 Mar 24 20:40 net_cls -> net_cls,net_prio
- dr-xr-xr-x 3 root root 0 Mar 24 20:40 net_cls,net_prio
- lrwxrwxrwx 1 root root 16 Mar 24 20:40 net_prio -> net_cls,net_prio
- dr-xr-xr-x 3 root root 0 Mar 24 20:40 perf_event
- dr-xr-xr-x 6 root root 0 Mar 24 20:40 pids
- dr-xr-xr-x 7 root root 0 Mar 24 20:40 systemd
内存子系统层次结构
- root@harshu:/sys/fs/cgroup/memory# ls
- cgroup.clone_children memory.memsw.failcnt
- cgroup.event_control memory.memsw.limit_in_bytes
- cgroup.procs memory.memsw.max_usage_in_bytes
- cgroup.sane_behavior memory.memsw.usage_in_bytes
- init.scope memory.move_charge_at_immigrate
- lxc memory.numa_stat
- memory.failcnt memory.oom_control
- memory.force_empty memory.pressure_level
- memory.kmem.failcnt memory.soft_limit_in_bytes
- memory.kmem.limit_in_bytes memory.stat
- memory.kmem.max_usage_in_bytes memory.swappiness
- memory.kmem.slabinfo memory.usage_in_bytes
- memory.kmem.tcp.failcnt memory.use_hierarchy
- memory.kmem.tcp.limit_in_bytes notify_on_release
- memory.kmem.tcp.max_usage_in_bytes release_agent
- memory.kmem.tcp.usage_in_bytes system.slice
- memory.kmem.usage_in_bytes tasks
- memory.limit_in_bytes user
- memory.max_usage_in_bytes user.slice
- root@harshu:/sys/fs/cgroup/memory#
命名空间
|
持续的
|
隔离
|
---|---|---|
Cgroup |
CLONE_NEWCGROUP
|
C组根目录
|
IPC |
CLONE_NEWIPC
|
System V IPC、POSIX 消息队列
|
Network | CLONE_NEWNET |
网络设备、堆栈、端口等。
|
Mount |
CLONE_NEWNS
|
挂载点
|
PID
|
CLONE_NEWPID
|
进程 ID
|
User |
CLONE_NEWUSER
|
用户和组 ID
|
UTS |
CLONE_NEWUTS
|
主机名和 NIS 域名
|
简单网络 命名空间
1、创建一个名为stylesen-net的网络命名空间:
# ip netns add stylesen-net
2、要列出新创建的网络命名空间中存在的所有设备,请发出以下命令。此示例显示默认环回设备。
- # ip netns exec stylesen-net ip link list
- 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1
- link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
3、尝试 ping 回环设备:
- # ip netns exec stylesen-net ping 127.0.0.1
- connect: Network is unreachable
- # ip netns exec stylesen-net ip link set dev lo up
- # ip netns exec stylesen-net ping 127.0.0.1PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
- 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.045 ms
- 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.059 ms
- 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.097 ms
- 64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.084 ms
- 64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.095 ms
- ^C
- --- 127.0.0.1 ping statistics ---
- 5 packets transmitted, 5 received, 0% packet loss, time 4082ms
- rtt min/avg/max/mdev = 0.045/0.076/0.097/0.020 ms
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。