mysql-cluster集群配置

Posted 狄成

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql-cluster集群配置相关的知识,希望对你有一定的参考价值。

环境:

centos7:192.168.1.16,192.168.1.170

mysql-cluster-community-7.6.8-1.el7.x86_64.rpm-bundle.tar

安装:

卸载系统已有的数据库yum -y remove MariaDB*(centos7默认安装的是mariadb)

tar xvf mysql-cluster-community-7.6.8-1.el7.x86_64.rpm-bundle.tar

yum -y install perl perl-Class-MethodMaker perl-DBI libaio numactl 

rpm -ivh mysql-cluster-community-common-7.6.8-1.el7.x86_64.rpm

rpm -ivh mysql-cluster-community-libs-7.6.8-1.el7.x86_64.rpm

rpm -ivh mysql-cluster-community-client-7.6.8-1.el7.x86_64.rpm

rpm -ivh mysql-cluster-community-server-7.6.8-1.el7.x86_64.rpm

rpm -ivh mysql-cluster-community-management-server-7.6.8-1.el7.x86_64.rpm

rpm -ivh mysql-cluster-community-devel-7.6.8-1.el7.x86_64.rpm

rpm -ivh mysql-cluster-community-data-node-7.6.8-1.el7.x86_64.rpm

 

mkdir /var/lib/mysql/data

mkdir /var/lib/mysql-cluster

mkdir /var/run/mysqld

chmod -R 1777 /var/lib/mysql

chmod -R 1777 /var/run/mysqld

chmod -R 1777 /var/lib/mysql-cluster

cd /var/lib/mysql-cluster,在该目录下创建config.ini文件

16上文件

[[email protected] ~]# cat /var/lib/mysql-cluster/config.ini
[computer]
Id=mgr-server-02
HostName=192.168.1.170
[mgm default]
datadir=/var/lib/mysql-cluster
[mgm]
HostName=192.168.1.16
NodeId=60
[mgm]
HostName=192.168.1.170
NodeId=61
[ndbd default]
NoOfReplicas = 2
DataMemory = 50M
IndexMemory = 50M
MaxNoOfTables = 1024
MaxNoOfAttributes = 5000000
MaxNoOfOrderedIndexes = 10000
[ndbd]
HostName=192.168.1.170
DataDir=/var/lib/mysql
NodeId=1
[ndbd]
HostName=192.168.1.16
DataDir=/var/lib/mysql
NodeId=2
[mysqld]
HostName=192.168.1.170
NodeId=81
[mysqld]
HostName=192.168.1.16
NodeId=82

170上文件

[[email protected] ~]# cat /var/lib/mysql-cluster/config.ini
[computer]
Id=mgr-server-02
HostName=192.168.1.170
[mgm default]
datadir=/var/lib/mysql-cluster
[mgm]
HostName=192.168.1.16
NodeId=60
[mgm]
HostName=192.168.1.170
NodeId=61
[ndbd default]
NoOfReplicas = 2
DataMemory = 50M
IndexMemory = 50M
MaxNoOfTables = 1024
MaxNoOfAttributes = 5000000
MaxNoOfOrderedIndexes = 10000
[ndbd]
HostName=192.168.1.170
DataDir=/var/lib/mysql
NodeId=1
[ndbd]
HostName=192.168.1.16
DataDir=/var/lib/mysql
NodeId=2
[mysqld]
HostName=192.168.1.170
NodeId=81
[mysqld]
HostName=192.168.1.16
NodeId=82

编辑/etc/my.cnf文件

[[email protected] ~]# cat /etc/my.cnf|grep -v "#"
[client]
socket=/var/lib/mysql/mysql.sock
[mysqld]
max_connections=100
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
ndbcluster
ndb-connectstring=192.168.1.16,192.168.1.170
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/lib/mysql/mysqld.pid
[mysql_cluster]
ndb-connectstring=192.168.1.16,192.168.1.170

关闭防火墙,关闭selinux,初始化密码在/var/log/mysqld.log文件中,首次登陆必须改密码,开启远程登录权限(也可设置只允许节点ip访问)

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

ndbd --initial

systemctl start mysqld.service














































































以上是关于mysql-cluster集群配置的主要内容,如果未能解决你的问题,请参考以下文章

简单使用Mysql-Cluster-7.5搭建数据库集群

Data Cluster真机环境下MySQL数据库集群搭建

使用MySQL-Cluster搭建MySQL数据库集群

Mysql数据库 | 基于Docker搭建Mysql-8.0以上版本主从实例实战

手把手教你用Mysql-Cluster-7.5搭建数据库集群

mysql-cluster集群原理介绍和搭建步骤(四个data/sql节点) (转)