Mysql数据库架构-一主多从

三台主机系统:

[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数据库架构-一主多从

安装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>

Mysql数据库架构-一主多从

?

Master主服务部署操作:

master开启binlog重启mysql服务:

Mysql数据库架构-一主多从

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

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

Mysql数据库架构-一主多从

?

Slave从服务器部署操作

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

Mysql数据库架构-一主多从

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

Mysql数据库架构-一主多从

测试

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

Mysql数据库架构-一主多从

?

?

?

上一篇:oracle查看创建了哪些存储过程,oracle查看存储过程的内容


下一篇:记录 把sql搭建到自己的电脑上