一、环境准备(关闭防火墙)
1、清除已安装数据库
[root@mysql01 ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.35-3.el7.x86_64
[root@mysql01 ~]# yum remove mariadb-libs-5.5.35-3.el7.x86_64
 
2、安装libaio-devel包
挂载光盘
配置yum仓库
[root@mysql01 yum.repos.d]# mount /dev/sr0 /mnt
[root@mysql01 yum.repos.d]# yum clean all
[root@mysql01 yum.repos.d]# yum repolist all
[root@mysql01 yum.repos.d]# yum intall -y libaio-devel
 
3、创建用户及用户密码
[root@mysql01 ~]# groupadd mysql
[root@mysql01 ~]# useradd -g mysql mysql
[root@mysql01 ~]# passwd mysql
Changing password for user mysql.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
 
4、创建数据目录、日志目录,并修改目录所有者所属组
[root@mysql01 ~]# mkdir -p /data/3306/data
[root@mysql01 ~]# mkdir -p /data/3306/binlog
[root@mysql01 yum.repos.d]# chown -R mysql.mysql /data*
 
二、上传MySQL数据库安装包并解压
[root@mysql01 stage]# ll
-rw-r--r--. 1 root root   664749587 Jun  9 20:46 mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
[root@mysql01 stage]# gunzip mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
[root@mysql01 stage]# ll
-rw-r--r--. 1 root root  2648074240 Jun  9 20:46 mysql-5.7.29-linux-glibc2.12-x86_64.tar
[root@mysql01 stage]# tar -xvf mysql-5.7.29-linux-glibc2.12-x86_64.tar
[root@mysql01 stage]# ll
drwxr-xr-x. 9 root root        4096 Jun  9 21:15 mysql-5.7.29-linux-glibc2.12-x86_64
-rw-r--r--. 1 root root  2648074240 Jun  9 20:46 mysql-5.7.29-linux-glibc2.12-x86_64.tar
 
三、创建软连接,并修改数据库安装目录所有者所属组
[root@mysql01 stage]# ln -s /stage/mysql-5.7.29-linux-glibc2.12-x86_64 /usr/local/mysql
[root@mysql01 stage]# ll /usr/local/
total 0
drwxr-xr-x. 2 root root  6 Mar 13  2014 bin
drwxr-xr-x. 2 root root  6 Mar 13  2014 etc
drwxr-xr-x. 2 root root  6 Mar 13  2014 games
drwxr-xr-x. 2 root root  6 Mar 13  2014 include
drwxr-xr-x. 2 root root  6 Mar 13  2014 lib
drwxr-xr-x. 2 root root  6 Mar 13  2014 lib64
drwxr-xr-x. 2 root root  6 Mar 13  2014 libexec
lrwxrwxrwx. 1 root root 42 Jun  9 21:17 mysql -> /stage/mysql-5.7.29-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root  6 Mar 13  2014 sbin
drwxr-xr-x. 5 root root 46 Mar 19  2019 share
drwxr-xr-x. 2 root root  6 Mar 13  2014 src
[root@mysql01 stage]# ll /usr/local/mysql/
total 292
drwxr-xr-x.  2 root root    4096 Jun  9 21:15 bin
drwxr-xr-x.  2 root root      52 Jun  9 21:15 docs
drwxr-xr-x.  3 root root    4096 Jun  9 21:15 include
drwxr-xr-x.  5 root root    4096 Jun  9 21:15 lib
-rw-r--r--.  1 7161 31415 276202 Dec 18 20:59 LICENSE
drwxr-xr-x.  4 root root      28 Jun  9 21:15 man
-rw-r--r--.  1 7161 31415    587 Dec 18 20:59 README
drwxr-xr-x. 28 root root    4096 Jun  9 21:15 share
drwxr-xr-x.  2 root root      86 Jun  9 21:15 support-files
 
四、修改环境变量并生效
[root@mysql01 stage]# vi /etc/profile
在文件末尾追加:
export PATH=/usr/local/mysql/bin:$PATH
[root@mysql01 stage]# source /etc/profile
[root@mysql01 stage]# mysql -V
mysql  Ver 14.14 Distrib 5.7.29, for linux-glibc2.12 (x86_64) using  EditLine wrapper
 
五、初始化
[root@mysql01 stage]# mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/3306/data
 
六、编辑my.cnf参数文件
[root@mysql01 stage]# vi /etc/my3306.cnf
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/3306/data
log_bin=/data/3306/binlog/mysql-bin
port=3306
server_id=1
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
 
七、启动数据库
[root@mysql01 stage]# mysqld_safe --defaults-file=/etc/my3306.cnf &
 
八、登陆数据库
[root@mysql01 stage]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql>
 
九、修改用户密码
alter user 'root'@'localhost' identified by 'mysql';
 
十、同上,搭建从库
从库参数文件如下:
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/3307/data
log_bin=/data/3307/binlog
port=3307
server_id=2
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
 
十一、主从配置
1、主从库开启gtid功能
[root@mysql01 stage]# vi /etc/my3306.cnf
gtid_mode=ON
enforce_gtid_consistency=ON
log_slave_updates=1
 
[root@mysql02 stage]# vi /etc/my3307.cnf
gtid_mode=ON
enforce_gtid_consistency=ON
log_slave_updates=1
 
2、重启主从数据库使参数生效
[root@mysql01 stage]# mysqladmin shutdown
[root@mysql01 stage]# mysqld_safe --defaults-file=/etc/my3306.cnf &
 
[root@mysql02 stage]# mysqladmin shutdown
[root@mysql02 stage]# mysqld_safe --defaults-file=/etc/my3307.cnf &
 
3、确认主从数据库binlog已开启
mysql> select @@log_bin;
+-----------+
| @@log_bin |
+-----------+
|         1 |
+-----------+
1 row in set (0.00 sec)
 
4、主库创建复制用户
mysql> grant replication slave on *.* to 'repl'@'192.168.12.%' identified by 'mysql';
 
5、从库启动复制
CHANGE MASTER TO
MASTER_HOST='192.168.12.60',
MASTER_USER='repl',
MASTER_PASSWORD='mysql',
MASTER_PORT=3306,
MASTER_AUTO_POSITION=1;
 
mysql> start slave;
 
6、查看从库状态
mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.12.60
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: binlog.000002
          Read_Master_Log_Pos: 448
               Relay_Log_File: mysql02-relay-bin.000002
                Relay_Log_Pos: 655
        Relay_Master_Log_File: binlog.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 448
              Relay_Log_Space: 864
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1
                  Master_UUID: 86b0307f-aa58-11ea-a834-005056395a48
             Master_Info_File: /data/3307/data/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: 86b0307f-aa58-11ea-a834-005056395a48:1
            Executed_Gtid_Set: 86b0307f-aa58-11ea-a834-005056395a48:1
                Auto_Position: 1
         Replicate_Rewrite_DB:
                 Channel_Name:
           Master_TLS_Version:
1 row in set (0.00 sec)
 
自此,MySQL 5.7.29主从配置完成。

MySQL 5.7.29主从安装配置的更多相关文章

  1. Mysql主从安装配置

    Mysql主从安装配置   环境: 主从服务器上的MySQL数据库版本同为5.1.34 主机IP:192.168.0.1 从机IP:192.168.0.2  一. MySQL主服务器配置 1.编辑配置 ...

  2. MySQL 5.7.9 免安装配置

    MySQL 5.7.9 免安装配置 环境:win10 64位 mysql版本:mysql-5.7.9-winx64.zip (http://dev.mysql.com/downloads/mysql/ ...

  3. python操作三大主流数据库(3)python操作mysql③python操作mysql的orm工具sqlaichemy安装配置和使用

    python操作mysql③python操作mysql的orm工具sqlaichemy安装配置和使用 手册地址: http://docs.sqlalchemy.org/en/rel_1_1/orm/i ...

  4. mysql 5.7以上版本安装配置方法图文教程(mysql 5.7.12\mysql 5.7.13\mysql 5.7.14)(转)

    http://www.jb51.net/article/90302.htm ******************************* 这篇文章主要为大家分享了MySQL 5.7以上缩版本安装配置 ...

  5. mysql数据库备份之主从同步配置

    主从同步意义? 主从同步使得数据可以从一个数据库服务器复制到其他服务器上,在复制数据时,一个服务器充当主服务器(master),其余的服务器充当从服务器(slave).因为复制是异步进行的,所以从服务 ...

  6. Linux 下 MySQL 的彻底卸载和安装配置字符集

    前言: Linux环境下MySQL的安装和配置在网上已经有很多教程了.之所以写这篇文章是因为在配置字符集的时候找了网上的一些教程发现并不能用导致折腾了一阵子.下面的教程均是亲自实践. MySQL的彻底 ...

  7. Linux下MySQL的彻底卸载和安装配置字符集

    前言: Linux环境下MySQL的安装和配置在网上已经有很多教程了.之所以写这篇文章是因为在配置字符集的时候找了网上的一些教程发现并不能用导致折腾了一阵子.下面的教程均是亲自实践. MySQL的彻底 ...

  8. MySQL 5.7.10 免安装配置

    # 配置环境:windows 64bit # 安装版本:mysql-5.7.10-win32(zip archive版本) 1. ZIP Archive版是免安装的,只需把mysql-5.7.10-w ...

  9. mysql 5.7.12 winx64安装配置方法图文教程

    这篇文章主要为大家分享了mysql 5.7.12winx64安装配置方法图文教程,感兴趣的朋友可以参考一下   之前安装mysql时未做总结,换新电脑,补上安装记录,安装的时候,找了些网友的安装记录, ...

随机推荐

  1. jdk1.7中hashmap扩容时不会产生死循环

    在扩容时 transfer( ) 方法中 newTable 新数组 局部变量 table 旧数组 全局变量 当第一个链表进行while循环时 执行到 e.next = newTable[i]; 时 n ...

  2. Cpython的全局解释器锁(GIL)

    # Cpyrhon解释器下有个全局解释器锁-GIL:在同一 # 在同一时刻,多线程中只有一个线程访问CPU # 有了全局解释器锁(GIL)后,在同一时刻只能有一个线程访问CPU. # 全局解释器锁锁的 ...

  3. 企业级工作流解决方案(十五)--集成Abp和ng-alain--Abp其他改造

    配置功能增强 Abp定义了各种配置接口,但是没有定义这些配置数据从哪里来,但是管理配置数据对于一个应用程序来说,是必不可少的一件事情. .net的配置数据管理,一般放在Web.config文件或者Ap ...

  4. 仅一年工作经验成功跳槽字节跳动,腾讯并拿到字节的offer,全靠这份面经!

    前言 前几天由于工作的原因一直没怎么看私信,昨天在整理私信的时候看到了一个粉丝给我疯狂私信想要我帮忙整理一份大厂面经,说自己工作也有几年了想跳槽冲刺一下,但是不知道该怎么做好前期准备.我看到这个粉丝也 ...

  5. 在 Spark 数据导入中的一些实践细节

    本文由合合信息大数据团队柳佳浩撰写 1.前言 图谱业务随着时间的推移愈发的复杂化,逐渐体现出了性能上的瓶颈:单机不足以支持更大的图谱.然而,从性能上来看,Neo4j 的原生图存储有着不可替代的性能优势 ...

  6. Camtasia中对录制视频进行编辑——行为

    小视频的逐渐兴起,让我们的生活变得多姿多彩,同时,也造就了一批新媒体的创业者还有越来越多的网红,这不禁使我们也想加入他们的行列.但是问题来了,拍摄视频后最重要的是对视频进行剪辑,没有一款经济适用的软件 ...

  7. Java中类加载的过程

    类加载过程 这里的加载过程是严格按照加载开始顺序进行的,注意是加载开始而不是加载完成.也就是有可能会有两个或几个阶段是同时进行的. 比如下面提到的验证过程中的符号引用验证是在解析阶段开始之后进行. 加 ...

  8. kakafka - 为CQRS而生fka - 为CQRS而生

    前段时间跟一个朋友聊起kafka,flint,spark这些是不是某种分布式运算框架.我自认为的分布式运算框架最基础条件是能够把多个集群节点当作一个完整的系统,然后程序好像是在同一台机器的内存里运行一 ...

  9. 一键加Q群的实现

    打开网址 选择创建的群 选择所需要的二维码或者代码

  10. C#设计模式-装饰器模式(Decorator Pattern)

    引言 当我们完成一个软件产品开发后就需要对其进行各种测试,适配快速迭代下质量的保障.当有一个完善的产品的对象后,如果我们想要给他添加一个测试功能,那么我们可以用一个新的类去装饰它来实现对原有对象职责的 ...