1.到mysql网站下载mysql cluster版本 http://www.mysql.com/downloads/cluster/

下载到/home/weijianzhongwj/software下

2.安装mysql cluster

cd /home/weijianzhongwj/software

tar xvf mysql-cluster-gpl-7.2.8-linux2.6-i686.tar.gz

ln -s mysql-cluster-gpl-7.2.8-linux2.6-i686 mysqlc

在$HOME/.bashrc增加 export PATH=$PATH:/home/weijianzhongwj/software/mysqlc/bin 一行,添加mysql的bin目录到path路径中

3.对于一个mysql集群,我们需要启动一个mysql server(mysqld),两个data nodes(NDB),还有一个管理结点(ndb_mgmd),我们测试是在单机中,对于在多台机器上,在data nodes配置的hostname修改为对应机器的ip则可。

我们先来添加爱mysql集群需要的配置文件

先进入mysqlc的目录,在这个目录下创建配置文件目录和数据文件目录

cd /home/weijianzhongwj/software/mysqlc
mkdir my_cluster my_cluster/ndb_data my_cluster/mysqld_data my_cluster/conf

然后在my_cluster/conf中创建下面两个文件:

my.cnf

[mysqld]
ndbcluster
datadir=/home/weijianzhongwj/software/mysqlc/my_cluster/mysqld_data
basedir=/home/weijianzhongwj/software/mysqlc
port=5000

config.ini

[ndb_mgmd]
hostname=localhost
datadir=/home/weijianzhongwj/software/mysqlc/my_cluster/ndb_data
NodeId=1
[ndbd default]
noofreplicas=2
datadir=/home/weijianzhongwj/software/mysqlc/my_cluster/ndb_data
[ndbd]
hostname=localhost
NodeId=3
[ndbd]
hostname=localhost
NodeId=4
[mysqld]
NodeId=50

然后在mysqlc的目录下,创建名称为mysql数据库,这是所有mysql需要创建的数据库

cd /home/weijianzhongwj/software/mysqlc/
scripts/mysql_install_db --no-defaults --datadir=/home/weijianzhongwj/software/mysqlc//my_cluster/mysqld_data/

4.启动管理结点,数据结点,mysql server

weijianzhongwj@ubuntu:~/software/mysqlc$ bin/ndb_mgmd -f my_cluster/conf/config.ini --initial --configdir=/home/weijianzhongwj/software/mysqlc/my_cluster/conf/
MySQL Cluster Management Server mysql-5.5.27 ndb-7.2.8
weijianzhongwj@ubuntu:~/software/mysqlc$ ps aufx|grep ndb
1000      2352  0.0  0.0   2256   316 ?        S    21:18   0:00  \_ /usr/lib/chromium-browser/chromium-browser-sandbox /usr/lib/chromium-browser/chromium-browser --type=zygote
1000      3286  0.0  0.0   5832   840 pts/3    S+   21:52   0:00      \_ grep --color=auto ndb
1000      3275  0.4  0.0  35964  2504 ?        Ssl  21:52   0:00 bin/ndb_mgmd -f my_cluster/conf/config.ini --initial --configdir=/home/weijianzhongwj/software/mysqlc/my_cluster/conf/
weijianzhongwj@ubuntu:~/software/mysqlc$ bin/ndbd -c localhost:1186
2012-11-08 21:53:12 [ndbd] INFO     -- Angel connected to 'localhost:1186'
2012-11-08 21:53:12 [ndbd] INFO     -- Angel allocated nodeid: 3
weijianzhongwj@ubuntu:~/software/mysqlc$ bin/ndbd -c localhost:1186
2012-11-08 21:53:14 [ndbd] INFO     -- Angel connected to 'localhost:1186'
2012-11-08 21:53:14 [ndbd] INFO     -- Angel allocated nodeid: 4
weijianzhongwj@ubuntu:~/software/mysqlc$ ps aufx|grep ndbd
1000      3395  0.0  0.0   5832   836 pts/3    S+   21:53   0:00      \_ grep --color=auto ndbd
1000      3316  0.0  0.0  19544  2284 ?        Ss   21:53   0:00 bin/ndbd -c localhost:1186
1000      3317  2.9  5.8 514332 479652 ?       Sl   21:53   0:00  \_ bin/ndbd -c localhost:1186
1000      3355  0.0  0.0  19544  2284 ?        Ss   21:53   0:00 bin/ndbd -c localhost:1186
1000      3356  3.3  5.8 514200 479260 ?       Sl   21:53   0:00  \_ bin/ndbd -c localhost:1186
weijianzhongwj@ubuntu:~/software/mysqlc$ bin/ndb_mgm -e show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=3   @127.0.0.1  (mysql-5.5.27 ndb-7.2.8, Nodegroup: 0, Master)
id=4   @127.0.0.1  (mysql-5.5.27 ndb-7.2.8, Nodegroup: 0)[ndb_mgmd(MGM)]  1 node(s)
id=1   @127.0.0.1  (mysql-5.5.27 ndb-7.2.8)[mysqld(API)]  1 node(s)
id=50 (not connected, accepting connect from any host)weijianzhongwj@ubuntu:~/software/mysqlc$ bin/mysqld --defaults-file=/home/weijianzhongwj/software/mysqlc/my_cluster/conf/my.cnf &
[1] 3449
weijianzhongwj@ubuntu:~/software/mysqlc$ 121108 21:54:50 [Note] Plugin 'FEDERATED' is disabled.
121108 21:54:50 InnoDB: The InnoDB memory heap is disabled
121108 21:54:50 InnoDB: Mutexes and rw_locks use InnoDB's own implementation
121108 21:54:50 InnoDB: Compressed tables use zlib 1.2.3
121108 21:54:50 InnoDB: Using Linux native AIO
121108 21:54:50 InnoDB: Initializing buffer pool, size = 128.0M
121108 21:54:50 InnoDB: Completed initialization of buffer pool
121108 21:54:50 InnoDB: highest supported file format is Barracuda.
121108 21:54:51  InnoDB: Waiting for the background threads to start
121108 21:54:52 InnoDB: 1.1.8 started; log sequence number 1595675
121108 21:54:52 [Note] NDB: NodeID is 50, management server 'localhost:1186'
121108 21:54:53 [Note] NDB[0]: NodeID: 50, all storage nodes connected
121108 21:54:53 [Warning] NDB: server id set to zero - changes logged to bin log with server id zero will be logged with another server id by slave mysqlds
121108 21:54:53 [Note] Starting Cluster Binlog Thread
121108 21:54:53 [Note] Server hostname (bind-address): '0.0.0.0'; port: 5000
121108 21:54:53 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
121108 21:54:53 [Note] Server socket created on IP: '0.0.0.0'.
121108 21:54:53 [Note] Event Scheduler: Loaded 0 events
121108 21:54:53 [Note] bin/mysqld: ready for connections.
Version: '5.5.27-ndb-7.2.8-cluster-gpl'  socket: '/tmp/mysql.sock'  port: 5000  MySQL Cluster Community Server (GPL)
121108 21:54:54 [Note] NDB Binlog: DISCOVER TABLE Event: REPL$mysql/ndb_schema
121108 21:54:54 [Note] NDB Binlog: logging ./mysql/ndb_schema (UPDATED,USE_WRITE)
121108 21:54:54 [Note] NDB Binlog: DISCOVER TABLE Event: REPL$mysql/ndb_apply_status
121108 21:54:54 [Note] NDB Binlog: logging ./mysql/ndb_apply_status (UPDATED,USE_WRITE)
121108 21:54:54 [Note] NDB: Cleaning stray tables from database 'information_schema'
121108 21:54:54 [Note] NDB: Cleaning stray tables from database 'ndbinfo'
121108 21:54:54 [Note] NDB: Cleaning stray tables from database 'performance_schema'
121108 21:54:54 [Note] NDB: Cleaning stray tables from database 'test'
2012-11-08 21:54:54 [NdbApi] INFO     -- Flushing incomplete GCI:s < 1320/5
2012-11-08 21:54:54 [NdbApi] INFO     -- Flushing incomplete GCI:s < 1320/5
121108 21:54:54 [Note] NDB Binlog: starting log at epoch 1320/5
121108 21:54:54 [Note] NDB Binlog: ndb tables writable

5.测试

weijianzhongwj@ubuntu:~/software/mysqlc$ bin/mysql -h 127.0.0.1 -P 5000 -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.27-ndb-7.2.8-cluster-gpl MySQL Cluster Community Server (GPL)Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> create database clusterdb;use clusterdb;
Query OK, 1 row affected (0.06 sec)Database changed
mysql> create table simples (id int not null primary key) engine=ndb;
121108 21:55:56 [Note] NDB Binlog: CREATE TABLE Event: REPL$clusterdb/simples
Query OK, 0 rows affected (2.34 sec)mysql> insert into simples values (1),(2),(3),(4);
Query OK, 4 rows affected (0.01 sec)
Records: 4  Duplicates: 0  Warnings: 0mysql> select * from simples;
+----+
| id |
+----+
|  3 |
|  1 |
|  2 |
|  4 |
+----+
4 rows in set (0.02 sec)mysql>

我们查看下my_cluster下的文件目录

weijianzhongwj@ubuntu:~/software/mysqlc/my_cluster$ ll mysqld_data/
总用量 28704
drwxrwxr-x 7 weijianzhongwj weijianzhongwj     4096 11月  8 21:55 ./
drwxrwxr-x 5 weijianzhongwj weijianzhongwj     4096 11月  8 15:29 ../
drwx------ 2 weijianzhongwj weijianzhongwj     4096 11月  8 21:55 clusterdb/
-rw-rw---- 1 weijianzhongwj weijianzhongwj 18874368 11月  8 17:22 ibdata1
-rw-rw---- 1 weijianzhongwj weijianzhongwj  5242880 11月  8 21:54 ib_logfile0
-rw-rw---- 1 weijianzhongwj weijianzhongwj  5242880 11月  8 15:52 ib_logfile1
drwx------ 2 weijianzhongwj weijianzhongwj     4096 11月  8 15:53 mysql/
drwx------ 2 weijianzhongwj weijianzhongwj     4096 11月  8 15:38 ndbinfo/
drwx------ 2 weijianzhongwj weijianzhongwj     4096 11月  8 15:38 performance_schema/
drwx------ 2 weijianzhongwj weijianzhongwj     4096 11月  8 15:33 test/
-rw-rw---- 1 weijianzhongwj weijianzhongwj        5 11月  8 21:54 ubuntu.pid
weijianzhongwj@ubuntu:~/software/mysqlc/my_cluster$ ll ndb_data/
总用量 72
drwxrwxr-x 4 weijianzhongwj weijianzhongwj  4096 11月  8 15:49 ./
drwxrwxr-x 5 weijianzhongwj weijianzhongwj  4096 11月  8 15:29 ../
-rw-rw-r-- 1 weijianzhongwj weijianzhongwj 14947 11月  8 21:54 ndb_1_cluster.log
-rw-r--r-- 1 weijianzhongwj weijianzhongwj    76 11月  8 21:52 ndb_1_out.log
-rw-r--r-- 1 weijianzhongwj weijianzhongwj     4 11月  8 21:52 ndb_1.pid
drwxr-x--- 9 weijianzhongwj weijianzhongwj  4096 11月  8 15:49 ndb_3_fs/
-rw-r--r-- 1 weijianzhongwj weijianzhongwj  9961 11月  8 21:54 ndb_3_out.log
-rw-r--r-- 1 weijianzhongwj weijianzhongwj     4 11月  8 21:53 ndb_3.pid
drwxr-x--- 9 weijianzhongwj weijianzhongwj  4096 11月  8 15:49 ndb_4_fs/
-rw-r--r-- 1 weijianzhongwj weijianzhongwj  9783 11月  8 21:54 ndb_4_out.log
-rw-r--r-- 1 weijianzhongwj weijianzhongwj     4 11月  8 21:53 ndb_4.pid

6关闭mysql server和data nodes

weijianzhongwj@ubuntu:~/software/mysqlc$ mysqladmin -u root -h 127.0.0.1 -P 5000 shutdown
121108 22:22:33 [Note] bin/mysqld: Normal shutdown121108 22:22:33 [Note] Event Scheduler: Purging the queue. 0 events
121108 22:22:33 [Note] Stopping Cluster Utility thread
weijianzhongwj@ubuntu:~/software/mysqlc$ 121108 22:22:33 [Note] Stopping Cluster Index Stats thread
121108 22:22:33 [Note] Stopping Cluster Binlog
121108 22:22:33 [Note] Stopping Cluster Index Statistics thread
121108 22:22:34  InnoDB: Starting shutdown...
121108 22:22:35  InnoDB: Shutdown completed; log sequence number 1595675
121108 22:22:35 [Note] bin/mysqld: Shutdown complete
weijianzhongwj@ubuntu:~/software/mysqlc$ bin/ndb_mgm -e shutdown
Connected to Management Server at: localhost:1186
3 NDB Cluster node(s) have shutdown.
Disconnecting to allow management server to shutdown.

执行出下面这个错误时,需要安装下面这个包

weijianzhongwj@ubuntu:~/software/mysqlc$ sh ./scripts/mysql_install_db --no-defaults --datadir=/home/weijianzhongwj/software/mysqlc/my_cluster/mysqld_data/
Installing MySQL system tables...
./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directoryInstallation of system tables failed!  Examine the logs in
/home/weijianzhongwj/software/mysqlc/my_cluster/mysqld_data/ for more information.sudo apt-get install libaio1

大家可以参考 http://dev.mysql.com/downloads/cluster/

mysql NDB的安装配置使用示例相关推荐

  1. 2023 年 MySQL 8.0 安装配置 最简易(保姆级)

    Windows MySQL 8.0 安装配置 最简易_Northern Crescent的博客-CSDN博客 Linux MySQL 8.0 安装 及 配置_Northern Crescent的博客- ...

  2. mysql 5.5 安装配置方法图文教程

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 回忆一下mysql 5.5 安装配置方法,整理mysql 5.5 安装配置教程笔记,分享给大家. M ...

  3. Apache+Mysql+php+ZenTaoPMS安装配置文档

    基于Apache+Mysql+php+ZenTaoPMS安装配置 一.Apache安装配置 tar zxvf httpd-2.2.23.tar.gz cd httpd-2.2.23 mkdir –p ...

  4. CentOS下MySQL 8.0安装配置

    1.源码编译安装MySQL8.0 版本信息 #cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) 安装依赖包 yum -y ins ...

  5. win7mysql5.7.25安装教程_win7下MySql 5.7安装配置方法图文教程

    上学的时候经常使用MySql,当时也没想其他,主要是MySql对电脑的要求比较低,负载比较小.工作后一直在使用Oracle,现在因为项目的需要,重新安装MySql,发现变化有点多. 本经验适用于安装M ...

  6. pureftpd 配置 mysql_pureftpd+mysql验证的安装配置文档

    pureftpd+mysql验证的安装配置文档 一.mysql编译安装: 1,准备工作 a,下载安装程序mysql-5.1.41.tar.gz b,为mysql建立用户和组 groupadd -g 2 ...

  7. mysql cluster java_Java学习笔记(十):MySQL集群安装配置

    需要安装软件(所有的节点都必须安装,不需要安装mysql mysql-server,mysql-cluster有自带的): mysql-cluster-gpl-7.3.7-linux-glibc2.5 ...

  8. mysql cluster安装配置_mysql cluster (mysql 集群)安装配置方案

    一.准备 1.准备服务器 计划建立有5个节点的MySQL CLuster体系,需要用到5台服务器,但是我们做实验时没有这么多机器,可以只用2台,我就是一台本机,一台虚拟机搭建了有5个节点的MySQL ...

  9. 【MySQL】MySQL NDB Cluster安装

    MySQL集群是一个无共享的(share-nothing).分布式节点架构的存储方案,目的是提供容错性和高性能. MySQL NDB Cluster架构如图: MySQL NDB Cluster架构按 ...

最新文章

  1. 视频直播常见问题与解决办法汇总【系列二—直播截图】
  2. vmware workstation 安装esx 启动vt功能
  3. 3.4. Wireless Networking
  4. Origin如何绘制泡泡图?
  5. wxWidgets:wxScopedArray< T >类模板的用法
  6. C++读图片——Mac下对于bmp文件读写读取过大的解决方案
  7. tensorflow学习笔记:tf.control_dependencies,tf.GraphKeys.UPDATE_OPS,tf.get_collection
  8. Mysql group by,order by,dinstict优化
  9. php负载均衡慕课网,Nginx实现负载均衡
  10. Android 选择文件(调用系统文件管理器)
  11. 模2除法(CRC冗余码计算)和二进制/十进制除法
  12. MySQL 百分比排序
  13. ERROR: Check hive‘s usability failed, please check the status of your cluster问题解决
  14. EXECUTE IMMEDIATE用法小结
  15. ionic 应用在iOS上打开相机拍照闪退、百度地图/高德地图定位失败(解决方案)
  16. input输入框限制(座机,手机号码)
  17. git添加/删除远程仓库
  18. WPS公式和字体对不齐
  19. 小程序的三种生命周期
  20. 如何使用VS+C#创建,优雅自动化的安装(不使用命令行),调试,更新Windows服务

热门文章

  1. Python实现秒杀某宝商品抢购
  2. 不动点理论在计算机科学中的应用,不动点定理
  3. 大疆 DJI Mavic 3 Classic 航拍无人机 评测
  4. Linux 23年来的发展历史
  5. 【opencvc++编译问题汇总】‘CV_BGR2RGB‘、 “CV_AA“、CV_WINDOW_NORMAL、CV_CAP 报错
  6. 每日一题(day3)
  7. 实现天猫查看物流功能
  8. Spring相关文章汇总篇【Spring,SpringBoot,SpringCloud等】
  9. 存储型XSS原理讲解及实战实验
  10. 推荐13个优秀的网站检测工具