`
zhaoshengbo
  • 浏览: 25059 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

ubunut mysql cluster 搭建

阅读更多

转自:http://www.catharinegeek.com/set-up-mysql-cluster-on-ubuntu-14041/

Overview

Recently, I setup mysql cluster on 4 computers with Ubuntu 14.04.1.

Assume that these 4 computers have names from A to D, ips from 192.168.1.101 to 192.168.1.104. 

The basic structure is as below:

  • Computer A is management node.
  • Computer B and C are data nodes.
  • Computer D is sql node.

Important:

Most the command used below should be perform using root. If you come across errors when running these commands, make a try using root instead.

 

Download Mysql Cluster

First of all, download mysql cluster 7.3.7 (64 bits) from here, choose the 'linux generic' category.

 

Install Management Node

Install ndb_mgmd and ndb_mgm

After download finish, you will get the file 'mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz'. Perform following steps to install ndb_mgmd and ndb_mgm:

  1. move to the folder of download file, and extract the ndb_mgm and ndb_mgmd binaries from the archive into /usr/local/bin:   
    tar -zxvf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
    cd mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64
    cp bin/ndb_mgm* /usr/local/bin
    
  2. make ndb_mgmd and ndb_mgm executable:
    cd /usr/local/bin
    chmod +x ndb_mgm*
    

Configuring the management node

Create a directory for config file:

mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
vim config.ini

The config.ini should be looked like this:

[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.0.101          # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster  # Directory for MGM node log files

[ndbd]
# Options for data node "A":
                                # (one [ndbd] section per data node)
hostname=192.168.0.102          # Hostname or IP address
datadir=/usr/local/mysql/data   # Directory for this data node's data files

[ndbd]
# Options for data node "B":
hostname=192.168.0.103          # Hostname or IP address
datadir=/usr/local/mysql/data   # Directory for this data node's data files

[mysqld]
# SQL node options:
hostname=192.168.0.104          # Hostname or IP address
                                # (additional mysqld connections can be
                                # specified for this node for various
                                # purposes such as running ndb_restore)

 

Install Data Node

Install ndbd and ndbmtd

  1. move to the folder of download file, and extract the ndbd and ndbmtd from the archive into /usr/local/bin:   
    tar -zxvf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
    cd mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64
    cp bin/ndbd /usr/local/bin
    
  2. make ndbd and ndbmtdexecutable
    cd /usr/local/bin
    chmod +x ndb*
    

Note:

the data directory on each machine hosting a data node is /usr/local/mysql/data. This piece of information is essential when configuring the management node. You should make this directory if it does not exist.

Configuring data node

my.cnf file is needed for each data node, put it in /etc .

vim /etc/my.cnf

my.cnf should be looked like this:

[mysqld]
# Options for mysqld process:
ndbcluster                      # run NDB storage engine

[mysql_cluster]
# Options for MySQL Cluster processes:
#原文中节点为192.168.0.102,此处需要配置管理节点
ndb-connectstring=192.168.0.101  # location of management server

 

Install Sql Node

Install mysql server

  1. Check  /etc/passwd and /etc/group files to see whether there is already a mysql group and mysql user on the system. If not, create a new mysql user group, and then add a mysql user to this group:
    groupadd mysql
    useradd -g mysql mysql
  2. Unpack the archive, and create a symbolic link named mysql to the mysql directory.
    tar -C /usr/local mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
    ln -s /usr/local/mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64 /usr/local/mysql
    
  3. Change location to the mysql directory and run the supplied script for creating the system databases:
    cd /usr/local/mysql
    scripts/mysql_install_db --user=mysql
    
  4. Set the necessary permissions for the MySQL server and data directories:
    chown -R root .
    chown -R mysql data
    chgrp -R mysql .
    
  5. Copy the MySQL startup script to the appropriate directory, make it executable, and set it to start when the operating system is booted up:
    cp support-files/mysql.server /etc/init.d
    chmod +x /etc/init.d/mysql.server
    update-rc.d mysql.server defaults
    

Configuring sql node

This configue file for sql node is the same as data node, just follow the configuration of data node.

 

Start Mysql Cluster

Once configuration has been set properly, the start up process should be easy. Note that the management node should be started first, followed by data nodes, and finally sql nodes.

 

For management node:

/usr/local/bin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini

For each data node:

/usr/local/bin/ndbd

For each sql node:

/etc/init.d/mysql.server start

 

That's all. Once you finish all the process, you can use the ndb_mgm management client to see whether your cluster is running correctly. If everything goes well, you should see something like below:

shell> /usr/local/bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> SHOW
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=2    @192.168.0.30  (Version: 5.5.41-ndb-7.2.19, Nodegroup: 0, *)
id=3    @192.168.0.40  (Version: 5.5.41-ndb-7.2.19, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.0.10  (Version: 5.5.41-ndb-7.2.19)

[mysqld(API)]   1 node(s)
id=4    @192.168.0.20  (Version: 5.5.41-ndb-7.2.19)
分享到:
评论

相关推荐

    Mysql 高可用 InnoDB Cluster 多节点搭建过程

    Mysql 高可用 InnoDB Cluster 多节点搭建过程 Mysql 高可用 InnoDB Cluster 多节点搭建过程是指使用 Mysql 的 InnoDB Cluster 功能来搭建一个高可用性的集群环境。在这个过程中,我们将使用四台服务器,node01、...

    MySQL Cluster 3台机器搭建集群环境

    ndb是一种存储引擎,通常在mysql cluster中使用,MySQL Cluster 是一个基于NDB Cluster 存储引擎的完整的分布式数据库系统。 和Oracle Real Cluster Application 不太一样的是,MySQL Cluster 是一个Share Nothing ...

    ubuntu mysql5.6 客户端安装包及说明

    在Ubuntu系统上,MySQL是广泛使用的开源关系型数据库管理系统,其客户端工具对于数据库的管理和维护至关重要。本资源针对的是Ubuntu 14.04及更高版本,并提供了MySQL客户端的5.6版本安装包,这对于那些需要与较低...

    ubuntu FTP 服务器搭建

    ubuntu FTP 服务器搭建 主用户+匿名用户 ubuntu FTP 服务器搭建 主用户+匿名用户 ubuntu FTP 服务器搭建 主用户+匿名用户

    ubuntu mysql my.cnf 服务器最佳配置

    ubuntu mysql my.cnf 服务器最佳配置(16G,32G 内存)

    slurm在ubuntu上的搭建

    slurm在ubuntu上的搭建

    ubuntu环境搭建jira

    在ubuntu环境下搭建jira管理系统,不使用jira自带的数据库,使用mysql数据库

    ubuntu mysql中中文乱码问题.docx

    Ubuntu MySQL 中文乱码问题解决方案 在 Ubuntu 系统中,MySQL 数据库中文乱码问题是一个常见的问题。乱码问题可能是由于 MySQL 数据库的字符编码设置不正确所致。解决这个问题需要对 MySQL 数据库的字符编码进行...

    Ubuntu 安装MySQL(国内镜像源).pdf

    Ubuntu 通过国内的镜像源安装 MySQL ,可以安装 MySQL 5.7 和 MySQL8.0 ,以及更新到最新版本。

    Ubuntu下Yocto搭建QT编译环境源文件

    Ubuntu下Yocto搭建QT编译环境源文件

    ubuntu mysql

    在Ubuntu系统上搭建MySQL数据库是许多开发者和系统管理员的日常任务。MySQL是一个广泛使用的开源关系型数据库管理系统(RDBMS),适用于各种规模的应用程序,从小型项目到大型企业级系统。本文将详细介绍如何在...

    unbuntu详细安装mysqlcluster

    在Ubuntu系统中安装MySQL Cluster是一项涉及多个步骤的技术任务,适合初学者熟悉分布式数据库系统的运作。MySQL Cluster是一种高可用性、高性能的数据库解决方案,它支持数据分片,可以在多个节点之间分散数据,从而...

    ubuntu下mysql安装教程

    在Ubuntu系统上安装MySQL是一个相对简单的过程,但对初学者来说可能会遇到一些挑战。这篇教程将引导你逐步完成MySQL的安装,并解决可能出现的问题。MySQL是一个流行的关系型数据库管理系统(RDBMS),广泛应用于Web...

    Ubuntu-mysql5.7.25离线完整安装包(含三个依赖包)

    在Ubuntu系统中,离线安装MySQL 5.7.25是一个相对复杂的过程,因为通常我们依赖于apt-get或其他在线包管理器来获取和安装软件。然而,在没有网络连接或者网络环境不稳定的情况下,我们需要手动下载所有必要的文件并...

    ubuntu完全分布式搭建CDH集群(Cloudera Manager)

    基于Ubuntu 14.04.3,搭建完全分布式CDH集群参考资料。 在公司测试环境中使用3台服务器完成搭建,

    NXP S32DS ubuntu18.04 环境搭建

    S32K 使用的 IDE S32DS Ubuntu18.04 环境搭建

    mysql-ubuntu14.04系统版

    mysql-ubuntu14.04系统版

    ubuntu mysql apache2 tomcat 安装配置

    ubuntu mysql apache2 tomcat 安装配置

    ubuntu能用的mysql5.7.38,并附带安装手册

    在Ubuntu操作系统上安装MySQL 5.7.38是一个相对简单的过程,适合那些希望在Linux环境中运行可靠数据库服务的用户。下面将详细介绍在Ubuntu上安装MySQL 5.7.38的步骤以及一些关键知识点。 首先,确保你的Ubuntu系统...

Global site tag (gtag.js) - Google Analytics