Lxc- Introduction
-
Upload
luis-eduardo -
Category
Technology
-
view
149 -
download
1
Transcript of Lxc- Introduction
LXCIntroduction
Luıs [email protected]
Federal University of Pernambuco
November 2014
Luıs Eduardo [email protected] (UFPE) LXC November 2014 1 / 19
Summary
1 Definition
2 General
3 ImplementationsMain implementations
4 Using LXCInstallationBasic UsageAdvanced Use
Luıs Eduardo [email protected] (UFPE) LXC November 2014 2 / 19
Definition
Linux Containers (LXC for LinuX Containers) are lightweight virtualmachines (VMs) which are realized using features provided by amodern Linux kernel – VMs without the hypervisor.
Operational system-level virtualization method for running multiplesand isolated systems (containers) on a single host.
Luıs Eduardo [email protected] (UFPE) LXC November 2014 3 / 19
General
Lightweight process virtualization is not new
Chroot
Solaris Zones
BSD jails
AIX WPARs (Workload Partitions)
Linux-based containers projects
Why now?
Kernel Support +3.8(Febuary 2013)
NamespacesCgroups
Luıs Eduardo [email protected] (UFPE) LXC November 2014 4 / 19
Implementations
Figure: Several ways to use container. Source:Wikipedia
Luıs Eduardo [email protected] (UFPE) LXC November 2014 5 / 19
Summary
1 Definition
2 General
3 ImplementationsMain implementations
4 Using LXCInstallationBasic UsageAdvanced Use
Luıs Eduardo [email protected] (UFPE) LXC November 2014 6 / 19
Main implementations
LXC
Mostly written in C
Stable and mature codebase
Docker
Mostly written in Go
Stable and mature codebase
Similar architecture with configuration management
OpenVZ
Mostly written in C
Stable and mature codebase
Project that gave rise to several other
Luıs Eduardo [email protected] (UFPE) LXC November 2014 7 / 19
Summary
1 Definition
2 General
3 ImplementationsMain implementations
4 Using LXCInstallationBasic UsageAdvanced Use
Luıs Eduardo [email protected] (UFPE) LXC November 2014 8 / 19
Installation
Debian distributions
$ sudo apt-get install lxc
Luıs Eduardo [email protected] (UFPE) LXC November 2014 9 / 19
Summary
1 Definition
2 General
3 ImplementationsMain implementations
4 Using LXCInstallationBasic UsageAdvanced Use
Luıs Eduardo [email protected] (UFPE) LXC November 2014 10 / 19
Usage
Test installation:
Check configurations
$ sudo lxc-checkconfig
Figure: lxc-checkconfig output
Luıs Eduardo [email protected] (UFPE) LXC November 2014 11 / 19
Usage
Your first container:
Run first container
$ sudo lxc-create -t ubuntu -n ubuntulxc
Where:
-t : template
-n : name of container
Luıs Eduardo [email protected] (UFPE) LXC November 2014 12 / 19
Usage
See information about new container:
Container information
$ sudo lxc-ls -f
Start new container:
Start new container
$ sudo lxc-start -n ubuntulxc
Luıs Eduardo [email protected] (UFPE) LXC November 2014 13 / 19
Usage
Stop a container
$ sudo lxc-stop -n ubuntulxc
Destroy a container
$ sudo lxc-destroy -n ubuntulxc
Clone a container
$ sudo lxc-clone -o ubuntulxc -n ubuntulxc2
Execute a temporary container
$ sudo lxc-execute -n guest – sleep 100
Luıs Eduardo [email protected] (UFPE) LXC November 2014 14 / 19
Summary
1 Definition
2 General
3 ImplementationsMain implementations
4 Using LXCInstallationBasic UsageAdvanced Use
Luıs Eduardo [email protected] (UFPE) LXC November 2014 15 / 19
Advanced Use
Containers storage: /var/lib/lxc/
Main configuration file: /var/lib/lxc/YOUR CONTAINER/config
Cgroups files: /sys/fs/cgroup/.../lxc/YOUR CONTAINER/
Scripts to install some templates: /usr/share/lxc/templates
Luıs Eduardo [email protected] (UFPE) LXC November 2014 16 / 19
Advanced Use
Controlling Container Resources
CPU information
$ sudo lxc-cgroup -n ubuntulxc cpuset.cpus
CPU time and block I/O access
$ sudo lxc-cgroup -n ubuntulxc cpu.shares 256$ sudo lxc-cgroup -n ubuntulxc blkio.weight 500
Dynamic Memory Allocation
$ sudo lxc-cgroup -n ubuntulxc memory.soft limit in bytes 268435456$ sudo lxc-cgroup -n ubuntulxc memory.limit in bytes 53687091
More cgroups here.
Luıs Eduardo [email protected] (UFPE) LXC November 2014 17 / 19
References
LXC Ubuntu. Available at:https://help.ubuntu.com/lts/serverguide/lxc.html.
Oracle Documentation. Available at:https://docs.oracle.com/cd/E37670 01/E37355/html/ol cgroups.html.
Arch Linux Containers. Available at:https://wiki.archlinux.org/index.php/Linux Containers.
Wikipedia LXC. Available at: http://en.wikipedia.org/wiki/LXC.
Rathore, Muhammad Siraj, Markus Hidell, and Peter Sjodin. ”KVMvs. LXC: comparing performance and isolation of hardware-assistedvirtual routers.” American Journal of Networks and Communications2.4 (2013): 88-96.
Luıs Eduardo [email protected] (UFPE) LXC November 2014 18 / 19
LXCIntroduction
Luıs [email protected]
Federal University of Pernambuco
November 2014
Luıs Eduardo [email protected] (UFPE) LXC November 2014 19 / 19