|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!思索到游戏批量上线的成绩,写了一个游戏mysql的安排剧本,因体系情况一样,以是剧本中并非往装置mysql,而是将编译好了mysql间接拿过去用- #!/bin/bash#2013/11/20#Email:SongShouJiong@gyyx.cncat<<EOF====================================================|此剧本用于XXXX数据库装置.||--------------------------------------------------||步伐目次:/usr/local/mysql5.5||--------------------------------------------------||数据目次:/home/mysql/data||--------------------------------------------------||剧本运转工夫由步伐下载速率决意,请耐烦期待.......|====================================================EOFurl=http://XXXXXX#-------------------checkdisk------------------------echo"------------------------------------------"check_disk(){iffdisk-l|grep-q/dev/[sh]db;thenifdf-h|grep-q/data;thenecho"Partitionisok!"elseecho"Youmustmount/data!"fielseecho"Youmusthavetwodiskandmountit!"fiecho"------------------------------------------"}#-----------------adduser---------------------------add_user(){useraddmysqlif[$?-eq0];thenecho"UseraddMysqlSuccess!"elseecho"MysqlUserisExits!!!"fiecho"--------------------------------------------"}#----------------downinstallmysql5andmysql----------down_mysql(){cd/usr/localwget$url/mysql5.tgz>/dev/null2>&1if[$?-eq0];thenecho"DownloadMysqlServer.tgzSuccess!"elseecho"DownloadMysqlServer.tgzError!!!"fiecho"--------------------------------------------"tarzxvfmysql5.tgz>/dev/null2>&1if[$?-eq0];thenecho"UnzipMysqlServer.tgzSuccess!"elseecho"UnzipMysqlServer.tgzError!!!"fiecho"/usr/local/mysql5.5/bin/mysqld_safe--defaults-file=/usr/local/mysql5.5/etc/my.cnf--user=mysql&">>/etc/rc.localecho"--------------------------------------------"#mkdir-p/data/mysql/cd/data/wget$url/mysql.tgz>/dev/null2>&1if[$?-eq0];thenecho"DownloadMysql_DatabaseSuccess!"elseecho"DownloadMysql_DatabaseError!!!"fiecho"--------------------------------------------"tarzxvfmysql.tgz>/dev/null2>&1if[$?-eq0];thenecho"UnzipMysql_DatabaseSuccess!"elseecho"UnzipMysql_DatabaseError!!"fichown-Rmysql.mysql/data/mysql/ln-s/data//home/mysql/echo"--------------------------------------------"}#------------------StartMysql--------------------------start_mysql(){/usr/local/mysql5.5/bin/mysqld_safe--defaults-file=/usr/local/mysql5.5/etc/my.cnf--user=mysql&>/dev/null2>&1sleep3a=`netstat-tunpl|grep:7036|wc-l`if[$a-gt0];thenecho"StartMysqlSuccess!"elseecho"StartMysqlError!"fiecho"--------------------------------------------"}#------------------CreateGameDatabase-------------------create_database(){#host=`ifconfigeth0|grep"inetaddr:"|awk{print$2}|cut-d:-f2`wget$url/DB.sql>/dev/null2>&1if[$?-eq0];thenecho"DownloadDB.sqlSuccess!"elseecho"DownloadDB.sqlError!"fiecho"----------------------------------------"wget$url/DB2.sql>/dev/null2>&1if[$?-eq0];thenecho"DownloadDB2.sqlSuccess!"elseecho"DownloadDB2.sqlError!!!"fiecho"----------------------------------------"user=XXXXpasswd=XXXXX/usr/local/mysql5.5/bin/mysql-u${user}-p${passwd}-e"sourceDB.sql;"sleep3/usr/local/mysql5.5/bin/mysql-u${user}-p${passwd}-e"sourceDB2.sql;"sleep3if[$?-eq0];thenecho"CreateGameDatabaseSuccess!"elseecho"CreateGameDatabaseError!"fiecho"---------------------------------------------"}check_diskadd_userdown_mysqlstart_mysqlcreate_database
复制代码 剧本的指定步调也许是:检测磁盘是不是切合数据库挂载请求------>新建mysql用户------>下载mysql步伐包并解压------>启动mysql并增加到开机启动------>新建游戏数据库。
剧本仅供参考,假如您有甚么好的倡议大概定见,接待您Sendmail:SongShouJiong@gyyx.cn.
本文出自“我的将来不是梦。”博客,请务必保存此出处http://song49.blog.51cto.com/4480450/1333221
欢迎大家来到仓酷云论坛! |
|