首页 > 数据库技术 > 详细

Mysql数据库架构-一主多从

时间:2021-07-20 19:29:55      阅读:18      评论:0      收藏:0      [点我收藏+]

三台主机系统:

[root@master ~]# cat /etc/redhat-release

CentOS Linux release 7.8.2003 (Core)

?

三台主机的角色:

Master: 192.168.101.222

Slave1: 192.168.101.75

Slave2: 192.168.101.79

?

三台数据库的版本mysql5.7.31:

技术分享图片

安装mysql数据库软件包:

yum localinstall mysql-* -y

?

启动mysql服务,修改登录密码:

[root@master ~]# systemctl start mysqld

[root@master ~]# cat /var/log/mysqld.log | grep -i pass

2021-07-20T04:44:10.088102Z 1 [Note] A temporary password is generated for root@localhost: t9eJ3r3+YJz9

[root@master ~]# mysqladmin -uroot -pt9eJ3r3+YJz9 password 1qaz@WSX

mysqladmin: [Warning] Using a password on the command line interface can be insecure.

Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

[root@master ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.? Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.31 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>

技术分享图片

?

Master主服务部署操作:

master开启binlog重启mysql服务:

技术分享图片

master授权其他主机replication slave的权限:

mysql> grant replication slave on *.* to rep@‘%‘ identified by ‘1qaz@WSX‘;

技术分享图片

?

Slave从服务器部署操作

1.slave1和slave2开启bin-log,不同的server_id即可:

技术分享图片

2.Master主库查看binlog文件和binlog位置点,从库指明同步主库信息,另一台从库和当前从库做一样的操作:

技术分享图片

测试

主库创建数据库aa,slave1和slave2同步到aa库即可:

技术分享图片

?

?

?

Mysql数据库架构-一主多从

原文:https://blog.51cto.com/215687833/3146947

(0)
(0)
   
举报
评论 一句话评论(0
分享档案
最新文章
教程昨日排行
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!