標籤:
準備:1、下載 MySQL-Cluster-gpl-7.3.8-1.el6.x86_64.rpm-bundle.tar
: http://mirrors.sohu.com/mysql/MySQL-Cluster-7.3/MySQL-Cluster-gpl-7.3.8-1.el6.x86_64.rpm-bundle.tar
解壓:
[[email protected] files]# tar -xvf MySQL-Cluster-gpl-7.3.8-1.el6.x86_64.rpm-bundle.tarMySQL-Cluster-test-gpl-7.3.8-1.el6.x86_64.rpmMySQL-Cluster-shared-compat-gpl-7.3.8-1.el6.x86_64.rpmMySQL-Cluster-client-gpl-7.3.8-1.el6.x86_64.rpmMySQL-Cluster-embedded-gpl-7.3.8-1.el6.x86_64.rpmMySQL-Cluster-server-gpl-7.3.8-1.el6.x86_64.rpmMySQL-Cluster-devel-gpl-7.3.8-1.el6.x86_64.rpmMySQL-Cluster-shared-gpl-7.3.8-1.el6.x86_64.rpm
2、停掉原有mysql 刪除開機自動運行 卸載原有mysql 相關(未有任何相關則忽略)
[[email protected] files]# service mysql stop
Shutting down MySQL.. SUCCESS!
[[email protected] files]# chkconfig mysql off
[[email protected] files]# rpm -qa | grep MySQL
MySQL-client-5.6.24-1.el6.x86_64
MySQL-server-5.6.24-1.el6.x86_64
MySQL-devel-5.6.24-1.el6.x86_64
[[email protected] files]# rpm -e --nodeps MySQL-client-5.6.24-1.el6.x86_64 MySQL-server-5.6.24-1.el6.x86_64 MySQL-devel-5.6.24-1.el6.x86_64
進行安裝操作
[[email protected] files]# rpm -ivh MySQL-Cluster-server-gpl-7.3.8-1.el6.x86_64.rpm
[[email protected] files]# rpm -ivh MySQL-Cluster-client-gpl-7.3.8-1.el6.x86_64.rpm
添加使用者資訊:
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
flush privileges ;
建立工作目錄及檔案配置:
[[email protected] var]# mkdir /var/mysql-cluster
[[email protected] var]# mkdir /var/lib/mysql/data
[[email protected] var]# mkdir /var/run/mysqld
[[email protected] var]# chmod -R 1777 /var/lib/mysql
[[email protected] var]# chmod -R 1777 /var/run/mysqld
[[email protected] var]# chmod -R 1777 /var/lib/mysql-cluster
[[email protected] var] vi /etc/config.ini
[computer]
Id=mgr-server-01
HostName=192.168.1.240
[mgm default]
datadir=/var/lib/mysql-cluster
[mgm]
HostName=192.168.1.240
NodeId=60
ExecuteOnComputer=mgr-server-01
PortNumber=1186
ArbitrationRank=2
[ndbd default]
NoOfReplicas=2
DataMemory=500M
IndexMemory=500M
[ndbd]
HostName=192.168.1.240
DataDir=/var/lib/mysql
NodeId=1
[ndbd]
HostName=192.168.1.241
DataDir=/var/lib/mysql
NodeId=2
[[email protected] var] vi /etc/my.conf
[client]
socket=/var/lib/mysql/mysql.sock
[mysqld]
max_connections=100
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
ndbcluster
ndb-connectstring=192.168.1.240
[mysqld_safe]
log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid
pid-file=/var/lib/mysql/mysqld.pid
[mysql_cluster]
ndb-connectstring=192.168.1.240
啟動:
註:關閉防火牆設定(可待調試成功後重新開啟防火牆僅開放用到的連接埠),selinux 設為 disabled
順序:管理節點->均衡節點->資料節點 (關閉時相反:資料節點 service mysql stop ->均衡節點 ndb_mgm -e shutdown)
[[email protected] mysql-cluster]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini //啟動 管理節點 操作
MySQL Cluster Management Server mysql-5.6.22 ndb-7.3.8
[[email protected] mysql-cluster]# ndbd --initial //均衡節啟動 初次開機加 --initial 再次不需加
[[email protected] mysql-cluster]# mysqld_safe --defaults-file=/etc/my.cnf --explicit_defaults_for_timestamp & //啟動資料節點
查看串連情況:
[[email protected] ~]# ndb_mgm-- NDB Cluster -- Management Client --ndb_mgm> showConnected to Management Server at: 192.168.1.240:1186Cluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=1 @192.168.1.240 (mysql-5.6.22 ndb-7.3.8, Nodegroup: 0)id=2 @192.168.1.241 (mysql-5.6.22 ndb-7.3.8, Nodegroup: 0, *)[ndb_mgmd(MGM)] 1 node(s)id=60 @192.168.1.240 (mysql-5.6.22 ndb-7.3.8)[mysqld(API)] 2 node(s)id=81 @192.168.1.240 (mysql-5.6.22 ndb-7.3.8)id=82 @192.168.1.241 (mysql-5.6.22 ndb-7.3.8)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
進入mysql出錯處理:
mysqld_safe --skip-grant-tables &
mysql -uroot -p
>use mysql;
>update mysql.user set password=PASSWORD(‘123456‘) where User=‘root‘ ;
>flush privileges ;
or
//在mysql 設定檔中加入以下一句話 ,重新啟動輸入 mysql 進入命令列修改密碼
[[email protected] files]# vi /etc/my.cnf
[mysqld]
skip-grant-tables
[[email protected] files]# mysql
出錯:
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
>SET PASSWORD = PASSWORD(‘123456‘);
CentOS 6.4 64位 搭建MySQL-Cluster 7.3.8 叢集