@@ -103,6 +103,24 @@ function create_maxscale_user() {
103103 fi
104104}
105105
106+ //TODO:
107+ # function create_maxscale_confsync_user() {
108+ # log "INFO" "Checking whether maxscale user exist or not......"
109+ # local mysql="$mysql_header --host=$localhost"
110+ # # At first, ensure that the command executes without any error. Then, run the command again and extract the output.
111+ # retry 120 ${mysql} -N -e "select count(host) from mysql.user where mysql.user.user='maxscale_confsync';" | awk '{print$1}'
112+ # out=$(${mysql} -N -e "select count(host) from mysql.user where mysql.user.user='maxscale_confsync';" | awk '{print$1}')
113+ # # if the user doesn't exist, crete new one.
114+ # if [[ "$out" -eq "0" ]]; then
115+ # log "INFO" "maxscale_confsync user not found. Creating new maxscale_confsync user........"
116+ # retry 120 ${mysql} -N -e "SET SQL_LOG_BIN=0;CREATE USER 'maxscale_confsync'@'%' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD';"
117+ # retry 120 ${mysql} -N -e "SET SQL_LOG_BIN=0;GRANT SELECT, INSERT, UPDATE, CREATE ON mysql.maxscale_config TO maxscale_confsync@'%';"
118+ # retry 120 ${mysql} -N -e "SET SQL_LOG_BIN=0;FLUSH PRIVILEGES;"
119+ # else
120+ # log "INFO" "maxscale_confsync user exists. Skipping creating new one......."
121+ # fi
122+ # }
123+
106124function create_monitor_user() {
107125 log " INFO" " Checking whether monitor user exist or not......"
108126 local mysql=" $mysql_header --host=$localhost "
@@ -114,8 +132,16 @@ function create_monitor_user() {
114132 if [[ " $out " -eq " 0" ]]; then
115133 log " INFO" " Monitor user not found. Creating new monitor user........"
116134 retry 120 ${mysql} -N -e " SET SQL_LOG_BIN=0;CREATE USER 'monitor_user'@'%' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD ';"
117- retry 120 ${mysql} -N -e " SET SQL_LOG_BIN=0;GRANT REPLICATION CLIENT on *.* to 'monitor_user'@'%';"
118- retry 120 ${mysql} -N -e " SET SQL_LOG_BIN=0;GRANT SUPER, RELOAD on *.* to 'monitor_user'@'%';"
135+ # mariadb 10.6+ change SUPER-> READ_ONLY ADMIN, REPLICATION CLIENT> SLAVE MONITOR
136+ if [[ " $( echo -e " 1:10.7\n$MARIADB_VERSION " | sort -V | tail -n1) " == " $MARIADB_VERSION " ]]; then
137+ retry 120 ${mysql} -N -e " SET SQL_LOG_BIN=0;GRANT READ_ONLY ADMIN, RELOAD on *.* to 'monitor_user'@'%';"
138+ retry 120 ${mysql} -N -e " SET SQL_LOG_BIN=0;GRANT SLAVE MONITOR ON *.* TO 'monitor_user'@'%';"
139+ retry 120 ${mysql} -N -e " SET SQL_LOG_BIN=0;GRANT BINLOG ADMIN, REPLICATION MASTER ADMIN, REPLICATION SLAVE ADMIN ON *.* TO 'monitor_user'@'%';"
140+ else
141+ retry 120 ${mysql} -N -e " SET SQL_LOG_BIN=0;GRANT SUPER, RELOAD on *.* to 'monitor_user'@'%';"
142+ retry 120 ${mysql} -N -e " SET SQL_LOG_BIN=0;GRANT REPLICATION CLIENT on *.* to 'monitor_user'@'%';"
143+ fi
144+
119145 retry 120 ${mysql} -N -e " SET SQL_LOG_BIN=0;FLUSH PRIVILEGES;"
120146 else
121147 log " INFO" " Monitor user exists. Skipping creating new one......."
@@ -210,6 +236,10 @@ create_maxscale_user
210236# ensure monitor user
211237create_monitor_user
212238
239+ # TODO:
240+ # ensure maxscale_confsync user
241+ # create_maxscale_confsync_user
242+
213243while true ; do
214244 kill -0 $pid
215245 exit=" $? "
0 commit comments