时间:2022-05-20 09:41:13 | 栏目:Mysql | 点击:次
一、添加Maria源
vi /etc/yum.repos.d/MariaDB.repo
粘贴阿里云的最新mariadb镜像:
[mariadb] name = MariaDB baseurl = https://mirrors.aliyun.com/mariadb/yum/10.5/centos7-amd64/ gpgkey=https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1
安装新版本的MariaDB
yum install mariadb mariadb-server
开启binlog日志
vim /etc/my.cnf.d/server.cnf 在mysqld下添加以下内容 server_id = 1 log_bin = mysql-bin systemctl restart mariadb
二、主从复制
1.在主上授权
grant replication slave on *.* to 'slave'@'192.168.59.%' identified by '123';
2.添加主机,执行同步master操作
停止slave,停止同步,开始修改信息 stop slave; 写master的信息 CHANGE MASTER TO -> MASTER_HOST='192.168.59.143', -> MASTER_USER='slave', -> MASTER_PASSWORD='123', -> MASTER_PORT=3306, -> MASTER_USE_GTID = current_pos; 开启从,开始同步 start slave;
验证是否成
show slave status \G;
至此GTID主从复制完成!!