After a few days of test, it can finally be released!
1. Add a new script install.sh in the MySQL source code, add the following code to this script:
#! / bin / bash
######################################################################################################################################################################################################################################################################################################## ###
## Title: MySQL 4.1 Cluster Installation Script ##
## Version: 1.0 ##
## Date: 2004-11-11 ##
## Author: Yipsilon ##
## email: Yipsilon@163.com ##
## license: General public license (GPL) ##
## CopyRight (C) 2004, Yipsilon All Rights Reserved ##
######################################################################################################################################################################################################################################################################################################## ###
## Changelog ##
######################################################################################################################################################################################################################################################################################################## ###
## Installation Guide ##
## 1. Copy The Script File Into MySQL SOURCE PATH ##
## 2. Change Script File's Permission to 755 ##
## 3. EXECUTE IT AND WAIT for ... ##
######################################################################################################################################################################################################################################################################################################## ###
#############################################################
######### mysql server config ##############
#############################################################
#Deetermine 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.
# The Second Server Will BE Installed to $ INST_PATH / 2 AND LISTEN 3307 Port.
# ... ...
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 Program
INST_CLUSTER = 1
#Define computers in config.ini, INTPUT STRINGS OF HOSTNAME with Whitespace Separated.
#The id attribute is auto inccess and start with 1.
# e.g. "192.168.1.253 192.168.252" Will Generate The Following Code
# [COMPUTER]
# Id = 1
# Hostname = 192.168.1.253
# [COMPUTER]
# Id = 2
# Hostname = 192.168.1.252
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
# [Mgm]
# Hostname = 192.168.1.253
# [Mgm]
# Hostname = 192.168.1.252
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
# [Db]
# Xicuteoncomputer = 1
# [Db]
# Ecuteoncomputer = 2
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
# [API]
# Xicuteoncomputer = 1
# [API]
# [API]
# Xicuteoncomputer = 1
# [API]
# Ecuteoncomputer = 2
APIS = "1 0 2 2"
######################################################################################################################################################################################################################################################################################################## ####################
########## Starting to install programs, do not modifi itm! #########
######################################################################################################################################################################################################################################################################################################## ####################
Echo "Starting to Install Program"> 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 ">> 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 "EXEC Make && Make Install" >> Install.log
Make && make Install
#Create var Directory for MySQL Data
MKDIR -P $ mysl_path / var
#Create my.cnf
Echo "Create $ mysl_path / var / my.cnf" >> Install.log
Echo "[Client]"> $ mysl_path / var / my.cnf
Echo "Port = $ port" >> $ mysl_path / var / my.cnf
Echo "Socket = $ mysl_path / var / mysql.sock" >> $ mysl_path / var / my.cnf
Echo ">> $ mysl_path / var / my.cnf
echo "[mysqld]" >> $ mysl_path / var / my.cnf
Echo "NDBCluster" >> $ mysl_path / var / my.cnf
Echo "NDB_CONNECTSTRING = Host = $ mgm_host: $ mgm_port" >> $ mysl_path / var / my.cnf
Echo "User = root" >> $ mysl_path / var / my.cnf
Echo "port = $ port" >> $ mysl_path / var / my.cnfecho "Basedir = $ mysl_path /" >> $ mysl_path / var / my.cnf
Echo "DATADIR = $ mysl_path / var /" >> $ mysl_path / var / my.cnf
Echo "Socket = $ mysl_path / var / mysql.sock" >> $ mysl_path / var / my.cnf
Echo "Default-Character-set = GBK" >> $ mysl_path / var / my.cnf
Echo "Default-Storage-Engine = InnoDB" >> $ mysl_path / var / my.cnf
Echo "Max_Connections = 500" >> $ mysl_path / var / my.cnf
Echo ">> $ mysl_path / var / my.cnf
Echo "query_cache_size = 33m" >> $ mysl_path / var / my.cnf
Echo "Table_Cache = 1520" >> $ mysl_path / var / my.cnf
Echo "TMP_TABLE_SIZE = 16M" >> $ mysl_path / var / my.cnf
Echo "thread_cache = 38" >> $ mysl_path / var / my.cnf
Echo ">> $ mysl_path / var / my.cnf
Echo "#myisam specific option" >> $ mysl_path / var / my.cnf
Echo "# Skip-myisam" >> $ mysl_path / var / my.cnf
Echo ">> $ mysl_path / var / my.cnf
Echo "#innodb specific options" >> $ mysl_path / var / my.cnf
Echo "# Skip-InnoDB" >> $ mysl_path / var / my.cnf
CHMOD 755 $ mysl_path / var / my.cnf
#Install mysql database
Echo "EXEC $ mysl_path / bin / mysql_install_db" >> 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 "Create $ mysl_path / start" >> Install.log
Echo "$ mysl_path / share / mysql / mysql.server start"> $ mysl_path / start
Echo "CHMOD 755 $ mysl_path / start" >> install.log
CHMOD 755 $ mysl_path / start # create mysql server stop script
Echo "Create $ mysl_path / stop" >> Install.log
Echo "$ mysl_path / share / mysql / mysql.server stop"> $ mysl_path / stop
Echo "CHMOD 755 $ mysl_path / stop" >> Install.log
CHMOD 755 $ mysl_path / stop
#Create MySQL Server Restart Script
Echo "Create $ mysl_path / rest" >> Install.log
Echo "$ mysl_path / share / mysql / mysql.server rest"> $ mysl_path / restart
Echo "CHMOD 755 $ mysl_path / rest" >> Install.log
CHMOD 755 $ mysl_path / restart
Else
# USE Custom MySQL Control Script
#Create mysql Server Start Script
Echo "Create $ mysl_path / start" >> Install.log
Echo "$ mysl_path / libexec / mysqld &"> $ mysl_path / start
Echo "CHMOD 755 $ mysl_path / start" >> install.log
CHMOD 755 $ mysl_path / start
#Create MySQL Server Stop Script
Echo "Create $ mysl_path / stop" >> Install.log
Echo "$ mysl_path / bin / mysqladmin -u root -p Shutdown"> $ mysl_path / stop
Echo "CHMOD 755 $ mysl_path / stop" >> Install.log
CHMOD 755 $ mysl_path / stop
#Create MySQL Server Restart Script
Echo "Create $ mysl_path / rest" >> Install.log
Echo "$ mysl_path / bin / mysqladmin -u root -p shutdown"> $ mysl_path / restart
Echo "$ mysl_path / libexec / mysqld &"> $ mysl_path / restart
Echo "CHMOD 755 $ mysl_path / rest" >> Install.log
CHMOD 755 $ mysl_path / restart
Fi
#Clean mysql server to get et f f next installation
Echo "Exec Make Clean" >> Install.log
Make clean
Installed_server_count = $ ($ Installed_Server_count 1)))
DONE
Echo "Configurations! MySQL Servers Has Been Installed Success," echo ""
echo "1. To start mySQL Server, Use the folload" ""
echo "cd
echo "./start"
echo ""
echo "2. to stop mysql server, use the folowing command:"
echo "cd
echo "./stop"
echo ""
echo "3. TO Restart MySQL Server, Use The Following Command:"
echo "cd
echo "./restart"
Fi
#Install cluster Program
IF [0 -LT $ INST_CLUSTER]
THEN
IF [-e $ INST_PATH / 1]
THEN
Echo "Now, Installing The Cluster Program ..."
#Define the cluster installation path
CLST_PATH = $ INST_PATH / CLUSTER
#Create Cluster Directory
Echo "EXEC MKDIR -P $ CLST_PATH" >> Install.log
MKDIR -P $ CLST_PATH
#Copy Cluster Binaries
Echo "EXEC CP $ INST_PATH / 1 / BIN / NDB * $ CLST_PATH /" >> Install.log
CP $ INST_PATH / 1 / BIN / NDB * $ CLST_PATH /
Echo "EXEC CP $ INST_PATH / 1 / LIBEXEC / NDB * $ CLST_PATH /" >> Install.log
CP $ INST_PATH / 1 / LIBEXEC / NDB * $ CLST_PATH /
#Create config.ini
Echo "CREATE $ CLST_PATH / Config.ini" >> Install.log
#Write Default Global Configuration
echo "[TCP Default] >> $ CLST_PATH / Config.ini
Echo "" >> $ clst_path / config.ini
Echo "[MGM Default] >> $ CLST_PATH / Config.ini
Echo "" >> $ clst_path / config.ini
Echo "[DB Default] >> $ CLST_PATH / Config.ini
Echo "NOOFREPLICAS = 1" >> $ CLST_PATH / Config.ini
Echo "" >> $ clst_path / config.ini
Echo "[API DEFAULT] >> $ CLST_PATH / Config.ini
Echo "" >> $ clst_path / config.ini
#Write Computers Configuration
Computer_ID = 1
FOR Computer In $ Computers
DO
Echo "[Computer] >> $ CLST_PATH / Config.ini
Echo "ID = $ Computer_ID" >> $ clst_path / config.ini
Echo "Hostname = $ Computer" >> $ CLST_PATH / Config.ini
Echo "" >> $ clst_path / config.ini
Computer_ID = $ ($ Computer_ID 1))))
DONE
#Write Management Server Configuration
For MGM in $ mms
DO
Echo "[MGM] >> $ CLST_PATH / Config.ini
Echo "Hostname = $ mgm" >> $ clst_path / config.ini
Echo "" >> $ clst_path / config.ini
DONE
# Write Storage Nodes Configuration
For DB IN $ dbs
DO
echo "[db]" >> $ clst_path / config.ini
Echo "ExecuteonComputer = $ db" >> $ clst_path / config.ini
Echo "" >> $ clst_path / config.ini
DONE
#Write MySQL Servers Configuration
For API IN $ API
DO
Echo "[API] >> $ CLST_PATH / Config.ini
IF [0 -ne $ API]
THEN
Echo "EXECUTEONCOMPUTER = $ API" >> $ clst_path / config.ini
Fi
Echo "" >> $ clst_path / config.ini
DONE
#Create ndb.cfg
Echo "CREATE $ CLST_PATH / NDB.CFG" >> Install.log
Echo "Host = $ mgm_host: $ mgm_port" >> $ clst_path / ndb.cfg
Echo ">> $ clst_path / ndb.cfg
Echo "Configurations! Cluster Program Has Been Installed SuccessFully."
echo ""
Echo "1. To Start Management Server (MGM), Use the folload command:"
ECHO "CD $ CLST_PATH"
echo "./ndb_mgmd"
echo ""
Echo "2. To Start Stroage Node (db), Use the folload strength:"
ECHO "CD $ CLST_PATH"
echo "./ndbd "echo" "
Echo "3. To Manage the Cluster, Use the folowing command:"
ECHO "CD $ CLST_PATH"
echo "./ndb_mgm"
echo ""
Echo "4. Else, Nothing to do .;"
echo ""
echo "enjoy yourself."
Else
Echo "Cluster Installation Has Been Stopped, The Reason IS:";
echo "No Database Server Installed."
Echo "So you can not use cluster programs in this machine!"
Fi
Fi
2. Set the script permissions to make it executable: chmod 755 install.sh
3. Execute this script: ./ install.sh or ./install
Specific instructions, English is good to see script: English is not good, then wait, after a few days will come out.