1、
2、配置master
修改/etc/my.cnf增加
[mysqld] log-bin = master-bin log-bin-index = master-bin.index server-id = 1
3、master创建一个复制用户
CREATE USER repl_user; GRANT REPLICATION SLAVE ON *.* TO repl_user IDENTIFIED BY ‘123456‘;
重启master
4、配置slave
修改/etc/my.cnf增加
[mysqld] server-id = 2 relay-log-index = slave-relay-bin.index relay-log slave-relay-bin
重启slave
5、连接master和slave
CHANGER MASTER TO MASTER_HOST = ‘master-1‘, MASTER_PORT = 3306, MASTER_USER = ‘repl_user‘, MASTER_PASSWORD = ‘123456‘; START SLAVE;
时间: 2024-11-12 12:08:36