Thursday, August 03, 2006

MySQL Cluster can be too much typing

Testing the MySQL Cluster can mean a lot of typing. Not being the best typist and getting tired of typing the same thing over and over again I created a short cut to make life better.

I have a file called shortcut.sh. Inside my .bash_profile for each of my test systems, I have added this file to be run when I login.

.bash_profile example

. /home/ndb/jmiller/shortcut.sh

Then all the command and connection strings I need are just few key strokes away.

shortcut.sh

alias ndbd='/home/ndb/jmiller/builds/libexec/ndbd'

alias ndb_mgmd='/home/ndb/jmiller/builds/libexec/ndb_mgmd'

alias ndb_mgm='/home/ndb/jmiller/builds/bin/ndb_mgm'

alias mysql='/home/ndb/jmiller/builds/bin/mysql'

alias mysql_server='/etc/init.d/mysql.server'

alias ndb_restore='/home/ndb/jmiller/builds/bin/ndb_restore'

alias mysqldump='/home/ndb/jmiller/builds/bin/mysqldump'

alias installdb='/home/ndb/jmiller/builds/bin/mysql_install_db'

export NDB_CONNECTSTRING=n10:14000

alias mysqladmin='/home/ndb/jmiller/builds/bin/mysqladmin'

dbvar="/space/var"

ndbrun="/space/run"

jmiller="/home/ndb/jmiller"

Before doing this, to start a cluster I would have to do the following:

(short example)

Either cd to

$> /home/ndb/jmiller/builds/libexec/

or

type

$> /home/ndb/jmiller/builds/libexec/ndb_mgmd -f /path/to/config/file

and then

$>/home/ndb/jmiller/builds/libexec/ndbd -c n10:14000 --initial

as you can see this would get to be tiring.

By adding the shortcut, I can just do

$>ndb_mgmd -f /path/to/config/file

$> ndbd --initial

Note that since I exported my NDB_CONNECTSTRING I do not need to include the -c option when starting the ndbd. In addition, I can now use ndb_mgm (mgt client) any where on the host and I do not need to include the connect string.

example:

$>ndb_mgm -e show

$>ndb_mgm -e "all status"

$>ndb_mgm -e shutdown

In addition I created in the file above some shortcuts to directories that I often need to go to.

Example:

cd /space/var

Or

cd $db

It only saved 7 key strokes, but in a day of typing that can really add up.

In short, we are supposed to work smarter, not harder. Hope this helps for those using MySQL Cluster

1 comment:

burtonator said...

You can do all/most of that with the PATH env var....... dude ;)