Installing SlapOS Slave Node from the Sources The goal of this tutorial is to teach how to install a SlapOS Slave node from the sources. This tutorial is useful to understand the architecture of SlapOS from a practical point of view. This tutorial is only focus on development. /!\ DO NOT USE THIS INSTALLATION ON PRODUCTION /!\ unless you know very well what you are doing. This tutorial will guide you step by step through the installation of a SlapOS node on your own infrastructure for development purpose. You can install a SlapOS node everywhere : on your servers, on your desktop computer or laptop. SlapOS nodes on laptops are particularly efficient for running tests or any other non mission-critical service through SlapOS. As a general convention use all commands from this tutorial with superuser privileges (root user). Agenda Requirements SlapOS Installation Additionnal configuration This tutorial will first list the requirements to install SlapOS Slave node from the sources. Then we will explain how to install SlapOS from the sources. Requirements Let us now review SlapOS installation requirements. The Requirements A GNU/Linux Server python 2.6 or 2.7 gcc, g++, make, linux-headers, patch uml-utilities, bridge-utils wget A slapos.org Account To follow this tutorial, you will need a server with a GNU/Linux distribution, python2.6 or python2.7 installed and a slapos.org account. You will also need the "gcc" and "g++" compiler with "make" and "patch" tools and linux headers, "uml-utilities" for tunneling tools, and "bridge-utils" for bridge tools. In Debian-like distribution, you can install it with the following command (with root privileges) : # apt-get install python gcc g++ make uml-utilities bridge-utils linux-headers-$(uname -r) patch wget slapos.org is a commercial cloud platform made by the SlapOS team, running SlapOS. Currently in Developer Preview pre-release, it allows developers to try and manipulate SlapOS. It will soon allow you to instantiate hundreds of different sofwares. Your GNU/Linux server should either be connected to the Internet with native IPv6 global address. Or it should have a public IPv4 address. For those who only have a public IPv4 address, we shall explain here how to create a tunnel to get IPv6. SlapOS Installation Now that we have an IPv6 address, we can start the installation of SlapOS Slave Node software components. A SlapOS Slave Node is composed of computer partitions. As a reminder, a Computer Partition on a Slave Node consists of a UNIX user, its home directory, a dedicated tap interface and a dedicated IPv6 address. A computer partition can host a SlapOS software instance. Whenever a software instance is requested to SlapOS Master, SlapOS Master looks for free partitions on every registered Slave Node and chooses one depending on specific "service level" parameters specified by the user. The chosen SlapOS Node is then requested to instantiate the user specified software into an free computer partition. Whenever a software instance is no longer used, it is deleted from the Slave Node it was previously allocated to and the computer partition is freed and again available. The installation process of SlapOS Slave node installs a couple of python scripts. Most important ones are: slapformat, slapgrid, slapconsole and slapgrid-supervisorctl. slapformat will be invoked to create users, directories, tap interfaces and IPv6 addresses for every of each computer partition. slapgrid implements the SLAP protocol and requests to SlapOS Master Node which software to install, to instanciate, to account and to delete. slapconsole provides a command line environment to contact SlapOS Master. slapgrid-supervisorctl provides access to the list of running processes in all computer partitions. SlapOS Bootstrap Copy/Paste the following shell script in your terminal : # Use sudo or superuser and create slapos directory mkdir -p /opt/slapos/log/ cd /opt/slapos/ # Create buildout.cfg SlapOS bootstrap file echo "[buildout] extends = https://lab.nexedi.com/nexedi/slapos/raw/master/component/slapos/buildout.cfg " > buildout.cfg # Required in some distros such as Mandriva unset PYTHONPATH unset PYTHONDONTWRITEBYTECODE unset CONFIG_SITE # Bootstrap SlapOS python -S -c 'import urllib2;print urllib2.urlopen("https://raw.github.com/buildout/buildout/1/bootstrap/bootstrap.py").read()' | python -S - Warning:Depending on your distribution you might need to replace python by python2 in the last command. This happens when your distribution considers that the standard python is the 3.x branch. bin/buildout SlapOS is installed using buildout technology. Buildout downloads the source code, the patches and the binaries required to build a software on a given architecture. It handles depencies between software components automatically. First, we are going to create the directory for SlapOS software by invoking mkdir /opt/slapos. We then move to the SlapOS software directory. We then create a buildout file which extends SlapOS's own buildout.cfg. There is nothing to download here, only create a text file with a link to a URL. Before starting the boostrap process, we unset some environment variables. This is mostly useless for most GNU/Linux distributions or UNIX-like operaring systems but it prevents certain errors in a few GNU/Linux distributions with uncommon environment settings. It is now possible to start the bootstrap process. We need to make sure that we use a recent version of python such as python 2.6 or python 2.7. The python invocation bootstraps buildout. The buildout invocation interpretes the buildout.cfg file and installs SlapOS on the server. Before you go to the next paragraph, please make sure that you have tried and finished installing of SlapOS with buildout. Crontab (optional) # vim/etc/cron.d/slapos Edit (6 lines) MAILTO="" # Run "Installation/Destruction of Software Releases" and "Deploy/Start/Stop Partitions" once per minute * * * * * root /opt/slapos/bin/slapos node software --verbose --logfile=/opt/slapos/log/slapos-node-software.log > /dev/null 2>&1 * * * * * root /opt/slapos/bin/slapos node instance --promise-timeout 20 --verbose --logfile=/opt/slapos/log/slapos-node-instance.log > /dev/null 2>&1 # Run "Destroy Partitions to be destroyed" once per hour 0 * * * * root /opt/slapos/bin/slapos node report --maximal_delay=3600 --verbose --logfile=/opt/slapos/log/slapos-node-report.log > /dev/null 2>&1 # Run "Check/add IPs and so on" once per hour 0 * * * * root /opt/slapos/bin/slapos node format >> /opt/slapos/log/slapos-node-format.log 2>&1 # Run "Booting" on every system start @reboot root /opt/slapos/bin/slapos node boot >> /opt/slapos/log/slapos-node-format.log 2>&1 # Run "Collect" once a minute * * * * * root /opt/slapos/bin/slapos node collect >> /opt/slapos/log/slapos-node-collect.log 2>&1 We can also now define the cron configuration. Simply copy the example above. Adapt parameters if you did not follow the exact tutorial (not recommended). slapformat is invoked every night so that if we any changes happen on the network (something not supposed to happen), the master will eventually be notified. This is very useful in case server hardware is move from one house to another, from one data center to another, etc. slapos node will run automatically every minute if you add those lines to your crontab. If you want to manually launch slapos node, do not add those lines. Where to go next? Setup SlapOS to run on your computer Now that your install is complete, it is time to move to the tutorial on running SlapOS !