標籤:linux bsp rest pad tab soc led glibc load
架構:
192.168.188.101 (NDB mgmd節點;sql節點01) |
192.168.188.102 (sql節點02) |
192.168.188.103 (NDBD節點01) |
192.168.188.104 (NDBD節點02) |
192.168.188.105 (LVS-01) |
192.168.188.106 (LVS-02) |
192.168.188.188 (WEB前端) |
一、NDB mgmd節點
安裝好centos 7.5後
1、關閉selinux和防火牆
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config
setenforce 0
systemctl stop firewalld.service
systemctl disable firewalld.service
=========================================================
2、更新yum庫
yum -y update
========================================
3、下載mysql安裝包
wget https://downloads.mysql.com/archives/get/file/mysql-cluster-gpl-7.6.6-linux-glibc2.12-x86_64.tar.gz
解壓:
tar -xvf mysql-cluster-gpl-7.6.6-linux-glibc2.12-x86_64.tar.gz
剪下檔案到/usr/local/mysql目錄
mv mysql-cluster-gpl-7.6.6-linux-glibc2.12-x86_64 /usr/local/mysql
建立mysql cluster檔案夾並建立設定檔
mkdir -p /data/mysql/mysql-cluster
cd /data/mysql/mysql-cluster
vim mgmd.cnf
[ndbd default]NoOfReplicas=2DataMemory=80MIndexMemory=18M[ndb_mgmd]hostname=192.168.188.101datadir=/data/mysql/mysql-cluster[ndbd]hostname=192.168.188.103datadir=/usr/local/mysql/data[ndbd]hostname=192.168.188.104datadir=/usr/local/mysql/data[mysqld]hostname=192.168.188.101[mysqld]hostname=192.168.188.102[mysqld]
啟動mysql cluster叢集
/usr/local/mysql/bin/ndb_mgmd -f mgmd.cnf
查看進程情況
[[email protected] mysql-cluster]# ps -ef|grep mgmd|grep -v grep
root 43958 1 0 19:28 ? 00:00:00 /usr/local/mysql/bin/ndb_mgmd -f mgmd.cnf
[[email protected] mysql-cluster]# /usr/local/mysql/bin/ndb_mgm 192.168.188.101
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: 192.168.188.101:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 (not connected, accepting connect from 192.168.188.103)
id=3 (not connected, accepting connect from 192.168.188.104)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.188.101 (mysql-5.7.22 ndb-7.6.6)
[mysqld(API)] 3 node(s)
id=4 (not connected, accepting connect from 192.168.188.101)
id=5 (not connected, accepting connect from 192.168.188.102)
id=6 (not connected, accepting connect from any host)
ndb_mgm>
其他sql節點和NDB節點未部署,所以提示沒串連;
二、sql節點:
安裝好centos 7.5後
1、關閉selinux和防火牆
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config
setenforce 0
systemctl stop firewalld.service
systemctl disable firewalld.service
=========================================================
2、更新yum庫
yum -y update
========================================
3、下載mysql安裝包
wget https://downloads.mysql.com/archives/get/file/mysql-cluster-gpl-7.6.6-linux-glibc2.12-x86_64.tar.gz
解壓:
tar -xvf mysql-cluster-gpl-7.6.6-linux-glibc2.12-x86_64.tar.gz
剪下檔案到/usr/local/mysql目錄
mv mysql-cluster-gpl-7.6.6-linux-glibc2.12-x86_64 /usr/local/mysql
建立data檔案夾並建立設定檔
mkdir -p /usr/local/mysqldata
=======================================
配置mysql檔案
vim /etc/my.cnf
[client]socket=/usr/local/mysql/mysql.sock[mysqld]basedir=/usr/local/mysqldatadir=/usr/local/mysql/datandbclusterndb-connectstring=192.168.188.101 #管理節點ip[mysql_cluster]ndb-connectstring=192.168.188.101 #管理節點ipbind-address = 0.0.0.0
初始化MYsql資料庫:
cd /usr/local/mysql
groupadd mysql
useradd -r -g mysql mysql
chown -R mysql .
chgrp -R mysql .
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
記錄下初始化後mysql的root密碼
A temporary password is generated for [email protected]: v:u-LSj,j7Nr
改回授權
[[email protected] mysql]# chown -R root .
[[email protected] mysql]# chown -R mysql data
尋找預設的mysql.sock目錄軟串連自訂的mysql.sock目錄
find / -name mysql.sock
ln -s /tmp/mysql.sock /usr/local/mysql/mysql.sock
添加系統啟動項
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql
service mysql start
添加全域變數:
vim /etc/profile
PATH=$PATH:/usr/local/mysql:/usr/local/mysql/bin
export PATH
wq
source /etc/profile
service mysql restart
cd //usr/local/mysql/
bin/mysqladmin -uroot -p password ‘2285003‘ #修改密碼
mysql -u root -p #登入mysql
其他多台也同樣重複配置即可;
=========================================
三、NDBD伺服器部署
安裝好centos 7.5後
1、關閉selinux和防火牆
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config
setenforce 0
systemctl stop firewalld.service
systemctl disable firewalld.service
=========================================================
2、更新yum庫
yum -y update
========================================
3、下載mysql安裝包
wget https://downloads.mysql.com/archives/get/file/mysql-cluster-gpl-7.6.6-linux-glibc2.12-x86_64.tar.gz
解壓:
tar -xvf mysql-cluster-gpl-7.6.6-linux-glibc2.12-x86_64.tar.gz
剪下檔案到/usr/local/mysql目錄
mv mysql-cluster-gpl-7.6.6-linux-glibc2.12-x86_64 /usr/local/mysql
建立data檔案夾並建立設定檔
mkdir -p /usr/local/mysqldata
編輯mysql設定檔
[[email protected] ~]# vim /etc/my.cnf
[mysqld]ndbcluster #運行NDB儲存引擎ndb-connectstring=192.168.188.101 #定位管理節點[mysql_cluster]ndb-connectstring=192.168.188.101 #定位管理節點
第一次串連需要加上 --initial串連成功後以後都不要加這個參數;
/usr/local/mysql/bin/ndbd --initial --ndb-connectstring=192.168.188.101
串連成功後查看進程
[[email protected] data]# ps -ef | grep nbd
root 43974 1272 0 20:11 pts/0 00:00:00 grep --color=auto nbd
其他多台也同樣重複配置即可;
============================================================================
回到NDB-mgmd節點查看狀態:
[[email protected] ~]# /usr/local/mysql/bin/ndb_mgm 192.168.188.101
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: 192.168.188.101:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @192.168.188.103 (mysql-5.7.22 ndb-7.6.6, Nodegroup: 0, *)
id=3 @192.168.188.104 (mysql-5.7.22 ndb-7.6.6, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.188.101 (mysql-5.7.22 ndb-7.6.6)
[mysqld(API)] 3 node(s)
id=4 (not connected, accepting connect from 192.168.188.101)
id=5 (not connected, accepting connect from 192.168.188.102)
id=6 @192.168.188.101 (mysql-5.7.22 ndb-7.6.6)
ndb_mgm>
這樣就完成了mysql cluster NDB部署,後面再補上lvs+keepalive的部署;
注意:NDB高可用叢集只支援用NDB引擎建立的表在各節點同步,sql庫的許可權也是獨立的,所以還需要做叢集後mysql使用者權限同步;
centos7.5部署mysql cluster NDB總結