ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

Build MySQL Cluster Environment

2019-07-21 15:38:37  阅读:164  来源: 互联网

标签:node cluster local Environment Cluster Build mysql data usr


原文链接:http://www.cnblogs.com/jeffreyf/p/build-mysql-cluster-environment.html

This post documents how build MySQL cluster environment with 4 machines. Their IP addresses and roles are listed below.

  • Host #1: 192.168.1.100, management node
  • Host #2: 192.168.1.101, SQL node
  • Host #3: 192.168.1.102, data node #1
  • Host #4: 192.168.1.103, data node #2 

 

Download MySQL Cluster on each host

wget http://dev.mysql.com/get/Downloads/MySQL-Cluster-7.3/mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
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/

 

Setup the cluster

On Management Node, run the following commands to copy ndb_mgm and ndb_mgmd to /usr/local/bin/.

cp bin/ndb_mgm /usr/local/bin/
cp bin/ndb_mgmd /usr/local/bin/

On Data Node, run the following commands to copy ndbd and ndbmtd to /usr/local/bin/.

cp bin/ndbd /usr/local/bin/
cp bin/ndbmtd /usr/local/bin/

On SQL Node

Check if the library libaio1 installed on the host, if not, execute the following command to install the library.

apt-get install libaio1

If the library can't be installed by running apt-get, you can download this package first, and then install it with dpkg -i like below.

wget http://archive.ubuntu.com/ubuntu/pool/main/liba/libaio/libaio1_0.3.109-4_amd64.deb
dpkg -i libaio1_0.3.109-4_amd64.deb

Run the following commands to install MySQL.

#
groupadd mysql
useradd -g mysql mysql
 
#
tar zxvf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
ln -s /usr/local/mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64 /usr/local/mysql

#
cd /usr/loca/mysql
scripts/mysql_install_db --user=mysql

#
chown -R root .
chown -R mysql data
chgrp -R mysql .
 
#
cp support-files/mysql.server /etc/init.d/
update-rc.d mysql.server defaults

 

Configure the Cluster

On the SQL and data nodes, type the following lines in /etc/my.cnf.

[mysqld]
ndbcluster

[mysql_cluster]
ndb-connectstring=1092.168.1.100

On the management node, type the following lines in /etc/mysql/config.ini.

[ndbd default]
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
                 

[tcp default]
# TCP/IP options:
portnumber=2202
                 

[ndb_mgmd]
# Management process options:
hostname=192.168.1.100
datadir=/var/lib/mysql-cluster  # Directory for MGM node log files


[ndbd]
# Options for data node #1:                                
hostname=192.168.1.102
datadir=/usr/local/mysql/data   # Directory for this data node's data files


[ndbd]
# Options for data node #2:
hostname=192.168.1.103
datadir=/usr/local/mysql/data   # Directory for this data node's data files


[mysqld]
# SQL node #1:
hostname=192.168.1.101

 

Start the cluster

Start the management node first.

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

Start the data nodes.

ndbd

Start the SQL node.

service mysql.server start

On the management node, run the following command to see if the cluster goes well.

ndb_mgm
ndb_mgm> show

On the SQL node, set password for root.

mysqladmin -u root password 'your password'

Finally, try to create a database to test.

 

转载于:https://www.cnblogs.com/jeffreyf/p/build-mysql-cluster-environment.html

标签:node,cluster,local,Environment,Cluster,Build,mysql,data,usr
来源: https://blog.csdn.net/weixin_30344995/article/details/96725900

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有