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/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 e455286..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://%%nodeName,%%custom_join(%%dbClusterMember, ',')" +wsrep_cluster_address="gcomm://%%custom_join(%%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]