!67 [sync] PR-64: [10.5.15 refresh] Fix up all issues during setting up mariadb 10.5.15

From: @openeuler-sync-bot 
Reviewed-by: @bzhaoop 
Signed-off-by: @bzhaoop
This commit is contained in:
openeuler-ci-bot 2022-04-21 06:16:23 +00:00 committed by Gitee
commit 02e7314e50
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 78 additions and 84 deletions

View File

@ -11,8 +11,8 @@
# Based on the original script from Unai Rodriguez
#
if [ -f @INSTALL_SYSCONFDIR@/sysconfig/clustercheck ]; then
. @INSTALL_SYSCONFDIR@/sysconfig/clustercheck
if [ -f /etc/sysconfig/clustercheck ]; then
. /etc/sysconfig/clustercheck
fi
MYSQL_USERNAME="${MYSQL_USERNAME-clustercheckuser}"
@ -22,7 +22,7 @@ MYSQL_PORT="${MYSQL_PORT:-3306}"
ERR_FILE="${ERR_FILE:-/dev/null}"
AVAILABLE_WHEN_DONOR=${AVAILABLE_WHEN_DONOR:-0}
AVAILABLE_WHEN_READONLY=${AVAILABLE_WHEN_READONLY:-1}
DEFAULTS_EXTRA_FILE=${DEFAULTS_EXTRA_FILE:-@INSTALL_SYSCONFDIR@/my.cnf}
DEFAULTS_EXTRA_FILE=${DEFAULTS_EXTRA_FILE:-/etc/my.cnf}
#Timeout exists for instances where mysqld may be hung
TIMEOUT=10

View File

@ -25,7 +25,7 @@ if test -e "$socketfile" ; then
fi
# some process uses the socket file
response=`@bindir@/mariadb-admin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER --connect-timeout="${CHECKSOCKETTIMEOUT:-10}" ping 2>&1`
response=`/usr/bin/mariadb-admin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER --connect-timeout="${CHECKSOCKETTIMEOUT:-10}" ping 2>&1`
if [ $? -eq 0 ] || echo "$response" | grep -q "Access denied for user" ; then
echo "Is another MariaDB daemon already running with the same unix socket?" >&2
echo "Please, stop the process using the socket $socketfile or remove the file manually to start the service." >&2

View File

@ -14,7 +14,7 @@ if [ -f "$upgrade_info_file" ] && [ -r "$upgrade_info_file" ] ; then
fi
# compute current version as integer
thisversion=$((@MAJOR_VERSION@*100+@MINOR_VERSION@))
thisversion=$((10*100+5))
# provide warning in cases we should run mysql_upgrade
if [ $version -ne $thisversion ] ; then
@ -28,7 +28,7 @@ if [ $version -ne $thisversion ] ; then
The datadir located at $datadir needs to be upgraded using 'mariadb-upgrade' tool. This can be done using the following steps:
1. Back-up your data before with 'mariadb-upgrade'
2. Start the database daemon using 'systemctl start @DAEMON_NAME@.service'
2. Start the database daemon using 'systemctl start mariadb.service'
3. Run 'mariadb-upgrade' with a database user that has sufficient privileges
Read more about 'mariadb-upgrade' usage at:

View File

@ -1,40 +1,7 @@
Adjust the mysql-log-rotate script in several ways:
* Use the correct log file pathname for Red Hat installations.
* Enable creation of the log file by logrotate (needed since
/var/log/ isn't writable by mysql user); and set the same 640
permissions we normally use.
* Comment out the actual rotation commands, so that user must edit
the file to enable rotation. This is unfortunate, but the fact
that the script will probably fail without manual configuration
(to set a root password) means that we can't really have it turned
on by default. Fortunately, in most configurations the log file
is low-volume and so rotation is not critical functionality.
See discussions at RH bugs 799735, 547007
* Note they are from Fedora 15 / 16
Update 3/2017
* it would be big unexpected change for anyone upgrading, if we start shipping it now.
Maybe it is good candidate for shipping with MariaDB 10.2 ?
* the 'mysqladmin flush logs' doesn´t guarantee, no entries are lost
during flushing, the operation is not atomic.
We should not ship it in that state
Update 6/2018
* the SIGHUP causes server to flush all logs. No password admin needed, the only constraint is
beeing able to send the SIGHUP to the process and read the mysqld pid file, which root can.
* Submited as PR: https://github.com/MariaDB/server/pull/807
Update 02/2021
* Enhance the script as proposed in:
https://mariadb.com/kb/en/rotating-logs-on-unix-and-linux/
* Discussion continues in:
https://jira.mariadb.org/browse/MDEV-16621
--- mariadb-10.5.8/support-files/mysql-log-rotate.sh 2021-02-12 08:37:47.857289694 +0100
+++ mariadb-10.5.8/support-files/mysql-log-rotate.sh_pacthed 2021-02-12 08:40:26.420372325 +0100
@@ -3,35 +3,22 @@
diff -Naur mariadb-10.5.15/support-files/mysql-log-rotate.sh mariadb-10.5.15_patched/support-files/mysql-log-rotate.sh
--- mariadb-10.5.15/support-files/mysql-log-rotate.sh 2022-02-10 20:11:35.000000000 +0000
+++ mariadb-10.5.15_patched/support-files/mysql-log-rotate.sh 2022-04-14 11:31:55.344000000 +0000
@@ -3,36 +3,24 @@
# in the [mysqld] section as follows:
#
# [mysqld]
@ -58,6 +25,7 @@ Update 02/2021
- # create 600 mysql mysql
+@LOG_LOCATION@ {
+ create 600 mysql mysql
su mysql mysql
notifempty
daily
rotate 3
@ -65,14 +33,16 @@ Update 02/2021
compress
+ delaycompress
+ sharedscripts
+
postrotate
# just if mariadbd is really running
- # just if mariadbd is really running
- if test -x @bindir@/mysqladmin && \
- @bindir@/mysqladmin ping &>/dev/null
- then
- @bindir@/mysqladmin --local flush-error-log \
- flush-engine-log flush-general-log flush-slow-log
- fi
+ # just if mariadbd is really running
+ if [ -e @PID_FILE_DIR@/@DAEMON_NO_PREFIX@.pid ]
+ then
+ kill -1 $(<@PID_FILE_DIR@/@DAEMON_NO_PREFIX@.pid)

View File

@ -40,7 +40,7 @@ else
SERVICE_NAME="$1"
if [ x"$SERVICE_NAME" = x ]
then
SERVICE_NAME=@DAEMON_NAME@.service
SERVICE_NAME=mariadb.service
fi
myuser=`systemctl show -p User "${SERVICE_NAME}" |
@ -90,21 +90,21 @@ if should_initialize "$datadir" ; then
[ -x /sbin/restorecon ] && /sbin/restorecon "$datadir"
# Now create the database
echo "Initializing @NICE_PROJECT_NAME@ database" >&2
echo "Initializing MariaDB database" >&2
# Avoiding deletion of files not created by mysql_install_db is
# guarded by time check and sleep should help work-arounded
# potential issues on systems with 1 second resolution timestamps
# https://bugzilla.redhat.com/show_bug.cgi?id=1335849#c19
INITDB_TIMESTAMP=`LANG=C date -u`
sleep 1
@bindir@/mariadb-install-db --rpm --datadir="$datadir" --user="$myuser" --skip-test-db >&2
/usr/bin/mariadb-install-db --rpm --datadir="$datadir" --user="$myuser" --skip-test-db >&2
ret=$?
if [ $ret -ne 0 ] ; then
echo "Initialization of @NICE_PROJECT_NAME@ database failed." >&2
echo "Perhaps @sysconfdir@/my.cnf is misconfigured or there is some problem with permissions of $datadir." >&2
echo "Initialization of MariaDB database failed." >&2
echo "Perhaps /etc/my.cnf is misconfigured or there is some problem with permissions of $datadir." >&2
# Clean up any partially-created database files
if [ ! -e "$datadir/mysql/user.frm" ] && [ -d "$datadir" ] ; then
echo "Initialization of @NICE_PROJECT_NAME@ database was not finished successfully." >&2
echo "Initialization of MariaDB database was not finished successfully." >&2
echo "Files created so far will be removed." >&2
find "$datadir" -mindepth 1 -maxdepth 1 -newermt "$INITDB_TIMESTAMP" \
-not -name "lost+found" -exec rm -rf {} +
@ -119,16 +119,16 @@ if should_initialize "$datadir" ; then
exit $ret
fi
# upgrade does not need to be run on a fresh datadir
echo "@VERSION@-MariaDB" >"$datadir/mysql_upgrade_info"
echo "10.5.15-MariaDB" >"$datadir/mysql_upgrade_info"
else
if [ -d "$datadir/mysql/" ] ; then
# mysql dir exists, it seems data are initialized properly
echo "Database @NICE_PROJECT_NAME@ is probably initialized in $datadir already, nothing is done."
echo "Database MariaDB is probably initialized in $datadir already, nothing is done."
echo "If this is not the case, make sure the $datadir is empty before running `basename $0`."
else
# if the directory is not empty but mysql/ directory is missing, then
# print error and let user to initialize manually or empty the directory
echo "Database @NICE_PROJECT_NAME@ is not initialized, but the directory $datadir is not empty, so initialization cannot be done." >&2
echo "Database MariaDB is not initialized, but the directory $datadir is not empty, so initialization cannot be done." >&2
echo "Make sure the $datadir is empty before running `basename $0`." >&2
exit 1
fi

View File

@ -18,7 +18,7 @@ get_mysql_option(){
sections="$1"
option_name="$2"
default_value="$3"
result=`@bindir@/my_print_defaults $my_print_defaults_extra_args $sections | sed -n "s/^--${option_name}=//p" | tail -n 1`
result=`/usr/bin/my_print_defaults $my_print_defaults_extra_args $sections | sed -n "s/^--${option_name}=//p" | tail -n 1`
if [ -z "$result" ]; then
# not found, use default
result="${default_value}"
@ -40,7 +40,7 @@ done
# on the default installation:
# 1) default values are hardcoded in the code of mariadbd daemon or
# mariadbd-safe script
# 2) configurable values are defined in @sysconfdir@/my.cnf
# 2) configurable values are defined in /etc/my.cnf
# 3) default values for helper scripts are specified bellow
# So, in case values are defined in my.cnf, we need to get that value.
# In case they are not defined in my.cnf, we need to get the same value
@ -48,9 +48,9 @@ done
# must correspond with values defined in mariadbd-safe script and source
# code itself.
server_sections="mysqld_safe mysqld server mysqld-@MAJOR_VERSION@.@MINOR_VERSION@ mariadb mariadb-@MAJOR_VERSION@.@MINOR_VERSION@ mariadbd mariadbd-@MAJOR_VERSION@.@MINOR_VERSION@ client-server galera"
server_sections="mysqld_safe mysqld server mysqld-10.5 mariadb mariadb-10.5 mariadbd mariadbd-10.5 client-server galera"
get_mysql_option "$server_sections" datadir "@MYSQL_DATADIR@"
get_mysql_option "$server_sections" datadir "/var/lib/mysql"
datadir="$result"
# if there is log_error in the my.cnf, my_print_defaults still
@ -60,7 +60,7 @@ datadir="$result"
get_mysql_option "$server_sections" log-error "$datadir/`uname -n`.err"
errlogfile="$result"
get_mysql_option "$server_sections" socket "@MYSQL_UNIX_ADDR@"
get_mysql_option "$server_sections" socket "/var/lib/mysql/mysql.sock"
socketfile="$result"
get_mysql_option "$server_sections" pid-file "$datadir/`uname -n`.pid"

View File

@ -74,7 +74,7 @@
Name: mariadb
Version: 10.5.15
Release: 1
Release: 2
Epoch: 4
Summary: A very fast and robust SQL database server
@ -101,6 +101,18 @@ Source71: LICENSE.clustercheck
Source72: mariadb-server-galera.te
# Patch4: yum distributions specific logrotate fix
# it would be big unexpected change, if we start shipping it now. Better wait for MariaDB 10.2
Patch4: %{pkgnamepatch}-logrotate.patch
# Patch7: add to the CMake file all files where we want macros to be expanded
Patch7: %{pkgnamepatch}-scripts.patch
# Patch9: pre-configure to comply with guidelines
Patch9: %{pkgnamepatch}-ownsetup.patch
# Patch10: Fix cipher name in the SSL Cipher name test
Patch10: %{pkgnamepatch}-ssl-cipher-tests.patch
# Patch11: Use PCDIR CMake option, if configured
Patch11: %{pkgnamepatch}-pcdir.patch
BuildRequires: make
BuildRequires: cmake gcc-c++
BuildRequires: multilib-rpm-config
@ -606,6 +618,12 @@ sources.
%prep
%setup -q -n mariadb-%{version}
%patch4 -p1
%patch7 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
# Remove JAR files that upstream puts into tarball
find . -name "*.jar" -type f -exec rm --verbose -f {} \;
# Remove testsuite for the mariadb-connector-c
@ -749,7 +767,8 @@ CXXFLAGS="$CFLAGS"
CPPFLAGS="$CFLAGS"
export CFLAGS CXXFLAGS CPPFLAGS
%make_build %{?_smp_mflags}
cmake -B . -LAH
cmake --build . %{?_smp_mflags} --verbose
# build selinux policy
%if %{with galera}
@ -760,7 +779,7 @@ make -f /usr/share/selinux/devel/Makefile %{name}-server-galera.pp
%install
%make_install
DESTDIR="%{buildroot}" cmake --install "."
# multilib header support #1625157
for header in mysql/server/my_config.h mysql/server/private/config.h; do
@ -1453,6 +1472,11 @@ fi
%endif
%changelog
* Sat Apr 16 2022 bzhaoop<bzhaojyathousandy@gmail.com> - 4:10.5.15-2
- Fix the systemd service issue about the env variable.
- Apply the patches from old branch.
- Adaption the cmake version and integrate into the spec file.
* Thur Mar 17 2022 bzhaoop<bzhaojyathousandy@gmail.com> -4:10.5.15-1
- Bump to 10.5.15
- For resolving CVEs:

View File

@ -1,3 +1,3 @@
# Do not edit this file.
# To override this, put /etc/tmpfiles.d/mariadb.conf instead.
d @PID_FILE_DIR@ 0755 mysql mysql -
d /var/lib/mysql 0755 mysql mysql -

View File

@ -14,5 +14,5 @@ symbolic-links=0
#
# include all files from the config directory
#
!includedir @INSTALL_SYSCONF2DIR@
!includedir /etc/my.cnf.d

View File

@ -2,7 +2,7 @@
# overwritten during package upgrades. If you want to customize, the
# best way is to:
#
# root> systemctl edit @DAEMON_NAME@.service
# root> systemctl edit mariadb.service
#
# Then add additonal directives under a section (probably [Service]).
#
@ -17,7 +17,7 @@
#
[Unit]
Description=@NICE_PROJECT_NAME@ @MAJOR_VERSION@.@MINOR_VERSION@ database server
Description=MariaDB 10.5.15 database server
Documentation=man:mariadbd(8)
Documentation=https://mariadb.com/kb/en/library/systemd/
After=network.target
@ -32,14 +32,14 @@ Type=notify
User=mysql
Group=mysql
ExecStartPre=@libexecdir@/mariadb-check-socket
ExecStartPre=/usr/libexec/mariadb-check-socket
# '%n' expands to 'Full unit name'; man systemd.unit
ExecStartPre=@libexecdir@/mariadb-prepare-db-dir %n
# MYSQLD_OPTS here is for users to set in /etc/systemd/system/@DAEMON_NAME@@.service.d/MY_SPECIAL.conf
ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n
# MYSQLD_OPTS here is for users to set in /etc/systemd/system/mysql@.service.d/MY_SPECIAL.conf
# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
# per bug #547485
ExecStart=@libexecdir@/mariadbd --basedir=@prefix@ $MYSQLD_OPTS $_WSREP_NEW_CLUSTER
ExecStartPost=@libexecdir@/mariadb-check-upgrade
ExecStart=/usr/libexec/mariadbd --basedir=/var/lib/mysql/ $MYSQLD_OPTS $_WSREP_NEW_CLUSTER
ExecStartPost=/usr/libexec/mariadb-check-upgrade
# Setting this to true can break replication and the Type=notify settings
# See also bind-address MariaDB option.

View File

@ -1,8 +1,8 @@
# Multi instance version of MariaDB. For if you run mutiple verions at once.
# Also used for @DAEMON_NAME@@bootstrap to bootstrap Galera.
# Also used for mariadb to bootstrap Galera.
#
# To use multi instance variant, use [mariadbd.INSTANCENAME] as sections in
# @sysconfdir@/@my.cnf to change per instance settings. A minimumal necessary
# /etc/my.cnf to change per instance settings. A minimumal necessary
# configuration items to change to avoid conflicts between instances is:
#
# [mariadbd.instancename]
@ -15,19 +15,19 @@
#
# and start the service via:
#
# root> systemctl start @DAEMON_NAME@@{instancename}.server
# root> systemctl start mariadb.server
#
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades. If you want to customize, for
# all instances, the best way is:
#
# root> systemctl edit @DAEMON_NAME@@.service
# root> systemctl edit mariadb.service
#
# Then add additonal directives under a section (probably [Service]).
#
# If you only want to change a specific instance:
#
# root> systemctl edit @DAEMON_NAME@@{instancename}.server
# root> systemctl edit mariadb.server
#
# For more info about custom unit files, see systemd.unit(5) or
# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
@ -39,7 +39,7 @@
# LimitNOFILE=10000
[Unit]
Description=@NICE_PROJECT_NAME@ @MAJOR_VERSION@.@MINOR_VERSION@ database server
Description=MariaDB 10.5.15 database server (multi-instance %I)
Documentation=man:mariadbd(8)
Documentation=https://mariadb.com/kb/en/library/systemd/
After=network.target
@ -54,13 +54,13 @@ Type=notify
User=mysql
Group=mysql
ExecStartPre=@libexecdir@/mariadb-check-socket --defaults-group-suffix=.%I
ExecStartPre=@libexecdir@/mariadb-prepare-db-dir --defaults-group-suffix=.%I %n
# MYSQLD_OPTS here is for users to set in /etc/systemd/system/@DAEMON_NAME@@.service.d/MY_SPECIAL.conf
ExecStartPre=/usr/libexec/mariadb-check-socket --defaults-group-suffix=.%I
ExecStartPre=/usr/libexec/mariadb-prepare-db-dir --defaults-group-suffix=.%I %n
# MYSQLD_OPTS here is for users to set in /etc/systemd/system/mysql@.service.d/MY_SPECIAL.conf
# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
# per bug #547485
ExecStart=@libexecdir@/mariadbd --defaults-group-suffix=.%I --basedir=@prefix@ $MYSQLD_OPTS $_WSREP_NEW_CLUSTER
ExecStartPost=@libexecdir@/mariadb-check-upgrade --defaults-group-suffix=.%I
ExecStart=/usr/libexec/mariadbd --defaults-group-suffix=.%I --basedir=/var/lib/mysql/ $MYSQLD_OPTS $_WSREP_NEW_CLUSTER
ExecStartPost=/usr/libexec/mariadb-check-upgrade --defaults-group-suffix=.%I
# Setting this to true can break replication and the Type=notify settings
# See also bind-address MariaDB option.

View File

@ -17,10 +17,10 @@ if [ "$status" = "unknown" ] ; then
fi
if [ -x @bindir@/mysql_config-$bits ] ; then
@bindir@/mysql_config-$bits "$@"
if [ -x /usr/bin/mysql_config-$bits ] ; then
/usr/bin/mysql_config-$bits "$@"
else
echo "$0: error: needed binary: @bindir@/mysql_config-$bits is missing"
echo "$0: error: needed binary: /usr/bin/mysql_config-$bits is missing"
exit 1
fi