zoukankan      html  css  js  c++  java
  • MySQL Cluster 7.2 集群的部署

    MySQL Cluster 7.2发布之后,大家都说好,性能如何提高。今天 wait4friend 就搭建一个小集群感受一下。

    环境

    Mangement Node (mgmd) 192.168.229.140
    SQL Node A (mysqld) 192.168.229.141
    SQL Node B (mysqld) 192.168.229.142
    Data Node A (ndbd) 192.168.229.143
    Data Node B (ndbd) 192.168.229.144

    安装MySQL

    在真实环境中,并不需要在MGMD和NDBD上面完整安装MySQL,不过考虑到方便些,直接在每个节点都进行了完整的安装。具体的安装过程和普通MySQL没有什么区别,只是暂时不需要配置/etc/my.cnf , 后面专门进行配置。

    MGMD节点的安装,仅需要把两个文件拷贝到下面的地址

    # cp /usr/local/mysql/bin/ndb_mgm* /usr/local/bin
    # chmod +x /usr/local/bin/ndb_mgm*

    配置MySQL Cluster

    NDBD配置

    # vi /etc/my.cnf

    [mysql_cluster]
    # Options for ndbd process:
    ndb-connectstring=192.168.229.140          # location of management server

    MYSQLD配置,在现有的my.cnf上增加下面的参数,测试环境也编辑一个新的my.cnf

    # vi /etc/my.cnf

    [mysqld]
    # Options for mysqld process:
    ndbcluster                                           # run NDB storage engine
    ndb-connectstring=192.168.229.140        # location of management server

    MGMD配置

    # mkdir /var/lib/mysql-cluster
    # vi /var/lib/mysql-cluster/config.ini

    [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

    [ndb_mgmd]
    # Management process options:
    hostname=192.168.229.140         # Hostname or IP address of MGM node
    datadir=/var/lib/mysql-cluster      # Directory for MGM node log files

    [ndbd]
    # Options for data node "A":
    hostname=192.168.229.143        
    datadir=/usr/local/mysql/data    

    [ndbd]
    # Options for data node "B":
    hostname=192.168.229.144        
    datadir=/usr/local/mysql/data      

    [mysqld]
    # SQL node options:
    hostname=192.168.229.141

    [mysqld]
    # SQL node options:
    hostname=192.168.229.142

    启动MySQL Cluster

    启动集群是需要按照特定的顺序, 先MGMD,然后NDBD,最后MySQLD

    1. MGMD 节点 首次启动过程中需要 -f 参数指定配置文件

    # ndb_mgmd -f /var/lib/mysql-cluster/config.ini

    如果修改了配置文件之后,需要 --reload 参数

    # ndb_mgmd -f /var/lib/mysql-cluster/config.ini –reload

    如果要用非root用户启动,需要修改几个目录的权限

    # chown -R mysql /var/lib/mysql-cluster/
    # chgrp -R mysql /var/lib/mysql-cluster/
    # chown -R mysql /usr/local/mysql/mysql-cluster/
    # chgrp -R mysql /usr/local/mysql/mysql-cluster/

    2. NDBD 节点

    第一次或者数据文件发生变化的时候使用 --initial 参数

    $ ndbd –initial

    正常情况下不需要任何参数启动

    $ ndbd

    3. MYSQLD 节点 的启动和单节点实例启动完全相同

    $ /etc/init.d/mysql.server start

    关闭MySQL Cluster

    1. MGMD 节点

    $ ndb_mgm –e shutdown

    2. MYSQLD 节点

    $ /etc/init.d/mysql.server stop

    查看集群状态

    $ 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.229.143  (mysql-5.5.19 ndb-7.2.4, Nodegroup: 0, Master)
    id=3    @192.168.229.144  (mysql-5.5.19 ndb-7.2.4, Nodegroup: 0)

    [ndb_mgmd(MGM)]    1 node(s)
    id=1    @192.168.229.140  (mysql-5.5.19 ndb-7.2.4)

    [mysqld(API)]    2 node(s)
    id=4    @192.168.229.141  (mysql-5.5.19 ndb-7.2.4)
    id=5 (not connected, accepting connect from 192.168.229.142)

  • 相关阅读:
    jvm误区--动态对象年龄判定
    jmeter入门实例
    七牛云的文件上传和下载
    layer.prompt添加多个输入框
    zero copy图解
    java枚举的线程安全及序列化
    java单例模式
    ubuntu16.04 python3.5 opencv的安装与卸载(转载)
    独家git clone 加速方法
    apt get update无法正常使用解决方案(转载)
  • 原文地址:https://www.cnblogs.com/wait4friend/p/2410202.html
Copyright © 2011-2022 走看看