`
zhaoshengbo
  • 浏览: 25253 次
  • 性别: 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台机器搭建集群环境

    在搭建MySQL Cluster时,通常包括以下几种节点类型: 1. **管理节点(ndb_mgmd)**:负责集群的管理和协调,包括节点的加入、离开、监控等。在本例中,管理节点位于192.168.2.50,配置文件`config.ini`中指定了节点...

    mysql集群搭建

    - 提到的是 MySQL Cluster 7.2.5 版本,这是一个较早的版本,适用于 Ubuntu 操作系统。 2. **环境设置**: - 集群包含三种类型的节点:数据节点(Data Nodes)、SQL 节点和管理节点(Management Node)。 - 数据...

    MySQL集群安装配置

    本文档记录了如何在四台Ubuntu 14.04.4 LTS服务器上搭建MySQL集群的过程。 **服务器详情:** 1. **mgmd (管理节点):** - IP: 192.168.1.21 - 操作系统: Ubuntu 14.04.4 LTS x64 - 内核版本: 3.13.0-32-generic ...

    Fate部署实战——从零开始实现Fate cluster部署.pdf

    在搭建FATE cluster的虚拟环境时,我们需要准备以下硬件: 1. 至少12核CPU 2. 24G内存 3. 1T硬盘(最好SSD) 4. 一个不低于10MB能上互联网的网络 通过以上步骤,我们可以从零开始实现FATE cluster的部署。

    Percona-XtraDB-Cluster-5.7.17-29.20

    Percona XtraDB Cluster是一款基于MySQL的数据库集群解决方案,它能够保证数据库的高可用性、防止服务中断和数据丢失,同时也支持对不断增长环境的线性扩展。该集群解决方案特别适用于需要高可靠性和无缝扩展能力的...

    MySql 高可用Percona Xtradb Cluste 5.5 (包含binlog server)实战安装部署指南中文版v2

    总结,Percona XtraDB Cluster提供了一种高效、可靠的MySQL高可用解决方案,通过实践安装部署指南,我们可以搭建一个具有高容错性和高性能的数据库集群。在日常运维中,还需要密切关注集群的健康状况,及时进行调整...

    运维进阶教程 系统运维高级教程 Linux系统运维之MySQL DBA 共38页.pdf

    - **部署步骤**:详细介绍如何搭建MySQL集群,包括节点配置、网络设置等。 - **维护管理**:集群的日常管理和故障处理方法。 #### 四、MySQL 性能监控 - **监控工具**:介绍常用的监控工具和方法,如MySQL自带工具...

    Percona-XtraDBCluster-5.6

    Percona XtraDB Cluster (PXC) 是一个专为 MySQL 用户设计的高度可用性和可扩展性解决方案。它通过提供同步复制、多主复制以及并行事件应用等功能来增强 MySQL 的性能和可靠性。PXC 旨在确保数据的一致性和完整性,...

    unbuntu 10.04 LTS上配置简单双机热备方案

    通过以上步骤,我们成功在 Ubuntu 10.04 LTS 系统上搭建了一个基于 Tomcat 6.0 和 MySQL 5.1 的简单双机热备方案。此方案不仅确保了数据的高可用性和一致性,还提供了会话保持功能,使得在 IP 失效转移时能够实现...

    MariaDB集群部署手册

    为了提高数据处理能力和系统可靠性,许多企业选择搭建数据库集群。MariaDB作为一款开源的关系型数据库管理系统,凭借其高性能、可扩展性和稳定性,在企业级应用中越来越受欢迎。本篇文章将详细介绍如何构建一个由...

    MariaDB Galera集群之MariaDB测试.pdf

    在测试环境中,可以直接通过虚拟IP地址连接到任意一个节点,例如使用命令`mysql -h 192.168.1.13 -uhaproxy_adm -pmypassword -e "show databases"`,这将展示可用的数据库列表,如information_schema、mysql、...

Global site tag (gtag.js) - Google Analytics