環(huán)境:
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供鄱陽網(wǎng)站建設(shè)、鄱陽做網(wǎng)站、鄱陽網(wǎng)站設(shè)計(jì)、鄱陽網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、鄱陽企業(yè)網(wǎng)站模板建站服務(wù),十余年鄱陽做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。192.168.5.155 mysql-mgm-node
192.168.5.156 mysql-sql-node1 mysql-data-node1
192.168.5.157 mysql-sql-node2 mysql-data-node2
下載cluster軟件并上傳至各服務(wù)器。
1、安裝MGM節(jié)點(diǎn):
創(chuàng)建安裝目錄
mkdir -p /usr/local/mysql/bin
mkdir -p /usr/local/mysql/ndbdata
添加執(zhí)行文件路徑
vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
拷貝執(zhí)行文件
cp bin/ndb_mgmd /usr/local/mysql/bin
cp bin/ndb_mgm /usr/local/mysql/bin
創(chuàng)建日志文件存儲目錄
mkdir /var/log/mysql-cluster
創(chuàng)建配置文件目錄及文件
mkdir /usr/local/mysql/cluster-conf
vi /usr/local/mysql/cluster-conf/config.ini
編輯配置文件:
[ndbd default]
NoOfReplicas=2
DataMemory=2048M
IndexMemory=512M
[ndb_mgmd]
id=1
hostname=192.168.5.155
DataDir=/var/log/mysql-cluster
[ndbd]
id=11
HostName=192.168.5.156
DataDir=/usr/local/mysql/ndbdata
[ndbd]
id=12
HostName=192.168.5.157
DataDir=/usr/local/mysql/ndbdata
[mysqld]
id=21
HostName=192.168.5.156
[mysqld]
id=22
HostName=192.168.5.157
[mysqld]
id=23
2、安裝數(shù)據(jù)節(jié)點(diǎn)及SQL節(jié)點(diǎn):
yum install libaio
#groupadd mysql
#useradd mysql -g mysql
#mv mysql-cluster-gpl-7.2.9-linux2.6-x86_64.tar.gz /usr/local/
#cd /usr/local/
#tar zxvf mysql-cluster-gpl-7.2.9-linux2.6-x86_64.tar.gz
#rm -f mysql-cluster-gpl-7.2.9-linux2.6-x86_64.tar.gz
#mv mysql-cluster-gpl-7.2.9-linux2.6-x86_64 mysql
#chown -R mysql:mysql mysql
#cd mysql
#scripts/mysql_install_db --user=mysql
#cp support-files/my-medium.cnf /etc/my.cnf
#cp support-files/mysql.server /etc/init.d/mysqld
#vi /etc/my.cnf
添加:
datadir=/usr/local/mysql/data/
ndbcluster
ndb-connectstring=192.168.5.155
[ndbd]
connect-string=192.168.5.155
[mysql_cluster]
ndb-connectstring=192.168.5.155
[ndb_mgm]
connect-string=192.168.5.155
[ndb_mgmd]
config-file=/var/lib/mysql-cluster/config.ini
3、啟動相關(guān)服務(wù)
(1)啟動管理節(jié)點(diǎn)相關(guān)服務(wù):
#/usr/local/mysql/bin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini
#netstat -lntpu
tcp 0 0 0.0.0.0:1186 0.0.0.0:*
LISTEN 22907/ndb_mgmd
(2)啟動數(shù)據(jù)節(jié)點(diǎn)相關(guān)服務(wù):
#/usr/local/mysql/bin/ndbd --initial (初次啟動需要加 --initial參數(shù))
#netstat -lntpu
mkdir /usr/local/mysql/ndbdata
chmod 755 /usr/local/mysql/ndbdata
#service mysqld start
4、功能測試:
[root@localhost bin]# ./ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=11 @192.168.5.156 (mysql-5.5.28 ndb-7.2.9, Nodegroup: 0)
id=12 @192.168.5.157 (mysql-5.5.28 ndb-7.2.9, Nodegroup: 0, Master)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.5.155 (mysql-5.5.28 ndb-7.2.9)
[mysqld(API)] 3 node(s)
id=21 @192.168.5.156 (mysql-5.5.28 ndb-7.2.9)
id=22 @192.168.5.157 (mysql-5.5.28 ndb-7.2.9)
id=23 (not connected, accepting connect from any host)
可關(guān)閉master,看master狀態(tài)是否轉(zhuǎn)移到另外一臺;在A關(guān)閉狀態(tài)下,修改B數(shù)據(jù)庫,啟動A,看數(shù)據(jù)是否同步。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。