`
- 浏览:
254533 次
- 性别:
- 来自:
未定
-
Replication enables data from one MySQL database server (the master) to be replicated to one or more MySQL database servers (the slaves). Replication is asynchronous by default.
Replication between servers in MySQL is based on the binary logging mechanism. The MySQL instance operating as the master (the source of the database changes) writes updates and changes as “events” to the binary log. The information in the binary log is stored in different logging formats according to the database changes being recorded. Slaves are configured to read the binary log from the master and to execute the events in the binary log on the slave's local database.
Replication works because events written to the binary log are read from the master and then processed on the slave. The events are recorded within the binary log in different formats according to the type of event.
1.Setting the Replication Master Configuration
[mysqld]
log-bin=mysql-bin
server-id=1
binlog_format=mixed
2.Setting the Replication Slave Configuration
[mysqld]
server-id=2
3.Creating a User for Replication
mysql> create user 'repl'@'%.bz.com' identified by '1234';
mysql> grant replication slave on *.* to 'repl'@'%.bz.com';
4.Obtaining the Replication Master Binary Log Coordinates
a. open an session to flush all tables and block:
mysql> flush table with read lock;
b. open another session to determine the current binary log file name and position:
mysql> show master status;
remeber the File and position for further use.
c. keep the first session read lock, now create a data snapshot with mysqldump,
mysqldump --all-databases --master-data > db.sql
the read lock prevent any further changes so that the data copied to the slave is in synchrony with the master.
d. unlock tables;(within the first session)
f. copy the master data to slave i another method to create a data snapshot
5.Setting Up Replication with Existing Data
a. The next step depends on how you created the snapshot of data on the master
if use mysqldump: start the slave with --skip-slave-start option and then import the dump sqldata
if use raw data: extract the dump data to the slave data directory and then start the slave with --skip-slave-start option
b. setting master configuration on the slave
mysql > change master to
> MASTER_HOST='192.168.1.111'
> MASTER_USER='repl'
> MASTER_PASSWORD='psw'
> MASTER_LOG_FILE='recorded_log_file'
> MASTER_LOG_POS=recorded_log_postion
c. start the slave
mysql > start slave;
6.Introducing Additional Slaves to an Existing Replication Environment
set up the new slave by making a copy of an existing slave, except that you configure the new slave with a different server-id value.
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
mysql replication搭建
MySql Replication Tutorial,关于MySql Replication 的 PPT
针对这一情况,提出在现有硬件的基础上利用JDBC规范与MySQL Replication实现数据库集群从而解决数据访问瓶颈。其主要方法是在进行JDBC连接之前实现负载均衡,所有SQL请求由负载均衡器进行统一调度。在数据库端利用...
MySQL Replication一主多从环境搭建
第18章 MySQL Replication(共27页).pptMySQL从入门到精通 第19章 MySQL Cluster(共49页).pptMySQL从入门到精通 第20章 PHP操作MySQL数据库(共7页).pptMySQL从入门到精通 第21章 MySQL实战-新闻发布系统数据库...
Mysql Replication HA 配置
mysql-replication mysql数据库主从复制步骤
胖子摸索出来的,Ubuntu上MySQL的Replication配置,的简单记录步骤
mysql replication修改库名及复制单个表
NULL 博文链接:https://risheng.iteye.com/blog/1853366
MySQL Replication PPT资源
MySQL Replication Tips and Tricks 关于mysql复制的使用技巧,在新版中的新特性,推荐!!
详细描述mysql-replication配置,mysql主从库切换,验证等
MySQL Group Replication 详细搭建部署过程
深入理解MySQL Group Replication.pdf
MySQLReplication主从复制全方位解决方案.docx
MySQL Replication(复制)已经在一些著名的网站和企业广泛应用以将数据库的扩展性提升到极限水平。对用户而言可以简单快速地为数据库创建多个副本,超越单个数据库实例容量的限制,弹性扩展数据库系统以满足快速增长...
mysql replication binlog php 同步工具 运行环境 目前只支持数据库utf8编码 php版本>=5.4 mysql版本>=5.1 需要安装php sockets扩展 运行用户需要有创建文件的权限
藏经阁-MySQL Replication Latest Developments.pdf
通过Heartbert2 让Mysql Replication 具有HA【pdf教程】