1.?
先了解一下你是否應該用
mysql
集群。
減少數據中心結點壓力和大數據量處理,采用把
mysql
分布,一個或多個
application
對應一個
mysql
數據庫。把幾個
mysql
數據庫公用的數據做出共享數據,例如購物車,用戶對象等等,存在數據結點里面。其他不共享的數據還維持在各自分布的
mysql
數據庫本身中。
?
?
?
2.?
集群
Mysql
中名稱概念
.(
如上圖
)
1
)
Sql
結點(
SQL node--
上圖對應為
mysqld
)
:
分布式數據庫。包括自身數據和查詢中心結點數據
.
2
)數據結點
(Data node -- ndbd):
集群共享數據
(
內存中
).
3
)管理服務器
(Management Server – ndb_mgmd):
集群管理
SQL node,Data node.
?
3
.配置
?????? mysql-max
版本,當然現在
mysql
集群系統
windonws
平臺上面不被支持
.
??????
安裝
mysql
就不多說了,網上一打堆,簡明扼要。
?????? A:192.168.1.251 – Data node
和
Management Server.
?????? B:192.168.1.254 – SQL node.
當然,你也可以讓一個機器同時為
3
者。
A,B my.inf
加上:
??????
[MYSQLD]???????????????????????
ndbcluster????????????????????? # run NDB engine
ndb-connectstring=192.168.1.251? # location of MGM node
?
# Options for ndbd process:
[MYSQL_CLUSTER]????????????????
ndb-connectstring=192.168.1.251? # location of MGM node
?
A: /var/lib/mysql-cluster/config.ini
[NDBD DEFAULT]???
NoOfReplicas=1??? # Number of replicas
DataMemory=80M??? # How much memory to allocate for data storage
IndexMemory=18M?? # How much memory to allocate for index storage
????????????????? # For DataMemory and IndexMemory, we have used the
????????????????? # default values. Since the "world" database takes up
????????????????? # only about 500KB, this should be more than enough for
????????????????? # this example Cluster setup.
# TCP/IP options:
[TCP DEFAULT]????
portnumber=2202?? # This the default; however, you can use any
???????????????
??# port that is free for all the hosts in cluster
????????????????? # Note: It is recommended beginning with MySQL 5.0 that
????????????????? # you do not specify the portnumber at all and simply allow
????????????????? # the default value to be used instead
# Management process options:
[NDB_MGMD]?????????????????????
hostname=192.168.1.251?????????? # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster? # Directory for MGM node logfiles
# Options for data node "A":
[NDBD]????????????????? ????????
??????????????????????????????? # (one [NDBD] section per data node)
hostname=192.168.1.251?????????? # Hostname or IP address
datadir=/usr/local/mysql/data?? # Directory for this data node's datafiles
# SQL node options:
[MYSQLD]
hostname=192.168.1.254
#[MYSQLD] #
這個相當于
192.168.1.251
?
?
4.??????
啟動測試
?
·????????
在管理服務器上面(這里是192.168.1.251
):
·???????????????
shell> ndb_mgmd -f /var/lib/mysql-cluster/config.ini
?
·????????
在數據結點服務器上面(依然是192.168.1.251
and more):
·???????????????
shell> ndbd --initial (
第一次時加 --initial 參數)
?
·????????
SQL
結點服務器上面(192.168.1.254
):
·???????????????
shell> mysqld &
?
在
251
上面察看
?
./ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: 192.168.1.251:1186
Cluster Configuration
---------------------
[ndbd(NDB)]???? 1 node(s)
id=2??? @192.168.1.251? (Version: 5.0.22, Nodegroup: 0, Master)
?
[ndb_mgmd(MGM)] 1 node(s)
id=1??? @192.168.1.251? (Version: 5.0.22)
?
[mysqld(API)]?? 1 node(s)
id=3??? @192.168.1.254? (Version: 5.0.22)
?
ok
關閉集群:
shell>
ndb_mgm -e shutdown
?
?
5
.基本的集群說明
1
)在mysql 集群中.當table引擎為NDBCLUSTER時才做集群,其他非NDBCLUSTER表和一般mysql數據庫表一樣,不會共享數據. NDBCLUSTER 表數據存儲在Data node服務器內存中,Data Node可以為1臺或多臺服務器,它們之間存放共享數據。Data Node服務器可以分組數據copy。
例如:2,3,4,5 為四臺Data Node服務器ID. 2,3為組0。? 4,5為組1。? 2,3維持數據相同, 4,5維持數據相同。 組0和組1維持數據不同。
??? 2
) sql node 服務器中,非NDBCLUSTER數據存在本身數據庫中,table引擎為NDBCLUSTER時,數據存儲在Data Node 中。當查詢NDBCLUSTER表時,它會從Data node集群中提起數據.
??? 3)Manager server
???
管理SQl node 和Data node 狀態。
?
?
6
深入了解
http://dev.mysql.com/doc/refman/5.0/en/ndbcluster.html
posted on 2006-06-28 11:58
地獄男爵(hellboys) 閱讀(61960)
評論(7) 編輯 收藏 所屬分類:
系統綜合