mysql主从配置

1,环境,ubuntu,mysql

1)在虚拟机上启动2个ubuntu,

masterIp地址为:10.0.1.88

slaveIp地址为:10.0.1.90

2,mysql主从配置用户名

1),master配置:登录mysql。执行

grant replication slave on *.* to 'root'@'10.0.1.%' identified by '123456'语句,

vim 打开my.cnf文件

在[mysqld]下添加

 

server-id=1 

log-bin=master-bin

log-bin-index=master-bin.index

重启服务

登录mysql

输入命令:show master status,查看日志文件master-bin.000013

   -> ;

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

| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |

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

| master-bin.000013 |     1847 |              |                  |

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

 

2,slave 配置,

vim打开my.cnf文件

在[mysqld]下添加

 

server-id=2

relay-log-index=slave-relay-bin.index

relay-log=slave-relay-bin

重启服务

登录mysql

change master to master_host='10.0.1.88', //Master 服务器Ip
master_port=3306,
master_user='repl',
master_password='mysql', 
master_log_file='master-bin.000013',//Master服务器产生的日志
master_log_pos=0;

 

 

posted @ 2016-08-19 19:55  通往酱油的路上  阅读(116)  评论(0编辑  收藏  举报