欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

(MySQL 集群) MySQL Cluster在Linux上的安装(RedHat 5.6)

程序员文章站 2022-06-05 23:14:01
...

(MySQL 集群) MySQL Cluster在Linux上的安装(RedHat 5.6)

一、环境介绍

IP_Address

Port_No

Node_name

Service_name

Desc

192.168.56.101

3306

SQL node(API Node)

mysqld

SQL节点(API节点)

192.168.56.101

2202

Data Node

ndbd

数据节点

192.168.56.102

3306

SQL node(API Node)

mysqld

SQL节点(API节点)

192.168.56.102

2202

Data Node

ndbd

数据节点

192.168.56.103

1186

Mgmt Node

ndb_mgmd

管理节点

二、准备工作

1)关闭防火墙(在三台服务器上操作)

[root@localhost ~]# service iptables stop

Flushing firewall rules: [ OK ]

Setting chains to policy ACCEPT: filter [ OK ]

Unloading iptables modules: [ OK ]

[root@localhost local]# chkconfig iptables off

2)默认不启动防火墙(在三台服务器上操作)

[root@localhost ~]# chkconfig iptables off

3)添加mysql用户和组(在三台服务器上操作)

[root@localhost ~]# groupadd mysql

[root@localhost ~]# useradd -g mysql mysql

4)上传安装文件(只需要在192.168.56.101上操作即可)

可以使用FileZilla软件来上传安装文件,比如上传到Linux 上的/tmp目录。我使用的安装文件是:mysql-cluster-gpl-7.1.10-linux-i686-glibc23.tar.gz

三、安装Mysql Cluster

1.安装数据节点和SQL节点(只需要在192.168.56.101上操作即可)

1)安装tar包

[root@localhost ~]# cd /tmp

[root@localhost tmp]# tar -C /usr/local -zxvf mysql-cluster-gpl-7.1.10-linux-i686-glibc23.tar.gz

[root@localhost tmp]# ln -s /usr/local/mysql-cluster-gpl-7.1.10-linux-i686-glibc23/ /usr/local/mysql

[root@localhost tmp]# cd /usr/local/mysql

[root@localhost mysql]# scripts/mysql_install_db --usr=mysql

2)授权

[root@localhost mysql]# cd ..

[root@localhost local]# chown -R mysql mysql

[root@localhost local]# chgrp -R mysql mysql

3)创建编辑my.cnf,键入下面内容

[mysqld]

ndbcluster

ndb-connectstring=192.168.56.103

[mysql_cluster]

ndb-connectstring=192.168.56.103

2.将/usr/local/mysql文件夹和/etc/my.cnf拷贝到192.168.56.102上

[root@localhost local]# scp -r ./mysql/* root@192.168.56.102:/usr/local/mysql

The authenticity of host '192.168.56.102 (192.168.56.102)' can't be established.

RSA key fingerprint is 1f:26:d9:20:d1:77:47:bf:3c:7b:64:6d:68:0f:bb:76.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.56.102' (RSA) to the list of known hosts.

root@192.168.56.102's password:

...........

[root@localhost local]# scp -r /etc/my.cnf root@192.168.56.102:/etc/

3.将/usr/local/mysql文件夹Copy到192.168.56.103(使用scp命令)

[root@localhost local]# scp -r ./mysql/* root@192.168.56.103:/usr/local/mysql

The authenticity of host '192.168.56.103 (192.168.56.103)' can't be established.

RSA key fingerprint is 1f:26:d9:20:d1:77:47:bf:3c:7b:64:6d:68:0f:bb:76.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.56.103' (RSA) to the list of known hosts.

root@192.168.56.103's password:

4.在102 & 103授权

[root@localhost ~]# cd /usr/local

[root@localhost local]# chown -R mysql mysql

[root@localhost local]# chgrp -R mysql mysql

5.配置管理节点(在192.168.56.103上操作)

[root@localhost mysql]# mkdir /var/lib/mysql-cluster

[root@localhost mysql]# chown -R mysql /var/lib/mysql-cluster

[root@localhost mysql]# chgrp -R mysql /var/lib/mysql-cluster

[root@localhost mysql]# cd /usr/local/mysql/

[root@localhost mysql]# vim config.ini

键入下面内容到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]

portnumber=2202 # This the default; however, you can use any

[ndb_mgmd]

hostname=192.168.56.103 # Hostname or IP address of MGM node

datadir=/var/lib/mysql-cluster # Directory for MGM node log files

[ndbd]

hostname=192.168.56.101 # Hostname or IP address

datadir=/usr/local/mysql/data # Directory for this data node's data files

[ndbd]

hostname=192.168.56.102 # Hostname or IP address

datadir=/usr/local/mysql/data # Directory for this data node's data files

[mysqld]

hostname=192.168.56.101 # Hostname or IP address

[mysqld]

hostname=192.168.56.102 # Hostname or IP address

四、启动Mysql Cluster

1.启动管理节点后台服务(在192.168.56.103上操作)

[root@localhost mysql]# /usr/local/mysql/bin/ndb_mgmd -f /usr/local/mysql/config.ini

2.启动管理节点管理服务(在192.168.56.103上操作)

[root@localhost mysql]# /usr/local/mysql/bin/ndb_mgm

3.查看Mysql Cluster配置信息(在192.168.56.103上操作)