mysql-cluter搭建

 

环境:

centos6.8

mysql-cluster版本:

mysql-cluster-gpl-7.4.11-linux-glibc2.5-x86_64.tar.gz

节点分配:

192.168.41.203 SQL节点

192.168.41.204 NDB节点1    SQL节点

192.168.41.205 NDB节点2 SQL节点

192.168.41.206 Manager节点

 

mysqld服务只需要安装在SQL节点,NDB和Manager只需可执行的二进制脚本和配置文件

 

安装

192.168.41.203 SQL节点

192.168.41.204 SQL节点

192.168.41.205 SQL节点

shell> groupadd mysql
shell> useradd -g mysql -s /bin/false mysql
shell> tar -xzvf mysql-cluster-gpl-7.4.12-linux2.6.tar.gz
shell> mv mysql-cluster-gpl-7.4.12-linux2.6-i686 /usr/local/mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> cp support-files/mysql.server /etc/rc.d/init.d/mysqld
shell> chmod +x /etc/rc.d/init.d/mysqld
shell> chkconfig --add mysqld

192.168.41.204 NDB节点1

192.168.41.205 NDB节点2

shell> cp mysql/bin/ndbd /usr/local/bin/ndbd
shell> cp mysql/bin/ndbmtd /usr/local/bin/ndbmtd
shell> cd /usr/local/bin
shell> chmod +x ndb*

192.168.41.206 Manager节点

shell> cp mysql/bin/ndb_mgm* /usr/local/bin
shell> cd /usr/local/bin
shell> chmod +x ndb_mgm*

 

集群各节点配置文件

192.168.41.203 SQL节点

192.168.41.204 NDB节点1 SQL节点

192.168.41.205 NDB节点2 SQL节点

shell> vi /etc/my.cnf
[mysqld]
# Options for mysqld process:
ndbcluster                      # run NDB storage engine

[mysql_cluster]
# Options for MySQL Cluster processes:
ndb-connectstring=192.168.0.10  # location of management server

192.168.41.206 Manager节点

shell> mkdir /var/lib/mysql-cluster
shell> cd /var/lib/mysql-cluster
shell> vi 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
                  # 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.10           # 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.30           # 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.40           # 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.20           # Hostname or IP address
                                # (additional mysqld connections can be
                                # specified for this node for various
                                # purposes such as running ndb_restore)

集群各个节点启动

192.168.41.206 Manager节点

shell> ndb_mgmd -f /var/lib/mysql-cluster/config.ini

192.168.41.204 NDB节点1

192.168.41.205 NDB节点2

shell> ndbd

192.168.41.203 SQL节点

192.168.41.204 SQL节点

192.168.41.205 SQL节点

shell> service mysqld start

 

查看集群状态

192.168.41.206 Manager节点

shell> 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.6.31-ndb-7.4.12, Nodegroup: 0, *)
id=3    @192.168.0.40  (Version: 5.6.31-ndb-7.4.12, Nodegroup: 0)

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

[mysqld(API)]   1 node(s)
id=4    @192.168.0.20  (Version: 5.6.31-ndb-7.4.12)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值