グループとユーザ追加(事前に追加していれば必要なし)
# groupadd mysql # useradd -s /sbin/nologin -g mysql mysql ←ログイン不可ユーザの追加
インストール
$ ./configure --prefix=/usr/local/mysql-cluster-gpl-7.1.18 --with-charset=utf8 --with-extra-charsets=all --sysconfdir=/usr/local/mysql-cluster/etc --with-unix-socket-path=/usr/local/mysql-cluster/tmp/mysql.sock --with-tcp-port=3308 --enable-thread-safe-client --with-plugins=partition,innobase,ndbcluster --localstatedir=/var/lib/mysql-cluster $ make # make install
シンボリックリンク作成
$ cd /usr/local # ln -s mysql-cluster-gpl-7.1.18 mysql-cluster
初期設定
# mkdir /usr/local/mysql-cluster/etc # cp ./support-files/my-huge.cnf /usr/local/mysql-cluster/etc/my.cnf # vi /usr/local/mysql-cluster/etc/my.cnf [mysqld] ndbcluster > ndb-connectstring = 127.0.0.1 # /usr/local/mysql-cluster/bin/mysql_install_db --user=mysql $ cd /var/lib # ln -s mysql-cluster-gpl-7.1.18 mysql-cluster $ cd /usr/local/src/mysql-cluster-gpl-7.1.18 # cp ./support-files/ndb-config-2-node.ini /var/lib/mysql-cluster/config.ini # vi /var/lib/mysql-cluster/config.ini [ndbd default] NoOfReplicas= 1 [ndb_mgmd] NodeId=1 HostName= 127.0.0.1 [ndbd] NodeId= 2 HostName= 127.0.0.1 これ以外の[ndbd]セクションは削除。 [mysqld] NodeId= 3 > HostName= 127.0.0.1 これ以外の[mysqld]セクションは削除。 #PortNumber= 63132
起動スクリプト設定
# cp ./support-files/mysql.server /etc/init.d/mysql-cluster 起動スクリプト内のmysql-cluster-gpl-7.1.18をmysql-clusterに置換 # sed -i 's/mysql-cluster-gpl-7.1.18/mysql-cluster/g' /etc/init.d/mysql-cluster 編集 # vi /etc/init.d/mysql-cluster # chkconfig: 2345 65 35 # Provides: mysql-cluster # chmod +x /etc/init.d/mysql-cluster # /sbin/chkconfig mysql-cluster on
ndb_mgmd、ndbmtdの初回起動
# /usr/local/mysql-cluster/libexec/ndb_mgmd --daemon --config-file /var/lib/mysql-cluster/config.ini # /usr/local/mysql-cluster/libexec/ndbmtd --initial ←initialは初回のみ
一旦停止
# /usr/local/mysql-cluster/bin/ndb_mgm ndb_mgm> shutdown ndb_mgm> exit # pkill ndb_mgmd
ndb_mgmd用起動スクリプトの作成
# vi /etc/init.d/ndb_mgmd
/etc/init.d/ndb_mgmd
#!/bin/bash
#
# Version: 0.1
#
# chkconfig: 2345 63 37
# description: Runs the ndb_mgmd
# processname: /usr/local/mysql-cluster/libexec/ndb_mgmd
# config: /var/lib/mysql-cluster/config.ini
# We require the /etc/delegeted.conf file, but supply it in the package, so it
# should always be there.
progname=ndb_mgmd
lockfile=/var/lock/subsys/ndb_mgmd
prog=/usr/local/mysql-cluster/libexec/ndb_mgmd
conffile=/var/lib/mysql-cluster/config.ini
[ -f $conffile ] || exit $?
# Source function library.
. /etc/init.d/functions
RETVAL=0
start() {
echo -n $"Starting $progname: "
daemon $prog --config-file $conffile
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch $lockfile
return $RETVAL
}
stop() {
echo -n $"Stopping $progname: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $lockfile
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $prog
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f $lockfile ]; then
stop
start
fi
;;
reload)
action $"Reloading $progname:" killall -HUP $prog
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
exit 1
esac
exit $RETVAL
ndbmtd用起動スクリプトの作成
# vi /etc/init.d/ndbmtd
/etc/init.d/ndbmtd
#!/bin/bash
#
# Version: 0.1
#
# chkconfig: 2345 64 36
# description: Runs the ndbmtd
# processname: /usr/local/mysql-cluster/libexec/ndbmtd
# config:
# We require the /etc/delegeted.conf file, but supply it in the package, so it
# should always be there.
progname=ndbmtd
lockfile=/var/lock/subsys/ndbmtd
prog=/usr/local/mysql-cluster/libexec/ndbmtd
conffile=
[ -f $conffile ] || exit $?
# Source function library.
. /etc/init.d/functions
RETVAL=0
start() {
echo -n $"Starting $progname: "
daemon $prog
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch $lockfile
return $RETVAL
}
stop() {
echo -n $"Stopping $progname: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $lockfile
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $prog
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f $lockfile ]; then
stop
start
fi
;;
reload)
action $"Reloading $progname:" killall -HUP $prog
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
exit 1
esac
exit $RETVAL
起動
# chmod +x /etc/init.d/ndb_mgmd # chmod +x /etc/init.d/ndbmtd # /sbin/chkconfig ndb_mgmd on # /sbin/chkconfig ndbmtd on # /sbin/service ndb_mgmd start # /sbin/service ndbmtd start # /sbin/service mysql-cluster start
アカウント作成
mysql> GRANT ALL ON *.* TO tappe@localhost IDENTIFIED BY 'パスワード' WITH GRANT OPTION; mysql> GRANT ALL ON *.* TO tappe@'%' IDENTIFIED BY 'パスワード' WITH GRANT OPTION;