CENTOS7 安裝Mysql 7.6.6 cluster
先把fireall關閉
# vi /etc/selinux/config
SELINUX=disabled
# SELINUXTYPE=targeted
存檔離開
#systemctl stop firewalld.service
# systemctl disable firewalld.service
存檔離開,重新開機
#systemctl stop firewalld.service
# systemctl disable firewalld.service
存檔離開,重新開機
- 安裝前先把CENTOS預設的MYSQL及MARIA移除
- yum erase mysql
- yum erase maria
- 先下載YUM需要的安裝檔,後續安裝會比較方便
- wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
- 下載成功後用RPM安裝剛剛下載下來的檔
mkdir -p /var/lib/mysql-cluster
yum install mysql-cluster-community-server
cp /usr/local/mysql/bin/ndb_mgm* /usr/local/bin/
以上指令其他台都需執行,可以在MGM完成設定後COPY虛擬機來使用會比較快一點
vi /var/lib/mysql-cluster/config.ini
[NDBD DEFAULT]
NoOfReplicas=2
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
[NDB_MGMD]
hostname=192.168.100.62
NodeId=1
[MYSQLD]
NodeId=2
hostname=192.168.100.64
[mysqld]
NodeId=3
hostname=192.168.100.68
[ndbd]
hostname=192.168.100.52
NodeId=4
[ndbd]
hostname=192.168.100.53
NodeId=5
啟動 MySQL Cluster 順序: 首先啟動管理節點服務器(ndb_mgmd),然後啟動存儲節點服務器(ndbd),最後才啟動SQL節點服務器(service mysql start)
1.啟動MGM主機
ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial看到下面訊息表示config.ini設定成功,如果沒有出現再去看ERROR LOG看是什麼問題
#MySQL Cluster Management Server mysql-5.7.22 ndb-7.6.6
然後可以到MGM那台,輸入以下指令可看到id=1那台是啟動的
ndb_mgm -e show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=4 (not connected, accepting connect from 192.168.100.52)
id=5 (not connected, accepting connect from 192.168.100.53)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.100.62 (mysql-5.7.22 ndb-7.6.6)
[mysqld(API)] 2 node(s)
id=2 (not connected, accepting connect from 192.168.100.64)
id=3 (not connected, accepting connect from 192.168.100.68)
- 設定Data Node
vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
#user=mysql
symbolic-link=0
ndbcluster
ndb-connectstring=192.168.100.62:1186
default-storage-engine=NDBCLUSTER
skip-character-set-client-handshake
character-set-server=utf8
collation-server=utf8_general_ci
init-connect=SET NAMES utf8
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysql_cluster]
ndb-connectstring=192.168.100.62:1186
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
scoket=/usr/local/mysql/data/mysql.sock
存檔離開
2.啟動Data Node(2台都要啟動)
ndbd --defaults-file=/etc/my.cnf -v
看到以下訊息表示啟動成功
2018-07-08 05:09:41 [ndbd] INFO -- Angel connected to '192.168.100.62:1186'
2018-07-08 05:09:41 [ndbd] INFO -- Angel allocated nodeid: 4
2018-07-08 05:09:41 [ndbd] DEBUG -- Using configuration with generation 1
2018-07-08 05:09:41 [ndbd] DEBUG -- Using StopOnError: 1
2018-07-08 05:09:41 [ndbd] DEBUG -- Using DataDir: .
可以到MGM那台輸入ndb_mgm -e show 看是不是有正常連線成功
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=4 @192.168.100.52 (mysql-5.7.22 ndb-7.6.6, Nodegroup: 0, *)
id=5 @192.168.100.53 (mysql-5.7.22 ndb-7.6.6, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.100.62 (mysql-5.7.22 ndb-7.6.6)
[mysqld(API)] 2 node(s)
id=2 (not connected, accepting connect from 192.168.100.64)
id=3 (not connected, accepting connect from 192.168.100.68)
3.啟動 SQL Node
vi /etc/my.cnf
[mysqld]
#skip-grant-tables -->這行是如果一開始mysql找不到登入的帳密時可以用這行先暫停讀取權限表,就可以不用密碼進入mysql
log-error=/tmp/mysqld.log
explicit_defaults_for_timestamp=1
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
user=mysql
ndbcluster
ndb-connectstring=192.168.100.62:1186
default-storage-engine=NDBCLUSTER
[mysql_cluster]
ndb-connectstring=192.168.100.62:1186
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
存檔離開
執行啟動mysql命令
service mysqld start
如果沒有錯誤訊息表示my.cnf設定成功
如果有出現錯誤訊息可以進入\tmp\mysqld.log查看錯誤是什麼原因造成,有可能是有的套件沒有安裝,保險的做法是在SQL NODE裝齊所有MYSQL-CLUSTER的套件
成功後可以到MGM那台輸入ndb_mgm -e show 看是不是有正常連線成功
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=4 @192.168.100.52 (mysql-5.7.22 ndb-7.6.6, Nodegroup: 0, *)
id=5 @192.168.100.53 (mysql-5.7.22 ndb-7.6.6, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.100.62 (mysql-5.7.22 ndb-7.6.6)
[mysqld(API)] 2 node(s)
id=2 @192.168.100.64 (mysql-5.7.22 ndb-7.6.6)
id=3 @192.168.100.68 (mysql-5.7.22 ndb-7.6.6)
留言
張貼留言