PDA

View Full Version : Installing MySQL-Max 5.0.21 On FC5



asyadiqin
17th May 2006, 12:17 PM
i have a freshly installed Fedora Core 5, with the standard package installation, eg. MySQL 5, PHP 5, Apache 2, etc... I need to install MySQL-Max 5.0.21 but yum could not locate that version of MySQL when I did a yum search.

I've been to the MySQL website and there was a list of files for MySQL-Max 5.0.21, but I am not sure which files I should download that works with FC5. If anyone have succesfully installed MySQL-Max 5.0.21 on FC5, could you please post detailed instructions on how you have installed it. Alternatively you can point me to the right direction where I can find installation notes for MySQL-Max AND specifically with FC5 or any version of FC.

Please also include detailed instructions on what I should uninstall/install, eg. PHP5, etc... before or after installing MySQL-Max 5.0.21.

Thanks in advance for any help.

PS : Its been ages since I've installed linux boxes, :p so please be kind and include as much details as possible. Thanks. ;)

Regards

asyadiqin
12th July 2006, 04:49 PM
Does anyone knows how to install MySQL-Max on FC5? Can anyone guide me please. Thanks.

overkill
13th September 2006, 01:23 AM
However I dont know how to make a fixit RPM.. If anyone else knows how then please let me know..

Details to follow..

overkill
13th September 2006, 01:39 AM
Ok, you need MySQL Max 5 for NDB support? Having trouble getting the server working? Read on..

NOTE: Assumes a stock install of Fedora Core 5

First things first: Install MySQL from RPM from the Fedora Install CD. This does not have the Max extensions but you need a file from this install first.

Next: COPY /etc/init.d/mysqld startup script to a safe location. eg: /safe/mysqld

Then: DOWNLAOD and INSTALL MySQL RPMs from MySQL.org
These are: Statically compiled GENERIC RPMs, all of them (NOT linked binaries)
NDB Clustering files from the GENERIC dynamically linked RPMs.
All of them that say the word "NDB"

Use the command "rpm -Uvh MySQL-*" to install/upgrade mysql version.

MySQL is now dead.

Now comes the tricky part..

Problem Number 1:
The RPM install has removed the startup script file /etc/init.d/mysqld and replaced it with /etc/init.d/mysql and this file is faulty.. Basically it needs more information.
Simple fix: DELETE the /etc/init.d/mysql startup script and RE-COPY the /safe/mysqld startup script saved earlier to /etc/init.d/mysqld
This file has all the required information.. It just works better..

Problem Number 2:
The MySQL User has been removed thanks to the generic RPM.. Need to re-insert user using following commands: (Taken from mysql rpm install script and modified to work)

groupadd -r mysql
useradd -M -r -d /var/lib/mysql -s /bin/bash -c "MySQL server" -g mysql mysql
usermod -g mysql mysql

This should now have the MySQL user installed.

Problem Number 3:
File permissions do not match new user number, mysql will fail.. Use following commands:
chown mysql.mysql /var/run/mysqld
chown -R mysql.mysql /var/lib/mysql
chown -R mysql.mysql /var/lib/mysql-cluster

Once doing this, use the command:
service mysqld restart

You may see failed when stopping the server, this is ok, it may mean you have not started the service before or the RPM install script has stopped the service..

However, a nice little message saying "Starting MySQL Server - OK" should now show..

running a "ps -a" you should see 2 processes called "mysqld_safe" and "mysql-max"

Log in with:
mysql mysql -u root -p
And once in type:
SHOW ENGINES;

You should now see all the Max extensions are now enabled..

All Done! Enjoy..

Good luck to all of you!

asyadiqin
13th October 2006, 12:52 PM
First of all, thanks for the guide. And sorry for the late reply. I had to reinstalled all the servers due to some unforeseen circumstances.

Anyway, I just need to clarify some stuff below before I proceed.


DOWNLOAD and INSTALL MySQL RPMs from MySQL.org
These are: Statically compiled GENERIC RPMs, all of them (NOT linked binaries)
NDB Clustering files from the GENERIC dynamically linked RPMs.
All of them that say the word "NDB"

MySQL Download Page : http://www.mysql.org/downloads/mysql/5.0.html

1) Which one should I download from? I assumed its the first one, but just needed to be sure.

Linux x86 generic RPM (statically linked against glibc 2.2.5) downloads
OR
Linux x86 generic RPM (dynamically linked) downloads

2) Assuming it IS the first one (ie. statically linked), should I download and install ALL 6 files or just the server?

3) If I was just download the server, should I download the Max version (Max - 5.0.26-0 2.8M) or the other (5.0.26-0 14.7M) or both?

Basically, I really just want to be sure before installing it. I wouldn't know what to do if I did something wrong along the way, so its best to clarify before starting the installation.

Currently, running SHOW ENGINES on the server shows this (I wouldn't know if it helps :P)

=====================================
| MyISAM DEFAULT
| MEMORY YES
| InnoDB YES
| BerkeleyDB YES
| BLACKHOLE NO
| EXAMPLE NO
| ARCHIVE NO
| CSV NO
| ndbcluster NO
| FEDERATED NO
| MRG_MYISAM YES
| ISAM NO
======================================

Thanks again.

asyadiqin
13th October 2006, 01:06 PM
I've tried to install the Max rpm file and get this error :

rpm -Uvh MySQL-Max-5.0.26-0.i386.rpm


error: Failed dependencies:
MySQL-server >= 5.0 is needed by MySQL-Max-5.0.26-0.i386

:(

So, I downloaded the server file and tried to install that and got this error

rpm -Uvh MySQL-server-5.0.26-0.i386.rpm


error: Failed dependencies:
libmysqlclient.so.15 is needed by (installed) perl-DBD-MySQL-3.0002-2.2.2.i386
libmysqlclient.so.15 is needed by (installed) mysql-connector-odbc-3.51.12-1.2.1.i386
libmysqlclient.so.15 is needed by (installed) libdbi-dbd-mysql-0.8.1a-1.2.1.i386
libmysqlclient.so.15 is needed by (installed) qt-MySQL-3.3.5-13.i386
libmysqlclient.so.15 is needed by (installed) mod_auth_mysql-3.0.0-3.i386
libmysqlclient.so.15 is needed by (installed) dovecot-1.0-0.beta8.2.fc5.i386
libmysqlclient.so.15 is needed by (installed) php-mysql-5.1.4-1.i386
libmysqlclient.so.15(libmysqlclient_15) is needed by (installed) dovecot-1.0-0.beta8.2.fc5.i386
libmysqlclient_r.so.15 is needed by (installed) MySQL-python-1.2.0-3.2.2.i386
libmysqlclient_r.so.15 is needed by (installed) mysql-connector-odbc-3.51.12-1.2.1.i386

:(

What should I do now? :confused: PLS HELP ME!!!! :p

Current version of MySQL installed is 5.0.22.

asyadiqin
13th October 2006, 02:44 PM
OK. Somehow I managed to get MySQL to start. This is what I did


COPY /etc/init.d/mysqld startup script to a safe location. eg: /safe/mysqld
Download and install ALL RPMs from http://www.mysql.org/downloads/mysql/5.0.html from (Linux x86 generic RPM (statically linked against glibc 2.2.5) downloads) - Total 7 files
Note : Install the server rpm first with the following command :
rpm -Uvh MySQL-server-5.0.26-0.i386.rpm --nodeps
Continue installing the other 6 rpms, eg. Max, client, libraries, etc...
Download and install 4 NDB Cluster RPMs from (Linux x86 generic RPM (dynamically linked) downloads) from the same site
Delete /etc/init.d/mysql and copy over the saved mysqld file from item(1) above
Add the MySQL group and user
groupadd -r mysql
useradd -M -r -d /var/lib/mysql -s /bin/bash -c "MySQL server" -g mysql mysql
usermod -g mysql mysql
Change the file permission
chown mysql.mysql /var/run/mysqld
chown -R mysql.mysql /var/lib/mysql
chown -R mysql.mysql /var/lib/mysql-cluster
Start MySQL
/etc/init.d/mysqld start
Check whether process is running. You should see 2 process, ie "mysqld_safe" and "mysql-max"
ps -a
Login to MySQL and check if the MySQL engines
mysql -u root -p yourpassword

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8 to server version: 5.0.26-max
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SHOW ENGINES;



Thats about it. If you have any error, check your mysql log file.

tail /var/log/mysqld.log

I am still unsure if this makes my MySQL to be cluster-ready. Below is what I got when I type SHOW ENGINES



MyISAM DEFAULT
MEMORY YES
InnoDB YES
BerkeleyDB YES
BLACKHOLE YES
EXAMPLE YES
ARCHIVE YES
CSV YES
ndbcluster DISABLED
FEDERATED YES
MRG_MYISAM YES
ISAM NO


If anyone knows if this mean that I could use mysql clustering on the server, please tell me.

Anyway, I hope this would help anyone else who need to install MySQL-Max for NDB Clustering. Thanks to overkill ;) for his wonderful guide/instructions

asyadiqin
13th October 2006, 03:55 PM
There are 4 NDB Cluster RPMs from the MySQL Download site :-


NDB Cluster - Storage engine (contains the NDB Data Node program)
NDB Cluster - Storage engine management (contains the NDB Management Server)
NDB Cluster - Storage engine basic tools
NDB Cluster - Storage engine extra tools


I am thinking of creating 1 main server with 2 nodes. My question is which RPM should I install on the main server and which RPM should be installed on the node servers?

Thanks

overkill
13th October 2006, 11:51 PM
Which RPMs?
I would suggest that you install all 4 NDB RPMs on every one of your servers.. Whether they be management nodes or cluster nodes.. This way if your management server fails, you can then quickly re-create a management server out of one of your cluster nodes, and it also means there is no problems with required files on any of your servers..

SHOW ENGINES?
The line that shows "ndbcluster DISABLED".
What you are seeing here is that ndbcluster is now available however it has been disabled.
This is perfectly normal.
From what you have told me, you haven't configured ndbcluster on any of your management or cluster nodes yet.

You can find a good howto on setting up a mysql cluster here: It may be for debian, but its exactly the same in Fedora.
http://www.howtoforge.com/loadbalanced_mysql_cluster_debian

Once you have configured it using that guide, you should start seeing "ndbcluster YES" in the show engines script.

Server Startup:
I will post my init.d scripts I created for starting and stopping the NDB_MGM and NDBD services on system boot. These will need to be saved as seperate files.

overkill
13th October 2006, 11:57 PM
Save as "ndbd" eg: /etc/init.d/ndbd
After saving as that file, evecute the following command:
chkconfig --add ndbd

this will add it to chkconfig making it easy to manage and control for system startup
================================================== ======
#!/bin/bash
#
# ndbd This shell script takes care of starting and stopping
# the MySQL NDB cluster server subsystem (ndb_mgmd).
#
# chkconfig: 2345 60 37
# description: MySQL NDB Cluster Server
# processname: ndbd

# Source function library.
. /etc/rc.d/init.d/functions


start(){
echo -n "Starting ndbd: "
/usr/sbin/ndbd
return 0
}

stop(){
echo -n "Shutting down ndbd: "
killall ndbd
return 0
}

restart(){
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: {start|stop}"
exit 1
esac
exit $?

overkill
13th October 2006, 11:59 PM
Save as "ndb_mgmd" eg: /etc/init.d/ndb_mgmd
After saving as that file, evecute the following command:
chkconfig --add ndb_mgmd

this will add it to chkconfig making it easy to manage and control for system startup
================================================== ======
#!/bin/bash
#
# ndb_mgmd This shell script takes care of starting and stopping
# the MySQL NDB Management server subsystem (ndb_mgmd).
#
# chkconfig: 2345 60 37
# description: MySQL NDB Management Server
# processname: ndb_mgmd

# Source function library.
. /etc/rc.d/init.d/functions


start(){
echo -n "Starting ndb_mgmd: "
/usr/sbin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini
return 0
}

stop(){
echo -n "Shutting down ndb_mgmd: "
killall ndb_mgmd
return 0
}

restart(){
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: {start|stop}"
exit 1
esac
exit $?

overkill
14th October 2006, 12:01 AM
Disclaimer:
I have not spent much time writing the chkconfig init.d scripts, and as such they may very well be not the best thing to do..

If anyone out there would like to re-write my init.d startup scripts to make them work better, please fell free and post the new scripts back here.. As long as they actually do work better :-P

overkill
14th October 2006, 12:02 AM
I believe the firewall stuff still only uses port 3306 for MySQL and NDB Cluster communication.. However I think I may be wrong.. If anyone out there can tell us all which ports are required for NDB it would be greatly appreciated!

asyadiqin
16th October 2006, 09:57 AM
Hi,

I followed the instructions to add the file to /etc/init.d but when I tried starting it by running the following in shell :-


/etc/init.d/ndbd start

I get this error


Starting ndbd: error=2350
2006-10-16 09:51:16 [ndbd] INFO -- Error handler restarting system
2006-10-16 09:51:16 [ndbd] INFO -- Error handler shutdown completed - exiting
sphase=0
exit=-1


Running "stop" or "restart" only gave me this message :-


Shutting down ndbd: Terminated

I have not added the ndbd_management yet but hope to get this sorted out before adding that.

Thanks again.

overkill
16th October 2006, 10:50 AM
I am sorry, but I am no good with startup scripts, and haven't put much time into the development of them..

Hopefully someone else more experienced can write a good startup script for us..

Good luck!

asyadiqin
16th October 2006, 11:15 AM
As far as I know, running "/etc/init.d/mysqld start" works fine and running "ps -a", I can see that the 2 process are running.

However, running


/etc/init.d/mysqld status

will always give me this message.


mysqld dead but subsys locked

Any insight as to why this is happening?

Below is the content of /etc/init.d/mysqld



#!/bin/bash
#
# mysqld This shell script takes care of starting and stopping
# the MySQL subsystem (mysqld).
#
# chkconfig: - 64 36
# description: MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile: /var/run/mysqld/mysqld.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network


prog="MySQL"

# extract value of a MySQL option from /etc/my.cnf
# Usage: get_mysql_option FILE VARNAME DEFAULT
# result is returned in $result
# Ugly as this is, it knows nothing of option file sections ...
get_mysql_option(){
result=`sed -n "s/^[ \t]*$2[ \t]*=[ \t]*//p" "$1" 2>/dev/null | tail -n 1`
if [ -z "$result" ]; then
# not found, use default
result="$3"
else
# found, still have to deal with quoting and end-of-line comments
dequoted=`echo "$result" | sed "s/^'\([^']*\)'.*$/\1/"`
if [ x"$dequoted" != x"$result" ]; then
result="$dequoted"
else
dequoted=`echo "$result" | sed 's/^"\([^"]*\)".*$/\1/'`
if [ x"$dequoted" != x"$result" ]; then
result="$dequoted"
else
result=`echo "$result" | sed 's/^\([^ \t#]*\).*$/\1/'`
fi
fi
fi
}

get_mysql_option /etc/my.cnf datadir "/var/lib/mysql"
datadir="$result"
get_mysql_option /etc/my.cnf socket "$datadir/mysql.sock"
socketfile="$result"
get_mysql_option /etc/my.cnf log-error "/var/log/mysqld.log"
errlogfile="$result"
get_mysql_option /etc/my.cnf pid-file "/var/run/mysqld/mysqld.pid"
mypidfile="$result"

start(){
touch "$errlogfile"
chown mysql:mysql "$errlogfile"
chmod 0640 "$errlogfile"
[ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile"
if [ ! -d "$datadir/mysql" ] ; then
action $"Initializing MySQL database: " /usr/bin/mysql_install_db
ret=$?
chown -R mysql:mysql "$datadir"
if [ $ret -ne 0 ] ; then
return $ret
fi
fi
chown -R mysql:mysql "$datadir"
chmod 0755 "$datadir"
# The reason for explicitly specifying --pid-file is that there may
# be no such entry in my.cnf, and the default behavior will be to not
# create it at all. Likewise, we specify --log-error in case there
# was not an entry in my.cnf.
/usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --pid-file="$mypidfile" --log-error="$errlogfile" >/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
# denied" response as meaning the server is functioning.
if [ $ret -eq 0 ]; then
STARTTIMEOUT=30
while [ $STARTTIMEOUT -gt 0 ]; do
RESPONSE=`/usr/bin/mysqladmin -uUNKNOWN_MYSQL_USER ping 2>&1` && break
echo "$RESPONSE" | grep -q "Access denied for user" && break
sleep 1
let STARTTIMEOUT=${STARTTIMEOUT}-1
done
if [ $STARTTIMEOUT -eq 0 ]; then
echo "Timeout error occurred trying to start MySQL Daemon."
action $"Starting $prog: " /bin/false
else
action $"Starting $prog: " /bin/true
fi
else
action $"Starting $prog: " /bin/false
fi
[ $ret -eq 0 ] && touch /var/lock/subsys/mysqld
return $ret
}

stop(){
MYSQLPID=`cat "$mypidfile" 2>/dev/null `
if [ -n "$MYSQLPID" ]; then
/bin/kill "$MYSQLPID" >/dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]; then
STOPTIMEOUT=60
while [ $STOPTIMEOUT -gt 0 ]; do
/bin/kill -0 "$MYSQLPID" >/dev/null 2>&1 || break
sleep 1
let STOPTIMEOUT=${STOPTIMEOUT}-1
done
if [ $STOPTIMEOUT -eq 0 ]; then
echo "Timeout error occurred trying to stop MySQL Daemon."
ret=1
action $"Stopping $prog: " /bin/false
else
rm -f /var/lock/subsys/mysqld
rm -f "$socketfile"
action $"Stopping $prog: " /bin/true
fi
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/mysqld ] && restart || :
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status mysqld
;;
restart)
restart
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|condrestart|restart}"
exit 1
esac

exit $?

overkill
16th October 2006, 09:10 PM
I can only assume that is because you are using an initd script for the mysqld daemon, not the mysqld-max daemon.. It may not find the process required because it is looking for mysqld and not mysqld-max..

I have always simply logged into the database server through the mysql console and run commands through there to determine the health of the service..

However without actually looking inside your machine I cannot be sure that this is the case..

asyadiqin
17th October 2006, 09:49 AM
Thanks again for the info, overkill. I manage to sort out the status issue by changing the following



status)
status mysqld

changed to

status)
status mysqld-max


I think I have managed to get the cluster to work. I've configure the management server and the 2 nodes.



[root@fc5-i3 ~]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @192.168.0.101 (Version: 5.0.26, starting, Nodegroup: 0)
id=3 @192.168.0.102 (Version: 5.0.26, starting, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1 (Version: 5.0.26)

[mysqld(API)] 2 node(s)
id=4 (not connected, accepting connect from any host)
id=5 (not connected, accepting connect from any host)

asyadiqin
17th October 2006, 02:05 PM
OK. I've made some changes to the initd script and now everything works fine. I'm posting it here so that it will help anyone who have the same problem.

For the initd script that starts the MySQL server, instead of using the previous initd script, I copied mysql.server to /etc/rc.d/init.d/


cp /usr/share/mysql/mysql.server /etc/init.d/mysql.server

Then performed the following command. The last line remove the mysqld initd script.



chmod 755 /etc/init.d/mysql.server
chkconfig --add mysql.server
chkconfig --del mysqld


Next, in /etc/my.cnf, comment out the basedir

[mysql.server]
user=mysql
#basedir=/var/lib


Now you can start server manually by running the following command

/etc/init.d/mysql.server start

You can check the process using the following command

ps -ef | grep mysql | grep -iv grep
You should see 2 process, ie. mysql_safe and mysqld-max

I have also made some modifications to the ndbd and ndb_mgmd initd scripts.

ndbd initd script


#!/bin/bash
#
# ndbd This shell script takes care of starting and stopping
# the MySQL NDB cluster server subsystem (ndb_mgmd).
#
# chkconfig: 2345 60 37
# description: MySQL NDB Cluster Server
# processname: ndbd

# Source function library.
. /etc/rc.d/init.d/functions


start(){
echo -n "Starting ndbd: "
/usr/sbin/ndbd
return 0
}

stop(){
echo -n "Shutting down ndbd: "
killall ndbd
return 0
}

restart(){
stop
start
}

initial(){
echo -n "Starting ndbd -initial: "
/usr/sbin/ndbd --initial
return 0
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status ndbd
;;
initial)
initial
;;
*)
echo $"Usage: {start|stop|restart|status|initial}"
exit 1
esac
exit $?

NOTE : If you are running the node servers for the first time, OR if you have made any changes to /var/lib/mysql-cluster/config.ini on the management server, use the following to start ndbd


/etc/init.d/ndbd initial


ndb_mgmd


#!/bin/bash
#
# ndb_mgmd This shell script takes care of starting and stopping
# the MySQL NDB Management server subsystem (ndb_mgmd).
#
# chkconfig: 2345 60 37
# description: MySQL NDB Management Server
# processname: ndb_mgmd

# Source function library.
. /etc/rc.d/init.d/functions


start(){
echo -n "Starting ndb_mgmd: "
/usr/sbin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini
return 0
}

stop(){
echo -n "Shutting down ndb_mgmd: "
killall ndb_mgmd
return 0
}

restart(){
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status ndb_mgmd
*)
echo $"Usage: {start|stop|restart|status}"
exit 1
esac
exit $?


I think I have covered all the changes that I have made so far. Hopefully, this will be of some help to someone else. ;) Thanks to overkill for his valuable help.