Commit dbe2fe25 authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

Added GTID configuration through CWMP

parent 4e47fb66
......@@ -145,6 +145,9 @@ define MARIADB_CONFIG
config wsrep 'galera'
option cluster_address ''
option cluster_options ''
option server_id ''
option wsrep_gtid_domain_id ''
option gtid_domain_id ''
endef
export MARIADB_CONFIG
......
......@@ -20,6 +20,9 @@ entry_execute_method_root_MySQL() {
common_execute_method_param "$DMROOT.MySQL.GaleraBootstrap" "1" "" "mysql_galera_bootstrap" "xsd:boolean"
common_execute_method_param "$DMROOT.MySQL.GaleraClusterAddress" "1" "mysql_get_cluster_address" "mysql_set_cluster_address"
common_execute_method_param "$DMROOT.MySQL.GaleraClusterOptions" "1" "mysql_get_cluster_options" "mysql_set_cluster_options"
common_execute_method_param "$DMROOT.MySQL.ServerID" "1" "mysql_get_server_id" "mysql_set_server_id"
common_execute_method_param "$DMROOT.MySQL.WSREPGTIDdomainID" "1" "mysql_get_wsrep_gtid_domain_id" "mysql_set_wsrep_gtid_domain_id"
common_execute_method_param "$DMROOT.MySQL.GTIDdomainID" "1" "mysql_get_gtid_domain_id" "mysql_set_gtid_domain_id"
return 0;
;;
esac
......@@ -96,3 +99,45 @@ mysql_set_cluster_options() {
systemctl restart mariadb
fi
}
mysql_get_server_id() {
echo `$UCI_GET mariadb.galera.server_id`
}
mysql_set_server_id() {
local server_id=`$UCI_GET mariadb.galera.server_id`
if [ "$server_id" != "$1" ]; then
$UCI_SET mariadb.galera.server_id="$1"
$UCI_COMMIT
wsrep-init
systemctl restart mariadb
fi
}
mysql_get_wsrep_gtid_domain_id() {
echo `$UCI_GET mariadb.galera.wsrep_gtid_domain_id`
}
mysql_set_wsrep_gtid_domain_id() {
local wsrep_gtid_domain_id=`$UCI_GET mariadb.galera.wsrep_gtid_domain_id`
if [ "$wsrep_gtid_domain_id" != "$1" ]; then
$UCI_SET mariadb.galera.wsrep_gtid_domain_id="$1"
$UCI_COMMIT
wsrep-init
systemctl restart mariadb
fi
}
mysql_get_gtid_domain_id() {
echo `$UCI_GET mariadb.galera.gtid_domain_id`
}
mysql_set_gtid_domain_id() {
local gtid_domain_id=`$UCI_GET mariadb.galera.gtid_domain_id`
if [ "$gtid_domain_id" != "$1" ]; then
$UCI_SET mariadb.galera.gtid_domain_id="$1"
$UCI_COMMIT
wsrep-init
systemctl restart mariadb
fi
}
......@@ -4,6 +4,9 @@ UCI_GET="/sbin/uci -q get"
ADDRESS=`$UCI_GET mariadb.galera.cluster_address`
OPTIONS=`$UCI_GET mariadb.galera.cluster_options`
SERVER_ID=`$UCI_GET mariadb.galera.server_id`
WSREP_GTID=`$UCI_GET mariadb.galera.wsrep_gtid_domain_id`
GTID=`$UCI_GET mariadb.galera.gtid_domain_id`
if [ ! -z $ADDRESS ]; then
cat << EOF > /run/mysqld/wsrep.conf
[mysqld]
......@@ -17,6 +20,17 @@ EOF
if [ ! -z "$OPTIONS" ]; then
echo "wsrep_provider_options = $OPTIONS" >> /run/mysqld/wsrep.conf
fi
if [ ! -z "$SERVER_ID" ]; then
echo "server_id = $SERVER_ID" >> /run/mysqld/wsrep.conf
fi
if [ ! -z "$WSREP_GTID" ]; then
echo "wsrep_gtid_mode = ON" >> /run/mysqld/wsrep.conf
echo "wsrep_gtid_domain_id = $WSREP_GTID" >> /run/mysqld/wsrep.conf
echo "log_slave_updates = ON" >> /run/mysqld/wsrep.conf
fi
if [ ! -z "$GTID" ]; then
echo "gtid_domain_id = $GTID" >> /run/mysqld/wsrep.conf
fi
chown mysql.mysql /run/mysqld/wsrep.conf
else
rm -f /run/mysqld/wsrep.conf
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment