Game Database deployment script

Source: Internet
Author: User
Tags sql error

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 "failed" check_disk () {if fdisk-l | grep-q/dev/[sh] db; then if df-h | grep-q/data; then echo "Partition is OK! "Else echo" You must mount/data! "Fi else echo" You must have two disk and mount it! "Fi echo" ------------------------------------------ "} # --------------------- add user ------------------------- add_user () {useradd mysql if [$? -Eq 0]; then echo "Useradd Mysql Success! "Else echo" Mysql User is Exits !!! "Fi echo" -------------------------------------------- "} # ------------------ down install mysql5 and mysql ---------- down_mysql () {cd/usr/local wget $ url/mysql5.tgz>/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_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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.