您好,登錄后才能下訂單哦!
環境:
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軟件并上傳至各服務器。
1、安裝MGM節點:
創建安裝目錄
mkdir -p /usr/local/mysql/bin
mkdir -p /usr/local/mysql/ndbdata
添加執行文件路徑
vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
拷貝執行文件
cp bin/ndb_mgmd /usr/local/mysql/bin
cp bin/ndb_mgm /usr/local/mysql/bin
創建日志文件存儲目錄
mkdir /var/log/mysql-cluster
創建配置文件目錄及文件
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、安裝數據節點及SQL節點:
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、啟動相關服務
(1)啟動管理節點相關服務:
#/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)啟動數據節點相關服務:
#/usr/local/mysql/bin/ndbd --initial (初次啟動需要加 --initial參數)
#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)
可關閉master,看master狀態是否轉移到另外一臺;在A關閉狀態下,修改B數據庫,啟動A,看數據是否同步。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。