本脚本有待学完bash之后更新。
#!/bin/bash
#------- write by Neil.xu 2008.0828--------
#save configurations
if [ -f /var/lib/mysql-cluster/config.ini ]
then
cp /var/lib/mysql-cluster/config.ini ~/config.ini_`date +"%Y%m%d-%T"`
fi
if [ -f /etc/my.cnf ]
then
cp /etc/my.cnf ~/my.cnf_`date +"%Y%m%d-%T"`
fi
# stop service and kill process
service mysql.server stop
killall -9 mysqld_safe mysqld ndb_mgmd ndbd
#clear old files
rm -rf /usr/local/mysql* /var/lib/mysql* /data/mysql-cluster/
#check mysql usee
if ! [ `grep mysql /etc/passwd` ]
then
groupadd -f mysql
useradd -g mysql mysql
fi
#install mysql files
cd ~
tar xzvf mysql-cluster-com-6.2.15-linux-x86_64-glibc23.tar.gz
mv -f ~/mysql-cluster-com-6.2.15-linux-x86_64-glibc23 /usr/local
ln -s /usr/local/mysql-cluster-com-6.2.15-linux-x86_64-glibc23 /usr/local/mysql
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
#install mgmd
echo " Would you like to run mgmd ? y/n "
read mgmd
if [ $mgmd == "y" ]
then
mkdir -p /var/lib/mysql-cluster
cp /usr/local/mysql/bin/ndb* /usr/local/bin
chmod +x /usr/local/bin/ndb*
fi
#install ndbd
echo " Would you like to run ndbd ? y/n "
read ndbd
if [ $ndbd == "y" ]
then
mkdir -p /data/mysql-cluster/
cp /usr/local/mysql/bin/ndb* /usr/local/bin
chmod +x /usr/local/bin/ndb*
fi
echo " Would you like to run mysqld ? y/n "
read mysqld
if [ $mysqld == "y" ]
then
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chkconfig --add mysql
echo " Please wait "
sleep 5
service mysql start
fi
#bin/mysqld_safe --user=mysql &
exit 0
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/