mysql cluster7.4.8安装和性能测试
测试环境
5台虚拟机centos6.5,4G内存
192.168.17.177 Management node (mgmd) 192.168.17.178 SQL node (mysqld) 192.168.17.179 SQL node (mysqld) 192.168.17.180 Data node(ndbd) 192.168.17.176 Data node(ndbd)
1台管理节点,2台sql节点,2台存储节点
Management node为管理节点,负责把数据保存到Data node节点;SQL node为mysql服务器节点,php、java可以mysql驱动连接该节点,访问mysql cluster数据,与普通mysql服务器不同,该节点只保存表结构不保存具体数据,表数据保存在Data node。
这里为了方便关闭了防火墙
service iptables stop chkconfig iptables off
删除centos6.5自带mysql
rpm -qa | grep mysql rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
在http://dev.mysql.com/downloads/cluster/ 下载安装文件MySQL-Cluster-gpl-7.4.8-1.el6.x86_64.rpm-bundle.tar,上传到5台服务器各自解压,包含文件
MySQL-Cluster-client-gpl-7.4.8-1.el6.x86_64.rpm MySQL-Cluster-devel-gpl-7.4.8-1.el6.x86_64.rpm MySQL-Cluster-embedded-gpl-7.4.8-1.el6.x86_64.rpm MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64.rpm MySQL-Cluster-shared-compat-gpl-7.4.8-1.el6.x86_64.rpm MySQL-Cluster-shared-gpl-7.4.8-1.el6.x86_64.rpm MySQL-Cluster-test-gpl-7.4.8-1.el6.x86_64.rpm
这里只用到MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64.rpm和MySQL-Cluster-client-gpl-7.4.8-1.el6.x86_64.rpm
1、安装
1)Data node安装
192.168.17.176、192.168.17.180两台服务器都需要执行下步安装
rpm -ivh MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64.rpm
该节点主要使用ndbd或ndbmtd(在/usr/sbin目录)命令运行MySQL Cluster data node服务。
2)SQL nodes安装
192.168.17.178、192.168.17.179两台服务器都需要执行下步安装
rpm -ivh MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64.rpm
安装带NDB引擎的mysqld服务(在/usr/sbin目录),mysql的启动命令mysql.server和mysqld_safe(在/usr/share/mysql或/usr/bin目录)
这两台服务器需要提供mysql服务,需要安装
rpm -ivh MySQL-Cluster-client-gpl-7.4.8-1.el6.x86_64.rpm
3)Management nodes
rpm -ivh MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64.rpm
安装ndb_mgmd服务管理(/usr/sbin目录)和ndb_mgm(NDB管理客户端)
2、配置
1)data nodes 和 SQL nodes配置
vim /etc/my.cnf
输入内容:
[mysqld] ndbcluster #NBD引擎 [mysql_cluster] ndb-connectstring=192.168.17.177 #管理节点
2)management node配置
命令行输入:
mkdir /var/lib/mysql-cluster cd /var/lib/mysql-cluster vim config.ini
config.ini内容为:
[ndbd default] # Options affecting ndbd processes on all data nodes: NoOfReplicas=2 # Number of replicas DataMemory=80M # How much memory to allocate for data storage IndexMemory=18M # How much memory to allocate for index storage # For DataMemory and IndexMemory, we have used the # default values. Since the "world" database takes up # only about 500KB, this should be more than enough for # this example Cluster setup. [tcp default] # TCP/IP options: portnumber=2202 # This the default; however, you can use any # port that is free for all the hosts in the cluster # Note: It is recommended that you do not specify the port # number at all and simply allow the default value to be used # instead [ndb_mgmd] # Management process options: hostname=192.168.17.177 # Hostname or IP address of MGM node datadir=/var/lib/mysql-cluster # Directory for MGM node log files [ndbd] # Options for data node # (one [ndbd] section per data node) hostname=192.168.17.176 # Hostname or IP address datadir=/usr/local/mysql/data # Directory for this data node's data files [ndbd] # Options for data node hostname=192.168.17.180 # Hostname or IP address datadir=/usr/local/mysql/data # Directory for this data node's data files [mysqld] # SQL node options: hostname=192.168.17.178 # Hostname or IP address # (additional mysqld connections can be [mysqld] # SQL node options: hostname=192.168.17.179 # specified for this node for various # purposes such as running ndb_restore)
3、启动
mysql cluster各节点启动顺序为:Management nodes -> data node -> SQL node;
1)启动管理节点Management nodes(192.168.17.177)
ndb_mgmd -f /var/lib/mysql-cluster/config.ini #如果第一次启动或配置文件修改过需要的尾后加上--initial
2)启动存储节点data node(192.168.17.180,192.168.17.176)
ndbd #如果第一次启动尾后加上--initial
3)启动SQL node (192.168.17.178, 192.168.17.179),让php,java等通过这边两台服务器访问mysql cluster
mysqld_safe &
php,java等需要连接这两台服务器访问数据库,执行下边命令修改默认密码和数据库初始化。
more /root/.mysql_secret #获取默认密码 /usr/bin/mysql_secure_installation #修改root密码和其它默认配置
4、关闭
mysql cluster关闭顺序与启动相反SQL node -> data node ->Management nodes
1)SQL node节点(192.168.17.178, 192.168.17.179),在各自服务器上执行命令
service mysql stop
2)由于关闭Management nodes时会自动关闭data node,只需在Management nodes(192.168.17.177)执行命令
ndb_mgm -e shutdown
5、测试比较
在另一台相同配置的虚拟机192.168.1.181上安装独立版本的mysql 5.6.28,下边是测试比较结果。截图上边为mysql cluster测试结果,下图为mysql结果,测试工具为jmeter2.13
jmeter JDBC连接配置
线程数从1000开始,线程组配置如下
线程数为1000时插入测试
线程数为5000时插入测试
线程数为10000时插入测试
线程数为15000时插入测试
线程数为1000时查询测试
线程数为5000时查询测试
线程数为10000时查询测试
线程数为15000时查询测试
参考文档
http://dev.mysql.com/doc/refman/5.6/en/mysql-cluster-install-linux-rpm.html