一、环境介绍
| IP_Address | Port_No | Node_name | Service_name | Desc |
| 192.168.56.101 | 3306 | SQL node(API Node) | mysqld | SQL节点(API节点) |
| 192.168.56.101 | 2202 | Data Node | ndbd | 数据节点 |
| 192.168.56.102 | 3306 | SQL node(API Node) | mysqld | SQL节点(API节点) |
| 192.168.56.102 | 2202 | Data Node | ndbd | 数据节点 |
| 192.168.56.103 | 1186 | Mgmt Node | ndb_mgmd | 管理节点 |
二、准备工作1)关闭防火墙(在三台服务器上操作)
| [root@localhost ~]# service iptables stopFlushing firewall rules: [ OK ]Setting chains to policy ACCEPT: filter [ OK ]Unloading iptables modules: [ OK ][root@localhost local]# chkconfig iptables off |
2)默认不启动防火墙(在三台服务器上操作)
| [root@localhost ~]# chkconfig iptables off |
3)添加mysql用户和组(在三台服务器上操作)
| [root@localhost ~]# groupadd mysql[root@localhost ~]# useradd -g mysql mysql |
4)上传安装文件(只需要在192.168.56.101上操作即可)可以使用FileZilla软件来上传安装文件,比如上传到Linux 上的/tmp目录。我使用的安装文件是:mysql-cluster-gpl-7.1.10-linux-i686-glibc23.tar.gz 三、安装Mysql Cluster1.安装数据节点和SQL节点(只需要在192.168.56.101上操作即可)1)安装tar包
| [root@localhost ~]# cd /tmp[root@localhost tmp]# tar -C /usr/local -zxvf mysql-cluster-gpl-7.1.10-linux-i686-glibc23.tar.gz[root@localhost tmp]# ln -s /usr/local/mysql-cluster-gpl-7.1.10-linux-i686-glibc23/ /usr/local/mysql[root@localhost tmp]# cd /usr/local/mysql[root@localhost mysql]# scripts/mysql_install_db --usr=mysql |
2)授权
| [root@localhost mysql]# cd ..[root@localhost local]# chown -R mysql mysql[root@localhost local]# chgrp -R mysql mysql |
3)创建编辑my.cnf,键入下面内容
| [mysqld]ndbclusterndb-connectstring=192.168.56.103[mysql_cluster]ndb-connectstring=192.168.56.103 |
2.将/usr/local/mysql文件夹和/etc/my.cnf拷贝到192.168.56.102上
| [root@localhost local]# scp -r ./mysql/* root@192.168.56.102:/usr/local/mysqlThe authenticity of host "192.168.56.102 (192.168.56.102)" can"t be established.RSA key fingerprint is 1f:26:d9:20:d1:77:47:bf:3c:7b:64:6d:68:0f:bb:76.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added "192.168.56.102" (RSA) to the list of known hosts.root@192.168.56.102"s password:...........[root@localhost local]# scp -r /etc/my.cnf root@192.168.56.102:/etc/ |
3.将/usr/local/mysql文件夹Copy到192.168.56.103(使用scp命令)
| [root@localhost local]# scp -r ./mysql/* root@192.168.56.103:/usr/local/mysqlThe authenticity of host "192.168.56.103 (192.168.56.103)" can"t be established.RSA key fingerprint is 1f:26:d9:20:d1:77:47:bf:3c:7b:64:6d:68:0f:bb:76.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added "192.168.56.103" (RSA) to the list of known hosts.root@192.168.56.103"s password: |
4.在102 & 103授权
| [root@localhost ~]# cd /usr/local[root@localhost local]# chown -R mysql mysql[root@localhost local]# chgrp -R mysql mysql |
5.配置管理节点(在192.168.56.103上操作)
| [root@localhost mysql]# mkdir /var/lib/mysql-cluster[root@localhost mysql]# chown -R mysql /var/lib/mysql-cluster[root@localhost mysql]# chgrp -R mysql /var/lib/mysql-cluster[root@localhost mysql]# cd /usr/local/mysql/[root@localhost mysql]# vim config.ini |
键入下面内容到config.ini中
| [ndbd default]NoOfReplicas=2 # Number of replicasDataMemory=80M # How much memory to allocate for data storageIndexMemory=18M # How much memory to allocate for index storage[tcp default]portnumber=2202 # This the default; however, you can use any[ndb_mgmd]hostname=192.168.56.103 # Hostname or IP address of MGM nodedatadir=/var/lib/mysql-cluster # Directory for MGM node log files[ndbd]hostname=192.168.56.101 # Hostname or IP addressdatadir=/usr/local/mysql/data # Directory for this data node"s data files[ndbd]hostname=192.168.56.102 # Hostname or IP addressdatadir=/usr/local/mysql/data # Directory for this data node"s data files[mysqld]hostname=192.168.56.101 # Hostname or IP address[mysqld]hostname=192.168.56.102 # Hostname or IP address |
四、启动Mysql Cluster1.启动管理节点后台服务(在192.168.56.103上操作)
| [root@localhost mysql]# /usr/local/mysql/bin/ndb_mgmd -f /usr/local/mysql/config.ini |
2.启动管理节点管理服务(在192.168.56.103上操作)
| [root@localhost mysql]# /usr/local/mysql/bin/ndb_mgm |
3.查看Mysql Cluster配置信息(在192.168.56.103上操作)
| ndb_mgm> showConnected to Management Server at: localhost:1186Cluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 (not connected, accepting connect from 192.168.56.101)id=3 (not connected, accepting connect from 192.168.56.102)[ndb_mgmd(MGM)] 1 node(s)id=1 @192.168.56.103 (mysql-5.1.51 ndb-7.1.10)[mysqld(API)] 2 node(s)id=4 (not connected, accepting connect from 192.168.56.101)id=5 (not connected, accepting connect from 192.168.56.102) |
4.启动数据节点(101 & 102上操作)
| [root@localhost local]# /usr/local/mysql/bin/ndbd --initial |
5.启动SQL节点(101 & 102上操作)
| [root@localhost local]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf & |
6.再次查看Mysql Cluster配置信息(在192.168.56.103上操作)
| ndb_mgm> showCluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 @192.168.56.101 (mysql-5.1.51 ndb-7.1.10, Nodegroup: 0, Master)id=3 @192.168.56.102 (mysql-5.1.51 ndb-7.1.10, Nodegroup: 0)[ndb_mgmd(MGM)] 1 node(s)id=1 @192.168.56.103 (mysql-5.1.51 ndb-7.1.10)[mysqld(API)] 2 node(s)id=4 @192.168.56.101 (mysql-5.1.51 ndb-7.1.10)id=5 @192.168.56.102 (mysql-5.1.51 ndb-7.1.10) |
五、Mysql Cluster测试1.在101(102)上创建数据库、表并插入数据
| [root@localhost ~]# mysql…mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || ndb_2_fs || ndbinfo || test |+--------------------+5 rows in set (0.00 sec)mysql> create database test1;Query OK, 1 row affected (0.06 sec)mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || ndb_2_fs || ndbinfo || test || test1 |+--------------------+6 rows in set (0.00 sec)mysql> use test1;Database changedmysql> create table tb_test(id int) engine=ndb;Query OK, 0 rows affected (0.36 sec)mysql> insert into tb_test select 1;Query OK, 1 row affected (0.06 sec)Records: 1 Duplicates: 0 Warnings: 0mysql> select * from tb_test;+------+| id |+------+| 1 |+------+1 row in set (0.00 sec) |
2.在102(101)上查看已有的数据库、表和表数据
| [root@localhost ~]# mysql…mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || ndb_3_fs || ndbinfo || test || test1 |+--------------------+6 rows in set (0.01 sec)mysql> use test1;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> select * from tb_test;+------+| id |+------+| 1 |+------+1 row in set (0.00 sec) |
通过测试,至此Mysql Cluster配置成功。更多关于MySQL Cluster的详细信息,或者下载地址请点这里Oracle中查询表字段基本信息、主键、外键Oracle学习笔记:用户管理相关资讯 redhat MySQL教程
- 30分钟带你快速入门MySQL教程 (02月03日)
- MySQL教程:关于I/O内存方面的一些 (01月24日)
- RedHat Linux 用户登录认证失败 (06/24/2014 19:56:55)
| - MySQL教程:关于checkpoint机制 (01月24日)
- 为什么像 RedHat 那样的开源旗手很 (12/23/2014 07:50:53)
- MySQL::Sandbox (04/14/2013 08:03:38)
|
本文评论 查看全部评论 (0)