mysql binary log
support for binary log and ensure is disabled by default.
This commit is contained in:
parent
666769ada4
commit
0670c6b831
2 changed files with 32 additions and 2 deletions
|
@ -245,6 +245,7 @@ FLUSH PRIVILEGES;
|
||||||
_EOF_
|
_EOF_
|
||||||
|
|
||||||
conf_write mysql true
|
conf_write mysql true
|
||||||
|
sudo log -mysql=binary -disable > /dev/null 2>&1
|
||||||
echo "${gre}MySQL has been installed successfully! ${end}"
|
echo "${gre}MySQL has been installed successfully! ${end}"
|
||||||
api-events_update im4
|
api-events_update im4
|
||||||
}
|
}
|
||||||
|
|
33
plugins/log
33
plugins/log
|
@ -62,8 +62,10 @@ elif [[ -n $mysql || -n $syslog ]]; then
|
||||||
echo "${red}[ERROR] MariaDB Error log (syslog) file not found or still empty!${end}"
|
echo "${red}[ERROR] MariaDB Error log (syslog) file not found or still empty!${end}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Slow Query Log
|
||||||
elif [[ $mysql == "slow" ]]; then
|
elif [[ $mysql == "slow" ]]; then
|
||||||
islow=$( grep -E "^slow_query_log[\t =]" /etc/mysql/my.cnf | cut -f 2 -d "=" -s | sed 's/[^0-9]*//g' )
|
islow=$( grep -P "^slow_query_log[\t =]" /etc/mysql/my.cnf | cut -f 2 -d "=" -s | sed 's/[^0-9]*//g' )
|
||||||
if [[ -n $enable && $islow != 1 ]]; then
|
if [[ -n $enable && $islow != 1 ]]; then
|
||||||
sudo sed -i -E "/^[#]?slow_query_log[\[ \t=]/c slow_query_log = 1" /etc/mysql/my.cnf
|
sudo sed -i -E "/^[#]?slow_query_log[\[ \t=]/c slow_query_log = 1" /etc/mysql/my.cnf
|
||||||
sudo service mysql restart
|
sudo service mysql restart
|
||||||
|
@ -85,10 +87,37 @@ elif [[ -n $mysql || -n $syslog ]]; then
|
||||||
echo "${red}[ERROR] MariaDB Slow Query log file not found or still empty!${end}"
|
echo "${red}[ERROR] MariaDB Slow Query log file not found or still empty!${end}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Binary Log
|
||||||
|
elif [[ $mysql == "binary" ]]; then
|
||||||
|
isbin=$( grep -P "^log_bin[\t =]" /etc/mysql/my.cnf | cut -f 2 -d "=" -s )
|
||||||
|
if [[ -n $enable && -z $isbin ]]; then
|
||||||
|
sudo sed -i -E "/^[#]?log_bin[\[ \t=]/c log_bin = /var/log/mysql/mariadb-bin" /etc/mysql/my.cnf
|
||||||
|
sudo sed -i -E "/^[#]?log_bin_index[\[ \t=]/c log_bin_index = /var/log/mysql/mariadb-bin.index" /etc/mysql/my.cnf
|
||||||
|
sudo service mysql restart
|
||||||
|
echo "${gre}MariaDB Binary log was successfully enabled!${end}"
|
||||||
|
elif [[ -n $enable && -n $isbin ]]; then
|
||||||
|
echo "${gre}MariaDB Binary log is already enabled!${end}"
|
||||||
|
elif [[ -n $disable && -n $isbin ]]; then
|
||||||
|
sudo sed -i -E "/^[#]?log_bin[\[ \t=]/c #log_bin = /var/log/mysql/mariadb-bin" /etc/mysql/my.cnf
|
||||||
|
sudo sed -i -E "/^[#]?log_bin_index[\[ \t=]/c #log_bin_index = /var/log/mysql/mariadb-bin.index" /etc/mysql/my.cnf
|
||||||
|
sudo service mysql restart
|
||||||
|
echo "${gre}MariaDB Binary log was successfully disabled!${end}"
|
||||||
|
elif [[ -n $disable && -z $isbin ]]; then
|
||||||
|
echo "${gre}MariaDB Binary log is already disabled!${end}"
|
||||||
|
elif [[ -s /var/log/mysql/mariadb-bin && -n $isbin ]]; then
|
||||||
|
sudo tail -f --lines=$clines /var/log/mysql/mariadb-bin
|
||||||
|
elif [[ -z $isbin ]]; then
|
||||||
|
echo "${red}[ERROR] MariaDB Binary log is not enabled!${end}"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "${red}[ERROR] MariaDB Binary log file not found or still empty!${end}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# General Log
|
# General Log
|
||||||
else
|
else
|
||||||
isgrl=$( grep -E "^general_log[\t =]" /etc/mysql/my.cnf | cut -f 2 -d "=" -s | sed 's/[^0-9]*//g' )
|
isgrl=$( grep -P "^general_log[\t =]" /etc/mysql/my.cnf | cut -f 2 -d "=" -s | sed 's/[^0-9]*//g' )
|
||||||
if [[ -n $enable && $isgrl != 1 ]]; then
|
if [[ -n $enable && $isgrl != 1 ]]; then
|
||||||
sudo sed -i -E "/^[#]?general_log[\[ \t=]/c general_log = 1" /etc/mysql/my.cnf
|
sudo sed -i -E "/^[#]?general_log[\[ \t=]/c general_log = 1" /etc/mysql/my.cnf
|
||||||
sudo service mysql restart
|
sudo service mysql restart
|
||||||
|
|
Loading…
Reference in a new issue