mysql cluster

Posted smlile-you-me

tags:

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

参考:http://www.cnblogs.com/linkstar/p/6510713.html

 

 

如果没有特殊声明,则所有命令都在node1上执行

 

192.168.1.201    node1  1核/448M  管理节点
192.168.1.202    node2  1核/448M  数据节点和mysql节点在同一台机器上
192.168.1.203    node3  1核/448M     数据节点和mysql节点在同一台机器上

 

#架构图及说明

技术图片

 

 

 

 

前期准备
#配置主机名和IP对应关系(所有节点上操作该步)
[[email protected] ~]# vim /etc/hosts
192.168.1.201  node1
192.168.1.202  node2
192.168.1.203  node3


#在node1上生成秘钥并分发到各节点
[[email protected] ~]# ssh-keygen -t rsa
[[email protected] ~]# cat .ssh/id_rsa.pub >>.ssh/authorized_keys


[[email protected] ~]# ssh-copy-id [email protected]
[[email protected] ~]# ssh-copy-id [email protected]


#做跳板机
[[email protected] ~]# alias a=‘for a in {1..3};do‘
[[email protected] ~]# alias b=‘for b in {2..3};do‘
#测试跳板机
[[email protected] ~]# a ssh node$a ‘hostname‘;done
#注:如果出现解析的出来的IP和主机名不对应的问题,就看下.ssh/known_hosts中的对应关系,将错误的删除即可

 

#关闭各节点防火墙
[[email protected] ~]# a ssh node$a ‘systemctl stop firewalld‘;done
[[email protected] ~]# a ssh node$a ‘systemctl disable firewalld‘;done
[[email protected] ~]# a ssh node$a ‘iptables -F‘;done


#安装配置管理节点

下载地址1      

[[email protected] ~]# wget https://cdn.mysql.com//archives/mysql-cluster-gpl-7.5/mysql-cluster-gpl-7.5.11-linux-glibc2.12-x86_64.tar.gz
注:这里的包地址是wget时跟随的新地址,原地址为https://dev.mysql.com/*****

技术图片

 


[[email protected] ~]# tar -zxvf mysql-cluster-gpl-7.5.11-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[[email protected] ~]# cp /usr/local/mysql-cluster-gpl-7.5.11-linux-glibc2.12-x86_64/bin/ndb_mgm* /usr/local/bin/
[[email protected] ~]# mkdir /var/lib/mysql-cluster
[[email protected] ~]# mkdir /usr/local/mysql
[[email protected] ~]# vim /var/lib/mysql-cluster/config.ini
[ndbd default]
NoOfReplicas=2
DataMemory=512M
IndexMemory=18M
[ndb_mgmd]
HostName=192.168.1.201
DataDir=/var/lib/mysql-cluster
[ndbd]
HostName=192.168.1.202
DataDir=/var/lib/mysql-cluster
[ndbd]
HostName=192.168.1.203
DataDir=/var/lib/mysql-cluster
[mysqld]
[mysqld]


#使用配置文件初始化管理节点
[[email protected] ~]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini

#使用ndb_mgm进行管理
[[email protected] ~]# ndb_mgm
ndb_mgm> show (使用show命令查看管理情况,当数据节点配置完毕之后再用这个命令查看和管理)

 

 


#安装配置数据节点 和 mysql节点
#以下的所有操作需要在所有的集群节点都要进行相同的操作
[[email protected] ~]# scp mysql-cluster-gpl-7.5.11-linux-glibc2.12-x86_64.tar.gz [email protected]2:~
[[email protected] ~]# scp mysql-cluster-gpl-7.5.11-linux-glibc2.12-x86_64.tar.gz [email protected]3:~
[[email protected] ~]# b ssh node$b ‘groupadd mysql‘;done
[[email protected] ~]# b ssh node$b ‘useradd -g mysql -s /bin/false mysql‘;done
[[email protected] ~]# b ssh node$b ‘mkdir /var/lib/mysql-cluster‘;done
[[email protected] ~]# b ssh node$b ‘chown root:mysql /var/lib/mysql-cluster‘;done

[[email protected] ~]# b ssh node$b ‘tar zxvf ~/mysql-cluster-gpl-7.5.11-linux-glibc2.12-x86_64.tar.gz -C /usr/local/‘;done
[[email protected] ~]# b ssh node$b ‘cp -R /usr/local/mysql-cluster-gpl-7.5.11-linux-glibc2.12-x86_64/ /usr/local/mysql‘;done

 

[[email protected] ~]# b ssh node$b ‘/usr/local/mysql/bin/mysqld --initialize‘;done   密码样式1: e,djt*Jre9vC    密码样式2: ew3;bg#B0Il6
[[email protected] ~]# b ssh node$b ‘mv /etc/my.cnf{,.bak}‘;done

[[email protected] ~]# b ssh node$b ‘echo ‘[mysqld]‘>>/etc/my.cnf‘;done
[[email protected] ~]# b ssh node$b ‘echo ‘ndbcluster‘>>/etc/my.cnf‘;done
[[email protected] ~]# b ssh node$b ‘echo ‘ndb-connectstring=192.168.1.201‘>>/etc/my.cnf‘;done
[[email protected] ~]# b ssh node$b ‘echo ‘ ‘>>/etc/my.cnf‘;done
[[email protected] ~]# b ssh node$b ‘echo ‘[mysql_cluster]‘>>/etc/my.cnf‘;done
[[email protected] ~]# b ssh node$b ‘echo ‘ndb-connectstring=192.168.1.201‘>>/etc/my.cnf‘;done
注:以上IP为管理节点的IP

[[email protected] ~]# b ssh node$b ‘chown -R root /usr/local/mysql‘;done
[[email protected] ~]# b ssh node$b ‘chown -R mysql /usr/local/mysql/data‘;done
[[email protected] ~]# b ssh node$b ‘chgrp -R mysql /usr/local/mysql‘;done
[[email protected] ~]# b ssh node$b ‘cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/‘;done
[[email protected] ~]# b ssh node$b ‘chmod +x /etc/rc.d/init.d/mysql.server‘;done
[[email protected]node1 ~]# b ssh node$b ‘chkconfig --add mysql.server‘;done


#启动ndbd
[[email protected] ~]# b ssh node$b ‘/usr/local/mysql/bin/ndbd --initial‘;done
技术图片

 

 技术图片

 

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

Command to destroy cluster

Kubernetes核心模块

Kubernetes核心模块

Kubernetes —— 核心模块

使用令牌通过服务帐户登录GKE

Linux学习之路-集群及LVS24---20180213