Compare commits
5 Commits
33a7cf66c6
...
pkg/dev/eo
Author | SHA1 | Date | |
---|---|---|---|
2ba4b56d51 | |||
065308a921 | |||
21b93a3462 | |||
c540b65e08 | |||
5e9eae5c13 |
2
debian/control
vendored
2
debian/control
vendored
@ -10,7 +10,7 @@ Vcs-Browser: https://forge.cadoles.com/Cadoles/eole-mariadb
|
|||||||
|
|
||||||
Package: eole-mariadb
|
Package: eole-mariadb
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: ${misc:Depends}, mariadb-server, mariadb-backup
|
Depends: ${misc:Depends}, mariadb-server
|
||||||
Conflicts: eole-mysql
|
Conflicts: eole-mysql
|
||||||
Provides: eole-mysql
|
Provides: eole-mysql
|
||||||
Description: Dictionnaires et templates pour la configuration d'un serveur MariaDB, testée uniquement avec eolebase
|
Description: Dictionnaires et templates pour la configuration d'un serveur MariaDB, testée uniquement avec eolebase
|
||||||
|
@ -2,24 +2,25 @@
|
|||||||
<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'>dbClusterMember</ip>
|
||||||
</service_restriction>
|
</service_restriction>
|
||||||
@ -116,8 +117,9 @@
|
|||||||
<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='ifDBCluster' type='string' description="Interface réseau dédiée à la grappe BDD" mandatory='True'/>
|
||||||
|
<variable name='nodeName' type='domain' description="Nom de domaine du noeud" mandatory='True'/>
|
||||||
|
|
||||||
<variable name='dbClusterMember' type='domain' description="Nom de domaine des membres de la grappe" multi="True" 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 -->
|
<!-- 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>
|
||||||
@ -167,6 +169,9 @@
|
|||||||
<slave>ifMariaDBLimit</slave>
|
<slave>ifMariaDBLimit</slave>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
|
<fill name='calc_val' target='nodeName'>
|
||||||
|
<param type='eole'>nom_domaine_machine</param>
|
||||||
|
</fill>
|
||||||
<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>
|
||||||
@ -179,6 +184,7 @@
|
|||||||
<target type='family'>MariaDB</target>
|
<target type='family'>MariaDB</target>
|
||||||
<!--target type='family'>Grappe MariaDB</target-->
|
<!--target type='family'>Grappe MariaDB</target-->
|
||||||
<target type='family'>MariaDB Tunning</target>
|
<target type='family'>MariaDB 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-->
|
||||||
|
@ -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
|
|
@ -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
20
posttemplate/25-bdd-cluster
Executable 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
|
66
posttemplate/25-mariadb-passwd
Executable file
66
posttemplate/25-mariadb-passwd
Executable file
@ -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
|
||||||
|
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
|
@ -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 $?
|
|
7
schedule_config/config.sh
Normal file
7
schedule_config/config.sh
Normal 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
|
27
schedule_scripts/mariadb
Normal file
27
schedule_scripts/mariadb
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DESC="Exportation des bases MariaDB"
|
||||||
|
|
||||||
|
. /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/mariadbBackup.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/mariadbBackup.cnf --databases $databasename --flush-privileges --create-options -Q -c $OPTION 2>/dev/null"
|
||||||
|
CreoleRun "$CMD" mysql > $MYSQLSAVDIR/$databasename.sql
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
@ -8,7 +8,7 @@ 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, ',')"
|
wsrep_cluster_address="gcomm://%%nodeName,%%custom_join(%%dbClusterMember, ',')"
|
||||||
|
|
||||||
# Tunning
|
# Tunning
|
||||||
wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb"
|
wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb"
|
||||||
@ -18,4 +18,4 @@ wsrep_sst_method=%%dbSSTMethod
|
|||||||
|
|
||||||
# Galera Node Configuration
|
# Galera Node Configuration
|
||||||
wsrep_node_address="%%getVar('adresse_ip_' + %%ifDBCluster)"
|
wsrep_node_address="%%getVar('adresse_ip_' + %%ifDBCluster)"
|
||||||
wsrep_node_name="%%dbClusterMember[%%dbClusterMemberIndex]
|
wsrep_node_name="%%nodeName"
|
||||||
|
Reference in New Issue
Block a user