demarrer une fois opennebula pour creer la base sqlite + migrer mysql avant le demarrage des services
This commit is contained in:
parent
79b5d8e86d
commit
a71da62006
|
@ -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)
|
||||||
|
|
|
@ -9,36 +9,51 @@
|
||||||
|
|
||||||
function clean_backups()
|
function clean_backups()
|
||||||
{
|
{
|
||||||
file=${1}
|
file=${1}
|
||||||
bcks=($(ls ${file}_*))
|
bcks=($(ls ${file}_*))
|
||||||
nbbck=$(expr ${#bcks[@]} - 2)
|
nbbck=$(expr ${#bcks[@]} - 2)
|
||||||
|
|
||||||
|
|
||||||
if [[ ${nbbck} -gt 1 ]]
|
if [[ ${nbbck} -gt 1 ]]
|
||||||
then
|
then
|
||||||
EchoGras "Cleaning up old backups !"
|
EchoGras "Cleaning up old backups !"
|
||||||
for idx in `seq 0 ${nbbck}`
|
for idx in `seq 0 ${nbbck}`
|
||||||
do
|
do
|
||||||
rm -f ${bcks[${idx}]}
|
rm -f ${bcks[${idx}]}
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDB()
|
function updateDB()
|
||||||
{
|
{
|
||||||
local dbfile='/var/lib/one/one.db'
|
local dbfile='/var/lib/one/one.db'
|
||||||
local cmd="onedb"
|
local cmd="onedb"
|
||||||
local res=0
|
local res=0
|
||||||
|
|
||||||
if [[ -f ${dbfile} ]]
|
if [[ -f ${dbfile} ]]
|
||||||
then
|
then
|
||||||
$cmd upgrade -f -s ${dbfile}
|
$cmd upgrade -f -s ${dbfile}
|
||||||
res=${?}
|
res=${?}
|
||||||
clean_backups ${dbfile}
|
clean_backups ${dbfile}
|
||||||
return ${res}
|
return ${res}
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
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
|
||||||
|
@ -46,4 +61,5 @@ EchoGras "Mise à jour de la base de données ONE"
|
||||||
echo
|
echo
|
||||||
updateDB
|
updateDB
|
||||||
echo
|
echo
|
||||||
|
to_mysql
|
||||||
exit ${?}
|
exit ${?}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue