主服务器配置步骤
1.关闭主数据库服务器的防火墙和Selinux设置
systemctl stop firewalld
systemctl disable firewalld
vim /etc/selinux/config(将enforcing修改为disabled)
2.修改主服务器上数据库的my.cnf配置文件,在配置文件port=3306上面添加以下内容
vim /etc/my.cnf
log-bin=master-bin
binlog-format=Row
server-id=1
登陆主服务器的mysql数据库中,添加从服务器并授权为可以远程连接
mysql -u root -p
grant replication slave on *.* to 'root'@'192.168.8.132' identified by 'Ww@123456';
刷新
flush privileges;
重新启动主服务器的mysql数据库
systemctl restart mysql
systemctl restart mysqld
mysql -u root -p
并查看数据库的日志状态(记住该状态)
show master status;
配置从服务器
1.关闭主数据库服务器的防火墙和Selinux设置
systemctl stop firewalld
systemctl disable firewalld
vim /etc/selinux/config(将enforcing修改为disabled)
2.修改主服务器上数据库的my.cnf配置文件,在配置文件port=3306上面添加以下内容
vim /etc/m
Linux中给数据库配置主从
最新推荐文章于 2023-08-12 10:58:34 发布