Mysql Cluster7.4.12分布式集群搭建
2016-09-19 16:32
337 查看
集群规划:
Mysql Cluster版本:
MySQL Cluster NDB 7.4.12 (5.6.31-ndb-7.4.12),
下载地址: http://dev.mysql.com/downloads/cluster/
集群部署:
1、环境清理及安装:
如果已经存在mysql相关的安装或者依赖包,则先清理mysql的相关安装和依赖
检查mysql是否存在mysql相关依赖包:
2、集群安装:
管理节点:
192.168.6.203
数据节点 和 mysql server:
192.168.6.204
192.168.6.205
配置文件:
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
ndb-connectstring="192.168.6.203:1186"
[mysql_cluster]
# # Options for MySQL Cluster processes:
ndb-connectstring="192.168.6.203:1186" # location of management server[/code]
3、启动集群:
准备工作:集群每台机器 关闭防火墙;设置selinux的SELINUX=disabled;
先启动管理节点:
192.168.6.203上启动管理节点:
再启动数据节点:
192.168.6.20[4,5]上启动数据节点:
最后192.168.6.20[4,5]启动mysqld服务:
通过管理节点,查看节点连接状态:
节点 | IP ADDRESS |
Management Server (ndb_mgmd) | 192.168.6.203 |
data nodes (ndbd) | 192.168.6.204 192.168.6.205 |
SQL node (mysqld) | 192.168.6.204 192.168.6.205 |
MySQL Cluster NDB 7.4.12 (5.6.31-ndb-7.4.12),
下载地址: http://dev.mysql.com/downloads/cluster/
集群部署:
1、环境清理及安装:
如果已经存在mysql相关的安装或者依赖包,则先清理mysql的相关安装和依赖
检查mysql是否存在mysql相关依赖包:
yum -y remove mysql
rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.x86_64
......
2、集群安装:
管理节点:
192.168.6.203
rpm -ivh MySQL-Cluster-server-gpl-7.4.12-1.el6.x86_64.rpm
数据节点 和 mysql server:
192.168.6.204
192.168.6.205
rpm -ivh MySQL-Cluster-server-gpl-7.4.12-1.el6.x86_64.rpm rpm -ivh MySQL-Cluster-client-gpl-7.4.12-1.el6.x86_64.rpm
配置文件:
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
ndb-connectstring="192.168.6.203:1186"
[mysql_cluster]
# # Options for MySQL Cluster processes:
ndb-connectstring="192.168.6.203:1186" # location of management server[/code]
3、启动集群:
准备工作:集群每台机器 关闭防火墙;设置selinux的SELINUX=disabled;
先启动管理节点:
192.168.6.203上启动管理节点:
ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial
再启动数据节点:
192.168.6.20[4,5]上启动数据节点:
ndbd
最后192.168.6.20[4,5]启动mysqld服务:
mysqld_safe --user=mysql &
通过管理节点,查看节点连接状态:
看到上面的状况,则说明集群启动成功。 进入mysqld,查看mysql是否已经支持分布式存储引擎ndbclustershell> mysql -uroot -p mysql> set password=password('xxxxxx') # 第一次登陆需要修改root 用户的登录密码 mysql> show engines\g; +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | ndbcluster | YES | Clustered, fault-tolerant tables | YES | NO | NO | | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | | MyISAM | YES | MyISAM storage engine | NO | NO | NO | | BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO | | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO | | CSV | YES | CSV storage engine | NO | NO | NO | | ARCHIVE | YES | Archive storage engine | NO | NO | NO | | FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL | | InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES | | ndbinfo | YES | MySQL Cluster system information storage engine | NO | NO | NO | | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ 11 rows in set (0.00 sec)
4、测试数据同步:
在192.168.6.204上创建一张t2表:mysql> use test; Database changed mysql> create table t2(id int, name varchar(20)) engine=ndbcluster; Query OK, 0 rows affected (0.10 sec) mysql> desc t2; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | name | varchar(20) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.00 sec)
在192.168.6.205上向表t2插入一条数据:mysql> desc t2; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | name | varchar(20) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) mysql> insert into t2 values(1,'lisan'); Query OK, 1 row affected (0.00 sec) mysql> select * from t2; +------+-------+ | id | name | +------+-------+ | 1 | lisan | +------+-------+ 1 row in set (0.00 sec)
在204上查看t2表:mysql> select * from t2; +------+-------+ | id | name | +------+-------+ | 1 | lisan | +------+-------+ 1 row in set (0.00 sec)
看到上面结果,则说明分布式mysql数据同步成功。
安装过程中遇到的问题:
1、Unable to connect with connect string: nodeid=0,localhost:1186 Retrying every 5 seconds. Attempts left: 2 1, failed.
可能原因:软件包安装错误(多装或者是少装都会出错);config.ini或者my.cnf配置文件有误;
2、Unable to connect with connect string: nodeid=0,192.168.1.102:1186 Retrying every 5 seconds. Attempts left: 12 11 10 9 8 7 6 5 4 3 2 1, failed.
可能原因:防火墙开启,阻止集群数据通信;selinux开启,可以通过setenforce 0 关闭;
MySQL Cluster 的局限性:
其官方的说明,若应用中的SQL操作为主键数据库访问,包含一些JOIN操作而非对整个表执行常规扫 描和 JOIN 而返回数万行数据,则适合Cluster,否则不合适,从这一条限制来看,表明大多数业务 场景并不合适 MySQL Cluster,业内有资深人士也凭评价:NDB不适合大多数业务场景,而且有安全 问题。
本文出自 “alfer” 博客,请务必保留此出处http://alfer.blog.51cto.com/9133887/1842087
相关文章推荐
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建
- Mysql Cluster7.4.12分布式集群搭建