准备: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.tar MySQL-Cluster-test-gpl-7.3.8-1.el6.x86_64.rpm MySQL-Cluster-shared-compat-gpl-7.3.8-1.el6.x86_64.rpm MySQL-Cluster-client-gpl-7.3.8-1.el6.x86_64.rpm MySQL-Cluster-embedded-gpl-7.3.8-1.el6.x86_64.rpm MySQL-Cluster-server-gpl-7.3.8-1.el6.x86_64.rpm MySQL-Cluster-devel-gpl-7.3.8-1.el6.x86_64.rpm MySQL-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 MySQLMySQL-client-5.6.24-1.el6.x86_64MySQL-server-5.6.24-1.el6.x86_64MySQL-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> show Connected to Management Server at: 192.168.1.240:1186 Cluster 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‘);