From 4dd7e78f7cb085eb6aed2f02674ca36752cf82f6 Mon Sep 17 00:00:00 2001 From: vincent Date: Thu, 14 Feb 2019 10:04:09 +0100 Subject: [PATCH 01/10] MAJ du README pour la 2.7.0 --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index bd34617..a0b97ae 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,32 @@ # eole-mariadb +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 dans Eole avec des fonctionalitées avancées du type mise en clustter From d84efbfaa4b9afe86f8339204f5efacb1b7f393f Mon Sep 17 00:00:00 2001 From: vincent Date: Fri, 15 Feb 2019 11:04:05 +0100 Subject: [PATCH 02/10] =?UTF-8?q?retour=20au=20sauvegarde=20Bareos=20pour?= =?UTF-8?q?=20incompatibilit=C3=A9=20Xtrabackup,=20personnalisation=20des?= =?UTF-8?q?=20sauvegardes=20pour=20MaraiDB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- schedule_extra/{01_mysql.xml => 01_mariadb.xml} | 6 +++--- schedule_scripts/{mysql => mariadb} | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename schedule_extra/{01_mysql.xml => 01_mariadb.xml} (74%) rename schedule_scripts/{mysql => mariadb} (60%) diff --git a/schedule_extra/01_mysql.xml b/schedule_extra/01_mariadb.xml similarity index 74% rename from schedule_extra/01_mysql.xml rename to schedule_extra/01_mariadb.xml index cd4118c..0d6fdf9 100644 --- a/schedule_extra/01_mysql.xml +++ b/schedule_extra/01_mariadb.xml @@ -2,14 +2,14 @@ - - + + daily - + non dbEnableBackup none diff --git a/schedule_scripts/mysql b/schedule_scripts/mariadb similarity index 60% rename from schedule_scripts/mysql rename to schedule_scripts/mariadb index 06b3ff9..0dda3ea 100644 --- a/schedule_scripts/mysql +++ b/schedule_scripts/mariadb @@ -2,7 +2,7 @@ set -e -DESC="Exportation des bases MySQL" +DESC="Exportation des bases MariaDB" . /usr/share/eole/schedule/config.sh @@ -12,7 +12,7 @@ OPTION="--lock-tables" rm -f $MYSQLSAVDIR/*.sql mkdir -p $MYSQLSAVDIR -CMD="mysql --defaults-file=/etc/mysql/mariadb.cnf -e 'show databases' | grep -v '^Database$'" +CMD="mysql --defaults-file=/etc/mysql/mariadbBackup.cnf -e 'show databases' | grep -v '^Database$'" DATABASES=$(CreoleRun "$CMD" mysql) for databasename in $DATABASES; do case "$databasename" in @@ -20,7 +20,7 @@ for databasename in $DATABASES; do continue ;; *) - CMD="mysqldump --defaults-file=/etc/mysql/mariadb.cnf --databases $databasename --flush-privileges --create-options -Q -c $OPTION 2>/dev/null" + CMD="mysqldump --defaults-file=/etc/mysql/mariadbBackup.cnf --databases $databasename --flush-privileges --create-options -Q -c $OPTION 2>/dev/null" CreoleRun "$CMD" mysql > $MYSQLSAVDIR/$databasename.sql ;; esac From f65fc173323025ecc70cd88bb877604b80c0b2db Mon Sep 17 00:00:00 2001 From: vincent Date: Fri, 15 Feb 2019 17:26:49 +0100 Subject: [PATCH 03/10] =?UTF-8?q?script=20cr=C3=A9ation=20maria-sys=20pour?= =?UTF-8?q?=20les=20sauvegardes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- posttemplate/25-mariadb-passwd | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 posttemplate/25-mariadb-passwd diff --git a/posttemplate/25-mariadb-passwd b/posttemplate/25-mariadb-passwd new file mode 100755 index 0000000..cf7ab71 --- /dev/null +++ b/posttemplate/25-mariadb-passwd @@ -0,0 +1,66 @@ +#!/bin/bash + +systemctl stop mariadb + +mariadb_cfdir=/etc/mysql/ +dc=$mysql_cfgdir/mariadbBackup.cnf +mariadb_rundir=/var/run/mysqld/ +mariadb_statedir=/var/lib/mysql + +if [ -e "$dc" -a -n "`fgrep mysql_upgrade $dc 2>/dev/null`" ]; then + pass="`sed -n 's/^[ ]*password *= *// p' $dc | head -n 1`" + # Basedir is deprecated. Remove the option if it's in an existing mariadbBackup.cnf + sed -i '/basedir/d' "$dc" +else + pass=`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)'`; + if [ ! -d "$mariadb_cfdir" ]; then + then install -o 0 -g 0 -m 0755 -d $mariadb_cfdir + fi + umask 066 + cat /dev/null > $dc + umask 022 + echo "# Automatically generated DONT'T TOUCH !!!!!!" >>$dc + echo "[client]" >>$dc + echo "host = localhost" >>$dc + echo "user = maria-sys-maint" >>$dc + echo "password = $pass" >>$dc + echo "socket = $mariadb_rundir/mysqld.sock" >>$dc + echo "[mysql_upgrade]" >>$dc + echo "host = localhost" >>$dc + echo "user = maria-sys-maint" >>$dc + echo "password = $pass" >>$dc + echo "socket = $mariadb_rundir/mysqld.sock" >>$dc +fi + +# If this dir chmod go+w then the admin did it. But this file should not. + chown 0:0 $dc + chmod 0600 $dc + +# If database doesn't exist we create it. +mkdir /var/lib/mariadb-files +mariadb_filesdir=/var/lib/mariadb-files + +if [ ! "$(ls -A "${mariadb_statedir}")" ] && [ -d "${mariadb_filesdir}" ]; then + existingdatabase=0 + initfile=`mktemp --tmpdir=/var/lib/mariadb-files/` + touch "$initfile" + chmod 600 "$initfile" + chown mysql:mysql "$initfile" + echo "USE mysql; " >> "$initfile" + db_get mysql-server/root_password && rootpw="$RET" + if [ ! -z "$rootpw" ]; then + rootpw=$(printf %q "${rootpw}") + echo "ALTER USER 'root'@'localhost' IDENTIFIED BY '$rootpw';" >> "$initfile" + fi + echo "CREATE USER IF NOT EXISTS 'maria-sys-maint'@'localhost' IDENTIFIED BY '$pass';" >> "$initfile" + echo "GRANT ALL ON *.* TO 'maria-sys-maint'@'localhost' WITH GRANT OPTION;" >> "$initfile" + echo "SHUTDOWN;" >> "$initfile" + mysqld --initialize-insecure --user=mysql --init-file="$initfile"> /dev/null 2>&1 || true + rm "$initfile" +else + existingdatabase=1 +fi + +systemctl start mariadb + +exit 0 From be45f4e3fabd6beba5083d0ec96384ff54469e4b Mon Sep 17 00:00:00 2001 From: vincent Date: Tue, 19 Feb 2019 10:02:40 +0100 Subject: [PATCH 04/10] =?UTF-8?q?ajout=20d'un=20warning=20sur=20les=20netm?= =?UTF-8?q?ask=20des=20ip=20des=20connexions=20autoris=C3=A9es=20=C3=A0=20?= =?UTF-8?q?la=20BDD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dicos/25_bdd_server.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dicos/25_bdd_server.xml b/dicos/25_bdd_server.xml index 9376818..d82d563 100644 --- a/dicos/25_bdd_server.xml +++ b/dicos/25_bdd_server.xml @@ -145,6 +145,10 @@ + + ipMariaDBLimit + + ['eth0', 'eth1', 'eth2', 'eth3', 'eth4'] From 5817d9aee4b994396eec1dd2458015b5ee120c35 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 19 Feb 2019 16:37:00 +0100 Subject: [PATCH 05/10] simplification + nom de domaine plutot que IP --- dicos/25_bdd_server.xml | 47 +++++++++++++++++++---------------------- tmpl/galera.cnf | 11 +++------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/dicos/25_bdd_server.xml b/dicos/25_bdd_server.xml index d82d563..4cd01ca 100644 --- a/dicos/25_bdd_server.xml +++ b/dicos/25_bdd_server.xml @@ -28,13 +28,13 @@ - non + oui non - + non @@ -51,13 +51,10 @@ - - 128 - - + 20 @@ -114,18 +111,16 @@ - + - - - - - - - galera_cluster + + + + + ROW @@ -135,7 +130,7 @@ rsync - + 128 @@ -149,14 +144,13 @@ ipMariaDBLimit + + ['ROW', 'STATEMENT', 'MIXED', 'NONE'] + ['eth0', 'eth1', 'eth2', 'eth3', 'eth4'] - - dbClusterMemberIP - - ['Default','Custom'] @@ -175,6 +169,9 @@ ifMariaDBLimit + + nom_domaine_machine + Default accLimits @@ -184,13 +181,13 @@ non - Database - Database Cluster - Database Tunning - dbCluster + MariaDB + + MariaDB Tunning + dbTunning dbMariaDB - dbCluster + bdd @@ -203,7 +200,7 @@ non - Database Cluster + Grappe MariaDB dbCluster dbCluster diff --git a/tmpl/galera.cnf b/tmpl/galera.cnf index 94cab58..e455286 100644 --- a/tmpl/galera.cnf +++ b/tmpl/galera.cnf @@ -8,12 +8,7 @@ wsrep_on=ON wsrep_provider=/usr/lib/galera/libgalera_smm.so # Galera Cluster Configuration wsrep_cluster_name="%%dbClusterName" -%set %%nodeIP = %%getVar('adresse_ip_' + %%ifDBCluster, '') -wsrep_cluster_address="gcomm://%%nodeIP%slurp -%for %%node in %%dbClusterMember -,%%node.dbClusterMemberIP%slurp -%end for -" +wsrep_cluster_address="gcomm://%%nodeName,%%custom_join(%%dbClusterMember, ',')" # Tunning wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb" @@ -22,5 +17,5 @@ wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb" wsrep_sst_method=%%dbSSTMethod # Galera Node Configuration -wsrep_node_address="%%nodeIP" -wsrep_node_name="%%nodeName" \ No newline at end of file +wsrep_node_address="%%getVar('adresse_ip_' + %%ifDBCluster)" +wsrep_node_name="%%nodeName" From 7800e9e20a0459c5a89fba9b53d90891ce8e9ed6 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 19 Feb 2019 16:51:14 +0100 Subject: [PATCH 06/10] corrections --- dicos/25_bdd_server.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dicos/25_bdd_server.xml b/dicos/25_bdd_server.xml index 4cd01ca..f151ba1 100644 --- a/dicos/25_bdd_server.xml +++ b/dicos/25_bdd_server.xml @@ -22,7 +22,7 @@ - dbClusterMemberIP + dbClusterMember @@ -119,7 +119,7 @@ - + ROW @@ -144,7 +144,7 @@ ipMariaDBLimit - + ['ROW', 'STATEMENT', 'MIXED', 'NONE'] @@ -169,7 +169,7 @@ ifMariaDBLimit - + nom_domaine_machine From 94fc8c241162fa9a982bfbb5980049ed7f07b46a Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 19 Feb 2019 17:21:46 +0100 Subject: [PATCH 07/10] multi --- dicos/25_bdd_server.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dicos/25_bdd_server.xml b/dicos/25_bdd_server.xml index f151ba1..5292cc4 100644 --- a/dicos/25_bdd_server.xml +++ b/dicos/25_bdd_server.xml @@ -116,10 +116,10 @@ galera_cluster - - + + - + ROW From 921e6b01a16dad9a3fa4cdd2b21d967be36df260 Mon Sep 17 00:00:00 2001 From: vincent Date: Fri, 1 Mar 2019 15:35:42 +0100 Subject: [PATCH 08/10] =?UTF-8?q?coorection=20script=20cr=C3=A9ation=20use?= =?UTF-8?q?r=20maria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- posttemplate/25-mariadb-passwd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posttemplate/25-mariadb-passwd b/posttemplate/25-mariadb-passwd index cf7ab71..f97b535 100755 --- a/posttemplate/25-mariadb-passwd +++ b/posttemplate/25-mariadb-passwd @@ -14,7 +14,7 @@ if [ -e "$dc" -a -n "`fgrep mysql_upgrade $dc 2>/dev/null`" ]; then else pass=`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)'`; if [ ! -d "$mariadb_cfdir" ]; then - then install -o 0 -g 0 -m 0755 -d $mariadb_cfdir + install -o 0 -g 0 -m 0755 -d $mariadb_cfdir fi umask 066 cat /dev/null > $dc From 796b71a992208bd0d76c1eb6bb1b8d6c18820107 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 4 Mar 2019 09:54:28 +0100 Subject: [PATCH 09/10] =?UTF-8?q?simplication=20d=C3=A9claration=20des=20n?= =?UTF-8?q?oeuds=20+=20ajustement=20r=C3=A8gle=20de=20firewall=20+=20d?= =?UTF-8?q?=C3=A9marrer=20mariadb=20en=20postservice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dicos/25_bdd_server.xml | 28 +++++++++++----------------- postservice/00-bdd-cluster | 11 +++++++++++ posttemplate/25-bdd-cluster | 20 -------------------- tmpl/galera.cnf | 4 ++-- 4 files changed, 24 insertions(+), 39 deletions(-) create mode 100755 postservice/00-bdd-cluster delete mode 100755 posttemplate/25-bdd-cluster diff --git a/dicos/25_bdd_server.xml b/dicos/25_bdd_server.xml index 5292cc4..62540d0 100644 --- a/dicos/25_bdd_server.xml +++ b/dicos/25_bdd_server.xml @@ -2,25 +2,24 @@ - + mariadb - 3306 - mariadb + 3306 + mariadb - - 4444 - 4567 - 4568 - 4567 - mariadb - - ipMariaDBLimit + + 3306 + 4444 + 4567 + 4568 + 4567 + dbClusterMember @@ -117,9 +116,8 @@ galera_cluster - - + ROW @@ -169,9 +167,6 @@ ifMariaDBLimit - - nom_domaine_machine - Default accLimits @@ -184,7 +179,6 @@ MariaDB MariaDB Tunning - dbTunning dbMariaDB diff --git a/postservice/00-bdd-cluster b/postservice/00-bdd-cluster new file mode 100755 index 0000000..7f9cf0c --- /dev/null +++ b/postservice/00-bdd-cluster @@ -0,0 +1,11 @@ +#!/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 diff --git a/posttemplate/25-bdd-cluster b/posttemplate/25-bdd-cluster deleted file mode 100755 index 1b56ee3..0000000 --- a/posttemplate/25-bdd-cluster +++ /dev/null @@ -1,20 +0,0 @@ -#!/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 \ No newline at end of file diff --git a/tmpl/galera.cnf b/tmpl/galera.cnf index e455286..8040ea8 100644 --- a/tmpl/galera.cnf +++ b/tmpl/galera.cnf @@ -8,7 +8,7 @@ wsrep_on=ON wsrep_provider=/usr/lib/galera/libgalera_smm.so # Galera Cluster Configuration wsrep_cluster_name="%%dbClusterName" -wsrep_cluster_address="gcomm://%%nodeName,%%custom_join(%%dbClusterMember, ',')" +wsrep_cluster_address="gcomm://%%dbClusterMember # Tunning wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb" @@ -18,4 +18,4 @@ wsrep_sst_method=%%dbSSTMethod # Galera Node Configuration wsrep_node_address="%%getVar('adresse_ip_' + %%ifDBCluster)" -wsrep_node_name="%%nodeName" +wsrep_node_name="%%dbClusterMember[%%dbClusterMemberIndex] From 4ee18114f4d582516eeff13b5b1e579483e731cb Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 4 Mar 2019 12:07:36 +0100 Subject: [PATCH 10/10] erreur template --- posttemplate/25-mariadb-passwd | 66 ---------------------------------- tmpl/galera.cnf | 2 +- 2 files changed, 1 insertion(+), 67 deletions(-) delete mode 100755 posttemplate/25-mariadb-passwd diff --git a/posttemplate/25-mariadb-passwd b/posttemplate/25-mariadb-passwd deleted file mode 100755 index f97b535..0000000 --- a/posttemplate/25-mariadb-passwd +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash - -systemctl stop mariadb - -mariadb_cfdir=/etc/mysql/ -dc=$mysql_cfgdir/mariadbBackup.cnf -mariadb_rundir=/var/run/mysqld/ -mariadb_statedir=/var/lib/mysql - -if [ -e "$dc" -a -n "`fgrep mysql_upgrade $dc 2>/dev/null`" ]; then - pass="`sed -n 's/^[ ]*password *= *// p' $dc | head -n 1`" - # Basedir is deprecated. Remove the option if it's in an existing mariadbBackup.cnf - sed -i '/basedir/d' "$dc" -else - pass=`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)'`; - if [ ! -d "$mariadb_cfdir" ]; then - install -o 0 -g 0 -m 0755 -d $mariadb_cfdir - fi - umask 066 - cat /dev/null > $dc - umask 022 - echo "# Automatically generated DONT'T TOUCH !!!!!!" >>$dc - echo "[client]" >>$dc - echo "host = localhost" >>$dc - echo "user = maria-sys-maint" >>$dc - echo "password = $pass" >>$dc - echo "socket = $mariadb_rundir/mysqld.sock" >>$dc - echo "[mysql_upgrade]" >>$dc - echo "host = localhost" >>$dc - echo "user = maria-sys-maint" >>$dc - echo "password = $pass" >>$dc - echo "socket = $mariadb_rundir/mysqld.sock" >>$dc -fi - -# If this dir chmod go+w then the admin did it. But this file should not. - chown 0:0 $dc - chmod 0600 $dc - -# If database doesn't exist we create it. -mkdir /var/lib/mariadb-files -mariadb_filesdir=/var/lib/mariadb-files - -if [ ! "$(ls -A "${mariadb_statedir}")" ] && [ -d "${mariadb_filesdir}" ]; then - existingdatabase=0 - initfile=`mktemp --tmpdir=/var/lib/mariadb-files/` - touch "$initfile" - chmod 600 "$initfile" - chown mysql:mysql "$initfile" - echo "USE mysql; " >> "$initfile" - db_get mysql-server/root_password && rootpw="$RET" - if [ ! -z "$rootpw" ]; then - rootpw=$(printf %q "${rootpw}") - echo "ALTER USER 'root'@'localhost' IDENTIFIED BY '$rootpw';" >> "$initfile" - fi - echo "CREATE USER IF NOT EXISTS 'maria-sys-maint'@'localhost' IDENTIFIED BY '$pass';" >> "$initfile" - echo "GRANT ALL ON *.* TO 'maria-sys-maint'@'localhost' WITH GRANT OPTION;" >> "$initfile" - echo "SHUTDOWN;" >> "$initfile" - mysqld --initialize-insecure --user=mysql --init-file="$initfile"> /dev/null 2>&1 || true - rm "$initfile" -else - existingdatabase=1 -fi - -systemctl start mariadb - -exit 0 diff --git a/tmpl/galera.cnf b/tmpl/galera.cnf index 8040ea8..28dbcbf 100644 --- a/tmpl/galera.cnf +++ b/tmpl/galera.cnf @@ -8,7 +8,7 @@ wsrep_on=ON wsrep_provider=/usr/lib/galera/libgalera_smm.so # Galera Cluster Configuration wsrep_cluster_name="%%dbClusterName" -wsrep_cluster_address="gcomm://%%dbClusterMember +wsrep_cluster_address="gcomm://%%custom_join(%%dbClusterMember, ',')" # Tunning wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb"