diff options
Diffstat (limited to 'support-files')
-rw-r--r-- | support-files/CMakeLists.txt | 8 | ||||
-rw-r--r-- | support-files/mysql.server.sh | 22 | ||||
-rw-r--r-- | support-files/mysql.spec.sh | 69 | ||||
-rw-r--r-- | support-files/rpm/server.cnf | 16 | ||||
-rw-r--r-- | support-files/wsrep.cnf.sh | 122 | ||||
-rw-r--r-- | support-files/wsrep_notify.sh | 102 |
6 files changed, 334 insertions, 5 deletions
diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index 5e9fd081a09..b48abde4fe8 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -41,7 +41,7 @@ ELSE() SET(inst_location ${INSTALL_SUPPORTFILESDIR}) ENDIF() -FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small) +FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small wsrep) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${inifile}.cnf.sh ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} @@ -94,6 +94,12 @@ IF(UNIX) DESTINATION ${inst_location} COMPONENT SupportFiles PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/wsrep_notify.sh + ${CMAKE_CURRENT_BINARY_DIR}/wsrep_notify @ONLY) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wsrep_notify + DESTINATION ${inst_location} COMPONENT SupportFiles + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ + GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) IF (INSTALL_SYSCONFDIR) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql-log-rotate DESTINATION ${INSTALL_SYSCONFDIR}/logrotate.d diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index 794b3ecbbbb..9c4d8e35ec5 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -52,6 +52,7 @@ datadir= # 0 means don't wait at all # Negative numbers mean to wait indefinitely service_startup_timeout=900 +startup_sleep=1 # Lock directory for RedHat / SuSE. lockdir='/var/lock/subsys' @@ -239,6 +240,8 @@ wait_for_gone () { wait_for_ready () { + sst_progress_file=$datadir/sst_in_progress + i=0 while test $i -ne $service_startup_timeout ; do @@ -252,9 +255,14 @@ wait_for_ready () { break fi + if test -e $sst_progress_file && [ $startup_sleep -ne 10 ];then + echo $echo_n "SST in progress, setting sleep higher" + startup_sleep=10 + fi + echo $echo_n ".$echo_c" i=`expr $i + 1` - sleep 1 + sleep $startup_sleep done @@ -340,7 +348,10 @@ case "$mode" in # Stop the service and regardless of whether it was # running or not, start it again. if $0 stop "$@"; then - $0 start "$@" + if ! $0 start "$@"; then + log_failure_msg "Failed to restart server." + exit 1 + fi else log_failure_msg "Failed to stop running server, so refusing to try to start." exit 1 @@ -417,6 +428,13 @@ case "$mode" in fi exit $r ;; + 'bootstrap') + # Bootstrap the cluster, start the first node + # that initiate the cluster + echo $echo_n "Bootstrapping the cluster.. " + $0 start $other_args --wsrep-new-cluster + exit $? + ;; *) # usage basename=`basename "$0"` diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 5af4783f919..ed3b697c0f9 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -69,6 +69,14 @@ # # ---------------------------------------------------------------------------- +# wsrep builds +# ---------------------------------------------------------------------------- +%if %{defined with_wsrep} +%define mysql_version @VERSION@_wsrep_@WSREP_API_VERSION@.@WSREP_PATCH_VERSION@ +%define wsrep_version @WSREP_VERSION@ +%endif + +# ---------------------------------------------------------------------------- # Commercial builds # ---------------------------------------------------------------------------- %if %{undefined commercial} @@ -116,6 +124,13 @@ %endif # ---------------------------------------------------------------------------- +# Packager +# ---------------------------------------------------------------------------- +%if %{undefined mysql_packager} +%define mysql_packager MySQL Build Team <build@mysql.com> +%endif + +# ---------------------------------------------------------------------------- # Distribution support # ---------------------------------------------------------------------------- %if %{undefined distro_specific} @@ -284,9 +299,16 @@ documentation and the manual for more information. ############################################################################## %package -n MySQL-server%{product_suffix} +%if %{defined with_wsrep} +Version: %{mysql_version} +%endif Summary: MySQL: a very fast and reliable SQL database server Group: Applications/Databases +%if %{defined with_wsrep} +Requires: %{distro_requires} rsync lsof +%else Requires: %{distro_requires} +%endif %if 0%{?commercial} Obsoletes: MySQL-server %else @@ -320,6 +342,9 @@ and the manual for more information. This package includes the MySQL server binary as well as related utilities to run and administer a MySQL server. +%if %{defined with_wsrep} +Built with wsrep patch %{wsrep_version}. +%endif If you want to access and work with the database, you have to install package "MySQL-client%{product_suffix}" as well! @@ -411,6 +436,7 @@ This package contains the shared libraries (*.so*) which certain languages and applications need to dynamically load and use MySQL. # ---------------------------------------------------------------------------- +%if %{undefined with_wsrep} %package -n MySQL-embedded%{product_suffix} Summary: MySQL - Embedded library Group: Applications/Databases @@ -440,6 +466,7 @@ The API is identical for the embedded MySQL version and the client/server version. For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ +%endif ############################################################################## %prep @@ -519,6 +546,9 @@ mkdir debug -DMYSQL_UNIX_ADDR="%{mysqldatadir}/mysql.sock" \ -DFEATURE_SET="%{feature_set}" \ -DCOMPILATION_COMMENT="%{compilation_comment_debug}" \ +%if %{defined with_wsrep} + -DWITH_WSREP=1 \ +%endif -DMYSQL_SERVER_SUFFIX="%{server_suffix}" echo BEGIN_DEBUG_CONFIG ; egrep '^#define' include/config.h ; echo END_DEBUG_CONFIG make ${MAKE_JFLAG} VERBOSE=1 @@ -535,6 +565,9 @@ mkdir release -DMYSQL_UNIX_ADDR="%{mysqldatadir}/mysql.sock" \ -DFEATURE_SET="%{feature_set}" \ -DCOMPILATION_COMMENT="%{compilation_comment_release}" \ +%if %{defined with_wsrep} + -DWITH_WSREP=1 \ +%endif -DMYSQL_SERVER_SUFFIX="%{server_suffix}" echo BEGIN_NORMAL_CONFIG ; egrep '^#define' include/config.h ; echo END_NORMAL_CONFIG make ${MAKE_JFLAG} VERBOSE=1 @@ -599,11 +632,20 @@ install -m 755 $MBD/release/support-files/mysql.server $RBR%{_sysconfdir}/init.d # Create a symlink "rcmysql", pointing to the init.script. SuSE users # will appreciate that, as all services usually offer this. -ln -s %{_sysconfdir}/init.d/mysql $RBR%{_sbindir}/rcmysql +ln -sf %{_sysconfdir}/init.d/mysql $RBR%{_sbindir}/rcmysql + +%if %{defined with_wsrep} +# Create a wsrep_sst_rsync_wan symlink. +install -d $RBR%{_bindir} +ln -sf wsrep_sst_rsync $RBR%{_bindir}/wsrep_sst_rsync_wan +%endif # Touch the place where the my.cnf config file might be located # Just to make sure it's in the file list and marked as a config file touch $RBR%{_sysconfdir}/my.cnf +%if %{defined with_wsrep} +touch $RBR%{_sysconfdir}/wsrep.cnf +%endif # Install SELinux files in datadir install -m 600 $MBD/%{src_dir}/support-files/RHEL4-SElinux/mysql.{fc,te} \ @@ -1065,6 +1107,11 @@ echo "=====" >> $STATUS_HISTORY %doc %{src_dir}/Docs/INFO_SRC* %doc release/Docs/INFO_BIN* %doc release/support-files/my-*.cnf +%if %{defined with_wsrep} +%doc %{src_dir}/Docs/README-wsrep +%doc release/support-files/wsrep.cnf +%doc release/support-files/wsrep_notify +%endif %if 0%{?commercial} %doc %attr(644, root, root) %{_infodir}/mysql.info* @@ -1100,6 +1147,9 @@ echo "=====" >> $STATUS_HISTORY %doc %attr(644, root, man) %{_mandir}/man1/resolveip.1* %ghost %config(noreplace,missingok) %{_sysconfdir}/my.cnf +%if %{defined with_wsrep} +%ghost %config(noreplace,missingok) %{_sysconfdir}/wsrep.cnf +%endif %dir %{_sysconfdir}/my.cnf.d %attr(755, root, root) %{_bindir}/innochecksum @@ -1127,6 +1177,14 @@ echo "=====" >> $STATUS_HISTORY %attr(755, root, root) %{_bindir}/replace %attr(755, root, root) %{_bindir}/resolve_stack_dump %attr(755, root, root) %{_bindir}/resolveip +%if %{defined with_wsrep} +%attr(755, root, root) %{_bindir}/wsrep_sst_common +%attr(755, root, root) %{_bindir}/wsrep_sst_mysqldump +%attr(755, root, root) %{_bindir}/wsrep_sst_rsync +%attr(755, root, root) %{_bindir}/wsrep_sst_rsync_wan +%attr(755, root, root) %{_bindir}/wsrep_sst_xtrabackup +%attr(755, root, root) %{_bindir}/wsrep_sst_xtrabackup-v2 +%endif %attr(755, root, root) %{_sbindir}/mysqld %attr(755, root, root) %{_sbindir}/mysqld-debug @@ -1205,8 +1263,10 @@ echo "=====" >> $STATUS_HISTORY %defattr(-, root, root, 0755) %attr(-, root, root) %{_datadir}/mysql-test %attr(755, root, root) %{_bindir}/mysql_client_test +%if %{undefined with_wsrep} %attr(755, root, root) %{_bindir}/mysql_client_test_embedded %attr(755, root, root) %{_bindir}/mysqltest_embedded +%endif %doc %attr(644, root, man) %{_mandir}/man1/mysql_client_test.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql-stress-test.pl.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql-test-run.pl.1* @@ -1214,11 +1274,13 @@ echo "=====" >> $STATUS_HISTORY %doc %attr(644, root, man) %{_mandir}/man1/mysqltest_embedded.1* # ---------------------------------------------------------------------------- +%if %{undefined with_wsrep} %files -n MySQL-embedded%{product_suffix} %defattr(-, root, root, 0755) %attr(755, root, root) %{_bindir}/mysql_embedded %attr(644, root, root) %{_libdir}/mysql/libmysqld.a %attr(644, root, root) %{_libdir}/mysql/libmysqld-debug.a +%endif ############################################################################## # The spec file changelog only includes changes made to the spec file @@ -1252,6 +1314,10 @@ echo "=====" >> $STATUS_HISTORY * Mon Jun 11 2012 Joerg Bruehe <joerg.bruehe@oracle.com> - Make sure newly added "SPECIFIC-ULN/" directory does not disturb packaging. + +* Wed Dec 07 2011 Alexey Yurchenko <alexey.yurchenko@codership.com> + +- wsrep-related cleanups. * Wed Sep 28 2011 Joerg Bruehe <joerg.bruehe@oracle.com> @@ -1305,7 +1371,6 @@ echo "=====" >> $STATUS_HISTORY - Fix bug#12561297: Added the MySQL embedded binary * Thu Jul 07 2011 Joerg Bruehe <joerg.bruehe@oracle.com> - - Fix bug#45415: "rpm upgrade recreates test database" Let the creation of the "test" database happen only during a new installation, not in an RPM upgrade. diff --git a/support-files/rpm/server.cnf b/support-files/rpm/server.cnf index a197868d16c..124fabcb985 100644 --- a/support-files/rpm/server.cnf +++ b/support-files/rpm/server.cnf @@ -11,6 +11,22 @@ # this is only for the mysqld standalone daemon [mysqld] +# +# * Galera-related settings +# +[galera] +# Mandatory settings +#wsrep_provider= +#wsrep_cluster_address= +#binlog_format=row +#default_storage_engine=InnoDB +#innodb_autoinc_lock_mode=2 +#bind-address=0.0.0.0 +# +# Optional setting +#wsrep_slave_threads=1 +#innodb_flush_log_at_trx_commit=0 + # this is only for embedded server [embedded] diff --git a/support-files/wsrep.cnf.sh b/support-files/wsrep.cnf.sh new file mode 100644 index 00000000000..a5390855ca1 --- /dev/null +++ b/support-files/wsrep.cnf.sh @@ -0,0 +1,122 @@ +# This file contains wsrep-related mysqld options. It should be included +# in the main MySQL configuration file. +# +# Options that need to be customized: +# - wsrep_provider +# - wsrep_cluster_address +# - wsrep_sst_auth +# The rest of defaults should work out of the box. + +## +## mysqld options _MANDATORY_ for correct opration of the cluster +## +[mysqld] + +# (This must be substituted by wsrep_format) +binlog_format=ROW + +# Currently only InnoDB storage engine is supported +default-storage-engine=innodb + +# to avoid issues with 'bulk mode inserts' using autoinc +innodb_autoinc_lock_mode=2 + +# Override bind-address +# In some systems bind-address defaults to 127.0.0.1, and with mysqldump SST +# it will have (most likely) disastrous consequences on donor node +bind-address=0.0.0.0 + +## +## WSREP options +## + +# Full path to wsrep provider library or 'none' +wsrep_provider=none + +# Provider specific configuration options +#wsrep_provider_options= + +# Logical cluster name. Should be the same for all nodes. +wsrep_cluster_name="my_wsrep_cluster" + +# Group communication system handle +#wsrep_cluster_address="dummy://" + +# Human-readable node name (non-unique). Hostname by default. +#wsrep_node_name= + +# Base replication <address|hostname>[:port] of the node. +# The values supplied will be used as defaults for state transfer receiving, +# listening ports and so on. Default: address of the first network interface. +#wsrep_node_address= + +# Address for incoming client connections. Autodetect by default. +#wsrep_node_incoming_address= + +# How many threads will process writesets from other nodes +wsrep_slave_threads=1 + +# DBUG options for wsrep provider +#wsrep_dbug_option + +# Generate fake primary keys for non-PK tables (required for multi-master +# and parallel applying operation) +wsrep_certify_nonPK=1 + +# Maximum number of rows in write set +wsrep_max_ws_rows=131072 + +# Maximum size of write set +wsrep_max_ws_size=1073741824 + +# to enable debug level logging, set this to 1 +wsrep_debug=0 + +# convert locking sessions into transactions +wsrep_convert_LOCK_to_trx=0 + +# how many times to retry deadlocked autocommits +wsrep_retry_autocommit=1 + +# change auto_increment_increment and auto_increment_offset automatically +wsrep_auto_increment_control=1 + +# retry autoinc insert, which failed for duplicate key error +wsrep_drupal_282555_workaround=0 + +# enable "strictly synchronous" semantics for read operations +wsrep_causal_reads=0 + +# Command to call when node status or cluster membership changes. +# Will be passed all or some of the following options: +# --status - new status of this node +# --uuid - UUID of the cluster +# --primary - whether the component is primary or not ("yes"/"no") +# --members - comma-separated list of members +# --index - index of this node in the list +wsrep_notify_cmd= + +## +## WSREP State Transfer options +## + +# State Snapshot Transfer method +wsrep_sst_method=rsync + +# Address which donor should send State Snapshot to. +# Should be the address of THIS node. DON'T SET IT TO DONOR ADDRESS!!! +# (SST method dependent. Defaults to the first IP of the first interface) +#wsrep_sst_receive_address= + +# SST authentication string. This will be used to send SST to joining nodes. +# Depends on SST method. For mysqldump method it is root:<root password> +wsrep_sst_auth=root: + +# Desired SST donor name. +#wsrep_sst_donor= + +# Reject client queries when donating SST (false) +#wsrep_sst_donor_rejects_queries=0 + +# Protocol version to use +# wsrep_protocol_version= diff --git a/support-files/wsrep_notify.sh b/support-files/wsrep_notify.sh new file mode 100644 index 00000000000..bdbe3d12a39 --- /dev/null +++ b/support-files/wsrep_notify.sh @@ -0,0 +1,102 @@ +#!/bin/sh -eu + +# This is a simple example of wsrep notification script (wsrep_notify_cmd). +# It will create 'wsrep' schema and two tables in it: 'membeship' and 'status' +# and fill them on every membership or node status change. +# +# Edit parameters below to specify the address and login to server. + +USER=root +PSWD=rootpass +HOST=127.0.0.1 +PORT=3306 + +SCHEMA="wsrep" +MEMB_TABLE="$SCHEMA.membership" +STATUS_TABLE="$SCHEMA.status" + +BEGIN=" +SET wsrep_on=0; +DROP SCHEMA IF EXISTS $SCHEMA; CREATE SCHEMA $SCHEMA; +CREATE TABLE $MEMB_TABLE ( + idx INT UNIQUE PRIMARY KEY, + uuid CHAR(40) UNIQUE, /* node UUID */ + name VARCHAR(32), /* node name */ + addr VARCHAR(256) /* node address */ +) ENGINE=MEMORY; +CREATE TABLE $STATUS_TABLE ( + size INT, /* component size */ + idx INT, /* this node index */ + status CHAR(16), /* this node status */ + uuid CHAR(40), /* cluster UUID */ + prim BOOLEAN /* if component is primary */ +) ENGINE=MEMORY; +BEGIN; +DELETE FROM $MEMB_TABLE; +DELETE FROM $STATUS_TABLE; +" +END="COMMIT;" + +configuration_change() +{ + echo "$BEGIN;" + + local idx=0 + + for NODE in $(echo $MEMBERS | sed s/,/\ /g) + do + echo "INSERT INTO $MEMB_TABLE VALUES ( $idx, " + # Don't forget to properly quote string values + echo "'$NODE'" | sed s/\\//\',\'/g + echo ");" + idx=$(( $idx + 1 )) + done + + echo "INSERT INTO $STATUS_TABLE VALUES($idx, $INDEX, '$STATUS', '$CLUSTER_UUID', $PRIMARY);" + + echo "$END" +} + +status_update() +{ + echo "SET wsrep_on=0; BEGIN; UPDATE $STATUS_TABLE SET status='$STATUS'; COMMIT;" +} + +COM=status_update # not a configuration change by default + +while [ $# -gt 0 ] +do + case $1 in + --status) + STATUS=$2 + shift + ;; + --uuid) + CLUSTER_UUID=$2 + shift + ;; + --primary) + [ "$2" = "yes" ] && PRIMARY="1" || PRIMARY="0" + COM=configuration_change + shift + ;; + --index) + INDEX=$2 + shift + ;; + --members) + MEMBERS=$2 + shift + ;; + esac + shift +done + +# Undefined means node is shutting down +if [ "$STATUS" != "Undefined" ] +then + $COM | mysql -B -u$USER -p$PSWD -h$HOST -P$PORT +fi + +exit 0 +# |