192.168.100.10 vm1
192.168.100.20 vm2
yum install -y mariadb mariadb-server
systemctl restart mariadb
y
密码
密码
y
n
y
y
vm1:
vi /etc/my.cnf
log_bin = mysql-bin
server_id = 10
systemctl restart mariadb
MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by "000000";
MariaDB [(none)]> grant replication slave on *.* to 'user'@'vm2' identified by '000000';
vm2:
vi /etc/my.cnf
log_bin = mysql-bin
server_id = 20
systemctl restart mariadb
MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by "000000";
MariaDB [(none)]> change master to master_host='vm1',master_user='user',master_password='000000';
MariaDB [(none)]> start slave;
MariaDB [(none)]> show slave status \G
MariaDB [book]> create table book(id int,name varchar(20));
MariaDB [book]> insert into book values(1,"java");