From 693532b324e87dcc03e1b93871d380937990bbd1 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Thu, 21 Feb 2019 10:53:26 +0100 Subject: [PATCH 1/5] Adding host sync with rsync ONE 5.6.1 is affected by this bug : https://github.com/OpenNebula/one/issues/2962 Fixed in 5.6.2 but we don't have packages for this version. --- postservice/30-one-mng | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/postservice/30-one-mng b/postservice/30-one-mng index 99018f8..757afb5 100755 --- a/postservice/30-one-mng +++ b/postservice/30-one-mng @@ -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} @@ -441,7 +456,7 @@ function init_ha() { function main() { wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null" - if [ $(CreoleGet one_ha_role) = "leader" ]; then + if [ "$(CreoleGet one_ha_role none)" = "leader" ]; then init_ha fi # @@ -466,6 +481,11 @@ function main() # attach_host ${host} "${clst_name}" + # + # Force host synchronisation + # + sync_host + # # Création des Datastores # From 8c28ae6e6bc4406b76d424bfab45d6eaabb9689a Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 21 Feb 2019 13:59:39 +0100 Subject: [PATCH 2/5] fusion one_followers_domain et one_nodes --- dicos/29_one-master.xml | 58 +++++++++++++++++++++++----- dicos/30_one-master-ha.xml | 78 -------------------------------------- postservice/30-one-mng | 4 +- posttemplate/90-one-db | 2 +- scripts/onehost_create_all | 4 +- tmpl/oned-ha-mysql.conf | 2 +- tmpl/oned.conf | 6 +-- tmpl/sched.conf | 2 +- 8 files changed, 57 insertions(+), 99 deletions(-) delete mode 100644 dicos/30_one-master-ha.xml diff --git a/dicos/29_one-master.xml b/dicos/29_one-master.xml index 560e048..04f2ead 100644 --- a/dicos/29_one-master.xml +++ b/dicos/29_one-master.xml @@ -23,6 +23,14 @@ port_sunstone vnc_proxy_port_sunstone + + + 2633 + + + + one_nodes + @@ -53,7 +61,7 @@ one - 50 + 50 @@ -135,7 +146,7 @@ Configuration de la base de données Configuration des réseaux de l'orchestrateur Configuration de l'orchestrateur - Configuration des nœuds de virtualisation + Configuration des nœuds de virtualisation @@ -194,8 +205,36 @@ non one_nodes - node_ip + + activer_one_ha + + + oui + activer_multinode + + + + non + one_ha_server_index + one_vip + one_vip_mask + sunstone_xmlrpc + + + + adresse_netmask_eth0 + + + + one_vip + + + one_vip + + + one_vip + vnet_range_start @@ -215,10 +254,6 @@ l2_vnet_vlan_trunk - - node_ip - - ['internet','admin','pedago','dmzpub','dmzpriv','wifi'] False @@ -326,5 +361,8 @@ Version de l'ISO EOLE à télécharger lors de l'initialisation Réseau de type IPv4 (niveau 3 du modèle OSI) Réseau de type ethernet (niveau 2 du modèle OSI) + Le leader à l'index 0, les followers commencent à 1 + Active la possibilité d'intégrer Hâpy dans une grappe de haute disponibilité OpenNebula + Adresse IP virtuelle (VIP) utilisée pour joindre le "Leader" de la grappe, les usagés utiliseront cette IP pour contacter la grappe diff --git a/dicos/30_one-master-ha.xml b/dicos/30_one-master-ha.xml deleted file mode 100644 index d1330f9..0000000 --- a/dicos/30_one-master-ha.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - 2633 - - - - one_followers_domain - - - - - - non - - - - - - - - - - - Rôle du nœud de virtualisation - Configuration de la VIP - - - - - - ['leader','follower'] - - - - non - Haute disponibilité - sunstone_xmlrpc - - - follower - one_vip - one_vip_mask - - - - leader - one_server_index - - - leader - one_ha_role - 0 - None - - - adresse_netmask_eth0 - - - one_vip - - - one_vip - - - one_vip - - - - - Active la possibilité d'intégrer Hâpy dans une grappe de haute disponibilité OpenNebula - Configuration du comportement du noeud dans la grappe - Rôle initial du noeud dans la grappe, permet de déterminer comment le serveur commence sa vie dans la grappe - Adresse IP virtuelle (VIP) utilisée pour joindre le "Leader" de la grappe, les clients utiliseront cette IP pour contacter la grappe - Masque de sous réseau du réseau de la VIP au format CIDR (ex: 24 pour 255.255.255.0) - - diff --git a/postservice/30-one-mng b/postservice/30-one-mng index 757afb5..55bfa4c 100755 --- a/postservice/30-one-mng +++ b/postservice/30-one-mng @@ -446,7 +446,7 @@ function init_ha() { # 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_followers_domain) + FOLLOWER=$(CreoleGet one_nodes) for follower in $FOLLOWER; do onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2 done @@ -456,7 +456,7 @@ function init_ha() { function main() { wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null" - if [ "$(CreoleGet one_ha_role none)" = "leader" ]; then + if [ "$(CreoleGet one_ha_server_index)" = "0" ]; then init_ha fi # diff --git a/posttemplate/90-one-db b/posttemplate/90-one-db index 7f0f2d7..f3e3891 100644 --- a/posttemplate/90-one-db +++ b/posttemplate/90-one-db @@ -43,7 +43,7 @@ function updateDB() } function to_mysql() { - if [ "$script" = 'instance' ] && [ $(CreoleGet one_database_type) = "mysql" ] && [ $(CreoleGet one_ha_role leader) = "leader" ]; then + 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 diff --git a/scripts/onehost_create_all b/scripts/onehost_create_all index 44961d6..a06fa83 100755 --- a/scripts/onehost_create_all +++ b/scripts/onehost_create_all @@ -90,10 +90,8 @@ then exit 1 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") echo -e "\n" EchoBleu "Vous allez inscrire un noeud dans une grappe Hâpy" @@ -112,7 +110,7 @@ do echo EchoVert " * Gestion des clés SSH" echo - copy_ssh_id ${HAPY_SLV_IP[${i}]} + copy_ssh_id ${HAPY_SLV[${i}]} [[ ${?} -ne 0 ]] && EchoRouge "Erreur lors de l'échange de clés SSH avec le noeud ${HAPY_SLV[${i}]}}" EchoVert " * Enregistrement du noeud" diff --git a/tmpl/oned-ha-mysql.conf b/tmpl/oned-ha-mysql.conf index 9094c89..17b618c 100644 --- a/tmpl/oned-ha-mysql.conf +++ b/tmpl/oned-ha-mysql.conf @@ -1,2 +1,2 @@ -%set global %%enable_one_ha='non' +%set global %%activer_one_ha='non' %include '/var/lib/creole/oned.conf' diff --git a/tmpl/oned.conf b/tmpl/oned.conf index bf606a6..e66d89c 100644 --- a/tmpl/oned.conf +++ b/tmpl/oned.conf @@ -78,7 +78,7 @@ SCRIPTS_REMOTE_DIR=/var/tmp/one PORT = 2633 -%if %%enable_one_ha == 'non' +%if %%activer_one_ha == 'non' LISTEN_ADDRESS = "127.0.0.1" %end if @@ -155,7 +155,7 @@ VNC_PORTS = [ FEDERATION = [ MODE = "STANDALONE", ZONE_ID = 0, -%if %%enable_one_ha == 'oui' +%if %%activer_one_ha == 'oui' SERVER_ID = %%one_server_index, %else SERVER_ID = -1, @@ -172,7 +172,7 @@ RAFT = [ XMLRPC_TIMEOUT_MS = 450 ] -%if %%enable_one_ha == 'oui' and %%one_ha_role == 'leader' +%if %%activer_one_ha == 'oui' and %%one_ha_server_index == 0 # Executed when a server transits from follower->leader RAFT_LEADER_HOOK = [ COMMAND = "raft/vip.sh", diff --git a/tmpl/sched.conf b/tmpl/sched.conf index 184b663..938e044 100644 --- a/tmpl/sched.conf +++ b/tmpl/sched.conf @@ -75,7 +75,7 @@ MESSAGE_SIZE = 1073741824 TIMEOUT = 60 -%if %%enable_one_ha == 'oui' +%if %%activer_one_ha == 'oui' ONE_XMLRPC = "http://%%adresse_ip_eth0:2633/RPC2" %else ONE_XMLRPC = "http://localhost:2633/RPC2" From 3a74f7932c99b613b13a23bef6be8b1fdab22d7b Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 21 Feb 2019 14:10:54 +0100 Subject: [PATCH 3/5] en mode mysql upgrade la database en mode mysql --- posttemplate/90-one-db | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/posttemplate/90-one-db b/posttemplate/90-one-db index f3e3891..10496e3 100644 --- a/posttemplate/90-one-db +++ b/posttemplate/90-one-db @@ -33,7 +33,13 @@ function updateDB() if [[ -f ${dbfile} ]] then - $cmd upgrade -f -s ${dbfile} + if [ $(CreoleGet one_database_type) = "mysql" ]; then + if [ $(CreoleGet one_ha_server_index 0) = "0" ]; then + $cmd sqlite2mysql -u $USER -p $PASS -d $DB -S $HOST + fi + else + $cmd upgrade -f -s ${dbfile} + fi res=${?} clean_backups ${dbfile} return ${res} @@ -52,20 +58,20 @@ function to_mysql() { 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 + 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 + 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 -to_mysql exit ${?} From 7a779cdec472236f307936f1bb2e2cd15e3b1b93 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 21 Feb 2019 14:23:33 +0100 Subject: [PATCH 4/5] one_server_index => one_ha_server_index --- tmpl/oned.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmpl/oned.conf b/tmpl/oned.conf index e66d89c..4978570 100644 --- a/tmpl/oned.conf +++ b/tmpl/oned.conf @@ -156,7 +156,7 @@ FEDERATION = [ MODE = "STANDALONE", ZONE_ID = 0, %if %%activer_one_ha == 'oui' - SERVER_ID = %%one_server_index, + SERVER_ID = %%one_ha_server_index, %else SERVER_ID = -1, %end if From a785cedbf6b2461b95533e82a7417c631e9a588e Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 21 Feb 2019 14:31:49 +0100 Subject: [PATCH 5/5] tester si one_ha_server_index est accessible --- postservice/30-one-mng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postservice/30-one-mng b/postservice/30-one-mng index 55bfa4c..635f170 100755 --- a/postservice/30-one-mng +++ b/postservice/30-one-mng @@ -456,7 +456,7 @@ function init_ha() { function main() { wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null" - if [ "$(CreoleGet one_ha_server_index)" = "0" ]; then + if [ "$(CreoleGet activer_one_ha)" = "oui" ] && [ "$(CreoleGet one_ha_server_index)" = "0" ]; then init_ha fi #