Considering the batch launch of games, I wrote a deployment script for the mysql game. Because the system environment is the same, I did not install mysql in the script, but took the compiled mysql directly for use #! /Bin/bash #2013/11/20 # Email: SongShouJiong@gyyx.cncat & lt; EOF =================================================== ================
Considering the batch launch of games, I wrote a game mysql deployment script. Because the system environment is the same, mysql is not installed in the script, but compiled and used directly by mysql.
#! /Bin/bash #2013/11/20 # Email: songShouJiong@gyyx.cncat <EOF ============================================= ===================| this script is used to install the XXXX database. | ---------------------------------------------- | program Directory:/usr/local/mysql5.5 | -------------------------------------------- | data directory: /home/mysql/data | ------------------------------------------------ | the script running time is determined by the program download speed. Please wait ....... | ================================================ =============== EOFurl = http://XXXXXX#------------------- Check disk ------------------------ echo "success" check_disk () {iffdisk-l | grep-q/dev/[sh] db; thenifdf-h | grep-q/data; thenecho "Partition is OK! "Elseecho" You must mount/data! "Fielseecho" You must have two disk and mount it! "Fiecho" ------------------------------------------ "} # --------------------- add user ------------------------- add_user () {useradd mysqlif [$? -Eq 0]; thenecho "Useradd Mysql Success! "Elseecho" Mysql User is Exits !!! "Fiecho" success "}# ---------------- down install mysql5 and mysql ---------- down_mysql () {cd/usr/localwget $ url/mysql5.tgz>/dev/null2> & 1if [$? -Eq 0]; thenecho "Download MysqlServer. tgz Success! "Elseecho" Download MysqlServer. tgz Error !!! "Fiecho" ------------------------------------------ "tar zxvf mysql5.tgz>/dev/null2> & 1if [$? -Eq 0]; thenecho "Unzip MysqlServer. tgz Success! "Elseecho" Unzip MysqlServer. tgz Error !!! "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 [$? -Eq 0]; thenecho "Download Mysql_Database Success! "Elseecho" Download Mysql_Database Error !!! "Fiecho" ------------------------------------------ "tar zxvf mysql. tgz>/dev/null2> & 1if [$? -Eq 0]; thenecho "Unzip Mysql_Database Success! "Elseecho" Unzip Mysql_Database Error !! "Fichown-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/null2> & 1 sleep 3a = 'netstat-tunpl | grep: 7036 | wc-l' if [$ a-gt 0]; thenecho "Start Mysql Success! "Elseecho" Start Mysql Error! "Fiecho" ------------------------------------------ "} # -------------------- Create Game Database ------------------- create_database () {# host = 'ifconfig eth0 | grep" inet addr: "| awk '{print $2}' | cut-d:-f2 'wget $ url/DB. SQL>/dev/null2> & 1if [$? -Eq 0]; thenecho "Download DB. SQL Success! "Elseecho" Download DB. SQL Error! "Fiecho" -------------------------------------- "wget $ url/DB2. SQL>/dev/null2> & 1if [$? -Eq 0]; thenecho "Download DB2. SQL Success! "Elseecho" Download DB2. SQL Error !!! "Fiecho" ------------------------------------ "user = XXXXpasswd = 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 3if [$? -Eq 0]; thenecho "Create Game Database Success! "Elseecho" Create Game Database Error! "Fiecho" ------------------------------------------- "} check_diskadd_userdown_mysqlstart_mysqlcreate_database
The procedure specified by the script is: check whether the disk meets the database Mount requirements ------> New mysql user ------> download mysql package and decompress ------> Start mysql and add to start startup ------> Create a game database.
The script is for reference only. If you have any suggestions or comments, please Send mail: SongShouJiong@gyyx.cn.
This article comes from "My future is not a dream ." Blog, please be sure to keep this source http://song49.blog.51cto.com/4480450/1333221