集群 mysql cluster
高可用 负载均衡
集群成员:
====管理节点(MGM) 进程名 ndb_mgmd
====数据节点(Data Nodes) 进程名 ndbd
====SQL节点(Sql Nodes) 进程名 mysqld
拓扑:
192.168.1.3 管理节点 mgm
192.168.1.4 192.168.1.5 SQL节点 sql1 sql2
192.168.1.6 192.168.1.7 数据节点 data1 data2
配置:
所有节点操作
1.创建mysql用户
[root@mgm ~]# useradd mysql
2.解压软件包
[root@mgm tmp]# tar xf mysql-cluster-gpl-7.4.12-linux-glibc2.5-x86_64.tar.gz
3.将软件包剪切并改名
[root@mgm tmp]# mv mysql-cluster-gpl-7.4.12-linux-glibc2.5-x86_64 /usr/local/mysql-cluster
4.修改权限
[root@mgm tmp]# chown mysql.mysql /usr/local/mysql-cluster -R
管理节点:
[root@mgm tmp]# mkdir /usr/local/mysql-cluster/cluster-conf
[root@mgm tmp]# vim /usr/local/mysql-cluster/cluster-conf/config.ini
[ndbd default]
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M
[ndb_mgmd]
id=1
hostname=192.168.1.3
datadir=/usr/local/mysql-cluster/data
[ndbd]
id=2
hostname=192.168.1.6
datadir=/usr/local/mysql-cluster/ndbdata
[ndbd]
id=3
hostname=192.168.1.7
datadir=/usr/local/mysql-cluster/ndbdata
[mysqld]
id=4
hostname=192.168.1.4
[mysqld]
id=5
hostname=192.168.1.5
sql节点配置:
# vim /etc/my.cnf
[mysqld]
ndbcluster
ndb-connectstring=192.168.1.3
[mysql_cluster]
ndb-connectstring=192.168.1.3
data节点配置:
# mkdir /usr/local/mysql-cluster/ndbdata
# vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql-cluster/ndbdata
ndbcluster
ndb-connectstring=192.168.1.3
[mysql_cluster]
ndb-connectstring=192.168.1.3
初始化sql节点:
# cd /usr/local/mysql-cluster
# ./scripts/mysql_install_db --user=mysql
启动manager节点:(启动前把mysqld服务关闭)
# cd /usr/local/mysql-cluster
# ./bin/ndb_mgmd -f cluster-conf/config.ini
启动数据节点:
# cd /usr/local/mysql-cluster
# ./bin/ndbd
启动sql节点:
# cd /usr/local/mysql-cluster
# ./bin/mysqld_safe --user=mysql &
管理节点:
# ./bin/ndb_mgm -e show \\检查集群的状态