Vincent.Chan‘s Blog

          常用鏈接

          統(tǒng)計(jì)

          積分與排名

          網(wǎng)站

          最新評(píng)論

          Mysql 集群簡介和配置

          1.? 先了解一下你是否應(yīng)該用 mysql 集群。

          減少數(shù)據(jù)中心結(jié)點(diǎn)壓力和大數(shù)據(jù)量處理,采用把 mysql 分布,一個(gè)或多個(gè) application 對(duì)應(yīng)一個(gè) mysql 數(shù)據(jù)庫。把幾個(gè) mysql 數(shù)據(jù)庫公用的數(shù)據(jù)做出共享數(shù)據(jù),例如購物車,用戶對(duì)象等等,存在數(shù)據(jù)結(jié)點(diǎn)里面。其他不共享的數(shù)據(jù)還維持在各自分布的 mysql 數(shù)據(jù)庫本身中。

          ?

          MySQL Cluster Components

          ?

          ?

          2.? 集群 Mysql 中名稱概念 .( 如上圖 )

          1 Sql 結(jié)點(diǎn)( SQL node-- 上圖對(duì)應(yīng)為 mysqld : 分布式數(shù)據(jù)庫。包括自身數(shù)據(jù)和查詢中心結(jié)點(diǎn)數(shù)據(jù) .

          2 )數(shù)據(jù)結(jié)點(diǎn) (Data node -- ndbd): 集群共享數(shù)據(jù) ( 內(nèi)存中 ).

          3 )管理服務(wù)器 (Management Server – ndb_mgmd): 集群管理 SQL node,Data node.

          ?

          3 .配置

          ?????? mysql-max 版本,當(dāng)然現(xiàn)在 mysql 集群系統(tǒng) windonws 平臺(tái)上面不被支持 .

          ?????? 安裝 mysql 就不多說了,網(wǎng)上一打堆,簡明扼要。

          ?????? A:192.168.1.251 – Data node Management Server.

          ?????? B:192.168.1.254 – SQL node.

          當(dāng)然,你也可以讓一個(gè)機(jī)器同時(shí)為 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] # 這個(gè)相當(dāng)于 192.168.1.251

          ?

          ?

          4.?????? 啟動(dòng)測試

          ?

          ·???????? 在管理服務(wù)器上面(這里是192.168.1.251):

          				
          						
          ·???????????????


          shell> ndb_mgmd -f /var/lib/mysql-cluster/config.ini

          ?

          ·???????? 在數(shù)據(jù)結(jié)點(diǎn)服務(wù)器上面(依然是192.168.1.251 and more):

          				
          						
          ·???????????????


          shell> ndbd --initial (

          第一次時(shí)加 --initial 參數(shù))






          ?

          ·???????? SQL 結(jié)點(diǎn)服務(wù)器上面(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

          關(guān)閉集群:

          shell> ndb_mgm -e shutdown

          ?

          ?

          5 .基本的集群說明

          1 )在mysql 集群中.當(dāng)table引擎為NDBCLUSTER時(shí)才做集群,其他非NDBCLUSTER表和一般mysql數(shù)據(jù)庫表一樣,不會(huì)共享數(shù)據(jù). NDBCLUSTER 表數(shù)據(jù)存儲(chǔ)在Data node服務(wù)器內(nèi)存中Data Node可以為1臺(tái)或多臺(tái)服務(wù)器,它們之間存放共享數(shù)據(jù)。Data Node服務(wù)器可以分組數(shù)據(jù)copy

          例如:2,3,4,5 為四臺(tái)Data Node服務(wù)器ID. 2,3為組0? 45為組1? 23維持數(shù)據(jù)相同, 45維持數(shù)據(jù)相同。 組0和組1維持數(shù)據(jù)不同。

          ??? 2 sql node 服務(wù)器中,非NDBCLUSTER數(shù)據(jù)存在本身數(shù)據(jù)庫中,table引擎為NDBCLUSTER時(shí),數(shù)據(jù)存儲(chǔ)在Data Node 中。當(dāng)查詢NDBCLUSTER表時(shí),它會(huì)從Data node集群中提起數(shù)據(jù).

          ??? 3)Manager server

          ??? 管理SQl node Data node 狀態(tài)。

          ?

          ?

          6 深入了解

          http://dev.mysql.com/doc/refman/5.0/en/ndbcluster.html

          posted on 2006-06-28 23:45 Vincent.Chen 閱讀(246) 評(píng)論(0)  編輯  收藏 所屬分類: Database

          主站蜘蛛池模板: 西峡县| 鞍山市| 扎赉特旗| 独山县| 昭通市| 平罗县| 乐山市| 卓资县| 惠东县| 民乐县| 海门市| 雷州市| 谢通门县| 徐州市| 宁乡县| 沙坪坝区| 岐山县| 汨罗市| 平昌县| 宜春市| 祁阳县| 邻水| 古丈县| 常山县| 故城县| 偃师市| 和顺县| 米泉市| 宜丰县| 合阳县| 光泽县| 宁陕县| 玉环县| 泸定县| 西藏| 进贤县| 利川市| 永登县| 同德县| 上饶市| 阳西县|