Release MySQL group to install script automatically 1
Tuesday, March 03, 2009 by rain
? ?
? ? # ! / Bin/bash
? ? #####################################################
? ? ## Title: ## of ? of ? of MySQL 4.1 Cluster Installation Script
? ? ## Version: ## of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of 1 ? ?
? ? ## Date: ## of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of 2004-11-11 ? ?
? ? ## Author: ## of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of Yipsilon ? ?
? ? ## Email: ## of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of Yipsilon@163.com ? ?
? ? ## License: ## of ? of ? of ? of ? of ? of General Public License (GPL)
? ? ## Copyright(c) 2004, yipsilon All Rights Reserved ##
? ? #####################################################
## of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ? of ChangeLog of ? of ? of ? of ? of ? of ? of ? of ? of ? ? ##
? ? #####################################################
## of ? of ? of ? of ? of ? of ? of ? of ? of ? of Installation Guide of ? of ? of ? of ? of ? of ? of ? ? ##
? of ? ? ## 1. Copy The Script File Into Mysql Source Path ##
? of ? ? ## 2. ## of ? of ? of ? of Change Script File's Permission To 755
? of ? ? ## 3. Execute It And Wait For. . . ## of ? of ? of ? of ? of ? of ? of ? ? ?
? ? #####################################################
? ? ############################################
? ? ######### MySQL Server Config ##############
? ? ############################################
? ? #Determine To Install MySQL Server
? ? #"0" Means Do Not Install Server Programs
? ? INST_SERVER=1
? ? #MySQL Installation Path
? ? INST_PATH="/usr/local/mysql "
? ? #Define The Ports Of MySQL Installation, intput Strings Of PORT With Whitespace Separated.
? ? #e.g. "3306 3307" Means Install Two MySQL Servers:
The First Server Will Be Installed To $INST_PATH/1 And Listen 3306 Port of ? of ? of ? ? # .
The Second Server Will Be Installed To $INST_PATH/2 And Listen 3307 Port of ? of ? of ? ? # .
? ? of ? ? # . . . . . .
? ? INST_PORTS="3306 "
? ? #The Management Server Information
? ? MGM_HOST="192.168.1.253 "
? ? MGM_PORT="2200 "
? ? ###########################################
? ? ######### MySQL Cluster Config ############
? ? ###########################################
? ? #Determine To Install Cluster
? ? #"0" Means Do Not Install Cluster Programs
? ? INST_CLUSTER=1
? ? #Define COMPUTERs In Config.ini, intput Strings Of HostName With Whitespace Separated.
? ? #The Id Attribute Is Auto Increment And Start With 1.
? ? #e.g. "192.168.1.253 192.168.252" Will Generate The Following Code
? of ? ? # [COMPUTER]
Id=1 of ? of ? of ? ? #
HostName=192.168.1.253 of ? of ? of ? ? #
? of ? ? # [COMPUTER]
Id=2 of ? of ? of ? ? #
HostName=192.168.1.252 of ? of ? of ? ? #
? ? COMPUTERS="192.168.1.253 192.168.1.252 "
? ? #Define MGMs In Config.ini, intput Strings Of HostName With Whitespace Separated.
? ? #e.g. "192.168.1.253 192.168.252" Will Generate The Following Code
? of ? ? # [MGM]
HostName=192.168.1.253 of ? of ? of ? ? #
? of ? ? # [MGM]
HostName=192.168.1.252 of ? of ? of ? ? #
? ? MGMS="192.168.1.253 "
? ? #Define DBs In Config.ini, intput Ids Of ExecuteOnComputer With Whitespace Separated.
? ? #e.g. "1 2" Will Generate The Following Code
? of ? ? # [DB]
ExecuteOnComputer=1 of ? of ? of ? ? #
? of ? ? # [DB]
ExecuteOnComputer=2 of ? of ? of ? ? #
? ? DBS="1 "
? ? #Define APIs In Config.ini, intput Ids Of ExecuteOnComputer With Whitespace Separated.
? ? #e.g. "1 0 1 2" Will Generate The Following Code
? of ? ? # [API]
ExecuteOnComputer=1 of ? of ? of ? ? #
? of ? ? # [API]
? of ? ? # [API]
ExecuteOnComputer=1 of ? of ? of ? ? #
? of ? ? # [API]
ExecuteOnComputer=2 of ? of ? of ? ? #
? ? APIS="1 0 2 2 "
? ? ######################################################################
? ? ########## Starting To Install Programs, do Not Modify Them! #########
? ? ######################################################################
? ? Echo "Starting To Install Programs "%26gt;Install.log
? ? #Find Installation Path
? ? If [$# -gt 0]
? ? Then
? ? INST_PATH="$1 "
? ? Else
? ? INST_PATH="/usr/local/mysql "
? ? Fi
? ? If [0 -lt $INST_SERVER]
? ? Then
? ? Echo "Now, installing The MySQL Servers. . . ..
? ?
? ? #Loop To Install Mysql Servers
? ? INSTALLED_SERVER_COUNT=1
? ? For PORT In $INST_PORTS
? ? Do
? ? #Define The Current Mysql Server Installation Path
? ? MYSL_PATH=$INST_PATH/$INSTALLED_SERVER_COUNT
? ?
? ? #Configure Mysql Server
? ? Echo "Exec. / Configure- - Prefix=$MYSL_PATH- - With-pthread- - With-unix-socket-path=$MYSL_PATH/var/mysql.sock- - With-mysqld-user=root- - With-tcp-port=$PORT- - With-charset=gbk- - With-ndbcluster%26quot; %26gt;%26gt;Install.log
? ? . / Configure- - Prefix=$MYSL_PATH- - With-pthread- - With-unix-socket-path=$MYSL_PATH/var/mysql.sock- - With-mysqld-user=root- - With-tcp-port=$PORT- - With-charset=gbk- - With-ndbcluster
? ?
? ? #Make Mysql Server
? ? Echo %26quot;Exec Make %26amp;%26amp;Make Install%26quot; %26gt;%26gt;Install.log
? ? Make %26amp;%26amp;Make Install
? ?
? ? #Create Var Directory For Mysql Data
? ? Mkdir -p $MYSL_PATH/var
? ?
? ? #Create My.cnf
? ? Echo %26quot;Create $MYSL_PATH/var/my.cnf%26quot; %26gt;%26gt;Install.log
? ? Echo "[client] "%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;port=$PORT%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;socket=$MYSL_PATH/var/mysql.sock%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;[mysqld]%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;ndbcluster%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo "ndb_connectstring=host=$MGM_HOST:$MGM_PORT%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;user=root%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;port=$PORT%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;basedir=$MYSL_PATH/%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;datadir=$MYSL_PATH/var/%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;socket=$MYSL_PATH/var/mysql.sock%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;default-character-set=gbk%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;default-storage-engine=INNODB%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;max_connections=500%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;query_cache_size=33M%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;table_cache=1520%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;tmp_table_size=16M%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;thread_cache=38%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;#MyISAM Specific Options%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;#skip-myisam%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;#INNODB Specific Options%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Echo %26quot;#skip-innodb%26quot; %26gt;%26gt;$MYSL_PATH/var/my.cnf
? ? Chmod 755 $MYSL_PATH/var/my.cnf
? ?
? ? #Install Mysql Database
? ? Echo %26quot;Exec $MYSL_PATH/bin/mysql_install_db%26quot; %26gt;%26gt;Install.log
? ? $MYSL_PATH/bin/mysql_install_db
? ?
? ? #Create Mysql Control Script
? ? If [-e $MYSL_PATH/share/mysql/mysql.server]
? ? Then
? ?
? ? #Use Default Mysql Control Script
? ?
? ? #Create Mysql Server Start Script
? ? Echo %26quot;Create $MYSL_PATH/start%26quot; %26gt;%26gt;Install.log
? ? Echo "$MYSL_PATH/share/mysql/mysql.server Start "%26gt;$MYSL_PATH/start
? ? Echo %26quot;Chmod 755 $MYSL_PATH/start%26quot; %26gt;%26gt;Install.log
? ? Chmod 755 $MYSL_PATH/start
? ?
? ? #Create Mysql Server Stop Script
? ? Echo %26quot;Create $MYSL_PATH/stop%26quot; %26gt;%26gt;Install.log
? ? Echo "$MYSL_PATH/share/mysql/mysql.server Stop "%26gt;$MYSL_PATH/stop
? ? Echo %26quot;Chmod 755 $MYSL_PATH/stop%26quot; %26gt;%26gt;Install.log
? ? Chmod 755 $MYSL_PATH/stop
? ?
? ? #Create Mysql Server Restart Script
? ? Echo %26quot;Create $MYSL_PATH/restart%26quot; %26gt;%26gt;Install.log
? ? Echo "$MYSL_PATH/share/mysql/mysql.server Restart "%26gt;$MYSL_PATH/restart
? ? Echo %26quot;Chmod 755 $MYSL_PATH/restart%26quot; %26gt;%26gt;Install.log
? ? Chmod 755 $MYSL_PATH/restart
? ? Else
? ?
? ? #Use Custom Mysql Control Script
? ?
? ? #Create Mysql Server Start Script
? ? Echo %26quot;Create $MYSL_PATH/start%26quot; %26gt;%26gt;Install.log
? ? Echo %26quot;$MYSL_PATH/libexec/mysqld %26amp; %26quot;%26gt;$MYSL_PATH/start
? ? Echo %26quot;Chmod 755 $MYSL_PATH/start%26quot; %26gt;%26gt;Install.log
? ? Chmod 755 $MYSL_PATH/start
? ?
? ? #Create Mysql Server Stop Script
? ? Echo %26quot;Create $MYSL_PATH/stop%26quot; %26gt;%26gt;Install.log
? ? Echo "$MYSL_PATH/bin/mysqladmi
...