MySQL NDB 6.3.20集群安裝配置 邁向高可靠性
本文會先對MySQL集群稍作一點介紹,然后會提供一個安裝過程。
介紹:
MySQL集群是一種在無共享架構(gòu)系統(tǒng)里應(yīng)用內(nèi)存數(shù)據(jù)庫集群的技術(shù)。這種無共享的架構(gòu)可以使得系統(tǒng)使用非常便宜的并且是最小配置的硬件。
MySQL集群是一種分布式設(shè)計,目標(biāo)是要達(dá)到?jīng)]有任何單點故障點。因此,任何組成部分都應(yīng)該擁有自己的內(nèi)存和磁盤。任何共享存儲方案如網(wǎng)絡(luò)共享,網(wǎng)絡(luò)文件系統(tǒng)和SAN設(shè)備是不推薦或不支持的。通過這種冗余設(shè)計,MySQL聲稱數(shù)據(jù)的可用度可以達(dá)到99。999%。
實際上,MySQL集群是把一個叫做NDB的內(nèi)存集群存儲引擎集成與標(biāo)準(zhǔn)的MySQL服務(wù)器集成。它包含一組計算機(jī),每個都跑一個或者多個進(jìn)程,這可能包括一個MySQL服務(wù)器,一個數(shù)據(jù)節(jié)點,一個管理服務(wù)器和一個專有的一個數(shù)據(jù)訪問程序。它們之間的關(guān)系如下圖所示:
安裝
準(zhǔn)備:
機(jī)器: 全部安裝Red Hat Linux AS 5且關(guān)閉防火墻
軟件: mysql-cluster-gpl-6.3.20-linux-i686-glibc23.tar.gz
IP
|
Description
|
192.168.99.80
|
Management Node
|
192.168.99.88
|
SQL Node
|
192.168.99.89
|
Data Node
|
192.168.99.90
|
Data Node
|
四臺機(jī)器分別分配如下IP及用途:
安裝節(jié)點,四臺機(jī)器,需要重復(fù)四次:
- [root@candyshop ~]#groupadd mysql
- [root@candyshop ~]#useradd –g mysql mysql
- [root@candyshop ~]#tar zxvf mysql-cluster-gpl-6.3.20-linux-i686-glibc23.tar.gz
- [root@candyshop ~]#chown mysql:mysql mysql-cluster-gpl-6.3.20-linux-i686-glibc23
- [root@candyshop ~]#mv mysql-cluster-gpl-6.3.20-linux-i686-glibc23 /usr/local/mysql
上述命令先創(chuàng)建mysql組和mysql用戶,并且把mysql分配到mysql組,然后將安裝文件解壓,把它放置到/usr/local/mysql目錄。
配置
配置管理節(jié)點[192.168.99.80]:
創(chuàng)建以下文件/usr/local/mysql/cluster-conf/config.ini,并且放置如下內(nèi)容:
- # Options affecting ndbd processes on all data nodes:
- [ndbd default]
- NoOfReplicas=2 # 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.
- # Management process options:
- [ndb_mgmd]
- Id=1
- Hostname=192.168.99.80 # Hostname or IP address of management node
- Datadir=/usr/local/mysql/logs # Directory for management node log files
- # Options for data node "A":
- [ndbd]
- Id=2
- Hostname=192.168.99.89 # Hostname or IP address
- Datadir=/usr/local/mysql/ndbdata # Directory for this data node's data files
- # Options for data node "B":
- [ndbd]
- Id=3
- Hostname=192.168.99.90 # Hostname or IP address
- Datadir=/usr/local/mysql/ndbdata # Directory for this data node's data files
- # SQL node options:
- [mysqld]
- Id=4
- Hostname=192.168.99.88 # Hostname or IP address
- # (additional mysqld connections can be
- # specified for this node for various
- # purposes such as running ndb_restore)
在這個文件里,我們分別給四個節(jié)點分配了ID,這有利于更好的管理和區(qū)分各個節(jié)點。當(dāng)然,要是不指定,MySQL也會動態(tài)分配一個。上述幾個Datadir如果還不存在的需要手動創(chuàng)建。用mkdir –p命令即可。
配置數(shù)據(jù)節(jié)點[192.168.99.89, 192.168.99.90]:
創(chuàng)建/etc/my.cnf文件,內(nèi)容如下
- # Options for mysqld process:
- [mysqld]
- Datadir=/usr/local/mysql/ndbdata
- ndbcluster # run NDB storage engine
- ndb-connectstring=192.168.99.80 # location of management server
- # Options for ndbd process:
- [mysql_cluster]
- ndb-connectstring=192.168.99.80 # location of management server
配置SQL節(jié)點[192.168.99.88]
創(chuàng)建/etc/my.cnf文件,內(nèi)容如下
- # Options for mysqld process:
- [mysqld]
- ndbcluster # run NDB storage engine
- ndb-connectstring=192.168.99.80 # location of management server
- # Options for ndbd process:
- [mysql_cluster]
- ndb-connectstring=192.168.99.80 # location of management server
- [root@server88 mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --ldata=/usr/local/mysql/data/
- Installing MySQL system tables...
- OK
- Filling help tables...
- OK
到這里,所有配置已經(jīng)完成了。
啟動
啟動管節(jié)點[192.168.99.80]:
- [root@candyshop mysql]# ./bin/ndb_mgmd -f cluster-conf/config.ini
- [root@candyshop mysql]# ./bin/ndb_mgm
- -- NDB Cluster -- Management Client --
- ndb_mgm> show
- Connected to Management Server at: 192.168.99.80:1186
- Cluster Configuration
- ---------------------
- [ndbd(NDB)] 2 node(s)
- id=2 (not connected, accepting connect from 192.168.99.89)
- id=3 (not connected, accepting connect from 192.168.99.90)
- [ndb_mgmd(MGM)] 1 node(s)
- id=1 @192.168.99.80 (mysql-5.1.30 ndb-6.3.20)
- [mysqld(API)] 1 node(s)
- id=4 (not connected, accepting connect from 192.168.99.88)
我們可以看到集群的狀態(tài)都還沒有啟動,都是not connected狀態(tài)。
- [root@candyshop mysql]# ./bin/ndb_mgmd -f cluster-conf/config.ini
- [root@candyshop mysql]# ./bin/ndb_mgm
- -- NDB Cluster -- Management Client --
- ndb_mgm> show
- Connected to Management Server at: 192.168.99.80:1186
- Cluster Configuration
- ---------------------
- [ndbd(NDB)] 2 node(s)
- id=2 (not connected, accepting connect from 192.168.99.89)
- id=3 (not connected, accepting connect from 192.168.99.90)
- [ndb_mgmd(MGM)] 1 node(s)
- id=1 @192.168.99.80 (mysql-5.1.30 ndb-6.3.20)
- [mysqld(API)] 1 node(s)
- id=4 (not connected, accepting connect from 192.168.99.88)
啟動數(shù)據(jù)節(jié)點[192.168.99.89, 192.168.99.90]:
- [root@server89 ~]#cd /usr/local/mysql
- [root@server89 mysql]#./bin/ndbd
啟動SQL節(jié)點[192.168.99.88]:
- [root@server88 mysql]# ./bin/mysqld_safe &
至此,所有節(jié)點已經(jīng)啟動完成,讓我們來查看系統(tǒng)狀態(tài):
- ndb_mgm> show
- Connected to Management Server at: localhost:1186
- Cluster Configuration
- ---------------------
- [ndbd(NDB)] 2 node(s)
- id=2 @192.168.99.89 (mysql-5.1.30 ndb-6.3.20, Nodegroup: 0, Master)
- id=3 @192.168.99.90 (mysql-5.1.30 ndb-6.3.20, Nodegroup: 0)
- [ndb_mgmd(MGM)] 1 node(s)
- id=1 @192.168.99.80 (mysql-5.1.30 ndb-6.3.20)
- [mysqld(API)] 1 node(s)
- id=4 @192.168.99.88 (mysql-5.1.30 ndb-6.3.20)
至此,安裝已經(jīng)結(jié)束
原文鏈接:http://ginge.javaeye.com/blog/320205
【編輯推薦】
- MySQL數(shù)據(jù)庫集群進(jìn)行正確配置步驟
- MySQL 集群在Server1與Server2上如何安裝MySQL
- MySQL集群配置
- MySQL集群自動安裝腳本
- MySQL觸發(fā)器如何正確使用