<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">The following is a description of
how to install Ubuntu & x2go server inside Linux Containers (LXC).<br>
<br>
All of the following was done on an Ubuntu 12.04 server installed inside LXC
containers. These examples are only for a single container but you can either
Clone the first container you create and make necessary changes regarding IP
addresses (they will be different for each LXC container) or start from scratch
and create each manually.<br>
<br>
If you are not familiar with LXC containers it is a very lightweight &
therefore very fast (faster than vmware, kvm, xen etc) technology built into
most modern Linux kernels and</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">distributions from Ubuntu, Debian, Fedora etc. Note that LXC does not support installing windows into an LXC container.<br>
</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">
LXC allows you to provide complete isolation of one container from another by
default. </span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial","sans-serif""></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">However, you can as an admin provide
more or less isolation between containers and also between containers and the
HOST computer OS. <br>
<br>
I will NOT go into how LXC works here as there is a lot of information on the
web which can help you understand more if you do a google search for
"lxc containers" or read some of the "references" I've put
at the end of this email.</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
Ubuntu 12.04 has made LXC very easy to use.<span style>
</span>Canonical has simplified many things to the extreme.<span style> </span>Other linux distributions <br>
may/will differ on how you create, access etc LXC containers.<br>
<br>
But lets begin creating our first LXC container and then we will install
Bonitasoft inside that container.<br>
<br>
<b>STEP 1</b><br>
<br>
Assuming you are using Ubuntu 12.04 Desktop we will install LXC first the
create our first container which we will call x2goserver1-lxc.<span style> </span>In the </span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">following we are going to use an “ubuntu” lxc template.<span style> </span>There are other “lxc templates” for debian,
fedora, centos etc that you could use if</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">you wanted to install one of those OS inside an LXC
Container even if the host is Ubuntu<br style>
<br style>
</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">NOTE:<span style> </span>you can
install any Linux OS into an LXC container the only major rule is that the
Linux must use the same Kernel as the Host linux.</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
<b><span style> </span>sudo apt-get install lxc</b></span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> </span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">Next create the LXC container we
are calling x2goserver1-lxc then start up that container:</span></p>
<p class="MsoNormal" style><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> </span></b></p>
<p class="MsoNormal" style><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style> </span>sudo lxc-create
-t ubuntu -n x2goserver1-lxc</span></b></p>
<p class="MsoNormal" style><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style> </span>sudo lxc-start -n
x2goserver1-lxc</span></b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
<br>
The “create” command above will create a new container called "x2goserver1-lxc"
and install ubuntu ... using the same version <br>
of Ubuntu as your host computer so it will install ubuntu 12.04 inside the LXC
container named "x2goserver1-lxc"<br style>
<br style>
</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
This will take some time as it downloads all the required files from the Ubuntu
repositories and installs them to create a <br>
bootable Ubuntu 12.04 system.<br>
<br>
The “start” command above will actually start the LXC container called "x2goserver1-lxc"
and its Ubuntu system and leave you <br>
at a terminal command prompt inside the LXC container.<br>
<br>
<b style>Note:</b> <span style> </span>that the command prompt will be different from
a terminal on your HOST computer as you will now be <u>inside</u> the <br>
container and because we haven't added any additional user accounts yet the
login USERID will be the default which </span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">is "ubuntu".<br>
<br>
The command prompt should look something like the following:<br>
<br>
<span style> </span><b>ubuntu@x2goserver1-lxc:~$</b><br>
<br>
Create a User Accounts for the users that will be using this container:<br>
<br>
<span style> </span><b>sudo adduser user-name1</b></span></p>
<p class="MsoNormal" style><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style> </span><span style> </span>etc.</span></b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br style>
<br style>
</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
<b>STEP 2</b><br>
<br>
While logged into the container and at the terminal prompt install whatever
other tools you usually use.<span style> </span><br>
<br>
In my case, because I wanted to see if x2go would work so I installed the
ubuntu desktop and the x2go server components.<span style>
</span><br style>
<br style>
</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">Install the Ubuntu Desktop:<br>
<br>
<span style> </span><b>sudo apt-get install
ubuntu-desktop</b><br>
<br>
when this completes reboot Ubuntu in the LXC container:<br>
<br>
<span style> </span><b>sudo shutdown -r now</b><br>
<br>
this will reboot ubuntu in the container so the desktop environment will be
available.<span style> </span>Login again and continue.</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
Next install the x2go "server" side applications so I can later
access the container using the x2goclient on my HOST PC.<span style> </span><br>
<br>
Next add the x2go repository: <br>
<br>
<b><span style> </span>sudo add-apt-repository
ppa:x2go/stable</b></span></p>
<p class="MsoNormal" style><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style> </span>sudo apt-get
update</span></b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
<br>
Install the x2go "server" side components:<br>
<br>
<b><span style> </span>sudo apt-get install x2goserver<br>
<span style> </span>sudo apt-get install
x2goserver-session</b><br style>
<br style>
</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">On your HOST computer install the x2go client:<br>
<br>
<b><span style> </span>sudo add-apt-repository
ppa:x2go/stable<br>
<span style> </span>sudo apt-get update<br>
<span style> </span>sudo apt-get install x2goclient</b><br>
<span style> </span><br style>
<br style>
</span></p>
<p class="MsoNormal" style><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">STEP 3</span></b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
<br>
This step is important if you want to be able to access the LXC container from
the host using SSH or whatever other tools you use.<span style> </span><br style>
<br style>
</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">The genesis of this step is from Stephane Graber who has
taught me alot about LXC from his blog.<br>
<br>
This step is:<br style>
<br style>
</span></p>
<ol start="1" type="1"><li class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">performed
outside of your linux container and must be done for the USER that will be
accessing the x2goserver1-lxc.</span></li><li class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">will
require that you know the container IP address.<span style> </span>Each LXC container will have a
different IP address even though they are all running on the same PC</span></li><li class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">is
necessary to allow someone on the HOST computer to access a container
using the container's name with something like SSH etc. for example
in our case "ssh userID-on-x2goserver1@x2goserver1-lxc"
will log the user-of-bos1-name into the container and leave them at a
terminal prompt </span></li></ol>
<p class="MsoNormal"><i style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">Add the following to each users
~/.ssh/config file. <u>Note</u> you may have to create ~/.ssh/config if it doesn't yet
exist and change the lxc-container IP address to the container that each user
is assigned to work with.</span></i><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
</span></b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
note: each of the following should be a single line entry<br>
<br>
Host *.lxc StrictHostKeyChecking no UserKnownHostsFile /dev/null ProxyCommand
nc $(host $(echo %h | sed "s/\\\\.lxc//g") <i style><span style="color:red">my-lxc-container-ip-address</span></i><span style="color:red"> </span>| tail -1 | awk '{print $NF}') %p <br>
<br>
Host *.libvirt StrictHostKeyChecking no UserKnownHostsFile /dev/null
ProxyCommand nc $(host $(echo %h | sed "s/\\\\.libvirt//g") <i style><span style="color:red">my-host-ip-address</span></i><span style="color:red"> </span>| tail -1 | awk '{print $NF}') %p </span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif""> </span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">From now on you can access the x2goserver1-lxc container
using either SSH or the x2go client</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
<br>
<b>STEP 4</b><br>
<br>
If you want to use x2go start the x2goclient, then on the HOST create a new x2go
"session" and add info about what LXC container IP address you want
to connect to, what desktop (unity, gnome etc) and what speed is the connection
(change this by moving the slider to LAN since we want the fastest/no
compression) and then save.<br style>
<br style>
</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">Start the x2goclient session and log into the LXC
container.<span style> </span>From now on you can do
everything as if you were on your HOST PC.<span style>
</span><br style>
<br style>
</span></p>
<p class="MsoNormal" style><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">Just remember you will be inside the LXC container so you
are separated from your host and changes made will only be <span style> </span>to the LXC container's Ubuntu.<br>
<br style>
<br style>
</span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">PARTING
THOUGHTS</span></b><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><br>
<br>
The reason for doing all of this?<span style> </span>Well
there are several I can think of but I’ll just name a couple:</span></p>
<span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style><span style="font:7.0pt "Times New Roman""></span></span></span><ol><li><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style><span style="font:7.0pt "Times New Roman"">
</span></span></span><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">Linux is now available on ARM.<span style> </span>ARM cpu’s don’t support h/w virtualization
solutions like vmware, kvm, xen etc.<span style> </span>but
since LXC does NOT require h/w virtualization you can use LXC containers to
provide different and isolated compute environments even on ARM computers.<span style></span></span></li><li><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style><span style="font:7.0pt "Times New Roman""> </span></span></span><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">LXC is much faster than vmware, kvm,
xen because there is no h/w virtualization and because its part of the linux
kernel each container can have as much or as little direct access to the HOST
PC resources as you want to configure (read up about LXC CGROUPS).</span></li><li><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style><span style="font:7.0pt "Times New Roman""> </span></span></span><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">Whereas Vmware, kvm, xen etc all
require at least one dedicated cpu “core” for each virtual machine you can only
run so many VMs concurrently on a system..<span style>
</span>LXC does not have this restriction so with LXC there are many people
running as many as 50-80 LXC containers on a single server although your mileage
may vary depending on what each container has installed, how much CPU, memory
etc is available.</span></li><li><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style><span style="font:7.0pt "Times New Roman""></span></span></span><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">Maybe you’d like to have multiple
customers each with an x2goserver but isolated from each other without
resorting to the expense of separate servers for each customer?</span></li><li><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style><span style="font:7.0pt "Times New Roman""></span></span></span><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">Web Servers often don’t really need
dedicated servers or even dedicated Virtual Machines.<span style> </span>LXC Containers works great for that
purpose.</span></li></ol><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style="color:#888888"></span></span>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:12.0pt;font-family:"Arial","sans-serif""><span style="color:#888888">
</span>Remember
I said that LXC containers can be as isolated from each other and from the HOST
as you want. They start totally isolated but we changed that a bit
above so you could ssh or x2go into a container by adding the 2 statements to a
users ~/.ssh/config file<br>
<br>
However, you can allow LXC containers to share a HOST file system/directory, or
even a something like an SQL server running on the HOST (again read about LXC
CGROUPS). <br>
<br>
I may have forgotten a step or mistyped something here and if so send me a note
and I'll double check and make any addition/correction. <br>
<br>
Have fun... </span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:12.0pt;font-family:"Arial","sans-serif";color:#888888"><br>
</span><b><span style="font-size:12.0pt;font-family:"Arial","sans-serif";color:#333333">References:</span></b><span style="font-size:12.0pt;font-family:"Arial","sans-serif";color:#888888"> <br>
<a href="http://lxc.teegra.net/" target="_blank"><span style="color:blue">http://lxc.teegra.net/</span></a><br>
<a href="http://www.ibm.com/developerworks/linux/library/l-lxc-containers/" target="_blank"><span style="color:blue">http://www.ibm.com/developerworks/linux/library/l-lxc-containers/</span></a><br>
<a href="http://www.stgraber.org/category/lxc/" target="_blank"><span style="color:blue">http://www.stgraber.org/category/lxc/</span></a> <br>
<br>
</span><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">Brian Mullan<br>
<span style="color:#888888"><br style>
<br style>
</span></span></p>