Add subpackage mariadb-server-galera

Resolves: 1310622
This commit is contained in:
Jakub Dorňák 2016-03-22 15:30:08 +01:00
parent 063b7bbe38
commit 803bbfca97
4 changed files with 169 additions and 8 deletions

27
LICENSE.clustercheck Normal file
View File

@ -0,0 +1,27 @@
Copyright (c) 2012-2014, Olaf van Zandwijk
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

89
clustercheck.sh Normal file
View File

@ -0,0 +1,89 @@
#!/bin/bash
#
# Script to make a proxy (ie HAProxy) capable of monitoring Galera cluster nodes properly
#
# Author: Olaf van Zandwijk <olaf.vanzandwijk@nedap.com>
# Author: Raghavendra Prabhu <raghavendra.prabhu@percona.com>
# Author: Ryan O'Hara <rohara@redhat.com>
#
# Documentation and download: https://github.com/olafz/percona-clustercheck
#
# Based on the original script from Unai Rodriguez
#
if [ -f @INSTALL_SYSCONFDIR@/sysconfig/clustercheck ]; then
. @INSTALL_SYSCONFDIR@/sysconfig/clustercheck
fi
MYSQL_USERNAME="${MYSQL_USERNAME-clustercheckuser}"
MYSQL_PASSWORD="${MYSQL_PASSWORD-clustercheckpassword!}"
MYSQL_HOST="${MYSQL_HOST:-127.0.0.1}"
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}
#Timeout exists for instances where mysqld may be hung
TIMEOUT=10
if [[ -r $DEFAULTS_EXTRA_FILE ]];then
MYSQL_CMDLINE="mysql --defaults-extra-file=$DEFAULTS_EXTRA_FILE -nNE \
--connect-timeout=$TIMEOUT \
--user=${MYSQL_USERNAME} --password=${MYSQL_PASSWORD} \
--host=${MYSQL_HOST} --port=${MYSQL_PORT}"
else
MYSQL_CMDLINE="mysql -nNE --connect-timeout=$TIMEOUT \
--user=${MYSQL_USERNAME} --password=${MYSQL_PASSWORD} \
--host=${MYSQL_HOST} --port=${MYSQL_PORT}"
fi
#
# Perform the query to check the wsrep_local_state
#
WSREP_STATUS=$($MYSQL_CMDLINE -e "SHOW STATUS LIKE 'wsrep_local_state';" \
2>${ERR_FILE} | tail -1 2>>${ERR_FILE})
if [[ "${WSREP_STATUS}" == "4" ]] || [[ "${WSREP_STATUS}" == "2" && ${AVAILABLE_WHEN_DONOR} == 1 ]]
then
# Check only when set to 0 to avoid latency in response.
if [[ $AVAILABLE_WHEN_READONLY -eq 0 ]];then
READ_ONLY=$($MYSQL_CMDLINE -e "SHOW GLOBAL VARIABLES LIKE 'read_only';" \
2>${ERR_FILE} | tail -1 2>>${ERR_FILE})
if [[ "${READ_ONLY}" == "ON" ]];then
# Galera cluster node local state is 'Synced', but it is in
# read-only mode. The variable AVAILABLE_WHEN_READONLY is set to 0.
# => return HTTP 503
# Shell return-code is 1
echo -en "HTTP/1.1 503 Service Unavailable\r\n"
echo -en "Content-Type: text/plain\r\n"
echo -en "Connection: close\r\n"
echo -en "Content-Length: 35\r\n"
echo -en "\r\n"
echo -en "Galera cluster node is read-only.\r\n"
sleep 0.1
exit 1
fi
fi
# Galera cluster node local state is 'Synced' => return HTTP 200
# Shell return-code is 0
echo -en "HTTP/1.1 200 OK\r\n"
echo -en "Content-Type: text/plain\r\n"
echo -en "Connection: close\r\n"
echo -en "Content-Length: 32\r\n"
echo -en "\r\n"
echo -en "Galera cluster node is synced.\r\n"
sleep 0.1
exit 0
else
# Galera cluster node local state is not 'Synced' => return HTTP 503
# Shell return-code is 1
echo -en "HTTP/1.1 503 Service Unavailable\r\n"
echo -en "Content-Type: text/plain\r\n"
echo -en "Connection: close\r\n"
echo -en "Content-Length: 36\r\n"
echo -en "\r\n"
echo -en "Galera cluster node is not synced.\r\n"
sleep 0.1
exit 1
fi

View File

@ -1,6 +1,6 @@
--- mariadb-10.1.11.orig/scripts/CMakeLists.txt 2016-01-28 13:12:51.000000000 +0100
+++ mariadb-10.1.11/scripts/CMakeLists.txt 2016-02-03 12:46:26.306109293 +0100
@@ -320,6 +320,34 @@ ELSE()
@@ -320,6 +320,35 @@ ELSE()
COMPONENT ${${file}_COMPONENT}
)
ENDFOREACH()
@ -17,6 +17,7 @@
+ mysql-check-upgrade
+ mysql-scripts-common
+ mysql_config_multilib
+ clustercheck
+ mysql.init
+ my.cnf
+ )

View File

@ -54,6 +54,7 @@
%bcond_without bench
%bcond_without test
%bcond_without connect
%bcond_without galera
# When there is already another package that ships /etc/my.cnf,
# rather include it than ship the file again, since conflicts between
@ -122,7 +123,7 @@
Name: mariadb
Version: %{compatver}.%{bugfixver}
Release: 2%{?with_debug:.debug}%{?dist}
Release: 3%{?with_debug:.debug}%{?dist}
Epoch: 1
Summary: A community developed branch of MySQL
@ -153,6 +154,9 @@ Source19: mysql.init.in
Source50: rh-skipped-tests-base.list
Source51: rh-skipped-tests-arm.list
Source52: rh-skipped-tests-ppc-s390.list
# TODO: clustercheck contains some hard-coded paths, these should be expanded using template system
Source70: clustercheck.sh
Source71: LICENSE.clustercheck
# Comments for these patches are in the patch files
# Patches common for more mysql-like packages
@ -306,6 +310,27 @@ MariaDB packages.
%endif
%if %{with galera}
%package server-galera
Summary: The configuration files and scripts for galera replication
Group: Applications/Databases
Requires: %{name}-common%{?_isa} = %{sameevr}
Requires: %{name}-server%{?_isa} = %{sameevr}
Requires: galera >= 25.3.3
# obsoletion of mariadb-galera-server
Provides: mariadb-galera-server = %{sameevr}
Obsoletes: mariadb-galera-server < %{obsoleted_mariadb_galera_server_evr}
%description server-galera
MariaDB is a multi-user, multi-threaded SQL database server. It is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MariaDB server and some accompanying files and directories.
MariaDB is a community developed branch of MySQL.
%endif
%package server
Summary: The MariaDB server and related files
Group: Applications/Databases
@ -350,10 +375,6 @@ Provides: mysql-compat-server%{?_isa} = %{sameevr}
%{?with_conflicts:Conflicts: mariadb-galera-server}
%{?obsoleted_mysql_evr:Obsoletes: mysql-server < %{obsoleted_mysql_evr}}
# obsoletion of mariadb-galera-server
Provides: mariadb-galera-server = %{sameevr}
Obsoletes: mariadb-galera-server < %{obsoleted_mariadb_galera_server_evr}
%description server
MariaDB is a multi-user, multi-threaded SQL database server. It is a
client/server implementation consisting of a server daemon (mysqld)
@ -551,7 +572,7 @@ cat %{SOURCE52} | tee -a mysql-test/rh-skipped-tests.list
cp %{SOURCE2} %{SOURCE3} %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} \
%{SOURCE14} %{SOURCE15} %{SOURCE16} %{SOURCE17} %{SOURCE18} %{SOURCE19} \
scripts
%{SOURCE70} scripts
%build
@ -762,6 +783,15 @@ install -p -m 0644 %{SOURCE5} %{basename:%{SOURCE5}}
install -p -m 0644 %{SOURCE6} %{basename:%{SOURCE6}}
install -p -m 0644 %{SOURCE7} %{basename:%{SOURCE7}}
install -p -m 0644 %{SOURCE16} %{basename:%{SOURCE16}}
install -p -m 0644 %{SOURCE71} %{basename:%{SOURCE71}}
# install galera config file
install -p -m 0644 support-files/wsrep.cnf %{buildroot}%{_sysconfdir}/my.cnf.d/galera.cnf
# install the clustercheck script
mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
touch %{buildroot}%{_sysconfdir}/sysconfig/clustercheck
install -p -m 0755 scripts/clustercheck %{buildroot}%{_bindir}/clustercheck
# install the list of skipped tests to be available for user runs
install -p -m 0644 mysql-test/rh-skipped-tests.list %{buildroot}%{_datadir}/mysql-test
@ -779,6 +809,9 @@ rm -f %{buildroot}%{_sysconfdir}/logrotate.d/mysql
# remove solaris files
rm -rf %{buildroot}%{_datadir}/%{pkg_name}/solaris/
# rename the wsrep README so it corresponds with the other README names
mv Docs/README-wsrep Docs/README.wsrep
%if %{without clibrary}
unlink %{buildroot}%{_libdir}/mysql/libmysqlclient.so
unlink %{buildroot}%{_libdir}/mysql/libmysqlclient_r.so
@ -1023,6 +1056,13 @@ fi
%lang(uk) %{_datadir}/%{pkg_name}/ukrainian
%endif
%files server-galera
%doc Docs/README.wsrep
%license LICENSE.clustercheck
%{_bindir}/galera_new_cluster
%{_bindir}/clustercheck
%config(noreplace) %{_sysconfdir}/my.cnf.d/galera.cnf
%files server
%doc README.mysql-cnf
@ -1031,7 +1071,6 @@ fi
%{_bindir}/aria_ftdump
%{_bindir}/aria_pack
%{_bindir}/aria_read_log
%{_bindir}/galera_new_cluster
%{_bindir}/mariadb-service-convert
%{_bindir}/myisamchk
%{_bindir}/myisam_ftdump
@ -1067,6 +1106,7 @@ fi
%config(noreplace) %{_sysconfdir}/my.cnf.d/%{pkg_name}-server.cnf
%config(noreplace) %{_sysconfdir}/my.cnf.d/auth_gssapi.cnf
%{?with_tokudb:%config(noreplace) %{_sysconfdir}/my.cnf.d/tokudb.cnf}
%attr(0640,root,root) %ghost %config(noreplace) %{_sysconfdir}/sysconfig/clustercheck
%{_libexecdir}/mysqld
@ -1204,6 +1244,10 @@ fi
%endif
%changelog
* Tue Mar 22 2016 Jakub Dorňák <jdornak@redhat.com> - 1:10.1.12-3
- Add subpackage mariadb-server-galera
Resolves: 1310622
* Tue Mar 01 2016 Honza Horak <hhorak@redhat.com> - 1:10.1.12-2
- Rebuild for BZ#1309199 (symbol versioning)