.1 Setting the Replication Master Configuration
/etc/my.cnf
[mysqld] basedir = /usr/local/mysql datadir = /var/lib/mysql port = 3306 #socket = /var/lib/mysql/mysql.sock user=mysql bind_address = :: #bin log conf log_bin = mysql-bin binlog_checksum = NONE binlog_format = ROW server-id = 2 innodb_flush_log_at_trx_commit=1 sync_binlog=1
2 Setting the Replication Slave Configuration
/etc/my.cnf basedir = /usr/local/mysql datadir = /var/lib/mysql port = 3306 server_id = 3 # socket = ..... user=mysql relay-log=mysqld-relay-bin report-host=hostname
3 Creating a User for Replication In master
mysql> CREATE USER 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.mydomain.com';
4 Obtaining the Replication Master Binary Log Coordinates
To obtain the master binary log coordinates, follow these steps:
-
Start a session on the master by connecting to it with the command-line client, and flush all tables and block write statements by executing the
FLUSH TABLES WITH READ LOCK
statement:mysql>
FLUSH TABLES WITH READ LOCK;
For
InnoDB
tables, note thatFLUSH TABLES WITH READ LOCK
also blocksCOMMIT
operations.WarningLeave the client from which you issued the
FLUSH TABLES
statement running so that the read lock remains in effect. If you exit the client, the lock is released. -
In a different session on the master, use the
SHOW MASTER STATUS
statement to determine the current binary log file name and position:mysql >
SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000003 | 73 | test | manual,mysql | +------------------+----------+--------------+------------------+The
File
column shows the name of the log file andPosition
shows the position within the file. In this example, the binary log file ismysql-bin.000003
and the position is 73. Record these values. You need them later when you are setting up the slave. They represent the replication coordinates at which the slave should begin processing new updates from the master.If the master has been running previously without binary logging enabled, the log file name and position values displayed by
SHOW MASTER STATUS
or mysqldump --master-data will be empty. In that case, the values that you need to use later when specifying the slave's log file and position are the empty string (''
) and4
.
5 Creating a Data Snapshot Using mysqldump
shell> mysqldump --all-databases --master-data > dbdump.db
6 Setting Up Replication with Existing Data
-
Start the slave, using the
--skip-slave-start
option so that replication does not start. -
Import the dump file:
shell>
mysql < fulldb.dump
mysql>CHANGE MASTER TO
->MASTER_HOST='
->master_host_name
',MASTER_USER='
->replication_user_name
',MASTER_PASSWORD='
->replication_password
',MASTER_LOG_FILE='
->recorded_log_file_name
',MASTER_LOG_POS=
recorded_log_position
;
d. Start the slave threads:
mysql> START SLAVE;
http://dev.mysql.com/doc/refman/5.6/en/replication-howto.html
相关推荐
After this, you'll learn how to set up replication, use load balancing to scale horizontally, and troubleshoot errors. Finally, you will get acquainted with useful tools available in the PostgreSQL ...
this, you'll learn how to set up replication, use load balancing to scale horizontally, and troubleshoot errors. As you continue through this book, you will see the significant impact of configuration...
After this, you'll learn how to set up replication, use load balancing to scale horizontally, and troubleshoot errors. Finally, you will get acquainted with useful tools available in the PostgreSQL ...
The book shows you how to set up and configure the Trove DBaaS framework, use prepackaged or custom database implementations, and provision and operate a variety of databases - including MySQL, ...
The book shows you how to set up and configure the Trove DBaaS framework, use prepackaged or custom database implementations, and provision and operate a variety of databases—including MySQL, ...
Chapter 9, Replication, explains how to set up various replication topologies. The recipes on switching a slave from master-slave to chain replication and switching a slave from chain replication to ...
Learn how to set up a cluster that can face a tornado of data reads and writes without wincing. If you are a beginner, you can use the examples to help you play around with Cassandra and test the ...
Since Trove is one of the most recent projects of OpenStack, DBAs and system administrators can find it difficult to set up and run a DBaaS using OpenStack Trove. This book helps DBAs make that step. ...
Chapter 7, Security Techniques (Guard Your Data), shows how to set up basic security with Redis, disable and obfuscate commands, protect Redis with firewall rules, and use client-to-server SSL ...
Chapter 2, Setting Up a Kafka Cluster, describes the steps required to set up a single- or multi-broker Kafka cluster and shares the Kafka broker properties list. Chapter 3, Kafka Design, discusses ...
This book will teach you how to use Storm for real-time data processing and to make your applications highly available with no downtime using Cassandra. The book starts off with the basics of Storm ...
This book will teach you how to use Storm for real-time data processing and to make your applications highly available with no downtime using Cassandra. The book starts off with the basics of Storm ...
Set up, manage, and configure the new InnoDB Cluster feature in MySQL from Oracle. If you are growing your MySQL installation and want to explore making your servers highly available, this book ...
Perform backup tasks, recover data and set up various replication topologies for your database Maximize performance by using new features of MySQL 8 like descending indexes, controlling query ...
How do you handle replica set failure and failover? This collection of MongoDB tips, tricks, and hacks helps you resolve issues with everything from application design and implementation to data ...
Here’s how to set up a cluster using Docker: ##### Load Balancer A load balancer distributes incoming traffic across nodes in the cluster. For Payara, you can use a software load balancer like ...