Mysql InnoDB Cluster部署装配
Mysql集群安装
参考官网:https://dev.mysql.com/doc/refman/5.7/en/mysql-innodb-cluster-userguide.html
环境简介:
四台虚拟机,分比为mysql1、mysql2、mysql3、mysql4(1、2、3安装集群,4安装mysqlrouter.)
(先看完再操作)
一、安装三个软件
1.1 mysql安装
官网资料: https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
安装:
$> yum install mysql-community-server mysql-community-client
$> service mysqld start
Starting mysqld:[ OK ]
$> sudo service mysqld status
mysqld (pid 3066) is running.
初始密码:
$> grep 'temporary password' /var/log/mysqld.log
$> mysql -u root -p
Mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Dascom12__';
1.2 mysql-shell安装
$> yum install mysql-shell
(以上两步在 mysql1、mysql2、mysql3都安装)
1.3 mysql-router安装
$> yum install mysql-router
(mysqlrouter在架构里是跟application在一个机器上,所以一个系统里可能有多个mysqlrouter.)
(只在 mysql4 上安装)
二、配置
2.1 关闭防火墙和selinux、host
$> systemctl stop firewalld
$> vim /etc/selinux/config
SELINUX=disabled
$> vim /etc/hosts 增加主机名配置
192.168.*.* mysql1
192.168.*.* mysql2
192.168.*.* mysql3
2.2 创建用户与检查 (3个服务器都执行)
a. mysqlsh> dba.configureLocalInstance('root@localhost:3306')
输入 2 (创建新的集群用户)
b. $> service mysqld restart (重启mysql)(关键重要)
c. $> mysqlsh --uri "ic_user@mysql1:3306"
mysqlsh> dba.checkInstanceConfiguration()
(输出 status : OK 就好了)
2.3 创建集群
(创建集群和添加实例都只在master上操作,初次安装选择 mysql1上操作,mysql1 就是master。但 mysql1重启master会飘走)
master服务器执行
$> mysqlsh --uri "ic_user@mysql1:3306"
mysqlsh*** > var cluster = dba.createCluster('ClusterName')
成功:
Adding Seed Instance...
Cluster successfully created. Use Cluster.addInstance() to add MySQL instances.
At least 3 instances are needed for the cluster to be able to withstand up to
one server failure.
失败:
提示Error就是失败了.
$> mysql -uroot -p
mysql> reset master
mysql> exit
再次尝试createCluster
2.4 添加实例
把mysql2、mysql3添加进来
注意:
1、获取cluster
var cluster是定义临时变量,\exit退出后失效.
$> mysqlsh --uri "ic_user@mysql1:3306"
mysqlsh***> var cluster = dba.getCluster('ClusterName')
2、添加之前先检查一下实例
$> mysqlsh
mysqlsh > dba.checkInstanceConfiguration('ic_user@mysql2:3306')
Please provide the password for 'ic_user@mysql2:3306': **********
Dba.checkInstanceConfiguration: Can't connect to MySQL server on 'mysql2' (113) (MySQL Error 2003)
如果出现这个错,就是从master(mysql1)到mysql2不通.检查防火墙或者主机名的配置.
直到在mysql1上 $> mysql -u mysql2 -u ic_user -p 能够登录为止. mysql3同理.
mysqlsh***> cluster.addInstance('ic_user@mysql2:3306')
mysqlsh***> cluster.addInstance('ic_user@mysql3:3306')
成功后
mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 95f024a0-e2af-11ea-8bb1-08002773b035 | mysql3 | 3306 | ONLINE |
| group_replication_applier | 9c40caa1-e2af-11ea-877c-080027054126 | mysql2 | 3306 | ONLINE |
| group_replication_applier | caa78af2-e2ae-11ea-b8ca-080027ab81dd | mysql1 | 3306 | ONLINE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
3 rows in set (0.00 sec)
(附: cluster.rejoinInstance()添加掉线的实例.)
2.5 配置mysqlrouter
安装后: (关闭firewalld)(在application服务器上)
$> mysqlrouter --bootstrap ic_user@192.168.21.97:3306 --user=mysqlrouter (注意这个user是mysqlrouter)
输出以下内容就是成功.
# Bootstrapping system MySQL Router instance...
- Creating account(s) (only those that are needed, if any)
- Verifying account (using it to run SQL queries that would be run by Router)
- Storing account in keyring
- Adjusting permissions of generated files
- Creating configuration /etc/mysqlrouter/mysqlrouter.conf
Existing configuration backed up to '/etc/mysqlrouter/mysqlrouter.conf.bak'
# MySQL Router configured for the InnoDB Cluster 'cluster1'
After this MySQL Router has been started with the generated configuration
$ /etc/init.d/mysqlrouter restart
or
$ systemctl start mysqlrouter
or
$ mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf
the cluster 'cluster1' can be reached by connecting to:
## MySQL Classic protocol
- Read/Write Connections: localhost:6446
- Read/Only Connections: localhost:6447
## MySQL X protocol
- Read/Write Connections: localhost:64460
- Read/Only Connections: localhost:64470
启动mysqlrouter
$> systemctl start mysqlrouter
$> systemctl status mysqlrouter (查看运行状态)
登录
$> mysql -uic_user -pDascom12__ -P6446 --protocol=TCP
mysql> SELECT coalesce(@@report_host, @@hostname);
+-------------------------------------+
| coalesce(@@report_host, @@hostname) |
+-------------------------------------+
| mysql1 |
+-------------------------------------+
1 row in set (0.00 sec)
显示的是master的主机名.
附:
---查primary是哪台机器
select member_host from performance_schema.replication_group_members where MEMBER_ID in (select variable_value from performance_schema.global_status where variable_name='group_replication_primary_member');
---查看cluster有哪些成员
select * from performance_schema.replication_group_members;
---查看mysql所在主机名
SELECT coalesce(@@report_host, @@hostname);
Mysql InnoDB Cluster部署装配相关推荐
- MySQL InnoDB Cluster部署
文章目录 安装 下载Yum存储库 安装发布包 导入密钥 安装MySQL 启动MySQL 查看临时口令 登录并修改口令 安装MySQL Shell InnoDB Cluster 账户配置 服务器配置账户 ...
- mysql高可靠部署_可能是我见过最好的 MySQL 高可用解决方案 MySQL InnoDB Cluster 中文教程!...
公众号关注 「运维之美」设为「星标」,每天带你玩转 Linux ! 这篇文章将详细地介绍 MySQL 的高可用解决方案-- MySQL InnoDB Cluster. 说到高可用性,首先要了解一下什么 ...
- MySQL InnoDB Cluster
Mysql高可用环境的搭建比较麻烦,而且之前的那种mysql cluster使用的是内存式存储引擎,一旦断电就会灰飞烟灭,数据丢失. 自从mysql被oracle收购后,新版本发布频繁,推出了很多好用 ...
- MySQL NDB Cluster部署方案与实践
MySQL Cluster集群 一.概述 MySQL Cluster是MySQL适用于分布式计算环境的高实用.高冗余版本.他采用了NDB Cluster存储引擎,允许在一个Cluster中运行多个 ...
- MySQL InnoDB Cluster安装
环境说明 centos 7.x 64位 mysql 5.7.20 编译源码安装 mysql shell linux generic版本 mysql router linux generic版本 路由节 ...
- MySQL高可用架构InnoDB Cluster (和NDB Cluster是两码事)
MySQL的高可用架构无论是社区还是官方,一直在技术上进行探索,这么多年提出了多种解决方案,比如MMM, MHA, NDB Cluster, Galera Cluster, InnoDB Cluste ...
- innodb 集群_部署MySQL InnoDB集群以实现高可用性
innodb 集群 In this article, I am going to explain how we can deploy the MySQL InnoDB cluster. InnoDB ...
- 技术分享 | InnoDB Cluster+GreatSQL快速部署MGR集群,并实现读写分离和故障自动转移(超详细)...
本文来源:原创投稿 * GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 0. 内容提纲 1. 部署环境及初始化 2. 利用MySQL Shell构建MGR集群 3. 对在 ...
- 初探mysql innodb集群_MySQL InnoDB Cluster搭建
MySQL的高可用架构无论是社区还是官方,一直在技术上进行探索,这么多年提出了多种解决方案,比如MMM, MHA, NDB Cluster, Galera Cluster, InnoDB Cluste ...
最新文章
- 实现samba可写不可删除
- 【踩坑】遇到 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 报错...
- Android NDK学习笔记3:JNI访问Java属性、方法
- 函数、指针、数组的组合 及结构体和共用体
- SAP UI5 应用开发教程之五十 - 如何使用 Cordova 将 SAP UI5 应用生成一个能在 Android 手机上安装的混合应用
- C#中通过HttpClient发送Post请求
- [python opencv 计算机视觉零基础到实战] 十六、用opencv画画
- linux c 指针和内存分配内存,linux-C基础系列-内存管理(野指针).md
- 946. 验证栈序列
- python如何并发运行2个软件_如何利用并发性加速你的python程序(二):I/O 绑定程序加速...
- Linux 查看磁盘的属性,Windows XP 查看磁盘属性(转)
- 前端路由跳转丢失端口号_Laravel框架-路由的基本概念及实例分析
- MAC 用命令查看IP
- java 集成 pageoffice 实现 word 文档的在线编辑以及流转
- xshell下载链接及安装步骤
- 计算机视觉 — Harris角点检测
- 【案例】10个视觉系优秀网页设计让你打破灵感的僵局
- Google Pay 谷歌支付(gateway = stripe)
- 论文:DKN:Deep Knowledge-Aware Network for News Recommendatio
- 计算机控制实验室装置,新型自控原理/计算机控制多功能实验装置