仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 702|回复: 7
打印 上一主题 下一主题

[学习教程] MYSQL网站制作之公布MySQL集群主动安装剧本1.0!

[复制链接]
活着的死人 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:44:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

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学习教程,客户怎样实施混合系统,或者需要帮助管理多个云服务?
老尸 该用户已被删除
沙发
发表于 2015-1-19 22:17:07 | 只看该作者
作了些试验,发现使用CLR的存储过程或函数在达到一定的阀值的时候,系统性能会呈指数级下滑!这是非常危险的!只使用几个可能没有问题,当一旦大规模使用会造成严重的系统性能问题!
简单生活 该用户已被删除
板凳
发表于 2015-1-25 09:22:11 | 只看该作者
财务软件要用SQL也只是后台的数据库而已,软件都是成品的,当然多学东西肯定是有好处的..
只想知道 该用户已被删除
地板
发表于 2015-2-2 18:07:26 | 只看该作者
大家注意一点。如下面的例子:
因胸联盟 该用户已被删除
5#
发表于 2015-2-8 03:44:01 | 只看该作者
学习SQL语言的话如果要学会去做网站就不是很难!但是要做数据库管理的话就有难度了!
愤怒的大鸟 该用户已被删除
6#
发表于 2015-2-24 03:50:22 | 只看该作者
索引视图2k就有。但是2005对其效率作了一些改进但是schema.viewname的作用域真是太限制了它的应用面。还有一大堆的环境参数和种种限制都让人对它有点却步。
兰色精灵 该用户已被删除
7#
发表于 2015-3-15 00:48:17 | 只看该作者
索引视图2k就有。但是2005对其效率作了一些改进但是schema.viewname的作用域真是太限制了它的应用面。还有一大堆的环境参数和种种限制都让人对它有点却步。
再见西城 该用户已被删除
8#
发表于 2015-3-21 15:41:12 | 只看该作者
如果我们从集合论(关系代数)的角度来看,一张数据库的表就是一组数据元的关系,而每个SQL语句会改变一种或数种关系,从而产生出新的数据元的关系(即产生新的表)。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-12-23 01:28

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表