Install mysql-wait-ready on RHEL-6 for the SysV init

This commit is contained in:
Honza Horak 2017-08-09 08:18:28 +02:00
parent 263dd48ce1
commit f130bf6899
3 changed files with 56 additions and 2 deletions

View File

@ -4,7 +4,7 @@ be expanded by cmake. Cmake needs to know about them, so adding them manually.
diff -up mariadb-10.2.8/scripts/CMakeLists.txt.p7 mariadb-10.2.8/scripts/CMakeLists.txt diff -up mariadb-10.2.8/scripts/CMakeLists.txt.p7 mariadb-10.2.8/scripts/CMakeLists.txt
--- mariadb-10.2.8/scripts/CMakeLists.txt.p7 2017-08-20 13:26:10.640779557 +0200 --- mariadb-10.2.8/scripts/CMakeLists.txt.p7 2017-08-20 13:26:10.640779557 +0200
+++ mariadb-10.2.8/scripts/CMakeLists.txt 2017-08-20 13:27:05.774925486 +0200 +++ mariadb-10.2.8/scripts/CMakeLists.txt 2017-08-20 13:27:05.774925486 +0200
@@ -338,6 +338,34 @@ ELSE() @@ -338,6 +338,35 @@ ELSE()
) )
ENDFOREACH() ENDFOREACH()
@ -14,6 +14,7 @@ diff -up mariadb-10.2.8/scripts/CMakeLists.txt.p7 mariadb-10.2.8/scripts/CMakeLi
+ mysql.service + mysql.service
+ mysql@.service + mysql@.service
+ mysql-prepare-db-dir + mysql-prepare-db-dir
+ mysql-wait-ready
+ mysql-check-socket + mysql-check-socket
+ mysql-check-upgrade + mysql-check-upgrade
+ mysql-scripts-common + mysql-scripts-common

View File

@ -144,6 +144,7 @@ Source7: README.mysql-license
Source10: mysql.tmpfiles.d.in Source10: mysql.tmpfiles.d.in
Source11: mysql.service.in Source11: mysql.service.in
Source12: mysql-prepare-db-dir.sh Source12: mysql-prepare-db-dir.sh
Source13: mysql-wait-ready.sh
Source14: mysql-check-socket.sh Source14: mysql-check-socket.sh
Source15: mysql-scripts-common.sh Source15: mysql-scripts-common.sh
Source16: mysql-check-upgrade.sh Source16: mysql-check-upgrade.sh
@ -645,7 +646,7 @@ cat %{SOURCE52} | tee -a mysql-test/unstable-tests
cat %{SOURCE53} | tee -a mysql-test/unstable-tests cat %{SOURCE53} | tee -a mysql-test/unstable-tests
%endif %endif
cp %{SOURCE2} %{SOURCE3} %{SOURCE10} %{SOURCE11} %{SOURCE12} \ cp %{SOURCE2} %{SOURCE3} %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} \
%{SOURCE14} %{SOURCE15} %{SOURCE16} %{SOURCE18} %{SOURCE19} \ %{SOURCE14} %{SOURCE15} %{SOURCE16} %{SOURCE18} %{SOURCE19} \
%{SOURCE70} scripts %{SOURCE70} scripts
@ -844,6 +845,9 @@ install -p -m 755 scripts/mysql-prepare-db-dir %{buildroot}%{_libexecdir}/mysql-
install -p -m 755 scripts/mysql-check-socket %{buildroot}%{_libexecdir}/mysql-check-socket install -p -m 755 scripts/mysql-check-socket %{buildroot}%{_libexecdir}/mysql-check-socket
install -p -m 755 scripts/mysql-check-upgrade %{buildroot}%{_libexecdir}/mysql-check-upgrade install -p -m 755 scripts/mysql-check-upgrade %{buildroot}%{_libexecdir}/mysql-check-upgrade
install -p -m 644 scripts/mysql-scripts-common %{buildroot}%{_libexecdir}/mysql-scripts-common install -p -m 644 scripts/mysql-scripts-common %{buildroot}%{_libexecdir}/mysql-scripts-common
%if %{with init_sysv}
install -p -m 755 scripts/mysql-wait-ready %{buildroot}%{_libexecdir}/mysql-wait-ready
%endif
# install selinux policy # install selinux policy
%if %{with galera} %if %{with galera}
@ -1354,6 +1358,9 @@ fi
%{_libexecdir}/mysql-check-socket %{_libexecdir}/mysql-check-socket
%{_libexecdir}/mysql-check-upgrade %{_libexecdir}/mysql-check-upgrade
%{_libexecdir}/mysql-scripts-common %{_libexecdir}/mysql-scripts-common
%if %{with init_sysv}
%{_libexecdir}/mysql-wait-ready
%endif
%{?with_init_systemd:%{_tmpfilesdir}/%{name}.conf} %{?with_init_systemd:%{_tmpfilesdir}/%{name}.conf}
%attr(0755,mysql,mysql) %dir %{pidfiledir} %attr(0755,mysql,mysql) %dir %{pidfiledir}
@ -1450,6 +1457,7 @@ fi
Resolves: #1403416 Resolves: #1403416
- Support --defaults-group-suffix properly in systemd unit file - Support --defaults-group-suffix properly in systemd unit file
Resolves: #1485777 Resolves: #1485777
- Install mysql-wait-ready on RHEL-6 for the SysV init
* Sun Aug 20 2017 Honza Horak <hhorak@redhat.com> - 3:10.2.8-1 * Sun Aug 20 2017 Honza Horak <hhorak@redhat.com> - 3:10.2.8-1
- Rebase to 10.2.8 - Rebase to 10.2.8

45
mysql-wait-ready.sh Normal file
View File

@ -0,0 +1,45 @@
#!/bin/sh
source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
# This script waits for mysqld to be ready to accept connections
# (which can be many seconds or even minutes after launch, if there's
# a lot of crash-recovery work to do).
# Running this as ExecStartPost is useful so that services declared as
# "After mysqld" won't be started until the database is really ready.
if [ $# -ne 1 ] ; then
echo "You need to pass daemon pid as an argument for this script."
exit 20
fi
# Service file passes us the daemon's PID (actually, mysqld_safe's PID)
daemon_pid="$1"
# Wait for the server to come up or for the mysqld process to disappear
ret=0
while /bin/true; do
# Check process still exists
if ! [ -d "/proc/${daemon_pid}" ] ; then
ret=1
break
fi
RESPONSE=`@bindir@/mysqladmin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`
mret=$?
if [ $mret -eq 0 ] ; then
break
fi
# exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected,
# anything else suggests a configuration error
if [ $mret -ne 1 -a $mret -ne 11 ]; then
echo "Cannot check for @NICE_PROJECT_NAME@ Daemon startup because of mysqladmin failure." >&2
ret=$mret
break
fi
# "Access denied" also means the server is alive
echo "$RESPONSE" | grep -q "Access denied for user" && break
sleep 1
done
exit $ret