demarrer une fois opennebula pour creer la base sqlite + migrer mysql avant le demarrage des services

This commit is contained in:
Emmanuel Garette 2019-02-18 17:39:41 +01:00
parent 79b5d8e86d
commit a71da62006
3 changed files with 45 additions and 38 deletions

View File

@ -433,7 +433,7 @@ function init_ha() {
# server 0 not displayed with onezone # server 0 not displayed with onezone
SERVER=$(CreoleGet one_master) SERVER=$(CreoleGet one_master)
DOMAIN=$(CreoleGet nom_domaine_machine) DOMAIN=$(CreoleGet nom_domaine_machine)
FOLLOWER=$(CreoleGet one_follower_servername) FOLLOWER=$(CreoleGet one_followers_domain)
onezone server-add 0 --name $SERVER --rpc http://$DOMAIN:2633/RPC2 onezone server-add 0 --name $SERVER --rpc http://$DOMAIN:2633/RPC2
for $follower in $FOLLOWER; do for $follower in $FOLLOWER; do
onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2 onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2
@ -441,26 +441,12 @@ function init_ha() {
fi fi
} }
function to_mysql() {
if [ $(CreoleGet one_database_type) = "mysql" && $(CreoleGet one_ha_role leader) = "leader" ]; 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)
onedb sqlite2mysql -s /var/lib/one/one.db -u $USER -p $PASS -d $DB -S $HOST
systemctl stop opennebula.service
systemctl start opennebula.service
fi
}
function main() function main()
{ {
wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null" 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) = "leader" ]; then
init_ha init_ha
fi fi
to_mysql
# #
# Rename default cluster # Rename default cluster
clst_name=$(CreoleGet one_cluster_name) clst_name=$(CreoleGet one_cluster_name)

View File

@ -41,9 +41,25 @@ function updateDB()
fi fi
} }
function to_mysql() {
if [ $(CreoleGet one_database_type) = "mysql" ] && [ $(CreoleGet one_ha_role leader) = "leader" ]; then
Question_ouinon "Voulez-vous migrer de SQLite à Mysql ?" "True" "non" "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)
onedb sqlite2mysql -s /var/lib/one/one.db -u $USER -p $PASS -d $DB -S $HOST
fi
fi
}
echo echo
EchoGras "Mise à jour de la base de données ONE" EchoGras "Mise à jour de la base de données ONE"
echo echo
updateDB updateDB
echo echo
to_mysql
exit ${?} exit ${?}

View File

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