考虑到游戏批量上线的问题,写了一个游戏mysql的部署脚本,因系统环境一样,所以脚本中并不是去安装mysql,而是将编译好了mysql直接拿过来用#!/bin/bash#2013/11
考虑到游戏批量上线的问题,写了一个游戏mysql的部署脚本,因系统环境一样,,所以脚本中并不是去安装mysql,而是将编译好了mysql直接拿过来用
#!/bin/bash
#2013/11/20
#Email:SongShouJiong@gyyx.cn
cat /dev/null 2>&1
if [ $? -eq 0 ];then
echo "Download MysqlServer.tgz Success!"
else
echo "Download MysqlServer.tgz Error!!!"
fi
echo "--------------------------------------------"
tar zxvf mysql5.tgz > /dev/null 2>&1
if [ $? -eq 0 ];then
echo "Unzip MysqlServer.tgz Success!"
else
echo "Unzip MysqlServer.tgz Error!!!"
fi
echo "/usr/local/mysql5.5/bin/mysqld_safe --defaults-file=/usr/local/mysql5.5/etc/my.cnf --user=mysql &" >> /etc/rc.local
echo "--------------------------------------------"
#mkdir -p /data/mysql/
cd /data/
wget $url/mysql.tgz > /dev/null 2>&1
if [ $? -eq 0 ];then
echo "Download Mysql_Database Success!"
else
echo "Download Mysql_Database Error!!!"
fi
echo "--------------------------------------------"
tar zxvf mysql.tgz > /dev/null 2>&1
if [ $? -eq 0 ];then
echo "Unzip Mysql_Database Success!"
else
echo "Unzip Mysql_Database Error!!"
fi
chown -R mysql.mysql /data/mysql/
ln -s /data/ /home/mysql/
echo "--------------------------------------------"
}
#------------------Start Mysql--------------------------
start_mysql(){
/usr/local/mysql5.5/bin/mysqld_safe --defaults-file=/usr/local/mysql5.5/etc/my.cnf --user=mysql & > /dev/null 2>&1
sleep 3
a=`netstat -tunpl | grep :7036 | wc -l`
if [ $a -gt 0 ];then
echo "Start Mysql Success!"
else
echo "Start Mysql Error!"
fi
echo "--------------------------------------------"
}
#------------------Create Game Database-------------------
create_database(){
#
host=`ifconfig eth0 | grep "inet addr:" | awk '{print $2}' | cut -d: -f2`
wget $url/DB.sql > /dev/null 2>&1
if [ $? -eq 0 ];then
echo "Download DB.sql Success!"
else
echo "Download DB.sql Error!"
fi
echo "----------------------------------------"
wget $url/DB2.sql > /dev/null 2>&1
if [ $? -eq 0 ];then
echo "Download DB2.sql Success!"
else
echo "Download DB2.sql Error!!!"
fi
echo "----------------------------------------"
user=XXXX
passwd=XXXXX
/usr/local/mysql5.5/bin/mysql -u${user} -p${passwd} -e"source DB.sql;"
sleep 3
/usr/local/mysql5.5/bin/mysql -u${user} -p${passwd} -e"source DB2.sql;"
sleep 3
if [ $? -eq 0 ];then
echo "Create Game Database Success!"
else
echo "Create Game Database Error!"
fi
echo "---------------------------------------------"
}
check_disk
add_user
down_mysql
start_mysql
create_database
脚本的指定步骤大概是:检测磁盘是否符合数据库挂载要求------>新建mysql用户------>下载mysql程序包并解压------>启动mysql并添加到开机启动------>新建游戏数据库。
脚本仅供参考,如果您有什么好的建议或者意见,欢迎您Send mail:SongShouJiong@gyyx.cn.
本文出自 “我的未来不是梦。” 博客,请务必保留此出处
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn