Set up Mysql Cluster on Ubuntu 14.04.1
来源:互联网 发布:pre软件是什么意思啊 编辑:程序博客网 时间:2024/05/20 20:48
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:
- 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
- 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 replicasDataMemory=80M # How much memory to allocate for data storageIndexMemory=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 nodedatadir=/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 addressdatadir=/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 addressdatadir=/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
- 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
- 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:ndb-connectstring=192.168.0.102 # location of management server
Install Sql Node
Install mysql server
- Check
/etc/passwd
and/etc/group
files to see whether there is already amysql
group andmysql
user on the system. If not, create a newmysql
user group, and then add amysql
user to this group:groupadd mysql
useradd -g mysql mysql - Unpack the archive, and create a symbolic link named
mysql
to themysql
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
- 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
- Set the necessary permissions for the MySQL server and data directories:
chown -R root .
chown -R mysql data
chgrp -R mysql .
- 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:1186Cluster 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)
- Set up Mysql Cluster on Ubuntu 14.04.1
- How To Set Up Database Replication In MySQL On Ubuntu
- How To Set Up an OpenVPN Server on Ubuntu 14.04
- How To Set Up an OpenVPN Server on Ubuntu 14.04
- Set up start development environment on ubuntu-12.04.1
- ES Cluster Set Up
- Set up wxWidgets 3.0.1 on Ubuntu 14.04 with OpenGL support
- HOWTO set up a MySQL Cluster for two servers
- How To Set Up a Private Docker Registry on Ubuntu 14.04
- How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 14.04 LTS
- How To Set Up Apache Virtual Hosts on Ubuntu 14.04 LTS
- How To Set Up A Load-Balanced MySQL Cluster --Part 1
- Set up of Qt/Embedded 4.5 on ubuntu 9.04
- Set up of Qt/Embedded 4.5 on ubuntu 9.04----2
- Set up professional rails3 develpment on ubuntu (part one)
- Set up professional rails3 develpment on ubuntu (part two)
- How to set up IceScrum on Ubuntu 12.04
- How to Set Up vsftpd on Ubuntu 12.04
- Object_c基础——getter、setter方法和@property、self关键字
- ngx_http_fastcgi_module的那些事:
- Android 开发之 ---- 底层驱动开发(二)
- [leetcode][list] Copy List with Random Pointer
- ubuntu 12.04安装chrome
- Set up Mysql Cluster on Ubuntu 14.04.1
- Jenkins Master/Slave架构
- 第六章 Realm及相关对象——《跟我学Shiro》
- VC STATIC控件响应鼠标点击事件
- TypeError: only length-1 arrays can be converted to Python scalars
- oracle添加数据时主键自动增长
- SAP用户权限相关操作
- 推荐一个不错的敏捷工具
- Puppet2d及教程