下载到/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: 0

mysql> 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 shutdown

121108 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 directory

Installation 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 安装_mysql NDB的安装配置使用示例相关推荐

  1. centos mysql安装_mysql yum源安装

    部署服务器环境的时候经常要安装mysql,以下是常见的安装方式 源码安装 rpm包安装 yum源安装 这篇主要介绍yum源安装. yum源下载 进入 https://dev.mysql.com/dow ...

  2. linux mysql odbc驱动安装_MySQL ODBC 驱动安装

    阅读目录 一.在线安装 1.yum在线安装驱动 2.配置驱动 3.测试连接 二.编译安装 1.MySQL创建测试用户和测试库 2.安装驱动 3.配置驱动 4.测试 一.在线安装 1.yum在线安装驱动 ...

  3. mysql binary安装_mysql的二进制安装方式

    mysql总共有三种安装方式,源代码安装,二进制安装和源安装.这次写的是二进制安装,对其他两种方式不予讨论. 关闭selinux和防火墙 上课的时候,老师说过这是重中之重,一定要先关闭selinux和 ...

  4. 2.mysql数据库如何安装_MySQL数据库如何安装

    MySQL数据库如何安装 时间:2019-06-17 13:50:14  来源:  作者: 伙伴们,这两年软件测试异常火爆,90%以上的软件都需要操作数据,比如游戏.社交.新闻.商城.财务等,这些软件 ...

  5. mysql主从安装_MySQL主从详细安装步骤

    网站: 程序在:web服务器192.168.1.100上面 数据库在:MySQL服务器192.168.1.123上面 实现目的:增加一台MySQL备份服务器(192.168.1.124),作为MySQ ...

  6. mysql压缩包删除_mysql解压缩方式安装和彻底删除的方法图文详解

    一.安装mysql (1)将下载下来的mysql压缩文件解压缩到需要安装mysql的目录中 (2)打开解压后的文件夹,复制default.ini文件并重命名为my.ini,此文件的相关配置为: (3) ...

  7. mysql galera 下载_MySQL galera 的安装使用

    现在已经有整合版本,Mariadb galera cluster 和 XtraDB galera cluster. 我要介绍的是通过自己的编译,安装MySQL galera. 准备工作: 需要下载的内 ...

  8. mysql8 安装_mysql 8.x 安装向导

    封面人物 琦玉 前言 解决如下问题: 1.MySQL 8.X 系列的安装流程 2.将MySQL安装到指定目录下 3.解决 mysql 8登录密码用caching_sha2_password验证的问题, ...

  9. mysql多实例配置安装_MySQL多实例安装配置方案

    一.基本概念 MySQL多实例就是,在一台机器上开启多个不同的服务端口(如:3306,3307,3308...),运行多个MySQL服务进程,这些服务进程通过不同的socket监听不同的端口提供服务. ...

  10. mysql++pc客户端_Mysql超详细安装配置+客户端连接

    下载 选择直接下载 解压 我将Mysql解压到:E:\devSofts\mysql-8.0.21-winx64\mysql-8.0.21-winx64地址,后面的内容和这相关,可以根据你的实际情况稍作 ...

最新文章

  1. ng-cordova和cordova区别
  2. python if条件判断_python if not in 多条件判断代码
  3. kylin KV+cube方案分析
  4. Java往事之《返回整数的长度》
  5. SAP物料主数据创建时间的线性增长
  6. node.js ajax success,前端如何通过ajax和node.js交互?
  7. codeforces166E - Tetrahedron DP
  8. 大数据学习笔记09:MapReduce概述
  9. 5分钟制作Unity过场动画 | Timeline
  10. Jupyter Notebook代码提示及补齐功能
  11. python选择哪个版本-Python学习,要选哪个版本?
  12. 更改计算机启动读盘,BIOS设置硬盘启动|BIOS启动里怎么更改启动盘
  13. python求最值_Python应用:python求极值点(波峰波谷)
  14. Scala(第五节)actor并发编程、文件操作和网络请求、隐式转换和隐式参数、Akka并发编程、Akka模拟简易Spark通信
  15. python实现嗅探
  16. 使用wget报错-颁发的证书已经过期。
  17. 相似度衡量: 苏剑林博客-1
  18. RK3399 ARM开发板添加中文输入法
  19. buildroot快速入门
  20. 《乔布斯传》圈点(1)

热门文章

  1. clustalw序列比对_序列比较中ClustalW和BLAST的区别
  2. 教你利用clustalw和blat解决接头问题问题
  3. ios13 微信提示音插件_iOS13免越狱修改微信提示音方法!亲测有用!
  4. Python3.X 爬虫实战(并发爬取)
  5. HTML中的botton type=reset标签失效(不起作用)的可能原因。
  6. 专家有料 | 李中文:美团软件成分安全分析(SCA)能力的建设与演进
  7. CCAI 2017 | 澳大利亚新南威尔士大学教授 Toby Walsh 将带来精彩演讲
  8. 高通8953烧录之后报ERROR: UFDT apply overlay failed
  9. 高通8953启动流程
  10. Excise_Oop1