广告
返回顶部
首页 > 资讯 > 数据库 >mysql innodb cluster 搭建
  • 632
分享到

mysql innodb cluster 搭建

2024-04-02 19:04:59 632人浏览 独家记忆
摘要

根据文档搭建...https://dev.Mysql.com/doc/refman/8.0/en/mysql-innodb-cluster-production-deployment.html 环境准备:1

根据文档搭建...https://dev.Mysql.com/doc/refman/8.0/en/mysql-innodb-cluster-production-deployment.html

环境准备:
1 下载和安装需要的软件(本人的软件版本--都是mysql CommUnity中的linux Generic版本)
mysql-server(mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz)
mysql-router(mysql-router-8.0.17-linux-glibc2.12-x86_64.tar.xz)
mysql-shell(mysql-shell-8.0.17-linux-glibc2.12-x86-64bit.tar.gz)

安装(以mySQL Server为例,其他类似,以下都是Mysql_tar操作系统用户操作):
cd /home/mysql_tar
tar -xvf mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz
ln -s mysql-8.0.17-linux-glibc2.12-x86_64 mysql_install(方便升级)
...mysql-router...
....mysql_shell...

  1. 编辑环境变量:
    vim /home/mysql_tar/.bash_profile
    #FOR MYSQL
    MYSQL_HOME=/home/mysql_tar/mysql_install
    PATH=$PATH:$MYSQL_HOME/bin
    export MYSQL_HOME

#MYSQL SHELL
MYSQL_SHELL_HOME=/home/mysql_tar/mysql_shell
PATH=$PATH:$MYSQL_SHELL_HOME/bin
export MYSQL_SHELL_HOME

#MYSQL_ROUTER
MYSQL_ROUTER=/home/mysql_tar/mysql_router
PATH=$PATH:$MYSQL_ROUTER/bin
export MYSQL_ROUTER

export PATH

  1. 准备mysql 配置文件my.cnf
    vim /etc/my.cnf

default-authentication-plugin=mysql_native_passWord
lower_case_table_names=1
datadir=/data_test
Socket=/data_test/mysql.sock
log-error=/data_test/mysqld.log
pid-file=/data_test/mysqld.pid

  1. 创建数据目录文件/data_test(用户和用户组均为mysql_tar)
  2. 初始化mysql
    cd /home/mysql_tar/mysql_install/bin(环境变量设置正确,该步可有可无)
    ./mysqld --initialize --user=mysql_tar(初始化mysql系统表空间和其他重要文件,initialize 拼错的话不会报错,只会提示数据目录找不到)
  3. 启动Mysql
    mysqld_safe --user=mysql_tar &
  4. 连接Mysql并且修改root账户密码:
    ./mysql -u root -S /data_test/mysql.sock -p(也可以通过tcp/IP登陆,这里通过套接字登陆)
    mysql>alter user root@localhost identified by 'mjj';
  5. 通过mysqlsh登陆mysql、检查环境并创建集群
    /home/mysql_tar/mysql_shell/bin/mysqlsh
    MySQL SQL > \connect root@mysql_host_a(加粗的是我的命令)
    Creating a session to 'root@mysql_host_a'
    Please provide the password for 'root@mysql_host_a': *
    Save password for 'root@mysql_host_a'? [Y]es/[N]o/Ne[v]er (default No): ~~
    MySQL mysql_host_a:33060+ ssl js > dba.checkInstanceConfiguration();
    Validating local MySQL instance listening at port 3306 for use in an InnoDB cluster...**

This instance reports its own address as mysql_host_a:3306
Clients and other cluster members will communicate with it through this address by default. If this is not correct, the report_host MySQL system variable should be changed.

Checking whether existing tables comply with Group Replication requirements...
No incompatible tables detected

Checking instance configuration...

NOTE: Some configuration options need to be fixed:
+--------------------------+---------------+----------------+--------------------------------------------------+
| Variable | Current Value | Required Value | Note |
+--------------------------+---------------+----------------+--------------------------------------------------+
| binlog_checksum | CRC32 | NONE | Update the server variable |
| enforce_gtid_consistency | OFF | ON | Update read-only variable and restart the server |
| gtid_mode | OFF | ON | Update read-only variable and restart the server |
| server_id | 1 | <unique ID> | Update read-only variable and restart the server |
+--------------------------+---------------+----------------+--------------------------------------------------+

Some variables need to be changed, but cannot be done dynamically on the server.
NOTE: Please use the dba.configureInstance() command to repair these issues.

{
"config_errors": [
{
"action": "server_update",
"current": "CRC32",
"option": "binlog_checksum",
"required": "NONE"
},
{
"action": "server_update+restart",
"current": "OFF",
"option": "enforce_gtid_consistency",
"required": "ON"
},
{
"action": "server_update+restart",
"current": "OFF",
"option": "gtid_mode",
"required": "ON"
},
{
"action": "server_update+restart",
"current": "1",
"option": "server_id",
"required": "<unique ID>"
}
],
"status": "error"
}
MySQL mysql_host_a:33060+ ssl JS > \exit
Bye!

根据错误往/etc/my.cnf添加以下参数:
#for innodb cluster
binlog_checksum=none
enforce_gtid_consistency=on
gtid_mode=on
server_id=1234

  1. 创建集群
    MySQL mysql_host_a:33060+ ssl JS > var cluster = dba.createCluster('mjjcluster');
    A new InnoDB cluster will be created on instance 'mysql_host_a:3306'.

Validating instance at mysql_host_a:3306...

This instance reports its own address as mysql_host_a:3306

Instance configuration is suitable.
Creating InnoDB cluster 'mjjcluster' on 'mysql_host_a:3306'...

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.

10 可以通过cluster.status();命令查看集群状态
MySQL mysql_host_a:33060+ ssl JS > cluster.status();
{
"clusterName": "mjjcluster",
"defaultReplicaSet": {
"name": "default",
"primary": "mysql_host_a:3306",
"ssl": "REQUIRED",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures.",
"topology": {
"mysql_host_a:3306": {
"address": "mysql_host_a:3306",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE",
"version": "8.0.17"
}
},
"topologyMode": "Single-Primary"
},
"groupInfORMationSourceMember": "mysql_host_a:3306"
}

11, 其他机子也安装软件和准备环境(dba.checkInstanceConfiguration()通过即可,步骤与主节点类似)

  1. 加入节点:
    MySQL mysql_host_a:33060+ ssl JS > cluster.addInstance('root@mysql_host_b:3306');(本人另一台机子的主机名是mysql_host_b)
    Cluster.addInstance: Connection 'root@mysql_host_b:3306' is not valid: unable to resolve the IPv4 address. (ArgumentError)
    MySQL mysql_host_a:33060+ ssl JS > cluster.addInstance('root@mysql_host_b:3306');
    Please provide the password for 'root@mysql_host_b:3306': ***
    Save password for 'root@mysql_host_b:3306'? [Y]es/[N]o/Ne[v]er (default No):

NOTE: The target instance 'mysql_host_b:3306' has not been pre-provisioned (GTID set
is empty). The Shell is unable to decide whether incremental distributed state
recovery can correctly provision it.
The safest and most convenient way to provision a new instance is through
automatic clone provisioning, which will completely overwrite the state of
'mysql_host_b:3306' with a physical snapshot from an existing cluster member.
To use this method by default, set the 'recoveryMethod' option to 'clone'.

The incremental distributed state recovery may be safely used if you are sure
all updates ever executed in the cluster were done with GTIDs enabled, there
are no purged transactions and the new instance contains the same GTID set as
the cluster or a subset of it. To use this method by default, set the
'recoveryMethod' option to 'incremental'.

Please select a recovery method [C]lone/[I]ncremental recovery/[A]bort (default Clone):
Validating instance at mysql_host_b:3306...

This instance reports its own address as mysql_host_b:3306

Instance configuration is suitable.
A new instance will be added to the InnoDB cluster. Depending on the amount of
data on the cluster this might take from a few seconds to several hours.

Adding instance to the cluster...

Monitoring recovery process of the new cluster member. Press ^C to stop monitoring and let it continue in background.
Clone based state recovery is now in progress.

NOTE: A server restart is expected to happen as part of the clone process. If the
server does not support the RESTART command or does not come back after a
while, you may need to manually start it back.

  • Waiting for clone to finish...
    NOTE: mysql_host_b:3306 is being cloned from mysql_host_a:3306
    Stage DROP DATA: Completed
    Clone Transfer
    FILE COPY ############################################################ 100% Completed
    PAGE COPY ############################################################ 100% Completed
    REDO COPY ############################################################ 100% Completed

NOTE: mysql_host_b:3306 is shutting down...

  • Waiting for server restart... ready
  • mysql_host_b:3306 has restarted, waiting for clone to finish...
    ** Stage RESTART: Completed
  • Clone process has finished: 58.50 MB transferred in about 1 second (~inf TB/s)

State recovery already finished for 'mysql_host_b:3306'

The instance 'mysql_host_b:3306' was successfully added to the cluster.

。。。完成了,基本的步骤就这些吧。
主要方法:
dba.configureInstance()

dba.createCluster()

Cluster.addInstance()----cluster=dba.getCluster()获取cluster变量

Cluster.removeInstance()

Cluster.rejoinInstance()

您可能感兴趣的文档:

--结束END--

本文标题: mysql innodb cluster 搭建

本文链接: https://www.lsjlt.com/news/47531.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • mysql innodb cluster 搭建
    根据文档搭建...https://dev.mysql.com/doc/refman/8.0/en/mysql-innodb-cluster-production-deployment.html 环境准备:1...
    99+
    2022-10-18
  • MySQL Innodb Cluster搭建与初探
    -------------------------------------------------------------------------------------------------正文----...
    99+
    2022-10-18
  • MySQL InnoDB Cluster环境搭建和简单测试
    InnoDB Cluster初印象   记得MySQL Group Replicatioin 刚开始的时候,MySQL界很是轰动,等待了多年,终于有了官方的这个高可用解决方案。你要说还...
    99+
    2022-10-18
  • MySQL Cluster搭建与测试
    1、服务器准备1) MySQL节点1 10.41.1.852) MySQL节点2 10.41.1.843) ndb节点1 10.4...
    99+
    2022-10-18
  • 使用MySQL-Cluster搭建MySQL数据库集群
    1、MySQL集群的作用:- 解决访问节点的单点故障- 数据存储节点的单点故障- 解决数据存储节点数据备份问题2、集群:使用一组服务器提供相同的服务3、关于MySQL-Cluster:MySQL官方提供的集...
    99+
    2022-10-18
  • MySQL中搭建ProxySQL Cluster的详细步骤
    下文给大家带来关于MySQL中搭建ProxySQL Cluster的详细步骤,感兴趣的话就一起来看看这篇文章吧,相信看完MySQL中搭建ProxySQL Cluster的详细步骤对大家多少有点帮助吧。环境:...
    99+
    2022-10-18
  • MySQL 8.1.0 推出 InnoDB Cluster 只读副本
    全面了解 8.1.0 版本新功能:InnoDB Cluster 只读副本的相关操作。 作者:Miguel Araújo 高级软件工程师 / Kenny Gryp MySQL 产品总监 本文来源:...
    99+
    2023-10-04
    mysql
  • MySQL Galera集群搭建流程(Percona XtraDB Cluster 5.7)
    避免创建偶数节点数量的集群,因为这样会导致脑裂。 Linux版本:CentOS 6.5 IP信息: Node     IP Node 1     ...
    99+
    2022-10-18
  • MySQL高可用Percona-XtraDB-Cluster环境的搭建
    本篇内容介绍了“MySQL高可用Percona-XtraDB-Cluster环境的搭建”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大...
    99+
    2022-10-18
  • MySQL 8.0 InnoDB Cluster出现故障如何解决
    下文给大家带来有关MySQL 8.0 InnoDB Cluster出现故障如何解决内容,相信大家一定看过类似的文章。我们给大家带来的有何不同呢?一起来看看正文部分吧,相信看完MySQL 8.0 InnoDB...
    99+
    2022-10-18
  • Redis Cluster集群部署搭建
    在Oracle的路上走了许多年,换换感觉,尝试一下新的知识,也是一个不错的感觉。Redis,一个超轻量化的内存数据库,只做一小块数据库功能实现,却非常优秀的一个产品。今天,就分享一下安装Redis集群的过程...
    99+
    2022-10-18
  • Docker Redis 5.0 集群(cluster)搭建
    一、准备工具 安装docker(来自官网) (1) 安装所需的软件包 $ sudo yum install -y yum-utils device-mapper-persistent-data lvm2 (2) 使用以下命令来设置稳定...
    99+
    2015-01-06
    Docker Redis 5.0 集群(cluster)搭建
  • Redis集群(cluster模式)搭建
    目录 1、什么是集群 2、为什么使用 3、集群连接 4、redis cluster 如何分配这六个节点 5、集群搭建: 1、什么是集群 Redis 集群(包括很多小集群)实现了对Redis的水平扩容,即启动N个redis节点,将整个数...
    99+
    2023-09-05
    redis 数据库 java linux
  • Redis Cluster 集群搭建你会吗
    三台机器 201、202、203,每台机器装两个 redis 实例,构建 redis cluster 集群。 1. 安装 添加 redis-cluster 目录,将 redis 压缩...
    99+
    2022-11-12
  • 使用InnoDB Cluster解决MySQL数据库高可用方案
    下文主要给大家带来使用InnoDB Cluster解决MySQL数据库高可用方案,希望这些内容能够带给大家实际用处,这也是我编辑使用InnoDB Cluster解决MySQL数据库高可用方案这篇文章的主要目...
    99+
    2022-10-18
  • MySQL 8.0.11 innodb cluster运维管理中如何进行备份
    本篇文章为大家展示了MySQL 8.0.11 innodb cluster运维管理中如何进行备份,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。MySQL 8.0.1...
    99+
    2022-10-18
  • Redis6.0搭建集群Redis-cluster的方法
    此处以三台服务器部署为例,IP地址分别为192.168.124.23,192.168.124.24,192.168.124.25 使用普通用户ubuntu登录 总共三个主节点和三个从...
    99+
    2022-11-12
  • mariadb集群搭建---Galera Cluster+ProxySQL教程
    目录前言一、Galera Cluster二、基础环境搭建三、加入配置参数启动集群四、 测试五、ProxySql总结前言 本篇主要用于记录mariadb环境下Galera Cluster模式集群环境的搭建过程,只做演示中间...
    99+
    2023-03-19
    mariadb集群搭建
  • Redis 6.X Cluster集群如何搭建
    这篇文章将为大家详细讲解有关Redis 6.X Cluster集群如何搭建,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。 Part1Redis 6.X Cluster 集群搭建1下载解压可直接到...
    99+
    2023-06-15
  • MySQL 8.0.11 innodb cluster 运维管理手册之三增加节点
    MySQL 8.0.11 innodb cluster 运维管理手册之三 增加节点 作者 方连超 假设innodb cluster集群跑了1年,突然某个节点挂掉了,这个时候,日志也已经没有binlog.0...
    99+
    2022-10-18
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作