活着的死人 发表于 2015-1-16 22:44:45

MYSQL网站制作之公布MySQL集群主动安装剧本1.0!

如果互联网服务提供商,支撑数据的云服务,或它们之间任一点网络被堵塞或中断,他们就会遇到与数据延迟或应用程序故障有关的问题。如果问题发生在企业内部,解决方案提供商可以排除故障找出原因。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##Id=1#HostName=192.168.1.253##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##HostName=192.168.1.253##HostName=192.168.1.252MGMS="192.168.1.253"#DefineDBsinconfig.ini,intputidsofExecuteOnComputerwithwhitespaceseparated.#e.g."12"willgeneratethefollowingcode##ExecuteOnComputer=1##ExecuteOnComputer=2DBS="1"#DefineAPIsinconfig.ini,intputidsofExecuteOnComputerwithwhitespaceseparated.#e.g."1012"willgeneratethefollowingcode##ExecuteOnComputer=1###ExecuteOnComputer=1##ExecuteOnComputer=2APIS="1022"################################################################################Startingtoinstallprograms,donotmodifythem!###############################################################################echo"Startingtoinstallprograms">install.log#Findinstallationpathif[$#-gt0]thenINST_PATH="$1"elseINST_PATH="/usr/local/mysql"fiifthenecho"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"">$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"">>$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#Installclusterprogramsifthenif[-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"">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.iniecho"NoOfReplicas=1">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.ini#WritecomputersconfigurationCOMPUTER_ID=1forCOMPUTERin$COMPUTERSdoecho"">>$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"">>$CLST_PATH/config.iniecho"HostName=$MGM">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.inidone#WritestoragenodesconfigurationforDBin$DBSdoecho"">>$CLST_PATH/config.iniecho"ExecuteOnComputer=$DB">>$CLST_PATH/config.iniecho"">>$CLST_PATH/config.inidone#WritemysqlserversconfigurationforAPIin$APISdoecho"">>$CLST_PATH/config.iniifthenecho"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学习教程,客户怎样实施混合系统,或者需要帮助管理多个云服务?

老尸 发表于 2015-1-19 22:17:07

作了些试验,发现使用CLR的存储过程或函数在达到一定的阀值的时候,系统性能会呈指数级下滑!这是非常危险的!只使用几个可能没有问题,当一旦大规模使用会造成严重的系统性能问题!

简单生活 发表于 2015-1-25 09:22:11

财务软件要用SQL也只是后台的数据库而已,软件都是成品的,当然多学东西肯定是有好处的..

只想知道 发表于 2015-2-2 18:07:26

大家注意一点。如下面的例子:

因胸联盟 发表于 2015-2-8 03:44:01

学习SQL语言的话如果要学会去做网站就不是很难!但是要做数据库管理的话就有难度了!

愤怒的大鸟 发表于 2015-2-24 03:50:22

索引视图2k就有。但是2005对其效率作了一些改进但是schema.viewname的作用域真是太限制了它的应用面。还有一大堆的环境参数和种种限制都让人对它有点却步。

兰色精灵 发表于 2015-3-15 00:48:17

索引视图2k就有。但是2005对其效率作了一些改进但是schema.viewname的作用域真是太限制了它的应用面。还有一大堆的环境参数和种种限制都让人对它有点却步。

再见西城 发表于 2015-3-21 15:41:12

如果我们从集合论(关系代数)的角度来看,一张数据库的表就是一组数据元的关系,而每个SQL语句会改变一种或数种关系,从而产生出新的数据元的关系(即产生新的表)。
页: [1]
查看完整版本: MYSQL网站制作之公布MySQL集群主动安装剧本1.0!