Ajout du support OpenNebula HA dans Hâpy

Ajouter la possibilité de créer une grappe haute disponibilité entre
plusieurs Hâpy (https://docs.opennebula.org/5.6/advanced_components/ha/index.html)

Pré-requis : Les datastores doivent être partagés entre tous les Hâpy
via NFS ou tout autre système de fichiers accécibles de manière
concurrente entre les serveurs (Glusterfs, Ceph, DRBD).

Pour faire ce développement nous nous sommes basés sur eole-glusterfs
qui permet de créer une grappe glusterfs (https://dev-eole.ac-dijon.fr/projects/eole-glusterfs)
Cette révision appartient à :
Philippe Caseiro 2019-02-06 14:14:03 +01:00
Parent 850585af21
révision 78a27b4fdd
13 fichiers modifiés avec 548 ajouts et 104 suppressions

Voir le fichier

@ -80,7 +80,7 @@ then
echo ""
else
for VM in $VMs ; do
NAME=$( one "onevm show $VM" | grep 'NAME' | cut -d: -f2 )
NAME=$( one "onevm show $VM" | grep '^NAME' | cut -d: -f2 )
STAT=$(one "onevm show $VM" | grep '^STATE' | cut -d: -f2 | tr -d ' ' )
printf ". %${len_pf}s => " "$NAME"
eOneStatus "$STAT"

Voir le fichier

@ -4,10 +4,13 @@
<!--file filelist='onesinglenode' name='/etc/one/sunstone-server.conf' rm='True' mkdir='True'/-->
<file filelist='onesinglenode' name='/etc/one/vmm_exec/vmm_exec_kvm.conf' rm='True' mkdir='True'/>
<file filelist='onesinglenode' name='/etc/one/oned.conf' rm='True'/>
<file filelist='onesinglenode' name='/etc/one/sched.conf' rm='True'/>
<file filelist='onesinglenode' name='/var/lib/one/remotes/etc/vnm/OpenNebulaNetwork.conf' rm='True' mkdir='True'/>
<file filelist='onesinglenode' name='/etc/one/auth/ldap_auth.conf'/>
<file filelist='one_ha' name='/usr/share/eole/bastion/data/60-one' mode='755'/>
<service>opennebula</service>
<service>opennebula-scheduler</service>
<service_access service='one-ssh'>
<tcpwrapper>sshd</tcpwrapper>
@ -16,6 +19,19 @@
<service_restriction service='one-ssh'>
<ip interface='eth0' ip_type='SymLinkOption'>adresse_ip_eth0</ip>
</service_restriction>
<service_access service='sunstone'>
<port port_type="SymLinkOption">port_sunstone</port>
<port port_type="SymLinkOption">vnc_proxy_port_sunstone</port>
</service_access>
<service_access service='sunstone_xmlrpc'>
<port service_accesslist="sunstone_xmlrpc">2633</port>
</service_access>
<service_restriction service='sunstone_xmlrpc'>
<ip interface='one_node_int_name' interface_type='SymLinkOption' ip_type='SymLinkOption'>one_nodes</ip>
</service_restriction>
</files>
<variables>
<family name='general'>
@ -30,6 +46,25 @@
<variable name='one_cluster_name' type='string' description="Nom de la grappe OpenNebula par défaut" mode='expert'>
<value>default</value>
</variable>
<!-- Base de donnée -->
<variable name="one_database_type" description="Moteur de base de données a utiliser" type="string" mode="expert">
<value>sqlite</value>
</variable>
<variable name="one_database_host" description="Adresse du serveur de base de données (mySQL uniquement)" mandatory="True" mode="expert"/>
<variable name="one_database_port" description="Port d'écoute du serveur de base de données" mode="expert" type="number" mandatory="True">
<value>3306</value>
</variable>
<variable name="one_database_name" description="Nom de la base de données" type="string" mandatory="True">
<value>onedb</value>
</variable>
<variable name="one_database_user" description="Utilisateur pour se connecter à la base de données" type="string" mandatory="True">
<value>one</value>
</variable>
<variable name="one_database_pass" description="Mot de passe pour se connecter à la base de données" type="password" mandatory="True"/>
<variable name="one_database_connections" description="Nombre de connection à la base de données" type="number" mandatory="True" mode="expert"><value>50</value></variable>
<!-- VNETS -->
<variable name='vnet_pilote' type='string' description='Pilote utilisé pour le réseau virtuel' hidden='True' />
<variable name='vnets' type='string' description="Nom du réseau virtuel à plage d'adresse IP" multi='True'/>
<variable name='vnet_range_start' type='ip' description='Première IP de la plage' mandatory="True"/>
@ -68,11 +103,16 @@
<variable name='activer_hooks' type='oui/non' description="Utiliser des hooks personnalisés" mode='expert'>
<value>non</value>
</variable>
<variable name='activer_multinode' description="Activer l'intégration de plusieurs nœuds de virtualisation" mode='expert' type='oui/non'>
<variable name='activer_one_ha' type='oui/non' description="Activer le support pour la haute disponibilité OpenNebula" mode='expert'>
<value>non</value>
</variable>
<variable name='one_nodes' type='string' description="Nom du nœud de virtualisation" multi='True' mandatory='True'/>
<variable name='node_ip' type='ip' description="Adresse IP du nœud de virtualisation" mandatory='True'/>
<variable name='activer_multinode' description="Activer l'intégration de plusieurs nœuds de virtualisation" mode='expert' type='oui/non'/>
<variable name='one_nodes' type='domain' description="Nom du nœud de virtualisation" multi='True' mandatory='True'/>
<variable name="one_ha_server_index" description="Index du serveur dans la liste des nœuds de virtualisation" type="number" mandatory="True"/>
<variable name='one_node_int' type='domain' description="Interface de communication des nœuds" mandatory='True'/>
<variable name='one_node_int_name' type='domain' description="Nom de l'interface de communication des nœuds"/>
<variable name="one_vip" description="Adresse IP de la VIP OpenNebula" type="ip" mandatory="True"/>
<variable name="one_vip_mask" description="Masque de sous-réseau de la VIP OpenNebula" type="netmask" mandatory="True"/>
</family>
<family name='Modèle' icon='cloud'>
<variable name='hapy_init_master' type='oui/non' description="Activer l'auto-création du modèle de machine virtuelle pour installer un module EOLE">
@ -106,9 +146,10 @@
<variable name='hapy_user_hook_arguments' type='string' description="Arguments à passer au script (arguments)" mode='expert'/>
</family>
<separators>
<separator name="one_database_type">Configuration de la base de données</separator>
<separator name='vnet_pilote'>Configuration des réseaux de l'orchestrateur</separator>
<separator name='one_ds_system_prefix'>Configuration de l'orchestrateur</separator>
<separator name='activer_multinode'>Configuration des nœuds de virtualisation</separator>
<separator name='activer_one_ha'>Configuration des nœuds de virtualisation</separator>
</separators>
</variables>
@ -121,6 +162,10 @@
<param type="eole" name="condition_1">vnet_pilote</param>
</auto>
<check name="valid_enum" target="one_database_type">
<param>['sqlite','mysql']</param>
</check>
<check name='valid_enum' target='one_video_driver'>
<param>['qxl','vga','std','cirrus']</param>
<param name='checkval'>False</param>
@ -151,11 +196,60 @@
<target type='variable'>arp_cache_poisoning</target>
</condition>
<condition name="disabled_if_in" source="one_database_type">
<param>sqlite</param>
<target type="variable">one_database_host</target>
<target type="variable">one_database_port</target>
<target type="variable">one_database_name</target>
<target type="variable">one_database_user</target>
<target type="variable">one_database_pass</target>
<target type="variable">one_database_connections</target>
</condition>
<check name="valid_enum" target="one_node_int">
<param>['0','1','2','3','4']</param>
</check>
<auto name='concat' target='one_node_int_name'>
<param>eth</param>
<param type='eole'>one_node_int</param>
</auto>
<condition name='disabled_if_in' source='activer_multinode'>
<param>non</param>
<target type='variable'>one_nodes</target>
<target type='variable'>node_ip</target>
<target type='variable'>one_node_int</target>
<target type='variable'>one_node_int_name</target>
</condition>
<fill name='calc_val' target='activer_multinode'>
<param type='eole' name='valeur'>activer_one_ha</param>
</fill>
<condition name='frozen_if_in' source='activer_one_ha'>
<param>oui</param>
<target type='variable'>activer_multinode</target>
</condition>
<condition name='disabled_if_in' source='activer_one_ha'>
<param>non</param>
<target type='variable'>one_ha_server_index</target>
<target type='variable'>one_vip</target>
<target type='variable'>one_vip_mask</target>
<target type='service_accesslist'>sunstone_xmlrpc</target>
<target type='filelist'>one_ha</target>
</condition>
<fill name='calc_val' target='one_vip_mask'>
<param type='eole' name='valeur'>adresse_netmask_eth0</param>
</fill>
<check name="valid_differ" target="adresse_ip_eth0">
<param type='eole' hidden='False'>one_vip</param>
</check>
<check name="valid_differ" target="adresse_ip_gw">
<param type='eole' hidden='False'>one_vip</param>
</check>
<check name="valid_ipnetmask" target="one_vip_mask" level="warning">
<param type='eole'>one_vip</param>
</check>
<group master='vnets'>
<slave>vnet_range_start</slave>
@ -175,10 +269,6 @@
<slave>l2_vnet_vlan_trunk</slave>
</group>
<group master='one_nodes'>
<slave>node_ip</slave>
</group>
<check name='valid_enum' target='vnets'>
<param>['internet','admin','pedago','dmzpub','dmzpriv','wifi']</param>
<param name='checkval'>False</param>
@ -286,5 +376,8 @@
<variable name='hapy_init_master_iso_version'>Version de l'ISO EOLE à télécharger lors de l'initialisation</variable>
<variable name='vnets'>Réseau de type IPv4 (niveau 3 du modèle OSI)</variable>
<variable name='l2_vnets'>Réseau de type ethernet (niveau 2 du modèle OSI)</variable>
<variable name='one_ha_server_index'>Le leader à l'index 0, les followers commencent à 1</variable>
<variable name='activer_one_ha'>Active la possibilité d'intégrer Hâpy dans une grappe de haute disponibilité OpenNebula</variable>
<variable name="one_vip">Adresse IP virtuelle (VIP) utilisée pour joindre le "Leader" de la grappe, les usagés utiliseront cette IP pour contacter la grappe</variable>
</help>
</creole>

Voir le fichier

@ -69,6 +69,21 @@ function check_host()
return ${res}
}
# Fix host creation error from 5.6.1 with sync methode rsync
function sync_host()
{
CMD="onehost"
OPT="sync -f --rsync"
AUTH=$(get_one_auth)
res=$(su - oneadmin -c "${CMD} ${OPT} --user ${AUTH%:*} --password ${AUTH#*:}")
if [[ ${?} -ne 0 ]]
then
error "Hosts sync failed"
else
echo "Hosts sync OK"
fi
}
function manage_host()
{
NAME=${1}
@ -185,9 +200,9 @@ function attach_host()
{
HOST=${1}
CLST=${2}
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#CLST_ID=$(get_cluster_id_by_name ${CLST})
CLST_ID=0
CLST_ID=0
HST_ID=$(get_host_id_by_name ${HOST})
AUTH=$(get_one_auth)
CMD="onecluster"
@ -249,10 +264,11 @@ function create_datastore()
{
ds_type="${1}"
ds_name="${2}"
# ref https://dev-eole.ac-dijon.fr/issues/16797
local ha=$(CreoleGet activer_one_ha)
# ref https://dev-eole.ac-dijon.fr/issues/16797
#ds_cluster="${3}"
if [[ $(CreoleGet activer_multinode 2>&1) == 'oui' ]]
if [[ $(CreoleGet activer_multinode 2>&1) == 'oui' ]] && [[ ${ha} == "non" ]]
then
SYS_TM_MAD='ssh'
ISO_TM_MAD='ssh'
@ -300,7 +316,7 @@ __EOF__
RUN=$(${cmd} ${opt})
if [[ ${?} -eq 0 ]]
then
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#attach_ds_to_cluster ${ds_name} ${ds_cluster}
rm ${TMPL_FILE}
return 0
@ -316,13 +332,14 @@ function update_datastore()
local cmd="onedatastore"
local opt="show"
local multinode=$(CreoleGet activer_multinode 2>&1)
local ha=$(CreoleGet activer_one_ha)
ds_type=""
ds_mad=""
ds_name=""
TMPL_FILE=$(mktemp)
if [[ ${multinode} == 'oui' ]]
if [[ ${multinode} == 'oui' ]] && [[ ${ha} == "non" ]]
then
SYS_TM_MAD='ssh'
ISO_TM_MAD='ssh'
@ -384,11 +401,11 @@ __EOF__
function manage_datastores()
{
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#cluster=${1}
AUTH=$(get_one_auth)
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#SYSTEM_DS="$(CreoleGet 'one_ds_system_prefix')${cluster}"
SYSTEM_DS="$(CreoleGet 'one_ds_system_prefix')default"
ISO_DS=$(CreoleGet 'one_ds_iso_name')
@ -398,7 +415,7 @@ function manage_datastores()
sid=$(get_ds_id_by_name ${SYSTEM_DS})
if [[ ${sid} = "ERR" ]]
then
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#create_datastore "SYSTEM" "${SYSTEM_DS}" "${cluster}"
create_datastore "SYSTEM" "${SYSTEM_DS}"
else
@ -408,7 +425,7 @@ function manage_datastores()
imgid=$(get_ds_id_by_name ${IMAGE_DS})
if [[ ${imgid} = "ERR" ]]
then
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#create_datastore "IMAGE" "${IMAGE_DS}" "${cluster}"
create_datastore "IMAGE" "${IMAGE_DS}"
else
@ -418,7 +435,7 @@ function manage_datastores()
isoid=$(get_ds_id_by_name ${ISO_DS})
if [[ ${isoid} = "ERR" ]]
then
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#create_datastore "ISO" "${ISO_DS}" "${cluster}"
create_datastore "ISO" "${ISO_DS}"
else
@ -430,32 +447,48 @@ function manage_datastores()
function main()
{
wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null"
if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then
if [ "$(CreoleGet one_ha_server_index)" != "0" ]; then
# ne pas faire sur les followers
return
fi
fi
#
# Rename default cluster
clst_name=$(CreoleGet one_cluster_name)
rename_default_cluster "${clst_name}"
# Wait 4 seconds for service (ref #16848)
sleep 4
# Wait 4 seconds for service (ref #16848)
sleep 4
#
# Creating Host
#
if [[ $(CreoleGet eole_module non) != 'hapy-master' ]]
then
host=$(CreoleGet nom_machine)
manage_host ${host}
fi
if [ ! "$(CreoleGet activer_one_ha)" = "oui" ]; then
if [[ $(CreoleGet eole_module non) != 'hapy-master' ]]
then
host=$(CreoleGet nom_machine)
manage_host ${host}
fi
fi
#
# Attaching Host to the Cluster
#
attach_host ${host} "${clst_name}"
#
# Force host synchronisation
#
sync_host
#
# Création des Datastores
#
manage_datastores "${clst_name}"
}
main
main $@
exit 0

Voir le fichier

@ -303,6 +303,14 @@ def main():
logger.debug(u"Configure OpenNebula networks")
client = CreoleClient()
mode_ha = client.get_creole('activer_one_ha')
if mode_ha == "oui":
indx = client.get_creole('one_ha_server_index')
if indx != 0:
# Mode HA is on and we are not in the Leader
exit(0)
one_client = OneClient('oneadmin')
networks = []
cluster = client.get_creole('one_cluster_name')

15
postservice/99-z-ha Fichier normal
Voir le fichier

@ -0,0 +1,15 @@
#!/bin/bash
ha=$(CreoleGet activer_one_ha non)
if [[ ${ha} == "oui" ]]
then
indx=$(CreoleGet one_ha_server_index)
else
indx="0"
fi
if [[ ${1} == "instance" ]] && [[ ${indx} == "0" ]]
then
/usr/share/eole/sbin/onehost_create_all
fi
exit 0

Voir le fichier

@ -6,44 +6,79 @@
#
. /usr/lib/eole/ihm.sh
script="$1"
function clean_backups()
{
file=${1}
bcks=($(ls ${file}_*))
nbbck=$(expr ${#bcks[@]} - 2)
file=${1}
ls ${file}_* > /dev/null 2>&1
if [ $? = 0 ]; then
bcks=($(ls ${file}_*))
nbbck=$(expr ${#bcks[@]} - 2)
if [[ ${nbbck} -gt 1 ]]
then
EchoGras "Cleaning up old backups !"
for idx in `seq 0 ${nbbck}`
do
rm -f ${bcks[${idx}]}
done
fi
if [[ ${nbbck} -gt 1 ]]
then
EchoGras "Cleaning up old backups !"
for idx in `seq 0 ${nbbck}`
do
rm -f ${bcks[${idx}]}
done
fi
fi
}
function updateDB()
{
local dbfile='/var/lib/one/one.db'
local cmd="onedb"
local res=0
local dbfile='/var/lib/one/one.db'
local cmd="onedb"
local res=0
if [[ -f ${dbfile} ]]
then
$cmd upgrade -f -s ${dbfile}
res=${?}
clean_backups ${dbfile}
return ${res}
else
return 0
fi
if [[ -f ${dbfile} ]]
then
if [ $(CreoleGet one_database_type) = "mysql" ]; then
if [ $(CreoleGet one_ha_server_index 0) = "0" ]; then
HOST=$(CreoleGet one_database_host)
DB=$(CreoleGet one_database_name)
USER=$(CreoleGet one_database_user)
PASS=$(CreoleGet one_database_pass)
$cmd upgrade -f -u $USER -p $PASS -d $DB -S $HOST
fi
else
$cmd upgrade -f -s ${dbfile}
fi
res=${?}
clean_backups ${dbfile}
return ${res}
else
return 0
fi
}
function to_mysql() {
if [ "$script" = 'instance' ] && [ $(CreoleGet one_database_type) = "mysql" ] && [ $(CreoleGet one_ha_server_index 0) = "0" ]; then
Question_ouinon "Voulez-vous migrer de SQLite à Mysql ?" "True" "oui" "warn"
rep=$(echo "$?")
if [ "$rep" == "0" ]; then
# do not recover db on follower
HOST=$(CreoleGet one_database_host)
DB=$(CreoleGet one_database_name)
USER=$(CreoleGet one_database_user)
PASS=$(CreoleGet one_database_pass)
cp -a /etc/one/oned.conf /etc/one/oned.conf.ori
# HA ne doit pas être activer pour la migration
CreoleCat -s /usr/share/eole/creole/distrib/oned-ha-mysql.conf -o /etc/one/oned.conf
oned -i
onedb sqlite2mysql -s /var/lib/one/one.db -u $USER -p $PASS -d $DB -S $HOST
cp -a /etc/one/oned.conf.ori /etc/one/oned.conf
fi
fi
}
echo
to_mysql
echo
EchoGras "Mise à jour de la base de données ONE"
echo
updateDB
echo
exit ${?}

Voir le fichier

@ -8,3 +8,10 @@ if [ -z "${auth_mode}" ]; then
else
ln -s /var/lib/one/remotes/auth/{${auth_mode},default}
fi
# creation de la base /var/lib/one/one.db
if [ ! -e /var/lib/one/one.db ]; then
systemctl daemon-reload
systemctl start opennebula.service
fi
exit 0

26
preservice/31-one-ha Fichier exécutable
Voir le fichier

@ -0,0 +1,26 @@
#!/bin/bash
HA=$(CreoleGet activer_one_ha non)
DBMODE=$(CreoleGet one_database_type "none")
LEADER_DB_FILE="/var/lib/one/one.db.leader"
DBFILE="/var/lib/one/one.db"
# If HA is enabled and a leader database file is present
# we restore the leader database.
if [[ ${HA} == "oui" ]] && [[ ${DBMODE} == "sqlite" ]]
then
if [[ -f ${LEADER_DB_FILE} ]]
then
if [[ $(CreoleGet one_ha_server_index) != "0" ]]
then
onedb restore --sqlite ${DBFILE} ${LEADER_DB_FILE} -f
if [[ $? -eq 0 ]]
then
rm ${LEADER_DB_FILE}
exit ${?}
fi
fi
fi
fi
exit 0

Voir le fichier

@ -7,24 +7,73 @@
. /usr/lib/eole/ihm.sh
#
# NAME: copy_ssh_id
# NAME: copy_ssh_id
# AIM: Copy the ssh key on the host
# PARAM: the hostname of the node
# PARAM: the hostname of the node
#
function copy_ssh_id()
{
local ip=${1}
local host=${1}
ssh ${ip} bash -s <<EOF
echo $(cat ~oneadmin/.ssh/id_rsa.pub) > /tmp/one-master.key.pub
if ! grep -qs /tmp/one-master.key.pub ~oneadmin/.ssh/authorized_keys
then
cat /tmp/one-master.key.pub >> ~oneadmin/.ssh/authorized_keys
chown oneadmin:oneadmin ~oneadmin/.ssh/authorized_keys
CLEF=$(cat ~oneadmin/.ssh/id_rsa.pub)
ssh ${host} bash <<EOF
if ! grep -qs "$CLEF" ~oneadmin/.ssh/authorized_keys; then
echo "$CLEF" >> ~oneadmin/.ssh/authorized_keys
chown oneadmin:oneadmin ~oneadmin/.ssh/authorized_keys
su - oneadmin -c "ssh-keyscan $host"
cat ~oneadmin/.ssh/id_rsa.pub >> ~oneadmin/.ssh/authorized_keys
fi
rm -f /tmp/one-master.key.pub
EOF
return ${?}
[[ ${?} -ne 0 ]] && EchoRouge "Erreur lors de l'échange de clés SSH avec le noeud ${host}"
REMOTEKEY=$(su - oneadmin -c "ssh ${host} 'cat ~oneadmin/.ssh/id_rsa.pub'")
if ! grep -qs "$REMOTEKEY" ~oneadmin/.ssh/authorized_keys; then
su - oneadmin -c "echo ${REMOTEKEY} >> ~oneadmin/.ssh/authorized_keys"
su - oneadmin -c "ssh-keyscan $host"
fi
}
function copy_files()
{
local host=${1}
su - oneadmin -c "scp .one/* ${host}:.one/"
}
#
# NAME: sync_db
# AIM: Sync onedb in HA and sqlite mode
# PARAM: the hostname of the node
#
function sync_db()
{
local ip=${1}
local user="oneadmin"
local DBFILE="/var/lib/one/one.db"
local DBBCK="/tmp/one.db.bck"
local ret=0
if [[ ! -f ${DBBCK} ]]
then
cmd="onedb backup --sqlite ${DBFILE} ${DBBCK}"
ret=$(su - ${user} -c -- "${cmd}")
fi
cmd2="scp ${DBBCK} ${ip}:${DBFILE}.leader"
ret=$(su - ${user} -c -- "${cmd2}")
return ${?}
}
#
# NAME: sync_nodes
# AIM: force nodes sync with rsync (ONE 5.6.1 bug)
# PARAM: none
#
function sync_nodes()
{
# Need to sync hosts with rsync after creation, ONE 5.6.1 bug
cmd2="onehost sync -f --rsync"
ret2=$(su - ${ONEUSER} -c -- "${cmd2}")
return ${?}
}
#
@ -35,21 +84,28 @@ EOF
function register_node()
{
cmd="onehost create -i kvm -v kvm -c 0 ${1}"
ret=$(su - ${ONEUSER} -c -- "${cmd}")
return $?
if [[ ${?} -ne 0 ]]
then
EchoRouge "Hosts register failed $res"
else
EchoVert "Hosts register OK"
fi
}
#
# NAME: wait_node_ok
# AIM: Wait until the node is OK or ERROR
# PARAM: The node name
# PARAM: The node name
#
function wait_node_ok()
{
local RET=0
local cmd="onehost show ${1} | awk '/^STATE/ {print \$3}'"
local spinstr='|/-\'
local delay=0.75
local cnt=0
while [ 1 ]
do
@ -58,8 +114,10 @@ function wait_node_ok()
[[ ${st} == '' ]] && break
if [[ ${st} == "ERROR" ]]
then
RET=2
break
if [ $cnt -gt 160 ]; then
EchoRouge "Erreur lors de l'enregistrement du noeud ${host} !"
break
fi
fi
local temp=${spinstr#?}
@ -67,10 +125,20 @@ function wait_node_ok()
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
cnt=$((cnt+1))
done
printf " \b\b\b\b"
return ${RET}
}
function init_ha_leader() {
# server with index 1 exists if already instanciate
onezone show 0 | grep -A 3 ^"HA & FEDERATION SYNC STATUS" | tail -n 1 | grep -q ^" 1 "
if [ ! $? = 0 ]; then
FOLLOWER=$(CreoleGet one_nodes)
for follower in $FOLLOWER; do
onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2
done
fi
}
#
@ -79,21 +147,35 @@ function wait_node_ok()
HAPY_ACTIF=$(echo $(CreoleGet activer_onesinglenode))
if [[ $HAPY_ACTIF == "non" ]]
then
EchoRouge "Le serveur de virtualisation n'est pas activé dans l'interface de configuration du module"
exit 1
EchoRouge "Le serveur de virtualisation n'est pas activé dans l'interface de configuration du module"
exit 1
fi
HAPY_NODE_SUPPORT=$(echo $(CreoleGet activer_multinode))
if [[ $HAPY_NODE_SUPPORT == "non" ]]
then
EchoRouge "Le mode multi-noeuds n'est pas activé dans l'interface de configuration du module"
exit 1
EchoRouge "Le mode multi-noeuds n'est pas activé dans l'interface de configuration du module"
exit 1
fi
HAPY_HA=$(CreoleGet activer_one_ha "non")
master=1
if [[ ${HAPY_HA} == "oui" ]]; then
idx=$(CreoleGet one_ha_server_index)
if [[ ${idx} != "0" ]]; then
EchoBleu "Mode HA: (on) Index : [${idx}]"
echo -e "\t$(basename ${0}) doit être lancé uniquement sur le leader (index 0)"
exit 0
else
master=0
fi
fi
declare -a HAPY_SLV=('')
declare -a HAPY_SLV_IP=('')
ONEUSER=$(CreoleGet virt_user)
HAPY_SLV=$(echo $(CreoleGet one_nodes) | sed -e "s/\n/ /g")
HAPY_SLV_IP=$(echo $(CreoleGet node_ip) | sed -e "s/\n/ /g")
DBMODE=$(CreoleGet one_database_type "none")
echo -e "\n"
EchoBleu "Vous allez inscrire un noeud dans une grappe Hâpy"
@ -101,28 +183,46 @@ EchoBleu "Pour ce faire vous devez vous munir du mot de passe de l'utilisateur '
Question_ouinon "Voulez-vous commencer ?" 'True' "oui"
if [[ $? -ne 0 ]]
then
EchoOrange "Abandon de l'enregistrement"
exit 1
EchoOrange "Abandon de l'enregistrement"
exit 1
fi
for ((i = 0; i < ${#HAPY_SLV[*]}; i +=1))
do
for host in ${HAPY_SLV}; do
echo -e "\n"
EchoOrange "Traitement du noeud ${HAPY_SLV[${i}]}"
EchoOrange "Traitement du noeud ${host}"
echo
EchoVert " * Gestion des clés SSH"
echo
copy_ssh_id ${HAPY_SLV_IP[${i}]}
[[ ${?} -ne 0 ]] && EchoRouge "Erreur lors de l'échange de clés SSH avec le noeud ${HAPY_SLV[${i}]}}"
copy_ssh_id ${host}
if [ $master = 0 ]; then
copy_files ${host}
fi
EchoVert " * Enregistrement du noeud"
register_node ${HAPY_SLV[${i}]}
wait_node_ok ${HAPY_SLV[${i}]}
if [[ ${?} -ne 0 ]]
register_node ${host}
if [[ ${HAPY_HA} == "oui" ]]
then
EchoRouge "Erreur lors de l'enregistrement du noeud ${HAPY_SLV[${i}]} !"
if [[ $DBMODE == "sqlite" ]]
then
if [[ $(CreoleGet one_ha_server_index) == "0" ]]
then
sync_db ${host}
fi
fi
fi
sync_nodes
if [[ ${HAPY_HA} != "oui" ]]
wait_node_ok ${HAPY_SLV[${i}]}
if [[ ${?} -ne 0 ]]
then
EchoRouge "Erreur lors de l'enregistrement du noeud ${HAPY_SLV[${i}]} !"
fi
fi
done
if [ $master = 0 ]; then
init_ha_leader
fi
echo -e "\n"
EchoVert "Enregistrement des noeuds terminé"

5
tmpl/60-one Fichier normal
Voir le fichier

@ -0,0 +1,5 @@
#!/bin/bash
%for %%host in %%one_nodes
/sbin/iptables -A eth%%{one_node_int}-root -s %%host -p tcp --syn -j ACCEPT
%end for

2
tmpl/oned-ha-mysql.conf Fichier normal
Voir le fichier

@ -0,0 +1,2 @@
%set global %%activer_one_ha='non'
%include '/var/lib/creole/oned.conf'

Voir le fichier

@ -78,18 +78,22 @@ SCRIPTS_REMOTE_DIR=/var/tmp/one
PORT = 2633
%if %%activer_one_ha == 'non'
LISTEN_ADDRESS = "127.0.0.1"
%end if
%if %%one_database_type == "sqlite"
DB = [ BACKEND = "sqlite" ]
%else
# Sample configuration for MySQL
# DB = [ BACKEND = "mysql",
# SERVER = "localhost",
# PORT = 0,
# USER = "oneadmin",
# PASSWD = "oneadmin",
# DB_NAME = "opennebula",
# CONNECTIONS = 50 ]
DB = [ BACKEND = "mysql",
SERVER = "%%one_database_host",
PORT = %%one_database_port,
USER = "%%one_database_user",
PASSWD = "%%one_database_pass",
DB_NAME = "%%one_database_name",
CONNECTIONS = %%one_database_connections ]
%end if
VNC_PORTS = [
START = 5900
@ -151,7 +155,11 @@ VNC_PORTS = [
FEDERATION = [
MODE = "STANDALONE",
ZONE_ID = 0,
%if %%activer_one_ha == 'oui'
SERVER_ID = %%one_ha_server_index,
%else
SERVER_ID = -1,
%end if
MASTER_ONED = ""
]
@ -164,17 +172,19 @@ RAFT = [
XMLRPC_TIMEOUT_MS = 450
]
%if %%activer_one_ha == 'oui'
# Executed when a server transits from follower->leader
# RAFT_LEADER_HOOK = [
# COMMAND = "raft/vip.sh",
# ARGUMENTS = "leader <interface> <ip_cidr>"
# ]
RAFT_LEADER_HOOK = [
COMMAND = "raft/vip.sh",
ARGUMENTS = "leader %%nom_zone_eth0 %%one_vip/%%calc_classe(%%one_vip_mask)"
]
# Executed when a server transits from leader->follower
# RAFT_FOLLOWER_HOOK = [
# COMMAND = "raft/vip.sh",
# ARGUMENTS = "follower <interface> <ip_cidr>"
# ]
RAFT_FOLLOWER_HOOK = [
COMMAND = "raft/vip.sh",
ARGUMENTS = "follower %%nom_zone_eth0 %%one_vip/%%calc_classe(%%one_vip_mask)"
]
%end if
#*******************************************************************************
# Default showback cost

110
tmpl/sched.conf Fichier normal
Voir le fichier

@ -0,0 +1,110 @@
#*******************************************************************************
# OpenNebula Configuration file
#*******************************************************************************
#*******************************************************************************
# Daemon configuration attributes
#-------------------------------------------------------------------------------
# MESSAGE_SIZE: Buffer size in bytes for XML-RPC responses.
#
# XMLRPC_TIMEOUT: Seconds to timeout XML-RPC calls to oned
#
# ONE_XMLRPC: URL to connect to the OpenNebula daemon (oned)
#
# SCHED_INTERVAL: Seconds between two scheduling actions
#
# MAX_VM: Maximum number of Virtual Machines scheduled in each scheduling
# action. Use 0 to schedule all pending VMs each time.
#
# MAX_DISPATCH: Maximum number of Virtual Machines actually dispatched to a
# host in each scheduling action
#
# MAX_HOST: Maximum number of Virtual Machines dispatched to a given host in
# each scheduling action
#
# LIVE_RESCHEDS: Perform live (1) or cold migrations (0) when rescheduling a VM
#
# DEFAULT_SCHED: Definition of the default scheduling algorithm
# - policy:
# 0 = Packing. Heuristic that minimizes the number of hosts in use by
# packing the VMs in the hosts to reduce VM fragmentation
# 1 = Striping. Heuristic that tries to maximize resources available for
# the VMs by spreading the VMs in the hosts
# 2 = Load-aware. Heuristic that tries to maximize resources available for
# the VMs by using those nodes with less load
# 3 = Custom.
# - rank: Custom arithmetic expression to rank suitable hosts based in their
# attributes
# 4 = Fixed. Hosts will be ranked according to the PRIORITY attribute found
# in the Host or Cluster template.
#
# DEFAULT_DS_SCHED: Definition of the default storage scheduling algorithm
# - policy:
# 0 = Packing. Tries to optimize storage usage by selecting the DS with
# less free space
# 1 = Striping. Tries to optimize I/O by distributing the VMs across
# datastores.
# 2 = Custom.
# - rank: Custom arithmetic exprission to rank suitable datastores based on
# their attributes
# 3 = Fixed. Datastores will be ranked according to the PRIORITY attribute
# found in the Datastore template.
#
#
# LOG: Configuration for the logging system
# - system: defines the logging system:
# file to log in the sched.log file
# syslog to use the syslog facilities
# - debug_level:
# 0 = ERROR
# 1 = WARNING
# 2 = INFO
# 3 = DEBUG Includes general scheduling information (default)
# 4 = DDEBUG Includes time taken for each step
# 5 = DDDEBUG Includes detailed information about the scheduling
# decision, such as VM requirements, Host ranking for
# each VM, etc. This will impact the performance
#
# MEMORY_SYSTEM_DS_SCALE: This factor scales the VM usage of the system DS with
# the memory size. This factor can be use to make the scheduler consider the
# overhead of checkpoint files:
# system_ds_usage = system_ds_usage + memory_system_ds_scale * memory
#
#*******************************************************************************
MESSAGE_SIZE = 1073741824
TIMEOUT = 60
%if %%activer_one_ha == 'oui'
ONE_XMLRPC = "http://%%adresse_ip_eth0:2633/RPC2"
%else
ONE_XMLRPC = "http://localhost:2633/RPC2"
%end if
SCHED_INTERVAL = 30
MAX_VM = 5000
MAX_DISPATCH = 30
MAX_HOST = 1
LIVE_RESCHEDS = 0
MEMORY_SYSTEM_DS_SCALE = 0
DEFAULT_SCHED = [
policy = 1
]
DEFAULT_DS_SCHED = [
policy = 1
]
#DEFAULT_SCHED = [
# policy = 3,
# rank = "- (RUNNING_VMS * 50 + FREE_CPU)"
#]
LOG = [
system = "file",
debug_level = 3
]