-
Notifications
You must be signed in to change notification settings - Fork 11
Vital Web Server installation
Currently, Vital system runs on Ubuntu 18.04.1 LTS
Ensure that the installed version of Python is 2.7.x
python --version
Install apache2 web server, Postgres, vlan, pip package management system, nfs
sudo apt-get update
sudo apt-get install postgresql-client postgresql-contrib apache2 libapache2-mod-php vlan python-pip nfs-common git python-pip
As a ROOT user run the following commands.
sudo pip install virtualenv virtualenvwrapper
Add an environment variable to ~/.bashrc
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
Next, reload the profile
source ~/.bash_profile
Run below command to create a new virtual environment
mkvirtualenv vital
mod_wsgi is a simple and easy to set up tool that serves python web apps from Apache server.
sudo apt-get install apache2 apache2-utils libexpat1 ssl-cert libapache2-mod-wsgi
Create user vital and make directory vital2.0
adduser vital
mkdir /home/vital/vital2.0
Under /home/vital, database configuration file 'config.ini' needs to be added
mkdir /home/vital/vital2.0/source
mkdir /home/vital/vital_static
sudo mkdir /var/log/vital
Activate the vital virtual environment and Download and place source code under '/home/vital/vital2.0/source'
workon vital
cd vital2.0/source/
git clone https://github.com/vital2/virtual_lab.git
Set read+write+execution permission for scripts folder and the 5 scripts in vital_site
Update below scripts with correct IP's of the servers
listen_xen_stats.sh sftp_account.sh on_web_server_startup.sh ws_course_network_startup.sh collect_dom_details.sh
Install dependencies (note: log in to the client and check the gluster version - server and client must match or server version should be higher)
sudo apt-get install attr glusterfs-common glusterfs-client
To mount, 2 mount options available
sudo mkdir /mnt/vlab-datastore
mount -t glusterfs gusterfs1-dev:volume1 /mnt/vlab-datastore
(on dev-environment)
mount -t nfs gusterfs1-dev:volume1 /mnt/vlab-datastore
NOTE: For ensure the file system is mounted on reboot add an entry to '/etc/fstab'.
workon vital
List of all necessary packages can be obtained from requirements.txt in virtual_lab/vital_site. **Install these into 'vital' virtual environment
workon vital
pip install -r requirements.txt
NOTE: pillow installation can give trouble because of missing packages. Install below packages.
sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
Update /etc/postgresql/9.3/main/postgresql.conf file on the database server (localhost or otherwise) for listen_addresses (host ip config) and /etc/postgresql/9.3/main/pg_hba.conf for specify access
sudo ln -s ~/vlab_scp /mnt/vlab-datastore/vlab_scp
sudo ln -s ~/OS_images /mnt/vlab-datastore/OS_images
sudo ln -s ~/vmdsk /mnt/vlab-datastore/vmdsk
sudo systemctl restart postgresql.service
sudo systemctl status postgresql.service
sudo apt-get install circus
Add watcher events to circus configuration.
Copy-paste the code below into /etc/circus/conf.d/vital-events.ini
[watcher:vitallistenxenstats]
working_dir = /home/vital/vital2.0/source/virtual_lab/vital_site
cmd = python manage.py StartServerStatsCollection
uid = www-data
numprocesses = 1
autostart = true
send_hup = true
stdout_stream.class = FileStream
stdout_stream.filename = /home/vital/logs/xenstats.stdout.log
stdout_stream.max_bytes = 10485760
stdout_stream.backup_count = 4
stderr_stream.class = FileStream
stderr_stream.filename = /home/vital/logs/xenstats.stderr.log
stderr_stream.max_bytes = 10485760
stderr_stream.backup_count = 4
[env:vitallistenxenstats]
PATH = /home/vital/.virtualenvs/vital/bin:$PATH
TERM=rxvt-256color
SHELL=/bin/bash
USER=www-data
LANG=en_US.UTF-8
HOME=/home/vital
PYTHONPATH=/home/vital/.virtualenvs/vital/lib/python2.7/site-packages
[watcher:vitalcollectxendomdetails]
working_dir = /home/vital/vital2.0/source/virtual_lab/vital_site
cmd = python manage.py CollectXenDomDetails
uid = www-data
numprocesses = 1
autostart = true
send_hup = true
stdout_stream.class = FileStream
stdout_stream.filename = /home/vital/logs/domDetails.stdout.log
stdout_stream.max_bytes = 10485760
stdout_stream.backup_count = 4
stderr_stream.class = FileStream
stderr_stream.filename = /home/vital/logs/domDetails.stderr.log
stderr_stream.max_bytes = 10485760
stderr_stream.backup_count = 4
[env:vitalcollectxendomdetails]
PATH = /home/vital/.virtualenvs/vital/bin:$PATH
TERM=rxvt-256color
SHELL=/bin/bash
USER=www-data
LANG=en_US.UTF-8
HOME=/home/vital
PYTHONPATH=/home/vital/.virtualenvs/vital/lib/python2.7/site-packages
[watcher:vitalzmqslave]
working_dir = /home/vital/vital2.0/source/virtual_lab/vital_site
cmd = python manage.py ZmqSlave
uid = www-data
numprocesses = 5
autostart = true
send_hup = true
stdout_stream.class = FileStream
stdout_stream.filename = /home/vital/logs/zmqslave.stdout.log
stdout_stream.max_bytes = 10485760
stdout_stream.backup_count = 4
stderr_stream.class = FileStream
stderr_stream.filename = /home/vital/logs/zmqslave.stderr.log
stderr_stream.max_bytes = 10485760
stderr_stream.backup_count = 4
[env:vitalzmqslave]
PATH = /home/vital/.virtualenvs/vital/bin:$PATH
TERM=rxvt-256color
SHELL=/bin/bash
USER=www-data
LANG=en_US.UTF-8
HOME=/home/vital
PYTHONPATH=/home/vital/.virtualenvs/vital/lib/python2.7/site-packages
Reload the circusd configurations:
sudo systemctl restart circusd
sudo systemctl status circusd
You can additionally monitor and control the circus functions using circus-top and circusctl respectively.
Get root permissions, Navigate to the systemd folder of the Vital Server cd /etc/systemd/system/
and check whether the services for the Vital Jobs are present, if not copy them from an existing vital installation. Or if you're installing for the first time follow the below steps
- Create a service by
sudo vi /etc/systemd/system/vital_autostart_resources.service
and add the below to the file.
[Unit]
Description=vital course network start service
After=network.target
After=vital_listen_xen_stats.service
[Service]
Type=simple
ExecStart=<<Vital VirtualEnv Install Path>> <<Install path in Vital User directory >>/virtual_lab/vital_site/manage.py AutoStartVMs
[Install]
WantedBy=multi-user.target
- Create a service by
sudo vi /etc/systemd/system/vital_on_server_start.service
and add the below to the file.
[Unit]
Description=vital course network start service
After=network.target
[Service]
ExecStart=<<Install path in Vital User directory >/virtual_lab/vital_site/scripts/on_web_server_startup.sh
[Install]
WantedBy=multi-user.target
Finally, enable the services sudo systemctl enable vital_on_server_start.service vital_autostart_resources.service
on the Vital server to pick up the updated changes.
Log in as the root user, generate an ssh id and copy the id to the /root/.ssh/authorized_keys file in the Xen Servers.
Create a config file under .ssh for the root user to specify the ports for each of the servers.
vim .ssh/config
Following the below template
Host <<Name of the server to be SSH'd into>>
Port <<SSH port for the server>>
Apache 2 User : www-data
sudo visudo
sudo crontab -e
NOTE : Remember to add cron command as www-data user.
0 */1 * * * www-data \<\<Python instance from the virtual env created>> \<\<Directory where source is installed>>/virtual_lab/vital_site/manage.py ForceLogoutInactiveUsers
Under directory run below command in vital virtualenv
python manage.py collectstatic
On the database server create a new user postgres.
sudo -u postgres psql
Set password for this user (This should match the password provided in the config.ini file)
\password
Create a database first and exit.
create database vital_db;
exit postgres
Navigate to directory '/home/vital/vital2.0/source/virtual_lab/vital_site/' and run commands to build database tables.**
python manage.py makemigrations
python manage.py migrate
Log in root user and navigate to the directory /var/www/ and git clone noVNC and SPICE clients into the folder.
sudo -i
cd /var/www/
git clone https://github.com/novnc/noVNC.git
mkdir spice
git clone https://github.com/eyeos/spice-web-client.git
Create/Copy a launch_spice.sh file to trigger the spice client.
Apache files need to be prepared for hosting the site '/etc/apache2/sites-enabled' & 'etc/apache2/sites-available'**
On Vital Machines
sudo systemctl restart vital_listen_xen_stats.service
sudo systemctl restart vital_collect_dom_details.service
sudo systemctl restart vital_on_server_start.service
sudo systemctl restart vital_autostart_resources.service
On XEN Servers
sudo systemctl restart vital_xen_api` (on xen machine)
Restart Apache2
sudo systemctl restart apache2.service
sudo systemctl status apache2.service