good tutorial of LXC:
http://en.community.dell.com/techcenter/os-applications/w/wiki/6950.lxc-containers-in-ubuntu-server-14-04-lts
http://en.community.dell.com/techcenter/os-applications/w/wiki/7440.lxc-containers-in-ubuntu-server-14-04-lts-part-2
http://wupengta.blogspot.com/2012/08/lxchadoop.html
golden tutorial:
http://www.kumarabhishek.co.vu/
Once you have installed LXC and created a user. You can check it under /var/lib/lxc:
Note, you have to be a root user to check it:
gstanden@vmem1:/usr/share/lxc/templates$ cd /var/lib/lxc
bash: cd: /var/lib/lxc:
Permission denied
gstanden@vmem1:/usr/share/lxc/templates$ sudo cd /var/lib/lxc
sudo: cd: command not found
gstanden@vmem1:/usr/share/lxc/templates$
sudo su
root@vmem1:~# cd /var/lib/lxc
#ifconfig -a
lxcbr0 Link encap:Ethernet HWaddr fe:d3:07:23:4d:71
inet addr:10.0.3.1 Bcast:10.0.3.255 Mask:255.255.255.0
LXC creates this NATed bridge "lxcbr0" at host startup, which means "lxcbr0" will connect containers.
>sudo lxc-create
-t ubuntu -n hdp1>sudo lxc-start -d -n hdp1
>sudo lxc-console -n hdp1
>sudo lxc-info –n hdp1
Name: hdp1
State: RUNNING
PID: 17954
IP: 10.0.3.156
CPU use: 2.18 seconds
BlkIO use: 160.00 KiB
Memory use: 9.13 MiB
State: RUNNING
PID: 17954
IP: 10.0.3.156
CPU use: 2.18 seconds
BlkIO use: 160.00 KiB
Memory use: 9.13 MiB
>sudo lxc-stop –n lxc-test
>sudo lxc-destroy –n lxc-test
ubuntu@hdp1#
sudo useradd -m hduser1ubuntu@hdp1:~$ sudo passwd hduser1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfull
Then install JDK on VM "hduser1":
apt-get install openjdk-7-jdk
THen we should set JAVA_HOME, etc., in .bashrc:export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH="$PATH:$JAVA_HOME/bin:/home/hduser1/hadoop-2.4.1/bin:$JRE_HOME/bin"
configure network:
http://www.kumarabhishek.co.vu/
http://tobala.net/download/lxc/
http://containerops.org/2013/11/19/lxc-networking/
Now I have 5 LXC virtual machines.
hdp1 : namenode,jobtracker,secondarynamenode
hdp2 : datanodes,tasktrackers
hdp3 : datanodes,tasktrackers
hdp4 : datanodes,tasktrackers
hdp5 : datanodes,tasktrackers
For each VM, check and change two files:
1:/var/lib/lxc/hdp1/config
make sure this line exists:
lxc.network.link = lxcbr0"lxcbr0" is the bridge created by LXC, whose virtual IP is: 10.0.3.1, who also has the same hostname as the host machine.
2:/var/lib/lxc/hdp1/rootfs/etc/network/interfaces
change 2nd part to assign a static IP address:
auto eth0iface eth0 inet static address 10.0.3.101 netmask 255.255.0.0 broadcast 10.0.255.255 gateway 10.0.3.1 dns-nameservers 10.0.3.1Once the master node is configured, we copy the LXC.
To clone our lxc-test container, we first need to stop it if it’s running:
$ sudo lxc-stop -n lxc-test
Then clone:
sudo lxc-clone -o hdp1 -n hdpX #replace X with 2,3,...,N
Then For each VM, we need edit /etc/hosts to reflect the changes we made on /etc/hosts on our host machine except the host machine.
10.0.3.101 hdp1
10.0.3.102 hdp2
10.0.3.103 hdp3
10.0.3.104 hdp4
10.0.3.105 hdp5
How to create multiple bridges?
add a bridge interface:
sudo brctl addbr br100
to delete a bridge inteface
# ip link set br100 down
# brctl delbr br100
Setting up a bridge is pretty much straightforward. At first you create a new bridge, and then continue with adding as many interfaces to it as you want:
# brctl addbr br0
# brctl addif br0 eth0
# brctl addif br0 eth1
# ifconfig br0 netmask 255.255.255.0 192.168.32.1 up
The name br0 is just a suggestion, following the loose conventions for interface names -- identifier followed by a number. However, you're free to choose anything you like. You can name your bridge pink_burning_elephant if you like to. I just don't know if you remember in 5 years why you're having iptables for a burning elephant.
Good tutorial of brctl command:
http://www.lainoox.com/bridge-brctl-tutorial-linux/
Bridge Mode
Multi-Cluster Multi-Node Distributed Virtual Network Setup
Bridge Mode
No comments:
Post a Comment