= LXC - Linux Containers = [[PageOutline]] == 2014-01-11 == * <參考> [http://ofirm.wordpress.com/2014/01/05/creating-a-virtualized-fully-distributed-hadoop-cluster-using-linux-containers/ Creating a virtualized fully-distributed Hadoop cluster using Linux Containers] * 測試環境:Debian Wheezy 7.1 netinstall ISO with [http://github.com/jazzwang/preseed preseed] {{{ jazz@debian:~$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 7.3 (wheezy) Release: 7.3 Codename: wheezy }}} * 安裝 LXC {{{ jazz@debian:~$ sudo apt-get install lxc }}} * 產生虛擬機器 {{{ jazz@debian:~$ sudo lxc-create -t debian -n test1 jazz@debian:~$ sudo lxc-start -d -n test1 }}} * 安裝 LXC Web Panel {{{ root@debian:~# wget http://lxc-webpanel.github.io/tools/install.sh -O - | bash }}} * <狀況> 指令可以建立 LXC VM, 但網頁似乎不太靈光。 == 2014-01-12 == * 測試環境:Ubuntu 12.04 LTS {{{ jazz@jazzbook:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 12.04.2 LTS Release: 12.04 Codename: precise }}} * 感覺上 LXC 1.0 的功能比較齊全(Ex. 支援根據 DNS 分配 IP 的機制),因此直接採用 precise-backports 套件庫中的 lxc 1.0 版本 {{{ echo "deb http://free.nchc.org.tw/ubuntu precise-backports main universe" > /tmp/precise-backport.list sudo mv /tmp/precise-backport.list /etc/apt/sources.list.d/ sudo apt-get update }}} * 安裝 LXC 1.0 版本 {{{ sudo apt-get install lxc }}} {{{ jazz@jazzbook:~$ lxc-version lxc version: 1.0.0.alpha1 }}} * 安裝 LXC Web Panel {{{ jazz@jazzbook:~$ sudo su - root@jazzbook:~# wget http://lxc-webpanel.github.io/tools/install.sh -O - | bash }}} * 建立 20 個 VM 名稱對應 {{{ }}} * 根據 /etc/default/lxc-net 的說明,可以設定一個檔案,來根據 hostname 決定 IP 分配 {{{ #!sh # Uncomment the next line if you'd like to use a conf-file for the lxcbr0 # dnsmasq. For instance, you can use 'dhcp-host=mail1,10.0.3.100' to have # container 'mail1' always get ip address 10.0.3.100. #LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf }}}