mysql master slave 搭建
来源:互联网 发布:java小项目开发案例 编辑:程序博客网 时间:2024/05/17 20:31
mysql master slave 搭建
master:192.168.1.113
slave:192.168.1.131
一、配置master
修改mysql.ini
server-id=1#master的标示
log-bin=mysql-bin#slave会基于此log-bin来做replication
binlog-do-db=godhd#用于master-slave的具体数据库
binlog-ignore-db=mysql#忽略的数据库
二、创建远程帐号并授予权限
mysql>grant REPLICATION SLAVE on *.* to slave@'%' identified by 'slave';
三、查看master信息
mysql>show master stauts;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000017 | 8133 | | |
+------------------+----------+--------------+------------------+
记好file和position
四、配置slave
server-id=2#slave标记
master-host=192.168.1.113#master主机master-user=slave#访问master的用户名
master-password=slave#访问master的密码
master-port=3306#端口
master-connect-retry=10#重试间隔时间10秒
replicate-do-db=**** #需要同步的数据库
log-slave-updates #启用从库日志,这样可以进行链式复制
read-only=1 #从库是否只读,0表示可读写,1表示只读
五、在slave连接上mysql
mysql> slave stop;(slave 默认可能是开启的)
mysql> change master to master_host='192.168.1.113',master_user='slave',master_password='slave',master_log_file='mysql-bin.000017',master_log_pos=8133
mysql>show slave status\G;
查看slave状态:
slave_io_running:yes
slave_sql_running:yes
这2点状态必须是yes的,否则不能同步
如果状态不对,可查看last_io_running和slave_sql_running报的错误,来找原因
如:last_io_error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it)
意思是slave和master的server_id相同,这是就应该检查下master和slave中server_id的配置,
mysql> show variables like 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | 1 |
+---------------+-------+
发现,mysql并没有从my.ini文件中更新server_id,既然这样就只能手动修改了
mysql> set global server_id=2; #此处的数值和my.cnf里设置的一样就行
mysql>slave start;就可以启动同步了
至此,完成。
- mysql master slave 搭建
- 搭建mysql master-slave replication
- Mysql Master/Slave环境搭建
- mySQL搭建master&slave环境记录
- Ubuntu10下MySQL搭建Master Slave
- 用meb搭建mysql master/slave
- MYSQL搭建双master-slave环境一系列问题
- MYSQL的master,slave环境的搭建
- MySQL Master-Slave 主从复制环境搭建
- 搭建MySQL的Master/Slave架构
- 搭建MySql的Master/Slave架构
- Windows下搭建MySQL Master Slave
- Ubuntu10下MySQL搭建Master Slave
- MySQL_Windows下搭建MySQL Master Slave
- mysql 5.6安装及Master/Slave搭建
- mysql 的master-slave的搭建
- MySQL 5.7搭建Master-Slave实践
- 搭建mysql的master-slave环境(mysql主从复制)
- 例题3-6
- #遍历E盘下的mp3文件
- UVa 11992 - Fast Matrix Operations 成段更新,求最值与和
- Liferay安装笔记(默认安装使用Mysql数据库)
- webkit 中 javascript 与 WebCore DOM 的绑定
- mysql master slave 搭建
- 为android程序添加背景音乐和Menu菜单
- 获取上一个页面的跳转地址
- C#开源资源大汇总
- 关于ORACLE的UPDATE更新多表的问题
- 转化为ico文件
- oracle 联表 update
- mybatis的参数
- C++标准库中的find()函数