|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果互联网服务提供商,支撑数据的云服务,或它们之间任一点网络被堵塞或中断,他们就会遇到与数据延迟或应用程序故障有关的问题。如果问题发生在企业内部,解决方案提供商可以排除故障找出原因。mysql|剧本|主动安装经由几天的测试,终究能够公布了!
1.在MySQL源代码目次下新建剧本install.sh,把上面的代码增加到这个剧本中:
#!/bin/bash#######################################################Title:MySQL4.1ClusterInstallationScript####Version:1.0####Date:2004-11-11####Author:yipsilon####Email:yipsilon@163.com####License:GeneralPublicLicense(GPL)####Copyright(c)2004,yipsilonAllRightsReserved#########################################################ChangeLog#########################################################InstallationGuide####1.Copythescriptfileintomysqlsourcepath####2.Changescriptfilespermissionto755####3.executeitandwaitfor...############################################################################################################MySQLServerConfig###########################################################DeterminetoinstallMySQLserver#"0"meansdonotinstallserverprogramsINST_SERVER=1#MySQLinstallationpathINST_PATH="/usr/local/mysql"#DefinetheportsofMySQLinstallation,intputstringsofPORTwithwhitespaceseparated.#e.g."33063307"meansinstalltwoMySQLservers:#Thefirstserverwillbeinstalledto$INST_PATH/1andlisten3306port.#Thesecondserverwillbeinstalledto$INST_PATH/2andlisten3307port.#......INST_PORTS="3306"#ThemanagementserverinformationMGM_HOST="192.168.1.253"MGM_PORT="2200"####################################################MySQLClusterConfig########################################################Determinetoinstallcluster#"0"meansdonotinstallclusterprogramsINST_CLUSTER=1#DefineCOMPUTERsinconfig.ini,intputstringsofHostNamewithwhitespaceseparated.#TheIdattributeisautoincrementandstartwith1.#e.g."192.168.1.253192.168.252"willgeneratethefollowingcode#[COMPUTER]#Id=1#HostName=192.168.1.253#[COMPUTER]#Id=2#HostName=192.168.1.252COMPUTERS="192.168.1.253192.168.1.252"#DefineMGMsinconfig.ini,intputstringsofHostNamewithwhitespaceseparated.#e.g."192.168.1.253192.168.252"willgeneratethefollowingcode#[MGM]#HostName=192.168.1.253#[MGM]#HostName=192.168.1.252MGMS="192.168.1.253"#DefineDBsinconfig.ini,intputidsofExecuteOnComputerwithwhitespaceseparated.#e.g."12"willgeneratethefollowingcode#[DB]#ExecuteOnComputer=1#[DB]#ExecuteOnComputer=2DBS="1"#DefineAPIsinconfig.ini,intputidsofExecuteOnComputerwithwhitespaceseparated.#e.g."1012"willgeneratethefollowingcode#[API]#ExecuteOnComputer=1#[API]#[API]#ExecuteOnComputer=1#[API]#ExecuteOnComputer=2APIS="1022"################################################################################Startingtoinstallprograms,donotmodifythem!###############################################################################echo"Startingtoinstallprograms">install.log#Findinstallationpathif[$#-gt0]thenINST_PATH="$1"elseINST_PATH="/usr/local/mysql"fiif[0-lt$INST_SERVER]thenecho"Now,installingtheMySQLservers..."#LooptoinstallmysqlserversINSTALLED_SERVER_COUNT=1forPORTin$INST_PORTSdo#DefinethecurrentmysqlserverinstallationpathMYSL_PATH=$INST_PATH/$INSTALLED_SERVER_COUNT#Configuremysqlserverecho"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#Makemysqlserverecho"Execmake&&makeinstall">>install.logmake&&makeinstall#Createvardirectoryformysqldatamkdir-p$MYSL_PATH/var#Createmy.cnfecho"Create$MYSL_PATH/var/my.cnf">>install.logecho"[client]">$MYSL_PATH/var/my.cnfecho"port=$PORT">>$MYSL_PATH/var/my.cnfecho"socket=$MYSL_PATH/var/mysql.sock">>$MYSL_PATH/var/my.cnfecho"">>$MYSL_PATH/var/my.cnfecho"[mysqld]">>$MYSL_PATH/var/my.cnfecho"ndbcluster">>$MYSL_PATH/var/my.cnfecho"ndb_connectstring=host=$MGM_HOST:$MGM_PORT">>$MYSL_PATH/var/my.cnfecho"user=root">>$MYSL_PATH/var/my.cnfecho"port=$PORT">>$MYSL_PATH/var/my.cnfecho"basedir=$MYSL_PATH/">>$MYSL_PATH/var/my.cnfecho"datadir=$MYSL_PATH/var/">>$MYSL_PATH/var/my.cnfecho"socket=$MYSL_PATH/var/mysql.sock">>$MYSL_PATH/var/my.cnfecho"default-character-set=gbk">>$MYSL_PATH/var/my.cnfecho"default-storage-engine=INNODB">>$MYSL_PATH/var/my.cnfecho"max_connections=500">>$MYSL_PATH/var/my.cnfecho"">>$MYSL_PATH/var/my.cnfecho"query_cache_size=33M">>$MYSL_PATH/var/my.cnfecho"table_cache=1520">>$MYSL_PATH/var/my.cnfecho"tmp_table_size=16M">>$MYSL_PATH/var/my.cnfecho"thread_cache=38">>$MYSL_PATH/var/my.cnfecho"">>$MYSL_PATH/var/my.cnfecho"#MyISAMSpecificoptions">>$MYSL_PATH/var/my.cnfecho"#skip-myisam">>$MYSL_PATH/var/my.cnfecho"">>$MYSL_PATH/var/my.cnfecho"#INNODBSpecificoptions">>$MYSL_PATH/var/my.cnfecho"#skip-innodb">>$MYSL_PATH/var/my.cnfchmod755$MYSL_PATH/var/my.cnf#Installmysqldatabaseecho"Exec$MYSL_PATH/bin/mysql_install_db">>install.log$MYSL_PATH/bin/mysql_install_db#Createmysqlcontrolscriptif[-e$MYSL_PATH/share/mysql/mysql.server]then#Usedefaultmysqlcontrolscript#Createmysqlserverstartscriptecho"Create$MYSL_PATH/start">>install.logecho"$MYSL_PATH/share/mysql/mysql.serverstart">$MYSL_PATH/startecho"Chmod755$MYSL_PATH/start">>install.logchmod755$MYSL_PATH/start#Createmysqlserverstopscriptecho"Create$MYSL_PATH/stop">>install.logecho"$MYSL_PATH/share/mysql/mysql.serverstop">$MYSL_PATH/stopecho"Chmod755$MYSL_PATH/stop">>install.logchmod755$MYSL_PATH/stop#Createmysqlserverrestartscriptecho"Create$MYSL_PATH/restart">>install.logecho"$MYSL_PATH/share/mysql/mysql.serverrestart">$MYSL_PATH/restartecho"Chmod755$MYSL_PATH/restart">>install.logchmod755$MYSL_PATH/restartelse#Usecustommysqlcontrolscript#Createmysqlserverstartscriptecho"Create$MYSL_PATH/start">>install.logecho"$MYSL_PATH/libexec/mysqld&">$MYSL_PATH/startecho"Chmod755$MYSL_PATH/start">>install.logchmod755$MYSL_PATH/start#Createmysqlserverstopscriptecho"Create$MYSL_PATH/stop">>install.logecho"$MYSL_PATH/bin/mysqladmin-uroot-pshutdown">$MYSL_PATH/stopecho"Chmod755$MYSL_PATH/stop">>install.logchmod755$MYSL_PATH/stop#Createmysqlserverrestartscriptecho"Create$MYSL_PATH/restart">>install.logecho"$MYSL_PATH/bin/mysqladmin-uroot-pshutdown">$MYSL_PATH/restartecho"$MYSL_PATH/libexec/mysqld&">>$MYSL_PATH/restartecho"Chmod755$MYSL_PATH/restart">>install.logchmod755$MYSL_PATH/restartfi#Cleanmysqlservertogetreadyforthenextinstallationecho"Execmakeclean">>install.logmakecleanINSTALLED_SERVER_COUNT=$(($INSTALLED_SERVER_COUNT+1))doneecho"Configurations!MySQLservershasbeeninstalledsuccessfully."echo""echo"1.Tostartmysqlserver,usethefollowingcommand:"echo"cd<MYSQL_INSTALLATION_PATH>"echo"./start"echo""echo"2.Tostopmysqlserver,usethefollowingcommand:"echo"cd<MYSQL_INSTALLATION_PATH>"echo"./stop"echo""echo"3.Torestartmysqlserver,usethefollowingcommand:"echo"cd<MYSQL_INSTALLATION_PATH>"echo"./restart"fi#Installclusterprogramsif[0-lt$INST_CLUSTER]thenif[-e$INST_PATH/1]thenecho"Now,installingtheclusterprograms..."#DefinetheclusterinstallationpathCLST_PATH=$INST_PATH/cluster#Createclusterdirectoryecho"Execmkdir-p$CLST_PATH">>install.logmkdir-p$CLST_PATH#Copyclusterbinariesecho"Execcp$INST_PATH/1/bin/ndb*$CLST_PATH/">>install.logcp$INST_PATH/1/bin/ndb*$CLST_PATH/echo"Execcp$INST_PATH/1/libexec/ndb*$CLST_PATH/">>install.logcp$INST_PATH/1/libexec/ndb*$CLST_PATH/#Createconfig.iniecho"Create$CLST_PATH/config.ini">>install.log#Writedefaultglobalconfigurationecho"[TCPDEFAULT]">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.iniecho"[MGMDEFAULT]">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.iniecho"[DBDEFAULT]">>$CLST_PATH/config.iniecho"NoOfReplicas=1">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.iniecho"[APIDEFAULT]">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.ini#WritecomputersconfigurationCOMPUTER_ID=1forCOMPUTERin$COMPUTERSdoecho"[COMPUTER]">>$CLST_PATH/config.iniecho"Id=$COMPUTER_ID">>$CLST_PATH/config.iniecho"HostName=$COMPUTER">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.iniCOMPUTER_ID=$(($COMPUTER_ID+1))done#WritemanagementserverconfigurationforMGMin$MGMSdoecho"[MGM]">>$CLST_PATH/config.iniecho"HostName=$MGM">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.inidone#WritestoragenodesconfigurationforDBin$DBSdoecho"[DB]">>$CLST_PATH/config.iniecho"ExecuteOnComputer=$DB">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.inidone#WritemysqlserversconfigurationforAPIin$APISdoecho"[API]">>$CLST_PATH/config.iniif[0-ne$API]thenecho"ExecuteOnComputer=$API">>$CLST_PATH/config.inifiecho"">>$CLST_PATH/config.inidone#CreateNdb.cfgecho"Create$CLST_PATH/Ndb.cfg">>install.logecho"host=$MGM_HOST:$MGM_PORT">>$CLST_PATH/Ndb.cfgecho"">>$CLST_PATH/Ndb.cfgecho"Configurations!Clusterprogramshasbeeninstalledsuccessfully."echo""echo"1.Tostartmanagementserver(MGM),usethefollowingcommand:"echo"cd$CLST_PATH"echo"./ndb_mgmd"echo""echo"2.Tostartstroagenode(DB),usethefollowingcommand:"echo"cd$CLST_PATH"echo"./ndbd"echo""echo"3.Tomanagethecluster,usethefollowingcommand:"echo"cd$CLST_PATH"echo"./ndb_mgm"echo""echo"4.Else,nothingtodo.;)"echo""echo"Enjoyyourself."elseecho"Clusterinstallationhasbeenstopped,thereasonis:";echo"Nodatabaseserverinstalled."echo"Soyoucannotuseclusterprogramsinthismachine!"fifi
2.设置剧本权限,让它可实行:chmod755install.sh
3.实行该剧本:./install.sh大概./install<MySQL安装目次>
详细利用申明,英语好的看剧本正文吧;英语欠好的,那就再等等,过几天会release出来。应用程序需要使用数据库,数据库本身需要设计、开发和部署。还有MySQL学习教程,客户怎样实施混合系统,或者需要帮助管理多个云服务? |
|