标签:mysql主从
mysql主从replication 主master 从slave 从mysql服务器根据主master的日志更新, master -change data- bin_log -transger-> slave --> repl_log --> change data (1)master mysql安装配置 (2)slave mysql安装配置 (3)master mysql配置 (a)vim /etc/my.cnf #设置 server-id #master和slave上的server-id不能一样 log-bin #设置log-bin名称 #binlog-do-db 要做主从的数据可名称 #binlog-ignore-db 不做主从的数据库名称 #重启mysql服务 service mysqld restart (b)登入master mysql设置 #赋权限给slave mysql #grant repelication slave on *.* to ‘repl‘@‘127.0.0.1‘ identified by ‘123123‘; grant repelication slave on *.* to user@salve_ip identified by ‘password‘; #刷新权限 flush privileges; #锁定 flush tables with read lock; show master status; (4)slave mysql配置 (a)vim /etc/my.cnf #设置 server-id #master和slave上的server-id不能一样 #log-bin #设置log-bin名称 #binlog-do-db 要做主从的数据可名称 #binlog-ignore-db 不做主从的数据库名称 #replicate-do-db #replicate-ignore-db #重启mysql服务 service mysqld restart (b)登入slave mysql设置 #暂停slave mysql slave stop #设置slave mysql的master mysql #master_host:主mysql服务器的ip #master_port:主mysql服务器mysql的端口 #master_user: #master_password: #master_log_file,master_log_pos指的是master mysql上执行show master status查询的结果; change master to master_host=‘127.0.0.1‘,master_port=3306,master_user=‘repl‘,master_password=‘123123‘,master_log_file=‘aming.******‘,master_log_pos=106; #开启slave mysql slave start #查看slave mysql状态 #主要是查看Slave_IO_Running及Slave_SQL_Running后是否为YES show slave status\G; (5)解锁master mysql #进入master mysql; unlock tables; (6)测试mysql主从是否设置成功,在master mysql操作检测
标签:mysql主从
原文地址:http://thankinglove.blog.51cto.com/2311485/1769768