Enable ndbcluster support, fix a couple of small issues

This commit is contained in:
Tom Lane 2008-07-27 17:54:30 +00:00 committed by Michal Schorm
parent 20564e52c0
commit e9e34fccd8
8 changed files with 411 additions and 12 deletions

15
my.cnf
View File

@ -6,6 +6,21 @@ user=mysql
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# To allow mysqld to connect to a MySQL Cluster management daemon, uncomment
# these lines and adjust the connectstring as needed.
#ndbcluster
#ndb-connectstring="nodeid=4;host=localhost:1186"
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[ndbd]
# If you are running a MySQL Cluster storage daemon (ndbd) on this machine,
# adjust its connection to the management daemon here.
# Note: ndbd init script requires this to include nodeid!
connect-string="nodeid=2;host=localhost:1186"
[ndb_mgm]
# connection string for MySQL Cluster management tool
connect-string="host=localhost:1186"

View File

@ -7,7 +7,7 @@ This patch also improves the documentation a tad.
diff -Naur mysql-5.0.40.orig/mysql-test/README mysql-5.0.40/mysql-test/README
--- mysql-5.0.40.orig/mysql-test/README 2007-04-20 10:14:42.000000000 -0400
+++ mysql-5.0.40/mysql-test/README 2007-05-23 14:41:03.000000000 -0400
@@ -6,6 +6,14 @@
@@ -6,6 +6,17 @@
actually have a co-existing MySQL installation. The tests will not
conflict with it.
@ -17,12 +17,15 @@ diff -Naur mysql-5.0.40.orig/mysql-test/README mysql-5.0.40/mysql-test/README
+ sudo -u mysql ./mysql-test-run
+This will use the installed mysql executables, but will run a private copy
+of the server process (using data files within /usr/share/mysql-test),
+so you need not start the mysqld service beforehand.
+so you need not start the mysqld service beforehand. If you have not
+installed mysql-cluster, use
+ sudo -u mysql ./mysql-test-run --skip-ndbcluster
+to skip the cluster-related tests.
+
All tests must pass. If one or more of them fail on your system, please
read the following manual section for instructions on how to report the
problem:
@@ -25,7 +33,8 @@
@@ -25,7 +36,8 @@
With no test cases named on the command line, mysql-test-run falls back
to the normal "non-extern" behavior. The reason for this is that some

17
mysql-no-dbug.patch Normal file
View File

@ -0,0 +1,17 @@
Don't build the dbug manual. We aren't going to install it anyway, so
there's no need to do so. Attempting to build it causes crashes if one
has built with -DDBUG_OFF, as we do by default. Per bug #437053.
diff -Naur mysql-5.0.51a.orig/dbug/Makefile.am mysql-5.0.51a/dbug/Makefile.am
--- mysql-5.0.51a.orig/dbug/Makefile.am 2008-01-11 09:43:29.000000000 -0500
+++ mysql-5.0.51a/dbug/Makefile.am 2008-07-27 12:21:56.000000000 -0400
@@ -35,7 +35,7 @@
factorial_SOURCES = my_main.c factorial.c
dbug_analyze_SOURCES = dbug_analyze.c
-all: user.t user.ps
+all:
user.t: user.r $(NROFF_INC)
-nroff -mm user.r > $@

View File

@ -46,7 +46,7 @@ start(){
chmod 0640 "$errlogfile"
[ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile"
if [ ! -d "$datadir/mysql" ] ; then
action $"Initializing MySQL database: " /usr/bin/mysql_install_db
action $"Initializing MySQL database: " /usr/bin/mysql_install_db --datadir="$datadir" --user=mysql
ret=$?
chown -R mysql:mysql "$datadir"
if [ $ret -ne 0 ] ; then
@ -60,7 +60,7 @@ start(){
# but we need to be sure.
/usr/bin/mysqld_safe --datadir="$datadir" --socket="$socketfile" \
--log-error="$errlogfile" --pid-file="$mypidfile" \
>/dev/null 2>&1 &
--user=mysql >/dev/null 2>&1 &
ret=$?
# Spin for a maximum of N seconds waiting for the server to come up.
# Rather than assuming we know a valid username, accept an "access

View File

@ -1,6 +1,6 @@
Name: mysql
Version: 5.0.51a
Release: 1%{?dist}
Release: 2%{?dist}
Summary: MySQL client programs and shared libraries
Group: Applications/Databases
URL: http://www.mysql.com
@ -16,6 +16,9 @@ Source1: mysql.init
Source3: my.cnf
Source4: scriptstub.c
Source5: my_config.h
Source6: ndbd.init
Source7: ndb_mgmd.init
Source8: ndb_types.h
# Working around perl dependency checking bug in rpm FTTB. Remove later.
Source999: filter-requires-mysql.sh
Patch1: mysql-libdir.patch
@ -30,6 +33,7 @@ Patch9: mysql-bdb-link.patch
Patch10: mysql-bdb-open.patch
Patch11: mysql-innodb-crash.patch
Patch12: mysql-ssl.patch
Patch13: mysql-no-dbug.patch
Patch14: mysql-ss-test.patch
Patch15: mysql-stack-guard.patch
@ -86,6 +90,22 @@ client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories.
%package cluster
Summary: MySQL Cluster daemons and related files
Group: Applications/Databases
Requires: %{name} = %{version}-%{release}
Conflicts: MySQL-storage-cluster
Conflicts: MySQL-management-cluster
Conflicts: MySQL-tools-cluster
Conflicts: MySQL-extra-cluster
%description cluster
MySQL is a multi-user, multi-threaded SQL database server.
MySQL Cluster is a distributed in-memory data store that can be accessed
by a MySQL server. This package contains the programs needed to run a MySQL
Cluster installation.
%package devel
Summary: Files for development of MySQL applications
@ -139,6 +159,7 @@ the MySQL sources.
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
@ -172,6 +193,7 @@ export CFLAGS CXXFLAGS
--with-mysqld-user="mysql" \
--with-extra-charsets=all \
--with-innodb \
--with-ndbcluster \
--with-berkeley-db \
--enable-local-infile \
--enable-largefile \
@ -206,12 +228,14 @@ rm -rf $RPM_BUILD_ROOT
%makeinstall
# multilib header hack
# multilib header hacks
# we only apply this to known Red Hat multilib arches, per bug #181335
case `uname -i` in
i386 | x86_64 | ppc | ppc64 | s390 | s390x | sparc | sparcv9 | sparc64 )
install -m 644 include/my_config.h $RPM_BUILD_ROOT/usr/include/mysql/my_config_`uname -i`.h
mv $RPM_BUILD_ROOT/usr/include/mysql/my_config.h $RPM_BUILD_ROOT/usr/include/mysql/my_config_`uname -i`.h
install -m 644 %{SOURCE5} $RPM_BUILD_ROOT/usr/include/mysql/
mv $RPM_BUILD_ROOT/usr/include/mysql/ndb/ndb_types.h $RPM_BUILD_ROOT/usr/include/mysql/ndb/ndb_types_`uname -i`.h
install -m 644 %{SOURCE8} $RPM_BUILD_ROOT/usr/include/mysql/ndb/
;;
*)
;;
@ -228,8 +252,11 @@ gzip ${RPM_BUILD_ROOT}%{_infodir}/*
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
mkdir -p $RPM_BUILD_ROOT/var/run/mysqld
install -m 0755 -d $RPM_BUILD_ROOT/var/lib/mysql
install -m 0755 -d $RPM_BUILD_ROOT/var/lib/mysql-cluster
install -m 0755 %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/mysqld
install -m 0644 %{SOURCE3} $RPM_BUILD_ROOT/etc/my.cnf
install -m 0755 %{SOURCE6} $RPM_BUILD_ROOT/etc/rc.d/init.d/ndbd
install -m 0755 %{SOURCE7} $RPM_BUILD_ROOT/etc/rc.d/init.d/ndb_mgmd
rm -f $RPM_BUILD_ROOT/%{_infodir}/dir*
mv $RPM_BUILD_ROOT/usr/sql-bench $RPM_BUILD_ROOT%{_datadir}/sql-bench
mv $RPM_BUILD_ROOT/usr/mysql-test $RPM_BUILD_ROOT%{_datadir}/mysql-test
@ -246,11 +273,11 @@ rm -f ${RPM_BUILD_ROOT}%{_bindir}/make_win_src_distribution
rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/make_win_bin_dist.1*
rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/make_win_src_distribution.1*
rm -f ${RPM_BUILD_ROOT}%{_libdir}/mysql/libmysqlclient*.la
rm -f ${RPM_BUILD_ROOT}%{_libdir}/mysql/libndbclient.la
rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/binary-configure
rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/make_binary_distribution
rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/make_sharedlib_distribution
rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/mi_test_all*
rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/ndb-config-2-node.ini
rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/mysql.server
rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/mysqld_multi.server
rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/MySQL-shared-compat.spec
@ -261,8 +288,12 @@ rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/mysql-*.spec
rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/mysql-log-rotate
rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/mysql-stress-test.pl.1*
rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/mysql-test-run.pl.1*
rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/ndbd.1*
rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/ndb_*.1*
rm -f ${RPM_BUILD_ROOT}/usr/libexec/ndb_cpcd
rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/ndb_cpcd.1*
# for the moment, remove ndb_size because of dependency on HTML::Template
rm -f ${RPM_BUILD_ROOT}%{_bindir}/ndb_size.pl
rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/ndb_size.pl.1*
rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/ndb_size.tmpl
mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d
echo "%{_libdir}/mysql" > $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf
@ -274,6 +305,10 @@ rm -rf $RPM_BUILD_ROOT
/usr/sbin/useradd -M -o -r -d /var/lib/mysql -s /bin/bash \
-c "MySQL Server" -u 27 mysql > /dev/null 2>&1 || :
%pre cluster
/usr/sbin/useradd -M -o -r -d /var/lib/mysql -s /bin/bash \
-c "MySQL Server" -u 27 mysql > /dev/null 2>&1 || :
%post
/sbin/install-info %{_infodir}/mysql.info.gz %{_infodir}/dir
@ -287,6 +322,13 @@ fi
/bin/chmod 0755 /var/lib/mysql
/bin/touch /var/log/mysqld.log
%post cluster
if [ $1 = 1 ]; then
/sbin/chkconfig --add ndbd
/sbin/chkconfig --add ndb_mgmd
fi
/bin/chmod 0755 /var/lib/mysql-cluster
%preun
if [ $1 = 0 ]; then
/sbin/install-info --delete %{_infodir}/mysql.info.gz %{_infodir}/dir || :
@ -297,6 +339,12 @@ if [ $1 = 0 ]; then
/sbin/chkconfig --del mysqld
fi
%preun cluster
if [ $1 = 0 ]; then
/sbin/chkconfig --del ndb_mgmd
/sbin/chkconfig --del ndbd
fi
%postun libs
if [ $1 = 0 ] ; then
/sbin/ldconfig
@ -308,6 +356,12 @@ if [ $1 -ge 1 ]; then
/sbin/service mysqld condrestart >/dev/null 2>&1 || :
fi
%postun cluster
if [ $1 -ge 1 ]; then
/sbin/service ndb_mgmd condrestart >/dev/null 2>&1 || :
/sbin/service ndbd condrestart >/dev/null 2>&1 || :
fi
%files
%defattr(-,root,root)
@ -331,7 +385,6 @@ fi
%{_infodir}/*
%{_mandir}/man1/mysql.1*
%{_mandir}/man1/mysql_config.1*
%{_mandir}/man1/mysql_find_rows.1*
%{_mandir}/man1/mysql_tableinfo.1*
%{_mandir}/man1/mysql_waitpid.1*
@ -353,6 +406,7 @@ fi
%dir %{_libdir}/mysql
%{_libdir}/mysql/libmysqlclient*.so.*
%{_libdir}/mysql/libndbclient.so.*
/etc/ld.so.conf.d/*
%dir %{_datadir}/mysql
@ -425,6 +479,7 @@ fi
%{_mandir}/man1/mysql_convert_table_format.1*
%{_mandir}/man1/myisam_ftdump.1*
%{_mandir}/man1/mysql.server.1*
%{_mandir}/man1/mysql_config.1*
%{_mandir}/man1/mysql_explain_log.1*
%{_mandir}/man1/mysql_fix_extensions.1*
%{_mandir}/man1/mysql_fix_privilege_tables.1*
@ -465,11 +520,58 @@ fi
%attr(0755,mysql,mysql) %dir /var/lib/mysql
%attr(0640,mysql,mysql) %config(noreplace) %verify(not md5 size mtime) /var/log/mysqld.log
%files cluster
%defattr(-,root,root)
%{_bindir}/ndb_config
%{_bindir}/ndb_delete_all
%{_bindir}/ndb_desc
%{_bindir}/ndb_drop_index
%{_bindir}/ndb_drop_table
%{_bindir}/ndb_error_reporter
%{_bindir}/ndb_mgm
%{_bindir}/ndb_restore
%{_bindir}/ndb_select_all
%{_bindir}/ndb_select_count
%{_bindir}/ndb_show_tables
#%{_bindir}/ndb_size.pl
%{_bindir}/ndb_test_platform
%{_bindir}/ndb_waiter
/usr/libexec/ndb_mgmd
/usr/libexec/ndbd
%{_datadir}/mysql/ndb-*.ini
#%{_datadir}/mysql/ndb_size.tmpl
/etc/rc.d/init.d/ndbd
/etc/rc.d/init.d/ndb_mgmd
%attr(0755,mysql,mysql) %dir /var/lib/mysql-cluster
%{_mandir}/man1/ndb_config.1*
%{_mandir}/man1/ndb_delete_all.1*
%{_mandir}/man1/ndb_desc.1*
%{_mandir}/man1/ndb_drop_index.1*
%{_mandir}/man1/ndb_drop_table.1*
%{_mandir}/man1/ndb_error_reporter.1*
%{_mandir}/man1/ndb_mgm.1*
%{_mandir}/man1/ndb_mgmd.1*
%{_mandir}/man1/ndb_print_backup_file.1*
%{_mandir}/man1/ndb_print_schema_file.1*
%{_mandir}/man1/ndb_print_sys_file.1*
%{_mandir}/man1/ndb_restore.1*
%{_mandir}/man1/ndb_select_all.1*
%{_mandir}/man1/ndb_select_count.1*
%{_mandir}/man1/ndb_show_tables.1*
#%{_mandir}/man1/ndb_size.pl.1*
%{_mandir}/man1/ndb_waiter.1*
%{_mandir}/man1/ndbd.1*
%files devel
%defattr(-,root,root)
/usr/include/mysql
%{_libdir}/mysql/*.a
%{_libdir}/mysql/libmysqlclient*.so
%{_libdir}/mysql/libndbclient.so
%files bench
%defattr(-,root,root)
@ -483,6 +585,16 @@ fi
%{_mandir}/man1/mysql_client_test.1*
%changelog
* Sun Jul 27 2008 Tom Lane <tgl@redhat.com> 5.0.51a-2
- Enable ndbcluster support
Resolves: #163758
- Suppress odd crash messages during package build, caused by trying to
build dbug manual (which we don't install anyway) with dbug disabled
Resolves: #437053
- Improve mysql.init to pass configured datadir to mysql_install_db,
and to force user=mysql for both mysql_install_db and mysqld_safe.
Related: #450178
* Mon Mar 3 2008 Tom Lane <tgl@redhat.com> 5.0.51a-1
- Update to mysql version 5.0.51a

116
ndb_mgmd.init Normal file
View File

@ -0,0 +1,116 @@
#!/bin/bash
#
# ndb_mgmd This shell script takes care of starting and stopping
# the MySQL Cluster management daemon (ndb_mgmd).
#
# chkconfig: - 62 38
# description: MySQL Cluster management daemon.
# processname: ndb_mgmd
# config: /var/lib/mysql-cluster/config.ini
# pidfile: /var/lib/mysql-cluster/ndb_${node_id}.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
prog="ndb_mgmd"
# extract value of a MySQL option from config files
# Usage: get_mysql_option SECTION VARNAME DEFAULT
# result is returned in $result
# We use my_print_defaults which prints all options from multiple files,
# with the more specific ones later; hence take the last match.
get_mysql_option(){
result=`/usr/bin/my_print_defaults --extra-file=/var/lib/mysql-cluster/config.ini "$1" | sed -n "s/^--$2=//p" | tail -n 1`
if [ -z "$result" ]; then
# not found, use default
result="$3"
fi
}
get_mysql_option ndb_mgmd id "1"
node_id="$result"
errlogfile="/var/lib/mysql-cluster/ndb_${node_id}_out.log"
pidfile="/var/lib/mysql-cluster/ndb_${node_id}.pid"
# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
SU=runuser
else
SU=su
fi
start(){
touch "$errlogfile"
chown mysql:mysql "$errlogfile"
chmod 0640 "$errlogfile"
[ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile"
# all options are expected to be specified in
# /var/lib/mysql-cluster/config.ini.
$SU -l mysql -c "cd /var/lib/mysql-cluster; /usr/libexec/ndb_mgmd" >> "$errlogfile" 2>&1 < /dev/null
ret=$?
if [ $ret -eq 0 ]; then
action $"Starting $prog: " /bin/true
else
action $"Starting $prog: " /bin/false
fi
[ $ret -eq 0 ] && touch /var/lock/subsys/ndb_mgmd
return $ret
}
stop(){
NDB_MGMD_PID=`cat "$pidfile" 2>/dev/null `
if [ -n "$NDB_MGMD_PID" ]; then
/usr/bin/ndb_mgm -e shutdown >/dev/null
ret=$?
if [ $ret -eq 0 ]; then
rm -f /var/lock/subsys/ndb_mgmd
rm -f "$pidfile"
action $"Stopping $prog: " /bin/true
else
action $"Stopping $prog: " /bin/false
fi
else
ret=1
action $"Stopping $prog: " /bin/false
fi
return $ret
}
restart(){
stop
start
}
condrestart(){
[ -e /var/lock/subsys/ndb_mgmd ] && restart || :
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status ndb_mgmd
;;
restart)
restart
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|condrestart|restart}"
exit 1
esac
exit $?

25
ndb_types.h Normal file
View File

@ -0,0 +1,25 @@
/*
* Kluge to support multilib installation of both 32- and 64-bit RPMS:
* we need to arrange that header files that appear in both RPMs are
* identical. Hence, this file is architecture-independent and calls
* in an arch-dependent file that will appear in just one RPM.
*
* To avoid breaking arches not explicitly supported by Red Hat, we
* use this indirection file *only* on known multilib arches.
*
* Note: this may well fail if user tries to use gcc's -I- option.
* But that option is deprecated anyway.
*/
#if defined(__x86_64__)
#include "ndb_types_x86_64.h"
#elif defined(__i386__)
#include "ndb_types_i386.h"
#elif defined(__ppc64__) || defined(__powerpc64__)
#include "ndb_types_ppc64.h"
#elif defined(__ppc__) || defined(__powerpc__)
#include "ndb_types_ppc.h"
#elif defined(__s390x__)
#include "ndb_types_s390x.h"
#elif defined(__s390__)
#include "ndb_types_s390.h"
#endif

111
ndbd.init Normal file
View File

@ -0,0 +1,111 @@
#!/bin/bash
#
# ndbd This shell script takes care of starting and stopping
# the MySQL Cluster data node daemon (ndbd).
#
# chkconfig: - 63 37
# description: MySQL Cluster data node daemon.
# processname: ndbd
# config: /etc/my.cnf
# pidfile: /var/lib/mysql-cluster/ndb_${node_id}.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
prog="ndbd"
# extract value of a MySQL option from config files
# Usage: get_mysql_option SECTION VARNAME DEFAULT
# result is returned in $result
# We use my_print_defaults which prints all options from multiple files,
# with the more specific ones later; hence take the last match.
get_mysql_option(){
result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1`
if [ -z "$result" ]; then
# not found, use default
result="$3"
fi
}
get_mysql_option ndbd connect-string "nodeid=2;host=localhost:1186"
ndbd_connect_string="$result"
node_id=`echo "$result" | sed 's/^nodeid=\([0-9]*\);.*$/\1/'`
connect_string=`echo "$result" | sed 's/^.*host=//'`
pidfile="/var/lib/mysql-cluster/ndb_${node_id}.pid"
# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
SU=runuser
else
SU=su
fi
start(){
# all options are expected to be specified in /etc/my.cnf
$SU -l mysql -c "/usr/libexec/ndbd" >/dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]; then
action $"Starting $prog: " /bin/true
else
action $"Starting $prog: " /bin/false
fi
[ $ret -eq 0 ] && touch /var/lock/subsys/ndbd
return $ret
}
stop(){
NDBD_PID=`cat "$pidfile" 2>/dev/null `
if [ -n "$NDBD_PID" ]; then
/usr/bin/ndb_mgm -e "$node_id STOP" "$connect_string" >/dev/null
ret=$?
if [ $ret -eq 0 ]; then
rm -f /var/lock/subsys/ndbd
rm -f "$pidfile"
action $"Stopping $prog: " /bin/true
else
action $"Stopping $prog: " /bin/false
fi
else
ret=1
action $"Stopping $prog: " /bin/false
fi
return $ret
}
restart(){
stop
start
}
condrestart(){
[ -e /var/lock/subsys/ndbd ] && restart || :
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status ndbd
;;
restart)
restart
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|condrestart|restart}"
exit 1
esac
exit $?