• MySQL8集群搭建(innodb cluster)


    1 基本环境

    1.1 操作系统

    Linux centos3 3.10.0-327.el7.x86_64(关闭防火墙,关闭selinux)

    1.2 准备rpm包

    1.2.1 MySQL8安装包

    https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-server-8.0.19-1.el7.x86_64.rpm

    https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-client-8.0.19-1.el7.x86_64.rpm

    https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-common-8.0.19-1.el7.x86_64.rpm

    https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-libs-8.0.19-1.el7.x86_64.rpm

    1.2.2 MySQL8 Cluster安装包

    https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7/mysql-router-8.0.12-1.el7.x86_64.rpm

    https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7/mysql-shell-8.0.12-1.el7.x86_64.rpm

    2 安装mysql

    2.1 安装rpm包

    yum remove mariadb-libs
    rpm -ivh mysql-community-common-8.0.19-1.el7.x86_64.rpm
    rpm -ivh mysql-community-libs-8.0.19-1.el7.x86_64.rpm
    rpm -ivh mysql-community-client-8.0.19-1.el7.x86_64.rpm
    rpm -ivh mysql-community-server-8.0.19-1.el7.x86_64.rpm

    2.2 启动mysql

    service mysqld start

    2.3 修改密码

    2.3.1 查看密码

    grep 'temporary password' /var/log/mysqld.log

    2.3.2 修改密码

    mysqladmin -p '上面查到的临时密码' password  '新的密码'

    2.4 设置允许远程访问

    2.4.1 登录mysql

    mysql -uroot -p

    2.4.2 设置允许远程访问

    use mysql;
    update user set host='%' where user='root';
    quit;

    3.4.2 重启服务

    service mysqld restart

    3 安装集群

    3.1 准备三台服务器

    10.10.10.201,主机名:centos1,角色:管理节点、数据节点
    10.10.10.202,主机名:centos2
    10.10.10.203,主机名:centos3

    3.2 三台服务器设置hosts

    vim /etc/hosts

    添加

    10.10.10.201 centos1
    10.10.10.202 centos2
    10.10.10.203 centos3

    3.3 三台服务器设置免密

    ssh-keygen -t rsa
    ssh-copy-id centos1
    ssh-copy-id centos2
    ssh-copy-id centos3

    3.4 三台服务器安装MySQL

    参见步骤2

    3.5 三台服务器Mysql赋予root用户所有权限

    3.5.1 登录mysql

    mysql -uroot -p

    3.5.2 设置允许远程访问

    grant all privileges on *.* to 'root'@'%' with grant option;
    flush privileges;

    3.6 centos1上安装mysql-shell

    rpm -ivh mysql-shell-8.0.12-1.el7.x86_64.rpm

    3.7 centos1上进入mysql-shell并创建集群

    3.7.1 进入mysql-shell

    mysqlsh

    3.7.2 创建集群

    shell.connect('root@centos1:3306')
    dba.configureLocalInstance()
    shell.connect('root@centos2:3306')
    dba.configureLocalInstance()
    shell.connect('root@centos3:3306')
    dba.configureLocalInstance()
    
    shell.connect('root@centos1:3306') 
    var cluster=dba.createCluster("MySQL_Cluster")
  • 相关阅读:
    数据库外连接和内连接详解
    关于省市联动问题的分析
    邮箱验证修改密码,通过邮箱找回密码
    格式化Json传递的日期
    项目中验证码的使用
    水仙花数
    回文数
    冒泡排序
    《终结者·洛谷小说》总集
    题解 CF151A 【Soft Drinking】
  • 原文地址:https://www.cnblogs.com/LOVE0612/p/12589669.html
Copyright © 2020-2023  润新知