硬件配置
普通PCserver*2(最小集群环境需要4台服务器)
模拟环境
redhatlinux9forx86(orredhatAS2以上版本),glibc-2.2,static,gcc
MySQL版本4.1.12binares
mysql-maxbinary版本目前只支持linux、maxosx和solaris
本方案不涉及从源代码编译安装
主机IP地址用途
ndb1_mgmd_sqld1192.168.1.100Ndbnode1mgmdnode1sqldnode1
ndb2_sqld2192.168.1.200Ndbnode2sqldnode2
Mgmd:managementserver
sqld:mysqlserver
ndb:storagednode(share-nothing,baseinmemory)
安装
从http://dev.mysql.com/downloads/mysql/4.1.html下载mysql-max-4.1.12-pc-linux-gnu-i686.tar.gz到/var/tmp
StorageandSQLNodeInstallation
在两台主机上执行如下过程
shell>groupaddmysql
shell>useradd-gmysqlmysql
shell>tarzxfvmysql-max-4.1.12-pc-linux-gnu-i686.tar.gz
shell>cp-vrmysql-max-4.1.12-pc-linux-gnu-i686/usr/local/mysql-max-4.1.12-pc-linux-gnu-i686
shell>cd/usr/local
shell>ln-smysql-max-4.1.12-pc-linux-gnu-i686mysql
shell>cdmysql;scripts/mysql_install_db–user=mysql
shell>chown-Rroot.;chown-Rmysqldata;chgrp-Rmysql.
shell>cpsupport-files/mysql.server/etc/rc.d/init.d/
shell>chmodx/etc/rc.d/init.d/mysql.server
shell>chkconfig--addmysql.server
shell>chkconfig–level3mysql.serveroff
ManagementNodeInstallation
在主机ndb1_mgmd_sqld1上执行如下过程
shell>cd/var/tmp
shell>tar-zxvfmysql-max-4.1.12a-pc-linux-gnu-i686.tar.gz/usr/local/bin'*/bin/ndb_mgm*'
Configuration
ConfiguringtheStorageandSQLNodes
在两台主机上执行如下过程:
shell>vi/etc/my.cnf
[MYSQLD] #Optionsformysqldprocess:
ndbcluster #runNDBengine 财 管家园 fs119.net
ndb-connectstring=192.168.1.100 #locationofMGMnode
[MYSQL_CLUSTER] #Optionsforndbdprocess:
ndb-connectstring=192.168.1.100 #locationofMGMnode
ConfiguringtheManagementNode
在主机ndb1_mgmd_sqld1上执行如下过程
shell>mkdir/var/lib/mysql-cluster
shell>cd/var/lib/mysql-cluster
shell>viconfig.ini
[NDBDDEFAULT] #Optionsaffectingndbdprocessesonalldatanodes:
NoOfReplicas=2 #Numberofreplicas
DataMemory=80M #Howmuchmemorytoallocatefordatastorage
IndexMemory=52M #Howmuchmemorytoallocateforindexstorage
#ForDataMemoryandIndexMemory,wehaveusedthe
#defaultvalues.Sincethe"world"databasetakesup
#onlyabout500KB,thisshouldbemorethanenoughfor
#thisexampleClustersetup.
[TCPDEFAULT]
[NDB_MGMD] #Managementprocessoptions:
hostname=192.168.1.100#HostnameorIPaddressofMGMnode 财软.联盟.fs119.net
datadir=/var/lib/mysql-cluster #DirectoryforMGMnodelogfiles
[NDBD] #Optionsfordatanode"A":
#(one[NDBD]sectionperdatanode)
HostName=192.168.1.100 #HostnameorIPaddress
DataDir=/usr/local/mysql/data #Directoryforthisdatanode'sdatafiles
[NDBD] #Optionsfordatanode"B":
hostname=192.168.1.200 #HostnameorIPaddress
datadir=/usr/local/mysql/data #Directoryforthisdatanode'sdatafiles
[MYSQLD] #SQLnodeoptions:
hostname=192.168.1.100 #HostnameorIPaddress
#DirectoryforSQLnode'sdatafiles
#(additionalmysqldconnectionscanbe
#specifiedforthisnodeforvarious
#purposessuchasrunningndb_restore)
[MYSQLD]#SQLnodeoptions:
hostname=192.168.1.200 #HostnameorIPaddress
#DirectoryforSQLnode'sdatafiles
#(additionalmysqldconnectionscanbe
#specifiedforthisnodeforvarious
#purposessuchasrunningndb_restore)
第一次启动
在主机ndb1_mgmd_sqld1上执行如下过程
shell>ndb_mgmd-f/var/lib/mysql-cluster/config.ini
在两台主机上执行如下过程
shell>ndbd–initial(note:--initial选项只能在第一次启动的时候使用)
shell>/etc/init.d/mysql.serverstart
测试
在主机ndb1_mgmd_sqld1上执行如下过程
shell>ndb_mgm
--NDBCluster--ManagementClient--
ndb_mgm>show
ConnectedtoManagementServerat:localhost:1186
ClusterConfiguration
---------------------
[ndbd(NDB)] 2node(s)
id=2 @192.168.0.100 (Version:4.1.12,Nodegroup:0,Master)
id=3 @192.168.0.200 (Version:4.1.12,Nodegroup:0)
[ndb_mgmd(MGM)]1node(s)
id=1 @192.168.0.100 (Version:4.1.12) 财软联.盟.fs119.net
[mysqld(SQL)] 1node(s)
id=4 (Version:4.1.12)
出现如上信息则表示mysql群集安装成功
数据抽样测试
在主机ndb1_mgmd_sqld1上执行如下过程
shell>/usr/local/mysql/bin/mysql-uroottest
MySQL>DROPTABLEIFEXISTSCity;
CREATETABLECity(
IDint(11)NOTNULLauto_increment,
Namechar(35)NOTNULLdefault'',
CountryCodechar(3)NOTNULLdefault'',
Districtchar(20)NOTNULLdefault'',
Populationint(11)NOTNULLdefault'0',
PRIMARYKEY (ID)
)ENGINE=NDBCLUSTER;
MySQL>INSERTINTOCityVALUES(1,'Kabul','AFG','Kabol',1780000);
INSERTINTOCityVALUES(2,'Qandahar','AFG','Qandahar',237500);
INSERTINTOCityVALUES(3,'Herat','AFG','Herat',186800);
在主机ndb2_sqld2上执行如下过程
shell>/usr/local/mysql/bin/mysql-urootmysql
MySQSL>select*fromCity; 财管家 园 fs119.net
如果成功显示数据信息,则表示集群已经成功启动
SafeShutdownandRestart
在主机ndb1_mgmd_sqld1上执行如下过程
shell>ndb_mgm-eshutdown(关闭集群服务器,storagenode也会自动被关闭)
在两台主机上执行如下过程
shell>/etc/init.d/mysql.serverstop
重新启动集群(顺序不能弄错)
在主机ndb1_mgmd_sqld1上执行如下过程
shell>ndb_mgmd-f/var/lib/mysql-cluster/config.ini
在两台主机上执行如下过程
shell>/usr/local/mysql/bin/ndbd
启动完ndbd进程后启动sqld进程
shell>/etc/init.d/mysql.serverstart
附:
config.ini中各部分解释
[COMPUTER]:定义群集主机.
[NDBD]:定义群集数据节点.
[MYSQLD]:定义Sqlserver节点. 财软联盟 fs119.net
[MGM|NDB_MGMD]:Definesthemanagementservernodeinthecluster.
[TCP]:DefinesTCP/IPconnectionsbetweennodesinthecluster,withTCP/IPbeingthedefaultconnectionprotocol.
[SHM]:Definesshared-memoryconnectionsbetweennodes.在MySQL4.1.9之前,这个功能必须使用--with-ndb-shmoption编译进去,从MySQL4.1.9-max版本开始,itisenabledbydefault
文章摘自网络,如有侵权,请与我们联系.
普通PCserver*2(最小集群环境需要4台服务器)
模拟环境
redhatlinux9forx86(orredhatAS2以上版本),glibc-2.2,static,gcc
MySQL版本4.1.12binares
mysql-maxbinary版本目前只支持linux、maxosx和solaris
本方案不涉及从源代码编译安装
主机IP地址用途
ndb1_mgmd_sqld1192.168.1.100Ndbnode1mgmdnode1sqldnode1
ndb2_sqld2192.168.1.200Ndbnode2sqldnode2
Mgmd:managementserver
sqld:mysqlserver
ndb:storagednode(share-nothing,baseinmemory)
安装
从http://dev.mysql.com/downloads/mysql/4.1.html下载mysql-max-4.1.12-pc-linux-gnu-i686.tar.gz到/var/tmp
StorageandSQLNodeInstallation
在两台主机上执行如下过程
shell>groupaddmysql
shell>useradd-gmysqlmysql
shell>tarzxfvmysql-max-4.1.12-pc-linux-gnu-i686.tar.gz
财 管家园 fs119.net
shell>cp-vrmysql-max-4.1.12-pc-linux-gnu-i686/usr/local/mysql-max-4.1.12-pc-linux-gnu-i686
shell>cd/usr/local
shell>ln-smysql-max-4.1.12-pc-linux-gnu-i686mysql
shell>cdmysql;scripts/mysql_install_db–user=mysql
shell>chown-Rroot.;chown-Rmysqldata;chgrp-Rmysql.
shell>cpsupport-files/mysql.server/etc/rc.d/init.d/
shell>chmodx/etc/rc.d/init.d/mysql.server
shell>chkconfig--addmysql.server
shell>chkconfig–level3mysql.serveroff
ManagementNodeInstallation
在主机ndb1_mgmd_sqld1上执行如下过程
shell>cd/var/tmp
shell>tar-zxvfmysql-max-4.1.12a-pc-linux-gnu-i686.tar.gz/usr/local/bin'*/bin/ndb_mgm*'
Configuration
ConfiguringtheStorageandSQLNodes
在两台主机上执行如下过程:
shell>vi/etc/my.cnf
[MYSQLD] #Optionsformysqldprocess:
ndbcluster #runNDBengine 财 管家园 fs119.net
ndb-connectstring=192.168.1.100 #locationofMGMnode
[MYSQL_CLUSTER] #Optionsforndbdprocess:
ndb-connectstring=192.168.1.100 #locationofMGMnode
ConfiguringtheManagementNode
在主机ndb1_mgmd_sqld1上执行如下过程
shell>mkdir/var/lib/mysql-cluster
shell>cd/var/lib/mysql-cluster
shell>viconfig.ini
[NDBDDEFAULT] #Optionsaffectingndbdprocessesonalldatanodes:
NoOfReplicas=2 #Numberofreplicas
DataMemory=80M #Howmuchmemorytoallocatefordatastorage
IndexMemory=52M #Howmuchmemorytoallocateforindexstorage
#ForDataMemoryandIndexMemory,wehaveusedthe
#defaultvalues.Sincethe"world"databasetakesup
#onlyabout500KB,thisshouldbemorethanenoughfor
#thisexampleClustersetup.
[TCPDEFAULT]
[NDB_MGMD] #Managementprocessoptions:
hostname=192.168.1.100#HostnameorIPaddressofMGMnode 财软.联盟.fs119.net
datadir=/var/lib/mysql-cluster #DirectoryforMGMnodelogfiles
[NDBD] #Optionsfordatanode"A":
#(one[NDBD]sectionperdatanode)
HostName=192.168.1.100 #HostnameorIPaddress
DataDir=/usr/local/mysql/data #Directoryforthisdatanode'sdatafiles
[NDBD] #Optionsfordatanode"B":
hostname=192.168.1.200 #HostnameorIPaddress
datadir=/usr/local/mysql/data #Directoryforthisdatanode'sdatafiles
[MYSQLD] #SQLnodeoptions:
hostname=192.168.1.100 #HostnameorIPaddress
#DirectoryforSQLnode'sdatafiles
#(additionalmysqldconnectionscanbe
#specifiedforthisnodeforvarious
#purposessuchasrunningndb_restore)
[MYSQLD]#SQLnodeoptions:
hostname=192.168.1.200 #HostnameorIPaddress
#DirectoryforSQLnode'sdatafiles
财软 联盟 fs119.net
#(additionalmysqldconnectionscanbe
#specifiedforthisnodeforvarious
#purposessuchasrunningndb_restore)
第一次启动
在主机ndb1_mgmd_sqld1上执行如下过程
shell>ndb_mgmd-f/var/lib/mysql-cluster/config.ini
在两台主机上执行如下过程
shell>ndbd–initial(note:--initial选项只能在第一次启动的时候使用)
shell>/etc/init.d/mysql.serverstart
测试
在主机ndb1_mgmd_sqld1上执行如下过程
shell>ndb_mgm
--NDBCluster--ManagementClient--
ndb_mgm>show
ConnectedtoManagementServerat:localhost:1186
ClusterConfiguration
---------------------
[ndbd(NDB)] 2node(s)
id=2 @192.168.0.100 (Version:4.1.12,Nodegroup:0,Master)
id=3 @192.168.0.200 (Version:4.1.12,Nodegroup:0)
[ndb_mgmd(MGM)]1node(s)
id=1 @192.168.0.100 (Version:4.1.12) 财软联.盟.fs119.net
[mysqld(SQL)] 1node(s)
id=4 (Version:4.1.12)
出现如上信息则表示mysql群集安装成功
数据抽样测试
在主机ndb1_mgmd_sqld1上执行如下过程
shell>/usr/local/mysql/bin/mysql-uroottest
MySQL>DROPTABLEIFEXISTSCity;
CREATETABLECity(
IDint(11)NOTNULLauto_increment,
Namechar(35)NOTNULLdefault'',
CountryCodechar(3)NOTNULLdefault'',
Districtchar(20)NOTNULLdefault'',
Populationint(11)NOTNULLdefault'0',
PRIMARYKEY (ID)
)ENGINE=NDBCLUSTER;
MySQL>INSERTINTOCityVALUES(1,'Kabul','AFG','Kabol',1780000);
INSERTINTOCityVALUES(2,'Qandahar','AFG','Qandahar',237500);
INSERTINTOCityVALUES(3,'Herat','AFG','Herat',186800);
在主机ndb2_sqld2上执行如下过程
shell>/usr/local/mysql/bin/mysql-urootmysql
MySQSL>select*fromCity; 财管家 园 fs119.net
如果成功显示数据信息,则表示集群已经成功启动
SafeShutdownandRestart
在主机ndb1_mgmd_sqld1上执行如下过程
shell>ndb_mgm-eshutdown(关闭集群服务器,storagenode也会自动被关闭)
在两台主机上执行如下过程
shell>/etc/init.d/mysql.serverstop
重新启动集群(顺序不能弄错)
在主机ndb1_mgmd_sqld1上执行如下过程
shell>ndb_mgmd-f/var/lib/mysql-cluster/config.ini
在两台主机上执行如下过程
shell>/usr/local/mysql/bin/ndbd
启动完ndbd进程后启动sqld进程
shell>/etc/init.d/mysql.serverstart
附:
config.ini中各部分解释
[COMPUTER]:定义群集主机.
[NDBD]:定义群集数据节点.
[MYSQLD]:定义Sqlserver节点. 财软联盟 fs119.net
[MGM|NDB_MGMD]:Definesthemanagementservernodeinthecluster.
[TCP]:DefinesTCP/IPconnectionsbetweennodesinthecluster,withTCP/IPbeingthedefaultconnectionprotocol.
[SHM]:Definesshared-memoryconnectionsbetweennodes.在MySQL4.1.9之前,这个功能必须使用--with-ndb-shmoption编译进去,从MySQL4.1.9-max版本开始,itisenabledbydefault
财.管家园.fs119.net
数据统计中!!
Google.cn搜索关键字:
方案 模拟 node for 如下 过程 执行 主机 mysql data
Google.cn搜索相关文章:
谷歌中搜索全球网 MySQL群集双机模拟方案
百度中搜索 MySQL群集双机模拟方案
谷歌中搜索www.fs119.net MySQL群集双机模拟方案
上一篇:SCO下用gcc编译调用mysql数据库的程序
Google.cn搜索相关文章:
谷歌中搜索全球网 MySQL群集双机模拟方案
百度中搜索 MySQL群集双机模拟方案
谷歌中搜索www.fs119.net MySQL群集双机模拟方案
下一篇:发布MySQL集群自动安装脚本1.0
精品课程推荐
相关文章
Sun以十亿美元收购MySQL 2008-01-18 06:17:30 EclipseJBossMySQL开发环境设置全攻略 2007-06-15 10:21:03 Win2K下安装IIS配置aspcgiphpmysql 2007-06-15 10:21:01 MySQL两种表存储结构性能比较测试过程 2007-06-15 10:21:01 MySQL数据库安全配置指南 2007-06-15 10:21:00 实例讲解MYSQL数据库的查询优化技术 2007-06-15 10:21:00
每日新新闻索引
热点专题
最新主题
推荐大折扣培训课程