当前位置:网站首页>centos上mysql5.7主从热备设置
centos上mysql5.7主从热备设置
2022-07-27 14:42:00 【吃胡萝卜的鳄鱼】
mysql的安装:https://blog.csdn.net/qq_37135484/article/details/78594782
前提:要确保服务器之间能够互相ping通,互相登陆。
1.服务器介绍
主(master):192.168.78.154
从 (slave):192.168.78.155
用户都为root,密码为:123456
2.主服务器配置
1)设置/etc/my.cnf
主要配置server-id(要求每台服务器的id唯一)
和log二进制(log-bin=mysql-bin)
vim /etc/my.cnf
在末尾添加
server-id=1
log-bin=mysql-bin
binlog-ignore-db=mysql
效果如小图所示:

2)设置从服务器用户权限,方便从服务器用户读取复制主服务器内容
grant replication slave,replication on *.* to 'root'@'192.168.78.155' identified by '123456';
用户名以及IP均为从服务器
可能会遇到Your password does not satisfy the current policy requirements这个错误,此时参考博客https://blog.csdn.net/qq_37135484/article/details/98735515
3)登陆主服务器mysql查看主服务器的状态
show master status;

记住此时的File 和Position,配置从服务的时候会用上
4)刷新
flush privileges;

3.从服务器配置
1) 配置从服务器的/etc/my.cnf

2)登陆mysql在mysql命令行下执行以下命令:
CHANGE MASTER TO MASTER_HOST='192.168.78.154',MASTER_USER='root',MASTER_PASSWORD='123456',MASTER_LOG_FILE='mysql-bin.000004',MASTER_LOG_POS=763;
其中的MASTER_LOG_FILE=‘mysql-bin.000004’,MASTER_LOG_POS=763;
对应上面主服务器执行命令show master status;显示的数据
然后启动slave;
start slave;

3)查看slave状态
show slave status\G

如果 Slave_IO_Running和Slave_SQL_Running项都是yes则表示主从复制配置成功,否则失败,失败不要慌张,下面会有错误提示。
边栏推荐
- Keil implements compilation with makefile
- [sword finger offer] interview question 42: the maximum sum of continuous subarrays -- with 0x80000000 and int_ MIN
- Pycharm导入已有的本地安装包
- Using Lombok results in the absence of parent class attributes in the printed toString
- DRF学习笔记(四):DRF视图
- openwrt 增加RTC(MCP7940 I2C总线)驱动详解
- 三星关闭在中国最后一家手机工厂
- [Yunxiang book club issue 13] coding format of video files
- scrapy爬虫框架
- 一款功能强大的Web漏洞扫描和验证工具(Vulmap)
猜你喜欢

juc包下常用工具类

Causes and solutions of deadlock in threads
![[sword finger offer] interview question 42: the maximum sum of continuous subarrays -- with 0x80000000 and int_ MIN](/img/01/bbf81cccb47b6351d7265ee4a77c55.png)
[sword finger offer] interview question 42: the maximum sum of continuous subarrays -- with 0x80000000 and int_ MIN
![[sword finger offer] interview question 53-i: find the number 1 in the sorted array -- three templates for binary search](/img/4b/460ac517e9a5d840a0961f5d7d8c9d.png)
[sword finger offer] interview question 53-i: find the number 1 in the sorted array -- three templates for binary search

DRF学习笔记(四):DRF视图

Flask连接mysql数据库已有表

Single machine high concurrency model design

Openwrt adds support for SD card

Inter thread wait and wake-up mechanism, singleton mode, blocking queue, timer

渗透测试-干货 | 80篇+网络安全面试经验帖(面试篇)
随机推荐
可载100人!马斯克发布史上最强“星际飞船” !最早明年上火星!
C: On function
To meet risc-v challenges? ARM CPU introduces custom instruction function!
drf使用:get请求获取数据(小例子)
接连取消安富利/文晔/世平代理权,TI到底打的什么算盘?
实现浅拷贝和深拷贝+
逗号操作符你有用过吗?
判断数据的精确类型
[regular expression] match the beginning and end
Voice live broadcast system -- a necessary means to improve the security of cloud storage
三星关闭在中国最后一家手机工厂
Go language slow start - Basic built-in types
openwrt 增加RTC(MCP7940 I2C总线)驱动详解
剑指 Offer 51. 数组中的逆序对
[sword finger offer] interview question 56-i: the number of numbers in the array I
[sword finger offer] interview question 50: the first character that appears only once - hash table lookup
go语言慢速入门——go运算符
C语言实现字节流与十六进制字符串的相互转换
禁令之下,安防巨头海康与大华的应对之策!
Leetcode-1: sum of two numbers