Compare commits

..

No commits in common. "03ce27c7f2bd1f8981064426f843097ba9be7618" and "7a99473352619a375c61af38f035812377730ea5" have entirely different histories.

11 changed files with 104 additions and 139 deletions

View File

@ -4,8 +4,8 @@
SOURCE=eole-mariadb SOURCE=eole-mariadb
VERSION=0.0.1 VERSION=0.0.1
EOLE_VERSION=2.7 EOLE_VERSION=2.6
EOLE_RELEASE=2.7.1 EOLE_RELEASE=2.6.2
PKGAPPS=non PKGAPPS=non
#FLASK_MODULE=<APPLICATION> #FLASK_MODULE=<APPLICATION>

View File

@ -1,58 +1,5 @@
# eole-mariadb # eole-mariadb
Paquet porté pour la 2.7.1. Les tests n'ont été réalisé que sur un Eolebase.
La version utilisé est mariadb 10.3
Ajout de ce paquet sur une 2.7.1 :
## Add the Cadoles repository on all the nodes and the Leader
GenConfig [Mode Expert] -> Dépôts Tiers
* Libellé du dépôt : Cadoles dev
* Déclaration du dépôt : deb [ arch=all ] https://vulcain.cadoles.com 2.7.1-dev main
* Méthode de récupération de la clé publique du dépôt : URL de la clé
* URL de la clé : https://vulcain.cadoles.com/cadoles.gpg
## Add the MariaDB repository on all the nodes and the Leader
GenConfig (Mode Expert) -> Dépôt tiers :
* Libellé du dépôt : MariaDB
* Déclaration du dépôt : deb [ arch=amd64 ] http://mariadb.mirrors.ovh.net/MariaDB/repo/10.3/ubuntu bionic main
* Méthode de récupération de la clé publique du dépôt : serveur de clés
* URL du serveur de clés : hkp://keyserver.ubuntu.com:80
* Empreinte de la clé : 0xF1656F24C74CD1D8
#######################################################################
Paquet porté pour la 2.7.0. Les tests n'ont été réalisé que sur un Eolebase.
La version utilisé est mariadb 10.3
Ajout de ce paquet sur une 2.7.0 :
## Add the Cadoles repository on all the nodes and the Leader
GenConfig [Mode Expert] -> Dépôts Tiers
* Libellé du dépôt : Cadoles dev
* Déclaration du dépôt : deb [ arch=all ] https://vulcain.cadoles.com 2.7.0-dev main
* Méthode de récupération de la clé publique du dépôt : URL de la clé
* URL de la clé : https://vulcain.cadoles.com/cadoles.gpg
## Add the MariaDB repository on all the nodes and the Leader
GenConfig (Mode Expert) -> Dépôt tiers :
* Libellé du dépôt : MariaDB
* Déclaration du dépôt : deb [ arch=amd64 ] http://mariadb.mirrors.ovh.net/MariaDB/repo/10.3/ubuntu bionic main
* Méthode de récupération de la clé publique du dépôt : serveur de clés
* URL du serveur de clés : hkp://keyserver.ubuntu.com:80
* Empreinte de la clé : 0xF1656F24C74CD1D8
#######################################################################
Début des travaux pour l'utilisation de mariadb Début des travaux pour l'utilisation de mariadb
dans Eole avec des fonctionalitées avancées du type dans Eole avec des fonctionalitées avancées du type
mise en clustter mise en clustter

View File

@ -2,38 +2,39 @@
<files> <files>
<file filelist='dbMariaDB' name='/etc/mysql/conf.d/mariadb.cnf' rm='True' mkdir='True'/> <file filelist='dbMariaDB' name='/etc/mysql/conf.d/mariadb.cnf' rm='True' mkdir='True'/>
<file filelist='dbCluster' name='/etc/mysql/conf.d/galera.cnf' rm='True' mkdir='True'/> <file filelist='dbCluster' name='/etc/mysql/conf.d/galera.cnf' rm='True' mkdir='True'/>
<file filelist='dbTunning' name='/etc/mysql/conf.d/tunning.cnf' rm='True' mkdir='True'/>
<file filelist='dbTunning' name='/etc/mysql/conf.d/tunning.cnf' rm='True' mkdir='True'/>
<service servicelist='bdd'>mariadb</service> <service servicelist='bdd'>mariadb</service>
<service_access service='mariadb'> <service_access service='mariadb'>
<port protocol='tcp'>3306</port> <port service_accesslist='mariadb' protocol='tcp'>3306</port>
<tcpwrapper>mariadb</tcpwrapper> <tcpwrapper service_accesslist='mariadb'>mariadb</tcpwrapper>
</service_access> </service_access>
<service_restriction service='mariadb'>
<ip interface='ifMariaDBLimit' interface_type="SymLinkOption" netmask='maskMariaDBLimit' netmask_type='SymLinkOption' ip_type='SymLinkOption'>ipMariaDBLimit</ip>
</service_restriction>
<service_access service='galera'> <service_access service='galera'>
<port service_accesslist='dbCluster' protocol='tcp'>3306</port>
<port service_accesslist='dbCluster' protocol='tcp'>4444</port> <port service_accesslist='dbCluster' protocol='tcp'>4444</port>
<port service_accesslist='dbCluster' protocol='tcp'>4567</port> <port service_accesslist='dbCluster' protocol='tcp'>4567</port>
<port service_accesslist='dbCluster' protocol='tcp'>4568</port> <port service_accesslist='dbCluster' protocol='tcp'>4568</port>
<port service_accesslist='dbCluster' protocol='udp'>4567</port> <port service_accesslist='dbCluster' protocol='udp'>4567</port>
<tcpwrapper service_accesslist='mariadb'>mariadb</tcpwrapper>
</service_access> </service_access>
<service_restriction service='mariadb'>
<ip interface='ifMariaDBLimit' interface_type="SymLinkOption" netmask='maskMariaDBLimit' netmask_type='SymLinkOption' ip_type='SymLinkOption'>ipMariaDBLimit</ip>
</service_restriction>
<service_restriction service='galera'> <service_restriction service='galera'>
<ip interface='ifDBCluster' interface_type="SymLinkOption" netmask='255.255.255.255' ip_type='SymLinkOption'>dbClusterMember</ip> <ip interface='ifDBCluster' interface_type="SymLinkOption" netmask='255.255.255.255' ip_type='SymLinkOption'>dbClusterMemberIP</ip>
</service_restriction> </service_restriction>
</files> </files>
<variables> <variables>
<family name="Services"> <family name="Services">
<variable name="dbEnable" type='oui/non' description='Activer le serveur de base de données MariaDB'> <variable name="dbEnable" type='oui/non' description='Activer le serveur de base de données MariaDB'>
<value>oui</value> <value>non</value>
</variable> </variable>
<variable name="dbEnableBackup" type='oui/non' description='Activer la sauvegarde sur le serveur de base de données MariaDB'> <variable name="dbEnableBackup" type='oui/non' description='Activer la sauvegarde sur le serveur de base de données MariaDB'>
<value>non</value> <value>non</value>
</variable> </variable>
</family> </family>
<family name="MariaDB" icon='mysql-alt'> <family name="Database">
<variable name='dbEnableCluster' type='oui/non' description="Activer la mise en grappe MariaDB Galera ?"> <variable name='dbEnableCluster' type='oui/non' description="Activer la mise en grappe MariaDB Galera ?">
<value>non</value> <value>non</value>
</variable> </variable>
@ -49,17 +50,14 @@
<value>Default</value> <value>Default</value>
</variable> </variable>
<variable name="accLimitTarget" type="string" description="Restriction d'accès à ces IP/noms d'hôtes (liste séparateur séparateur ',')" /> <variable name="accLimitTarget" type="string" description="Restriction d'accès à ces IP/noms d'hôtes (liste séparateur séparateur ',')" />
<variable name="create_db" type='oui/non' description="Créer des bases de données">
<value>non</value> <variable name="dbClusterGcacheSizeMb" type="number" description="FIXME Gcachesize">
<value>128</value>
</variable> </variable>
</family> </family>
<family name="MariaDB Databases">
<variable name="db_name" type='string' description='Nom de la base de donnée' multi="True"/>
<variable name="db_admin_user" type='string' description="Nom de l'utilisateur gestionnaire de la base de données"/>
</family>
<!-- Tunning --> <!-- Tunning -->
<family name="MariaDB Tunning" mode="expert" icon='mysql-alt'> <family name="Database Tunning" mode="expert">
<variable name="dbInnoDBBufferPoolPercentage" type="number" description="Pourcentage de mémoire à dédier à MariaDB"> <variable name="dbInnoDBBufferPoolPercentage" type="number" description="Pourcentage de mémoire à dédier à MariaDB">
<value>20</value> <value>20</value>
</variable> </variable>
@ -116,15 +114,18 @@
</variable> </variable>
</family> </family>
<family name="Grappe MariaDB" icon='mysql-alt'> <family name="Database Cluster">
<variable name='dbClusterPosition' type='string' description="Rôle dans la grappe" mandatory='True'/> <variable name='dbClusterPosition' type='string' description="Rôle dans la grappe" mandatory='True'/>
<variable name='ifDBCluster' type='string' description="Interface réseau dédiée à la grappe BDD"/>
<!-- FIXME : Fill this variable with nom_machine -->
<variable name='nodeName' type='string' description="Nom du noeud local"/>
<variable name='dbClusterMember' type='string' description="Membre de la grappe BDD" multi='True'/>
<variable name='dbClusterMemberIP' type='ip' description="Adresse IP"/>
<!-- Expert Variables -->
<variable name='dbClusterName' type='string' description='Nom de la grappe'> <variable name='dbClusterName' type='string' description='Nom de la grappe'>
<value>galera_cluster</value> <value>galera_cluster</value>
</variable> </variable>
<variable name='ifDBCluster' type='string' description="Interface réseau dédiée à la grappe BDD" mandatory='True'/>
<variable name='dbClusterMember' type='domain' description="Nom de domaine des membres de la grappe" multi="True" mandatory='True'/>
<variable name="dbClusterMemberIndex" description="Index du serveur dans la liste des membres de la grappe" type="number" mandatory="True"/>
<!-- Expert Variables -->
<variable name='dbBinLogFormat' type='string' mode='expert' description='Format du binlog'> <variable name='dbBinLogFormat' type='string' mode='expert' description='Format du binlog'>
<value>ROW</value> <value>ROW</value>
</variable> </variable>
@ -134,28 +135,24 @@
<variable name='dbSSTMethod' type='string' mode='expert' description='Méthode SST'> <variable name='dbSSTMethod' type='string' mode='expert' description='Méthode SST'>
<value>rsync</value> <value>rsync</value>
</variable> </variable>
<variable name='dbClusterGcacheSizeMb' type='number' mode='expert' description="Write-set Cache Size (gcache.size)"> <variable name='dbClusterGcacheSize' type='number' mode='expert' description="Write-set Cache Size (gcache.size)">
<value>128</value> <value>128</value>
</variable> </variable>
<!-- End --> <!-- End -->
</family> </family>
<separators> <separators>
<separator name='dbCreateFixAdmin'>Comptes d'administration supplémentaires</separator> <separator name='dbCreateFixAdmin'>Comptes d'administration supplémentaires</separator>
<separator name='create_db'>Ajouter des bases de données</separator>
</separators> </separators>
</variables> </variables>
<constraints> <constraints>
<check name="valid_ipnetmask" target="maskMariaDBLimit" level="warning">
<param type='eole'>ipMariaDBLimit</param>
</check>
<check name='valid_enum' target='dbBinLogFormat'>
<param>['ROW', 'STATEMENT', 'MIXED', 'NONE']</param>
</check>
<check name='valid_enum' target='ifDBCluster'> <check name='valid_enum' target='ifDBCluster'>
<param>['eth0', 'eth1', 'eth2', 'eth3', 'eth4']</param> <param>['eth0', 'eth1', 'eth2', 'eth3', 'eth4']</param>
</check> </check>
<group master='dbClusterMember'>
<slave>dbClusterMemberIP</slave>
</group>
<check name='valid_enum' target='accLimits'> <check name='valid_enum' target='accLimits'>
<param>['Default','Custom']</param> <param>['Default','Custom']</param>
</check> </check>
@ -174,10 +171,6 @@
<slave>ifMariaDBLimit</slave> <slave>ifMariaDBLimit</slave>
</group> </group>
<group master='db_name'>
<slave>db_admin_user</slave>
</group>
<fill name='calc_multi_condition' target='accLimitTarget'> <fill name='calc_multi_condition' target='accLimitTarget'>
<param>Default</param> <param>Default</param>
<param type='eole' name='condition_1'>accLimits</param> <param type='eole' name='condition_1'>accLimits</param>
@ -187,20 +180,16 @@
<condition name='disabled_if_in' source="dbEnable"> <condition name='disabled_if_in' source="dbEnable">
<param>non</param> <param>non</param>
<target type='family'>MariaDB</target> <target type='family'>Database</target>
<!--target type='family'>Grappe MariaDB</target--> <target type='family'>Database Cluster</target>
<target type='family'>MariaDB Tunning</target> <target type='family'>Database Tunning</target>
<target type='service_accesslist'>dbCluster</target>
<target type='filelist'>dbTunning</target> <target type='filelist'>dbTunning</target>
<target type='filelist'>dbMariaDB</target> <target type='filelist'>dbMariaDB</target>
<!--target type='filelist'>dbCluster</target--> <target type='filelist'>dbCluster</target>
<target type='servicelist'>bdd</target> <target type='servicelist'>bdd</target>
</condition> </condition>
<condition name='disabled_if_in' source='create_db'>
<param>non</param>
<target type='family'>MariaDB Databases</target>
</condition>
<condition name='disabled_if_in' source="dbCreateFixAdmin"> <condition name='disabled_if_in' source="dbCreateFixAdmin">
<param>non</param> <param>non</param>
<target type='variable'>accName</target> <target type='variable'>accName</target>
@ -210,7 +199,7 @@
<condition name='disabled_if_in' source="dbEnableCluster"> <condition name='disabled_if_in' source="dbEnableCluster">
<param>non</param> <param>non</param>
<target type='family'>Grappe MariaDB</target> <target type='family'>Database Cluster</target>
<target type='service_accesslist'>dbCluster</target> <target type='service_accesslist'>dbCluster</target>
<target type='filelist'>dbCluster</target> <target type='filelist'>dbCluster</target>
</condition> </condition>

View File

@ -1,11 +0,0 @@
#!/bin/bash
set -e
if [[ "$1" == "instance" ]] && [[ "$(CreoleGet dbEnable)" == "oui" ]] && [[ "$(CreoleGet dbEnableCluster)" == "oui" ]] && [[ "$(CreoleGet dbClusterPosition)" == "Leader" ]]
then
service mariadb stop
galera_new_cluster
fi
exit 0

View File

@ -28,8 +28,6 @@ then
previousUsers=($(awk -F ':' '{print $1}' ${readerfile} )) previousUsers=($(awk -F ':' '{print $1}' ${readerfile} ))
index=0
for user in ${accounts[@]} for user in ${accounts[@]}
do do
PASS=$(awk -F ':' "/${user}:/ {print \$2}" ${readerfile}) PASS=$(awk -F ':' "/${user}:/ {print \$2}" ${readerfile})
@ -56,6 +54,7 @@ then
done done
fi fi
index=0
for hst in ${hostsList[@]} for hst in ${hostsList[@]}
do do
SQL="DROP USER IF EXISTS '${user}'@'${hst}';" SQL="DROP USER IF EXISTS '${user}'@'${hst}';"
@ -87,3 +86,4 @@ then
fi fi
exit 0 exit 0

20
posttemplate/25-bdd-cluster Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
db=$(CreoleGet dbEnable non)
cluster=$(CreoleGet dbEnableCluster non)
role=$(CreoleGet dbClusterPosition 'Node')
gstateFile="/var/lib/mysql/grastate.dat"
if [[ ${db} == "oui" ]]
then
if [[ ${cluster} == "oui" ]]
then
if [[ ${role} == "Leader" ]]
then
service mariadb stop
galera_new_cluster
fi
fi
fi
exit 0

View File

@ -1,19 +0,0 @@
#!/bin/bash
set -e
DESC="Exportation des bases MariaDB"
. /usr/share/eole/schedule/config.sh
MYSQLSAVDIR=$SAVDIR/sql
OPTION="--lock-tables"
if [[ -d ${MYSQLSAVDIR} ]]
then
rm -rf ${MYSQLSAVDIR}
mkdir -p ${MYSQLSAVDIR}
fi
mariabackup --defaults-file=/etc/mysql/debian.cnf --backup --target-dir=$MYSQLSAVDIR
exit $?

View File

@ -0,0 +1,7 @@
# Configuration commune aux scripts schedule
# Configuration de base modifiée pour copier dans le partage nfs plutôt que /home
SAVDIR=/mnt/sauvegardes/
# pour que l'affichage de [ ok ] soit ok
export TERM='dumb'
umask 0077

View File

@ -2,14 +2,14 @@
<creole> <creole>
<variables> <variables>
<family name="mariadb" description="Exportation des bases de données MariaDB"> <family name="mysql" description="Exportation des bases de données MySQL">
<variable name="description" type="string" hidden="True"><value>Exportation des bases MariaDB</value></variable> <variable name="description" type="string" hidden="True"><value>Exportation des bases MySQL</value></variable>
<variable name="day" type="schedule" description="Périodicité d'exécution"><value>daily</value></variable> <variable name="day" type="schedule" description="Périodicité d'exécution"><value>daily</value></variable>
<variable name="mode" type="schedulemod" hidden="True"><value>pre</value></variable> <variable name="mode" type="schedulemod" hidden="True"><value>pre</value></variable>
</family> </family>
</variables> </variables>
<constraints> <constraints>
<fill name='calc_multi_condition' target='schedule.mariadb.day'> <fill name='calc_multi_condition' target='schedule.mysql.day'>
<param>non</param> <param>non</param>
<param type='eole' name='condition_1'>dbEnableBackup</param> <param type='eole' name='condition_1'>dbEnableBackup</param>
<param name='match'>none</param> <param name='match'>none</param>

27
schedule_scripts/mysql Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
set -e
DESC="Exportation des bases MySQL"
. /usr/share/eole/schedule/config.sh
MYSQLSAVDIR=$SAVDIR/sql
OPTION="--lock-tables"
rm -f $MYSQLSAVDIR/*.sql
mkdir -p $MYSQLSAVDIR
CMD="mysql --defaults-file=/etc/mysql/mariadb.cnf -e 'show databases' | grep -v '^Database$'"
DATABASES=$(CreoleRun "$CMD" mysql)
for databasename in $DATABASES; do
case "$databasename" in
information_schema|performance_schema|bareos)
continue
;;
*)
CMD="mysqldump --defaults-file=/etc/mysql/mariadb.cnf --databases $databasename --flush-privileges --create-options -Q -c $OPTION 2>/dev/null"
CreoleRun "$CMD" mysql > $MYSQLSAVDIR/$databasename.sql
;;
esac
done

View File

@ -8,7 +8,12 @@ wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration # Galera Cluster Configuration
wsrep_cluster_name="%%dbClusterName" wsrep_cluster_name="%%dbClusterName"
wsrep_cluster_address="gcomm://%%custom_join(%%dbClusterMember, ',')" %set %%nodeIP = %%getVar('adresse_ip_' + %%ifDBCluster, '')
wsrep_cluster_address="gcomm://%%nodeIP%slurp
%for %%node in %%dbClusterMember
,%%node.dbClusterMemberIP%slurp
%end for
"
# Tunning # Tunning
wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb" wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb"
@ -17,5 +22,5 @@ wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb"
wsrep_sst_method=%%dbSSTMethod wsrep_sst_method=%%dbSSTMethod
# Galera Node Configuration # Galera Node Configuration
wsrep_node_address="%%getVar('adresse_ip_' + %%ifDBCluster)" wsrep_node_address="%%nodeIP"
wsrep_node_name="%%dbClusterMember[%%dbClusterMemberIndex] wsrep_node_name="%%nodeName"