Virtualisation

De ifb
Aller à : Navigation, rechercher

Cette page décrit les différentes étapes de la virtualisation d'une instance Galaxy. Elle se base sur un cas concret de virtualisation à l'URGI de Versailles.

Sommaire

Un repository pour l'image ISO

Creation du fichier ks.cfg

#version=DEVEL
text
%post --log=/root/ks-post-stage-2.log
#!/bin/sh
service network start #sinon pas de réseau en chroot (tout ce qui est passer en %post l'est dans un env chrooté)
install
cdrom
lang fr_FR.UTF-8
keyboard fr-latin9
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw *******
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone --utc Europe/Paris
bootloader --location=mbr --append="crashkernel=auto rhgb quiet"

#partition
zerombr yes
clearpart --all --initlabel
part /boot --fstype=ext4 --size=500
part pv.01 --grow --size=1
volgroup VolGroup pv.01
logvol / --fstype=ext4 --vgname=VolGroup --size=1 --grow --name=lv_root
logvol swap --vgname=VolGroup --recommended --name=lv_swap
repo --name="centos" --baseurl=file:///mnt/source --cost=100

reboot --eject
%packages --nobase
@core
%post --nochroot
#!/bin/sh
mkdir /mnt/sysimage/tmp/install-file
cp -r /mnt/source/gridengine /mnt/sysimage/tmp/install-file/gridengine
cp -r /mnt/source/tunnel /mnt/sysimage/tmp/install-file/tunnel
cp -r /mnt/source/galaxy-conf /mnt/sysimage/tmp/install-file/galaxy-conf
%post --log=/root/ks-post-stage-2.log
#!/bin/sh
service network start #sinon pas de réseau en chroot (tout ce qui est passer en %post l'est dans un env chrooté)

# Dépôt, packets et mise à jour
#-------------------------------
# Ajout du dépôt EPEL
/bin/rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# Mise à jour et ajout des paquets pré-requis
/usr/bin/yum update -y --skip-broken
/usr/bin/yum install -y mercurial postgresql-server gridengine.x86_64 autossh nfs-utils
# Ajout de paquets utiles
/usr/bin/yum install -y screen vim man

# Ajout du user galaxy on impose le même id 7643 que celui du cluster.
#---------------------------------------------------------------------
useradd -m -u 7643 galaxy
#Recuperation adresse mac
adrMac=$(ip link show eth0 | awk '/ether/ {print $2}')
adrMac=$(echo $adrMac | sed s/\:/-/g)

# Modification de l'etc/profile
#---------------------------------------------------------------------
sed -i 's/unset -f pathmunge//g' /etc/profile
echo 'pathmunge /share/apps/bin' >> /etc/profile
echo 'pathmunge /share/apps/RepeatMasker' >> /etc/profile
echo 'pathmunge /share/apps/MUMmer3.23' >> /etc/profile
echo 'pathmunge /share/apps/iprscan/bin' >> /etc/profile
echo 'pathmunge /share/apps/framedp-1.0.3/bin' >> /etc/profile
echo 'pathmunge /share/apps/eugene-3.5g/bin' >> /etc/profile
echo 'pathmunge /share/apps/gth-1.4.8-Linux_x86_64-32bit/bin' >> /etc/profile
echo 'pathmunge /share/apps/genemark_hmm_euk.linux_64' >> /etc/profile
echo 'pathmunge /share/apps/augustus.2.5.5/bin' >> /etc/profile
echo 'pathmunge /share/apps/paraloop-1.3/bin' >> /etc/profile
echo 'pathmunge /share/apps/marthlab/bin' >> /etc/profile
echo 'pathmunge /share/apps/instantclient_11_2' >> /etc/profile
echo 'pathmunge /share/apps/palmapper-0.4' >> /etc/profile
echo 'pathmunge /share/apps/FastQC' >> /etc/profile
echo 'pathmunge /share/apps/trans-ABySS/wrappers' >> /etc/profile
echo 'pathmunge /share/apps/velvet' >> /etc/profile
echo 'pathmunge /share/apps/circos-0.60/bin' >> /etc/profile
echo 'pathmunge /share/apps/apache-maven-2.2.1/bin' >> /etc/profile
echo 'pathmunge /share/apps/indel_detection' >> /etc/profile
echo 'pathmunge /share/apps/samtools' >> /etc/profile
echo 'pathmunge /share/apps/lib64' >> /etc/profile
echo 'export SGE_ROOT="/usr/share/gridengine"' >> /etc/profile
echo "export PYTHONPATH='/home/galaxy/galaxy-dist/distant/tools/repet_pipe'" >> /etc/profile
echo "export REPET_PATH='/home/galaxy/galaxy-dist/distant/tools/repet_pipe'" >> /etc/profile
echo 'export REPET_JOB_MANAGER="SGE"' >> /etc/profile
echo "export SMARTTMPPATH='/home/galaxy/galaxy-dist/distant/$adrMac/tmp/'" >> /etc/profile
echo 'export GALAXY_TEST_FILE_DIR="/home/galaxy/galaxy-dist/distant/galaxy-data"' >> /etc/profile
echo 'export GALAXY_TEST_TOOL_PATH="/home/galaxy/galaxy-dist/distant/tools/"' >> /etc/profile
echo 'unset -f pathmunge' >> /etc/profile

# Configuration de la base de donnée postgres
#---------------------------------------------
/etc/init.d/postgresql initdb
/etc/init.d/postgresql start
/sbin/chkconfig postgresql on
#config postgres
su - postgres -c "echo \"CREATE ROLE galaxy PASSWORD 'password' NOSUPERUSER NOCREATEDB NOCREATEROLE  INHERIT LOGIN;\"|/usr/bin/psql"
su - postgres -c "/usr/bin/createdb -O galaxy galaxy"

#Configuration de GridEngine
#----------------------------
#copie de la configuration gridengine
cp -r /tmp/install-file/gridengine/default /usr/share/gridengine/default
# Ajout variable env pour sge
echo 'export SGE_ROOT="/usr/share/gridengine"' >> /home/galaxy/.bashrc
# configuration du /etc/hosts pour fonctionner avec SGE
hostname $(hostname -s)
sed -i 's/.*/& '"$(hostname -s)"'/' /etc/hosts

# Mise en place du service de tunnel entre la VM et saruman
# ----------------------------------------------------------
cp /tmp/install-file/tunnel/tunnel /etc/init.d/tunnel
/sbin/chkconfig --add tunnel
/sbin/chkconfig tunnel on
mkdir /home/galaxy/.ssh
cp /tmp/install-file/tunnel/galaxy.key /home/galaxy/.ssh/id_rsa
cp /tmp/install-file/tunnel/known_hosts /home/galaxy/.ssh/known_hosts
chown galaxy:galaxy -R /home/galaxy/.ssh
chmod 600 /home/galaxy/.ssh/id_rsa
chmod 644 /home/galaxy/.ssh/known_hosts
/etc/init.d/tunnel start

# Installation de Rscript
# ----------------------------------------------------------
yum install -y libgomp libgfortran libgfortran.x86_64 compat-libgfortran-41.x86_64 gcc-gfortran.x86_64

# Installation de pango et des fonts:
# ----------------------------------------------------------
yum install -y pango
yum groupinstall -y fonts

# Installation de git
# ----------------------------------------------------------
yum install -y git

# Installation de galaxy
# ----------------------------------------------------------
su - galaxy -c 'hg clone https://bitbucket.org/galaxy/galaxy-dist/'
su - galaxy -c 'cp /tmp/install-file/galaxy-conf/universe_wsgi.ini /home/galaxy/galaxy-dist/universe_wsgi.ini'
su - galaxy -c 'cp /tmp/install-file/galaxy-conf/urgi_tool_conf.xml /home/galaxy/galaxy-dist/urgi_tool_conf.xml'

# Copier les galaxy_utils dans repet_pipe
# ----------------------------------------------------------
su - galaxy -c cp -r /home/galaxy/galaxy-dist/lib/galaxy_utils /home/galaxy/galaxy-dist/distant/$adrMac/tools/repet_pipe

# Virtual env
# ----------------------------------------------------------
#Installation
yum install -y python-virtualenv.noarch

#set de /usr/bin comme repertoire source principal pour les binaires
su - galaxy -c echo 'export OLDPATH=$PATH'
su - galaxy -c echo 'export PATH=/usr/bin:$PATH'

#Créer son virtualenv
su - galaxy -c 'virtualenv /home/galaxy/GalaxyPython2_6'
su - galaxy -c echo 'export PATH=$OLDPATH'

#activation
su - galaxy -c 'GalaxyPython2_6/bin/activate'
su - galaxy -c 'source ./GalaxyPython/bin/activate'

#on utilise la mac adresse
su - galaxy -c "sed -i 's/__HOSTNAME__/$adrMac/g' /home/galaxy/galaxy-dist/universe_wsgi.ini"
su - galaxy -c 'cp /home/galaxy/galaxy-dist/contrib/galaxy.fedora-init /etc/init.d/galaxy'
sed -i 's/\/path\/to\/galaxy-dist/\/home\/galaxy\/galaxy-dist/g' /etc/init.d/galaxy
chmod 755 /etc/init.d/galaxy

#avant d'aller plus on monte le NFS
su - galaxy -c 'mkdir /home/galaxy/galaxy-dist/distant'
mkdir -p /share/apps
/sbin/chkconfig rpcbind on
/etc/init.d/rpcbind start
echo '192.168.0.5:/tmpvmgalaxy /home/galaxy/galaxy-dist/distant nfs defaults 0 0' >> /etc/fstab
echo '192.168.0.5:/shareapps/shareapps /share/apps nfs defaults 0 0' >> /etc/fstab
mount -a

#creation des répertoires file job et  tmp
#ajouter un sed pour modifier les ':' par '-'
su - galaxy -c "mkdir /home/galaxy/galaxy-dist/distant/${adrMac}"
su - galaxy -c "mkdir /home/galaxy/galaxy-dist/distant/${adrMac}/tmp"
su - galaxy -c "mkdir /home/galaxy/galaxy-dist/distant/${adrMac}/tools"
su - galaxy -c "mkdir /home/galaxy/galaxy-dist/distant/${adrMac}/files"
su - galaxy -c "mkdir /home/galaxy/galaxy-dist/distant/${adrMac}/job_working_directory"

#Mesg of the day galaxy

cat << EOF >> /etc/motd
--------------------------------------
# Welcome to Urgi CentOS Galaxy VM ! #
--------------------------------------

- The default root password is "******"

Change iti, type the command : passwd

- To init galaxy server (on first run only) :
su - galaxy
cd galaxy-dist
./run.sh

- To automatic startup galaxy on next boot :
chkconfig --add galaxy     
chkconfig galaxy on
Galaxy is installed in /home/galaxy/galaxy-dist
EOF

exit 0

Generation de l'image

genisoimage -o ~/<nom de l'image>.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V "CentOS" .

Démarrage de la machine depuis l'environement Proxmox

Obtention de l'ip de la machine depuis l'interface console de Proxmox


Connection à l'instance Galaxy

Modification de la route

sudo route add -net 10.0.0.0 netmask 255.255.255.0 gw 138.102.77.247
ssh root@<ip-de-la-VM>
su - galaxy

Activation de Virtual Env

GalaxyPython2_6/bin/activate
source ./GalaxyPython/bin/activate

Démarrage de l'intance

sh ./run.sh
Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Boîte à outils