mysql主从同步部署

1.mysql主从同步部署

master:10.3.30.243

slave:10.3.30.244

2.master端

vim /etc/my.cnf

server-id       = 1   #master端ID号

binlog-do-db = cacti   #同步库的名字:wq

mysql -u root -p Fancy

mysql>grant replication slave on *.* to Fancy@'10.3.30.244' identified by 'Fancy';

mysql>flush privileges;

mysql>flush tables with read lock;

mysql>show master status;#记住file和positon,从库需要使用
File             | Position |

+------------------+----------

| mysql-bin.000023 | 332

mysql>unlock tables;

3.slave端

vim /etc/my.cnf

server-id = 2     slave的ID号,此处一定要大于master端。

stop slave;

change master to master_host='10.3.30.243', #master端
master_user='Fancy', #master端创建的用于主从同步的密码
master_password='Fancy', #master端创建的用于主从同步的密码
master_port=3306, #master端设置的client端使用的端口号
master_log_file='mysql-bin.000057',#master端记录的file值
master_log_pos=1253536;#master端记录的position值

start slave;
show slave status \G

Slave_IO_Running: Yes

Slave_SQL_Running: Yes两个均为Yes表示成功

Slave_SQL_Running:No解决方案

show variables like ‘server_id’;//查看端口如果唯一重启mysql

Slave_IO_Running:No解决方案

0

评论0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
没有账号? 忘记密码?