mariadb主从

vim /etc/my.cnf +10

i

log-bin=mysql-bin

binlog-ignore-db=information_schema

binlog-ignore-db=mysql

binlog-ignore-db=performance_schema

server-id= 1

 

 

vim /etc/my.cnf +10

i

server-id=2

read_only = 1

 

 

 

systemctl restart mariadb

 

主库

mysql -p123qwe

 

 

CREATE USER ‘abc‘@‘%‘ IDENTIFIED BY ‘123qwe‘;

grant replication slave on *.* to ‘abc‘@‘172.16.0.227‘ identified by ‘123qwe‘;

flush privileges;

show master status;

 

MariaDB [(none)]> show master status;                                      

+——————+———-+————–+———————————————+

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB                            |

+——————+———-+————–+———————————————+

| testsql.000001 |      5416 |              | information_schema,mysql,performance_schema |

+——————+———-+————–+———————————————+

1 row in set (0.00 sec)

 

mysql -p123qwe

 

stop slave;

CHANGE MASTER TO MASTER_HOST=‘172.16.0.226‘, MASTER_USER=‘abc‘,  MASTER_PASSWORD=‘123qwe‘, MASTER_LOG_FILE=‘testsql.000001‘, MASTER_LOG_POS=5416;

start slave;        

show slave status\G;

 

select host,user from mysql.user;   

delete from mysql.user where user=‘repl‘;

show master status;

show variables like ‘server_id‘;