Mysql replication 配置
来源:互联网 发布:怎么开通淘宝达人 编辑:程序博客网 时间:2024/05/19 20:48
MySQL 设定写入 Master 后, 自动 Replication 到 Slave 去, 运作基本原理是:
- INSERT/UPDATE/DELETE 语法, 自动写入 Master 的 binlog file.
- 由 GRANT REPLICATION 授权的账号, 自动将 SQL 语法 repl 到 Slave 的 DB 执行.
- 因而完成 Replication 的动作.
操作系统:Linux
Master端IP:192.168.2.122
Slave端IP:192.168.2.123
注意:在做配置的过程中,最好不要向 Master 数据库做写入操作。
1 主机master设置
1.1 测试用数据库
1.
create database test1;
2.
CREATE TABLE `test1` ( `id` bigint(20) unsignedNOT NULL AUTO_INCREMENT,
3.
INSERT INTO `test1` VALUES (1,'name1');
INSERT INTO `test1` VALUES (2,'name2');
INSERT INTO `test1` VALUES (3,'name3');
1.2 设置Mysql Replication
1.
mysql>GRANT REPLICATIONSLAVE,REPLICATION CLIENT,RELOAD,SUPER ON *.* TO'root'@'192.168.2.123' IDENTIFIED BY 'password';
(授与从192.168.2.123主机上登录用户root数据复制权限)
2.
mysql>flush privileges;
3.
mysql> exit
4.
service mysqld stop
5.
1)
vi /etc/my.cnf
2)
#bind-address = 127.0.0.1
server-id = 1 (注意不能与其他服务器的配置一样)
log_bin = /var/log/mysql/mysql-bin.log
# 若是 innodb, 且有用 transaction 的话, 需再加入下面两行
innodb_flush_log_at_trx_commit=1
sync_binlog=1
#如果指定具体的数据库,需加入下面一行
binlog-do-db= test1
3)
mysql>show master status; #这边资料都要记好,等一下设定slave要用
+----------------------+------------+------------------+----------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+----------------------+------------+------------------+----------------------+
| mysql-bin.000014 | 232 | | |
+----------------------+------------+------------------+----------------------+
6.
tar czvf /var/lib/mysql/test1.tar.gztest1
7.
service mysqld start
2 备机slave设置
1.
3)
vi /etc/my.cnf
4)
master-host = 192.168.2.122
master-user = root
master-password = password
master-port = 3306
master-connect-retry = 10
master_log_file='mysql-bin.000014'# 这边就要用到之前 Master 抄下来的值.
master_log_pos=232 # 这边就要用到之前 Master 抄下来的值.
replicate-do-db = test1 #当需要具体到某个数据库的时候,才配置该行
2.
cd /var/lib/mysql
tar zxvf
chmod 700 test1
chmod 660 test1
3.
service mysqld
4.
mysql> START SLAVE;
查看slave状态:
mysql> show slavestatus\G;
*************************** 1. row***************************
Replicate_Wild_Ignore_Table:
1 row in set (0.00 sec)
******************************************************
可以看到
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
如果都是yes,代表已经在同步
至此server服务器上的Mysql设置完毕
3 测试
1.
2.
3.
4.
- mysql replication 配置方法
- 配置MySQL Replication
- Mysql replication 配置
- 配置MySQL Replication
- MySQL Replication主从配置
- MySql Replication配置
- MySql Replication配置
- mysql之replication配置
- MySQL replication 主从配置
- 配置MySQL主从复制(Replication)
- MySQL Master Slave Replication配置
- 配置MySQL主从复制(Replication)
- MySQL Group Replication 安装配置
- mysql replication 基本原理,mysql主从配置原理
- mysql replication(mysql配置主从)
- Mysql Replication的安装和配置
- mysql replication很脑残的一个配置
- 【转】配置MySQL主从复制(Replication)服务
- [Linux] Ibus添加GooglePinyin
- 【转】Visual Studio 2010下配置PC-Lint 9.0i
- javascript--Math.random方法
- 有关UIView、subview的几个基础知识点
- /dev/null 2>&1详解
- Mysql replication 配置
- 流程图说明
- flex和Flash的区别
- 第三方苹果开发库之ASIHTTPRequest(翻译版)
- 操作系统--2,操作系统的分类
- Android 编译系统(一):Android.mk的学习
- 完全卸载oracle11g步骤
- 分享信息到微信
- 项目管理SPI,CPI,CV,SV