MySQL Cluster for two serversWord文档下载推荐.docx
- 文档编号:20040476
- 上传时间:2023-01-16
- 格式:DOCX
- 页数:8
- 大小:19.34KB
MySQL Cluster for two serversWord文档下载推荐.docx
《MySQL Cluster for two serversWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《MySQL Cluster for two serversWord文档下载推荐.docx(8页珍藏版)》请在冰豆网上搜索。
InstallMySQLonthefirsttwoservers:
Completethefollowingstepsonbothmysql1andmysql2:
cd/usr/local/
from/
groupaddmysql
useradd-gmysqlmysql
tar-zxvfmysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
rmmysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
ln-smysql-max-4.1.9-pc-linux-gnu-i686mysql
cdmysql
scripts/mysql_install_db--user=mysql
chown-Rroot.
chown-Rmysqldata
chgrp-Rmysql.
cpsupport-files/mysql.server/etc/rc.d/init.d/
chmod+x/etc/rc.d/init.d/mysql.server
chkconfig--addmysql.server
Donotstartmysqlyet.
STAGE2:
Installandconfigurethemanagmentserver
Youneedthefollowingfilesfromthebin/ofthemysqldirectory:
ndb_mgmandndb_mgmd.Downloadthewholemysql-maxtarballandextractthemfromthebin/directory.
mkdir/usr/src/mysql-mgm
cd/usr/src/mysql-mgm
cdmysql-max-4.1.9-pc-linux-gnu-i686
mvbin/ndb_mgm.
mvbin/ndb_mgmd.
chmod+xndb_mg*
mvndb_mg*/usr/bin/
cd
rm-rf/usr/src/mysql-mgm
Younowneedtosetuptheconfigfileforthismanagment:
mkdir/var/lib/mysql-cluster
cd/var/lib/mysql-cluster
vi[oremacsoranyothereditor]config.ini
Now,insertthefollowing(changingthebitsasindicated):
[NDBDDEFAULT]
NoOfReplicas=2
[MYSQLDDEFAULT]
[NDB_MGMDDEFAULT]
[TCPDEFAULT]
#ManagmentServer
[NDB_MGMD]
HostName=192.168.0.3#theIPofTHISSERVER
#StorageEngines
[NDBD]
HostName=192.168.0.1#theIPoftheFIRSTSERVER
DataDir=/var/lib/mysql-cluster
HostName=192.168.0.2#theIPoftheSECONDSERVER
DataDir=/var/lib/mysql-cluster
#2MySQLClients
#Ipersonallyleavethisblanktoallowrapidchangesofthemysqlclients;
#youcanenterthehostnamesoftheabovetwoservershere.Isuggestyoudont.
[MYSQLD]
Now,startthemanagmentserver:
ndb_mgmd
ThisistheMySQLmanagmentserver,notmaganmentconsole.Youshouldthereforenotexpectanyoutput(wewillstarttheconsolelater).
STAGE3:
Configurethestorage/SQLserversandstartmysql
Oneachofthetwostorage/SQLservers(192.168.0.1and192.168.0.2)enterthefollowing
(changingthebitsasappropriate):
vi/etc/f
Enteritogotoinsertmodeagainandinsertthisonbothservers(changingtheIPaddresstotheIPofthemanagmentserverthatyousetupinstage2):
[mysqld]
ndbcluster
ndb-connectstring=192.168.0.3#theIPoftheMANAGMENT(THIRD)SERVER
[mysql_cluster]
Now,wemakethedatadirectoryandstartthestorageengine:
/usr/local/mysql/bin/ndbd--initial
/etc/rc.d/init.d/mysql.serverstart
Ifyouhavedoneoneservernowgobacktothestartofstage3andrepeatexactlythesameprocedureonthesecondserver.
Note:
youshouldONLYuse
--initial
ifyouareeitherstartingfromscratchorhavechangedthe
config.ini
fileonthemanagment.
STAGE4:
Checkitsworking
Youcannowreturntothemanagmentserver(mysql3)andenterthemanagmentconsole:
/usr/local/mysql/bin/ndb_mgm
EnterthecommandSHOWtoseewhatisgoingon.Asampleoutputlookslikethis:
[root@mysql3mysql-cluster]#/usr/local/mysql/bin/ndb_mgm
--NDBCluster--ManagementClient--
ndb_mgm>
show
ConnectedtoManagementServerat:
localhost:
1186
ClusterConfiguration
---------------------
[ndbd(NDB)]2node(s)
id=2@192.168.0.1(Version:
4.1.9,Nodegroup:
0,Master)
id=3@192.168.0.2(Version:
0)
[ndb_mgmd(MGM)]1node(s)
id=1@192.168.0.3(Version:
4.1.9)
[mysqld(API)]2node(s)
id=4(Version:
id=5(Version:
Ifyousee
notconnected,acceptingconnectfrom192.168.0.[1/2/3]
inthefirstorlasttwolinestheyyouhaveaproblem.PleaseemailmewithasmuchdetailasyoucangiveandIcantrytofindoutwhereyouhavegonewrongandchangethisHOWTOtofixit.
IfyouareOKtohereitistimetotestmysql.Oneitherservermysql1ormysql2enterthefollowingcommands:
Notethatwehavenorootpasswordyet.
mysql
usetest;
CREATETABLEctest(iINT)ENGINE=NDBCLUSTER;
INSERTINTOctest()VALUES
(1);
SELECT*FROMctest;
Youshouldsee1rowreturned(withthevalue1).
Ifthisworks,nowgototheotherserverandrunthesameSELECTandseewhatyouget.Insertfromthathostandgobacktohost1andseeifitworks.Ifitworksthencongratulations.
Thefinaltestistokilloneservertoseewhathappens.Ifyouhavephysicalaccesstothemachinesimplyunplugitsnetworkcableandseeiftheotherserverkeepsongoingfine(trytheSELECTquery).Ifyoudonthavephysicalaccessdothefollowing:
psaux|grepndbd
Yougetanoutputlikethis:
root55780.00.362201964?
S03:
140:
00ndbd
root55790.020.4492072102828?
R03:
04ndbd
root235320.00.13680684pts/1S07:
590:
00grepndbd
Inthiscaseignorethecommand"
grepndbd"
(thelastline)butkillthefirsttwoprocessesbyissuingthecommandkill-9pidpid:
kill-955785579
Thentrytheselectontheotherserver.Whileyouareatitruna
SHOW
commandonthemanagmentnodetoseethattheserverhasdied.Torestartit,justissue
ndbd
no
--inital!
Furthernotesaboutsetup
Istronglyrecommendthatyoureadallofthis(andbookmarkthispage).Itwillalmostcertainlysaveyoualotofsearching.
TheManagmentServer
Istronglyrecommendthatyoudonotstopthemanagmentserveronceithasstarted.Thisisforseveralresons:
∙Theservertakeshardlyanyserverresources
∙Ifaclusterfallsover,youwanttobeabletojustsshinandtypendbdtostatit.Youdontwanttohavetostartmessingaroundwithanotherserver
∙Ifyouwanttotakebackupsthenyouneedthemanagmentserverup
∙Theclusterlogissenttothemanagementserversotocheckwhatisgoingonintheclusterorhashappenedsincelastthisisanimportanttool
∙Allcommandsfromthendb_mgmclientissenttothemanagementserverandthusnomanagementcommandswithoutmanagementserver.
∙Themanagmentserverisrequiredincaseofclusterreconfiguration(crashedserverornetworksplit).Inthecasethatitisnotrunning,"
split-brain"
scenariowilloccure.Themanagementserverarbitrationroleisrequiredforthistypeofsetuptoprovidebetterfaulttollerance.
Howeveryouarewelcometostoptheserverifyouprefer.
Startingandstoppingndbdautomaticallyonboot
Toachievethis,dothefollowingonbothmysql1andmysql2:
echo"
ndbd"
>
/etc/rc.d/init.d/ndbdchmod+x/etc/rc.d/init.d/ndbdchkconfig--addndbd
Notethatthisisareallyquickscript.Yououghtreallytowriteonethatatleastchecksifndbdisalreadystartedonthemachine.
Useofhostnames
YouwillnotethatIhaveusedIPaddressesexclusivelythroughtthissetup.Thisisbecauseusinghostnamessimplyincreasesthenumberofthingsthatcangowrong.MikaelRonstro"
mofMySQLABkindlyexplains:
"
HostnamescertainlyworkwithMySQLCluster.ButusinghostnamesintroducesquiteafewerrorsourcessinceaproperDNSlookupsystemmustbeset-up,sometimes/etc/hostsmustbeeditedandtheirmightbesecurityblocksensuringthatcommunicationbetweencertainmachinesisnotpossibleotherthanoncertainports"
.
IstronglysuggestthatwhiletestingyouuseIPaddressesifyoucan,thenonceitisallworkingchangetohostnames.
RAM
UsethefollowingformulatoworkouttheamountofRAMthatyouneedoneachstoragenode:
(Sizeofdatabase*NumberofReplicas*1.1)/Numberofstoragenodes
NumberofReplicasissettotwobydefault.Youcanchangeitinconfig.iniifyouwant.Soforexampletoruna4GBdatabaseovertwoserverswithNumbeOfReplicassettotwoyouneed4.4GBofRAMoneachstoragenode.FortheSQLnodesandmanagmentnodesyoudontneedmuchRAMatall.Toruna4GBdatabaseover4serverswithNumberOfReplicassettotwoyouwouldneed2.2GBpernode.
Alotofpeoplehaveemailedmequeryingthemathsabove!
Rememberthattheclusterisfaulttolerant,andeachpieceofdataisstoredonatleast2nodes.(2bydefault,assetbyNumberOfReplicas).SoyouneedTWICEthespaceyouwouldneedjustforonecopy
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- MySQL Cluster for two servers
![提示](https://static.bdocx.com/images/bang_tan.gif)