Merge lp:~hrvojem/percona-xtrabackup/pxb-128-2.1 into lp:percona-xtrabackup/2.1

Proposed by Hrvoje Matijakovic
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 599
Proposed branch: lp:~hrvojem/percona-xtrabackup/pxb-128-2.1
Merge into: lp:percona-xtrabackup/2.1
Diff against target: 99 lines (+84/-0)
2 files modified
doc/source/how-tos.rst (+1/-0)
doc/source/howtos/recipes_ibkx_gtid.rst (+83/-0)
To merge this branch: bzr merge lp:~hrvojem/percona-xtrabackup/pxb-128-2.1
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+163529@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'doc/source/how-tos.rst'
2--- doc/source/how-tos.rst 2013-04-30 12:43:40 +0000
3+++ doc/source/how-tos.rst 2013-05-13 13:32:30 +0000
4@@ -39,6 +39,7 @@
5
6 howtos/setting_up_replication
7 howtos/backup_verification
8+ howtos/recipes_ibkx_gtid
9
10 .. _aux-guides:
11
12
13=== added file 'doc/source/howtos/recipes_ibkx_gtid.rst'
14--- doc/source/howtos/recipes_ibkx_gtid.rst 1970-01-01 00:00:00 +0000
15+++ doc/source/howtos/recipes_ibkx_gtid.rst 2013-05-13 13:32:30 +0000
16@@ -0,0 +1,83 @@
17+.. _recipes_ibkx_gtid:
18+
19+=========================================================
20+How to create a new (or repair a broken) GTID based slave
21+=========================================================
22+
23+|MySQL| 5.6 introduced the new Global Transaction ID (`GTID <http://dev.mysql.com/doc/refman/5.6/en/replication-gtids-concepts.html>`_) support in replication. |Percona XtraBackup| from 2.1.0 version, automatically stores the ``GTID`` value in the :file:`xtrabackup_binlog_info` when doing the backup of |MySQL| and |Percona Server| 5.6 with the ``GTID`` mode enabled. This information can be used to create a new (or repair a broken) ``GTID`` based slave.
24+
25+
26+STEP 1: Take a backup from any server on the replication environment, master or slave
27+-------------------------------------------------------------------------------------
28+
29+Following command will take a backup to the /data/backups/$TIMESTAMP folder: ::
30+
31+ $ innobackupex /data/backups/
32+
33+In the destination folder there will be a file with the name :file:`xtrabackup_binlog_info`. This file will contain both, binary log coordinates and ``GTID`` information. ::
34+
35+ $ cat xtrabackup_binlog_info
36+ mysql-bin.000002 1232 c777888a-b6df-11e2-a604-080027635ef5:1-4
37+
38+That information is also printed by innobackupex after backup is taken: ::
39+
40+ innobackupex: MySQL binlog position: filename 'mysql-bin.000002', position 1232, gtid_executed c777888a-b6df-11e2-a604-080027635ef5:1-4
41+
42+STEP 2: Prepare the backup
43+--------------------------
44+
45+Back will be prepared with the following command:
46+
47+.. code-block:: console
48+
49+ TheMaster$ innobackupex --apply-log /data/backups/$TIMESTAMP/
50+
51+You need to select path where your snapshot has been taken, for example ``/data/backups/2013-05-07_08-33-33``. If everything is ok you should get the same OK message. Now the transaction logs are applied to the data files, and new ones are created: your data files are ready to be used by the MySQL server.
52+
53+STEP 3: Move the backup to the destination server
54+-------------------------------------------------
55+
56+Use :command:`rsync` or :command:`scp` to copy the data to the destination server. If you're syncing the data directly to already running slave's data directory it's advised to stop the |MySQL| server there.
57+
58+.. code-block:: console
59+
60+ TheMaster$ rsync -avprP -e ssh /path/to/backupdir/$TIMESTAMP NewSlave:/path/to/mysql/
61+
62+After you copy data over, make sure |MySQL| has proper permissions to access them.
63+
64+.. code-block:: console
65+
66+ NewSlave$ chown mysql:mysql /path/to/mysql/datadir
67+
68+STEP 4: Configure and start replication
69+---------------------------------------
70+
71+Following command will tell the new slave what was the last ``GTID`` executed on the master when backup was taken.
72+
73+.. code-block:: mysql
74+
75+ NewSlave > SET GLOBAL gtid_purged="c777888a-b6df-11e2-a604-080027635ef5:1-4";
76+ NewSlave > CHANGE MASTER TO
77+ MASTER_HOST="$masterip",
78+ MASTER_USER="repl",
79+ MASTER_PASSWORD="$slavepass",
80+ MASTER_AUTO_POSITION = 1;
81+
82+STEP 5: Check the replication status
83+------------------------------------
84+
85+Following command will show the slave status:
86+
87+.. code-block:: mysql
88+
89+ NewSlave > show slave status\G
90+ [..]
91+ Slave_IO_Running: Yes
92+ Slave_SQL_Running: Yes
93+ [...]
94+ Retrieved_Gtid_Set: c777888a-b6df-11e2-a604-080027635ef5:5
95+ Executed_Gtid_Set: c777888a-b6df-11e2-a604-080027635ef5:1-5
96+
97+We can see that the slave has retrieved a new transaction with number 5, so transactions from 1 to 5 are already on this slave.
98+
99+That's all, we have created a new slave in our ``GTID`` based replication environment.

Subscribers

People subscribed via source and target branches