From 227f568aabffb85312e31739a7cf271000151fb0 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 8 Feb 2019 17:43:22 +0100 Subject: [PATCH] prise en compte mysql + script init ha --- dicos/29_one-master.xml | 28 ++++++++++++++-------------- dicos/30_one-master-ha.xml | 8 ++++---- scripts/one_ha_init | 12 ++++++++++++ tmpl/oned.conf | 18 ++++++++++-------- 4 files changed, 40 insertions(+), 26 deletions(-) create mode 100755 scripts/one_ha_init diff --git a/dicos/29_one-master.xml b/dicos/29_one-master.xml index 725a18e..28f982a 100644 --- a/dicos/29_one-master.xml +++ b/dicos/29_one-master.xml @@ -46,20 +46,20 @@ - + sqlite - - + + 3306 - + onedb - + one - + - + @@ -27,17 +27,17 @@ non - ONE HA + Haute disponibilité Active la possibilité d'intégrer Hâpy dans une grappe de haute disponibilité OpenNebula - Configuration du comportement du noeud dans la grappe + 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 Identifiant unique du serveur dans la grappe, cet identifiant est un entier (0,1,2,3...) - Addresse IP Virtuelle (VIP) utilisée pour joindre le "Leader" de la grappe, les clients utiliseront cette IP pour contacter 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/scripts/one_ha_init b/scripts/one_ha_init new file mode 100755 index 0000000..b498139 --- /dev/null +++ b/scripts/one_ha_init @@ -0,0 +1,12 @@ +SERVER=$(CreoleGet one_master) +IP=$(CreoleGet adresse_ip_eth0) +if [ $(CreoleGet one_database_type) = "mysql" && $(CreoleGet one_ha_role) = "leader" ]; then + HOST=$(CreoleGet one_database_host) + DB=$(CreoleGet one_database_name) + USER=$(CreoleGet one_database_user) + PASS=$(CreoleGet one_database_pass) + onedb sqlite2mysql -s /var/lib/one/one.db -u $USER -p $PASS -d $DB -S $HOST + systemctl stop opennebula + systemctl start opennebula +fi +onezone server-add 0 --name $SERVER --rpc http://$IP:2633/RPC2 diff --git a/tmpl/oned.conf b/tmpl/oned.conf index 4ae093f..72f8ab3 100644 --- a/tmpl/oned.conf +++ b/tmpl/oned.conf @@ -80,16 +80,18 @@ PORT = 2633 LISTEN_ADDRESS = "127.0.0.1" +%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 = 50 ] +%end if VNC_PORTS = [ START = 5900