Mysql主从备份搭建全流程
环境准备
本人使用环境为VM中的两台虚拟机,系统为CentOS7,最小镜像。IP分别以128和129结尾(IP获取策略为DHCP).预期将129设置为主机,128设置为备机。验证主从同步,读写分离。下面开干。文章原创,有疑问可以留言交流。
配置mysql源
进下方的网站,根据自己的实际系统选择。复制内容,新建文件/etc/yum.repos.d/mysql-community.repo,粘贴到其中。(本人为centos7,其他系统文件位置不一样,具体看下网址的选框)
https://mirrors.cnnic.cn/help/mysql/
本人安装的版本为5.7,可以将8.0的enablef的1修改为0;
系统和我一样的同学们也可以直接复制
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
[mysql-tools-community]
name=MySQL Tools Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
[mysql-5.6-community]
name=MySQL 5.6 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.6-community-el7-$basearch/
enabled=0
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
[mysql-5.7-community]
name=MySQL 5.7 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
[mysql-8.0-community]
name=