init
commit
6d5936c8eb
@ -0,0 +1,23 @@
|
|||||||
|
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Folders
|
||||||
|
_obj
|
||||||
|
_test
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Architecture specific extensions/prefixes
|
||||||
|
*.[568vq]
|
||||||
|
[568vq].out
|
||||||
|
|
||||||
|
*.cgo1.go
|
||||||
|
*.cgo2.c
|
||||||
|
_cgo_defun.c
|
||||||
|
_cgo_gotypes.go
|
||||||
|
_cgo_export.*
|
||||||
|
|
||||||
|
_testmain.go
|
||||||
|
|
||||||
|
*.exe
|
@ -0,0 +1,339 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
{description}
|
||||||
|
Copyright (C) {year} {fullname}
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
{signature of Ty Coon}, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
@ -0,0 +1,79 @@
|
|||||||
|
mysql_binlog_utils
|
||||||
|
==================
|
||||||
|
|
||||||
|
Some utilities for mysql binlog
|
||||||
|
|
||||||
|
WARNING: these utilities are tested for mysql 5.5.33, but are not tested for mysql 5.6+
|
||||||
|
|
||||||
|
Dump binlog from pos
|
||||||
|
----
|
||||||
|
`DumpBinlogFromPos(srcFilePath string, startPos int, targetFilePath string)`
|
||||||
|
|
||||||
|
This function will dump binlog (at `srcFilePath`) from pos (`startPos`), and the output is at `targetFilePath`
|
||||||
|
|
||||||
|
If the `startPos` is 0 or 4, the whole binlog will be dump. Otherwise, the source binlog header (including `FORMAT_DESCRIPTION_EVENT` & `ROTATE_EVENT` & `PREVIOUS_GTIDS_LOG_EVENT`) will be dump as the target binlog header, and then the source data will be dump from `startPos`
|
||||||
|
|
||||||
|
This will make target binlog complete and available to replay.
|
||||||
|
|
||||||
|
Rotate relay log
|
||||||
|
----
|
||||||
|
`RotateRelayLog(relayLogPath string, endPos int)`
|
||||||
|
|
||||||
|
This function will add a rotate event to a relay log (at `relayLogPath`), after the position (`endPos`), and truncate the data after the position (`endPos`)
|
||||||
|
|
||||||
|
WARNING: after manually rotate relay log, DONOT forget to update `relay-log.index`
|
||||||
|
|
||||||
|
Fake master server
|
||||||
|
----
|
||||||
|
`NewFakeMasterServer(port int, unusedServerId int, characterSet int, keepAliveWhenFinish bool, baseDir string)`
|
||||||
|
|
||||||
|
WARNING: only support mysql 5.5.x
|
||||||
|
|
||||||
|
This fake master server is very helpful if you want to replay some binlog files to a mysql instance, and you're afraid of `mysqlbinlog` (http://bugs.mysql.com/bug.php?id=33048, for example)
|
||||||
|
|
||||||
|
Mysql replication is [more reliable way](http://www.xaprb.com/blog/2010/09/04/why-mysql-replication-is-better-than-mysqlbinlog-for-recovery/) to replay binlog, what we need is :
|
||||||
|
|
||||||
|
1. server := NewFakeMasterServer(...)
|
||||||
|
2. server.Start()
|
||||||
|
3. In target mysql instance, `change master` to the fake server, and `start slave`
|
||||||
|
4. the server will be closed when done or error
|
||||||
|
5. you can abort the server by `server.Abort()`
|
||||||
|
|
||||||
|
####Some other features:
|
||||||
|
|
||||||
|
1. `start slave until` is also supported
|
||||||
|
2. large packet (>= `1<<24-1` bytes) is supported
|
||||||
|
3. multiple binlog files are supported, fake server will act as a real replication master (rotate to the next when one is finished)
|
||||||
|
|
||||||
|
####Arguments:
|
||||||
|
|
||||||
|
Argument|_
|
||||||
|
--- | ---
|
||||||
|
`port` | the fake server port
|
||||||
|
`unusedServerId` | the fake server id, should not be duplicate with any other mysql instance
|
||||||
|
`characterSet` |the fake server character set id, should be the same with target mysql instance's. You can get the id by `SELECT id, collation_name FROM information_schema.collations ORDER BY id`
|
||||||
|
`keepAliveWhenFinish` |when false, the fake server will quit when all binlogs are replayed. when true, the fake server will wait for more binlogs.
|
||||||
|
`baseDir` | where the binlog files are located
|
||||||
|
|
||||||
|
|
||||||
|
Get unexecuted binlog files by gtid
|
||||||
|
----
|
||||||
|
|
||||||
|
`GetUnexecutedBinlogFilesByGtid(binlogDir string, binlogBaseName string, executedGtidDesc string) (ret []string, err error)`
|
||||||
|
|
||||||
|
This function will search binlog files in `binlogDir`, for the one contains a event whose gtid is not contained in `executedGtidDesc`
|
||||||
|
|
||||||
|
The scenario is in mysql replication, if mysql master is broken, mysql slave can call `GetUnexecutedBinlogFilesByGtid` to search in mysql master binlog dir, for the binlog files which need to be replay in slave
|
||||||
|
|
||||||
|
|
||||||
|
Get unexecuted binlog pos by gtid
|
||||||
|
---
|
||||||
|
|
||||||
|
`GetUnexecutedBinlogPosByGtid(binlogFilePath string, executedGtidDesc string) (pos uint, err error) `
|
||||||
|
|
||||||
|
This function will search first binlog event pos, which is not contained in `executedGtidDesc`, in binlog file (`binlogFilePath`)
|
||||||
|
|
||||||
|
Or return `EOF` error if has no unexecuted binlog event
|
||||||
|
|
||||||
|
----
|
||||||
|
####Pull requests and issues are warmly welcome
|
@ -0,0 +1 @@
|
|||||||
|
binlog starttime stoptime startpos stoppos rows duration tables
|
@ -0,0 +1,39 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var binlogFileSuffixPattern = regexp.MustCompile("\\d\\d\\d\\d\\d\\d$")
|
||||||
|
|
||||||
|
func NextBinlogPath(binlogPath string) (string, error) {
|
||||||
|
r := regexp.MustCompile("(.*)\\.(\\d\\d\\d\\d\\d\\d)$")
|
||||||
|
if !r.MatchString(binlogPath) {
|
||||||
|
return "", fmt.Errorf("path %v is not a binlog path", binlogPath)
|
||||||
|
}
|
||||||
|
matches := r.FindStringSubmatch(binlogPath)
|
||||||
|
seq, _ := strconv.Atoi(matches[2])
|
||||||
|
return fmt.Sprintf("%v.%06d", matches[1], seq+1), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func BinlogIndexPath(binlogPath string) (string, error) {
|
||||||
|
r := regexp.MustCompile("(.*)\\.(\\d\\d\\d\\d\\d\\d)$")
|
||||||
|
if !r.MatchString(binlogPath) {
|
||||||
|
return "", fmt.Errorf("path %v is not a binlog path", binlogPath)
|
||||||
|
}
|
||||||
|
matches := r.FindStringSubmatch(binlogPath)
|
||||||
|
return fmt.Sprintf("%v.index", matches[1]), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NextBinlogName(binlogPath string) (string, error) {
|
||||||
|
if path, err := NextBinlogPath(binlogPath); nil != err {
|
||||||
|
return "", err
|
||||||
|
} else {
|
||||||
|
path = strings.Replace(path, "\\", "/", -1) //fix windows-style path
|
||||||
|
return filepath.Base(path), nil
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
binlog starttime stoptime startpos stoppos inserts updates deletes database table
|
@ -0,0 +1,25 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNextBinlogPath(t *testing.T) {
|
||||||
|
a, err := NextBinlogPath("/opt/mysql-relay-log.000199")
|
||||||
|
if nil != err {
|
||||||
|
t.Errorf("got err %v", err)
|
||||||
|
}
|
||||||
|
if "/opt/mysql-relay-log.000200" != a {
|
||||||
|
t.Errorf("got wrong return %v", a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNextBinlogName(t *testing.T) {
|
||||||
|
a, err := NextBinlogName("/opt/mysql-relay-log.000199")
|
||||||
|
if nil != err {
|
||||||
|
t.Errorf("got err %v", err)
|
||||||
|
}
|
||||||
|
if "mysql-relay-log.000200" != a {
|
||||||
|
t.Errorf("got wrong return %v", a)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,109 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func innerDumpBinlogFromPos(srcFilePath string, startPos uint, dumpEmptyBinlog bool, targetFilePath string) error {
|
||||||
|
tracef("dump binlog from pos : srcFilePath=%v, startPos=%v, targetFilePath=%v", srcFilePath, startPos, targetFilePath)
|
||||||
|
srcFile, err := os.Open(srcFilePath)
|
||||||
|
if nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer srcFile.Close()
|
||||||
|
|
||||||
|
stat, err := srcFile.Stat()
|
||||||
|
if nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
srcFileSize := uint(stat.Size())
|
||||||
|
|
||||||
|
if dumpEmptyBinlog {
|
||||||
|
startPos = srcFileSize
|
||||||
|
}
|
||||||
|
|
||||||
|
if startPos > srcFileSize {
|
||||||
|
return fmt.Errorf("startPos (%v) >= binlog file size (%v)", startPos, srcFileSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
emptyFile := startPos == srcFileSize
|
||||||
|
headerBs := make([]byte, 19)
|
||||||
|
headerEndPos := uint(4)
|
||||||
|
|
||||||
|
for {
|
||||||
|
if _, err := srcFile.Seek(int64(headerEndPos), 0); nil != err {
|
||||||
|
if "EOF" == err.Error() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.ReadFull(srcFile, headerBs); nil != err {
|
||||||
|
if "EOF" == err.Error() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
eventType := int(headerBs[4])
|
||||||
|
length := binary.LittleEndian.Uint32(headerBs[9:13])
|
||||||
|
if FORMAT_DESCRIPTION_EVENT != eventType && ROTATE_EVENT != eventType && PREVIOUS_GTIDS_LOG_EVENT != eventType {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
headerEndPos += uint(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
if headerEndPos >= srcFileSize {
|
||||||
|
emptyFile = true
|
||||||
|
} else if startPos < headerEndPos {
|
||||||
|
return fmt.Errorf("dump binlog from startPos (%v) failed, pos < headerEndPos (%v) ", startPos, headerEndPos)
|
||||||
|
}
|
||||||
|
|
||||||
|
if target, err := os.Create(targetFilePath); nil != err {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
defer target.Close()
|
||||||
|
if _, err := srcFile.Seek(0, 0); nil != err {
|
||||||
|
os.Remove(targetFilePath)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.CopyN(target, srcFile, int64(headerEndPos)); nil != err {
|
||||||
|
os.Remove(targetFilePath)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !emptyFile {
|
||||||
|
if _, err := srcFile.Seek(int64(startPos), 0); nil != err {
|
||||||
|
os.Remove(targetFilePath)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.Copy(target, srcFile); nil != err {
|
||||||
|
os.Remove(targetFilePath)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DumpBinlogFromPos(srcFilePath string, startPos uint, targetFilePath string) error {
|
||||||
|
return innerDumpBinlogFromPos(srcFilePath, startPos, false, targetFilePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DumpUnexecutedBinlogByGtid(srcFilePath string, executedGtidDesc string, targetFilePath string, includeEventBeforeFirst bool) error {
|
||||||
|
pos, err := GetUnexecutedBinlogPosByGtid(srcFilePath, executedGtidDesc, includeEventBeforeFirst)
|
||||||
|
if nil != err {
|
||||||
|
if "EOF" == err.Error() {
|
||||||
|
return innerDumpBinlogFromPos(srcFilePath, 0, true, targetFilePath)
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return innerDumpBinlogFromPos(srcFilePath, pos, false, targetFilePath)
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDumpBinlogFromPos0(t *testing.T) {
|
||||||
|
defer os.Remove("./test/test-mysql-bin-dump")
|
||||||
|
if err := DumpBinlogFromPos("./test/test-mysql-bin", 107, "./test/test-mysql-bin-dump"); nil != err {
|
||||||
|
t.Errorf("expect no err, but got %v", err)
|
||||||
|
}
|
||||||
|
if err := exec.Command("sh", "-c", "./test/mysqlbinlog ./test/test-mysql-bin-dump > /dev/null").Run(); nil != err {
|
||||||
|
t.Errorf("expect dump log could be parsed by mysqlbinlog, but failed with err=%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDumpBinlogFromPos1(t *testing.T) {
|
||||||
|
defer os.Remove("./test/test-mysql-bin-dump")
|
||||||
|
if err := DumpBinlogFromPos("./test/test-mysql-bin", 24959, "./test/test-mysql-bin-dump"); nil != err {
|
||||||
|
t.Errorf("expect no err, but got %v", err)
|
||||||
|
}
|
||||||
|
if err := exec.Command("sh", "-c", "./test/mysqlbinlog ./test/test-mysql-bin-dump > /dev/null").Run(); nil != err {
|
||||||
|
t.Errorf("expect dump log could be parsed by mysqlbinlog, but failed with err=%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDumpUnexecutedBinlogByGtid(t *testing.T) {
|
||||||
|
defer os.Remove("./test/test-mysql-bin-dump")
|
||||||
|
if err := DumpUnexecutedBinlogByGtid("./test/mysql-bin56.000003", "f60ab33c-c604-11e3-8e1c-e66ccf50db66:1-73", "./test/test-mysql-bin-dump", false); nil != err {
|
||||||
|
t.Errorf("expect no err, but got %v", err)
|
||||||
|
}
|
||||||
|
if err := exec.Command("sh", "-c", "./test/mysqlbinlog ./test/test-mysql-bin-dump > /dev/null").Run(); nil != err {
|
||||||
|
t.Errorf("expect dump log could be parsed by mysqlbinlog, but failed with err=%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDumpBinlogWithOnlyHeader(t *testing.T) {
|
||||||
|
defer os.Remove("./test/test-mysql-bin-dump")
|
||||||
|
if err := DumpBinlogFromPos("./test/only-header-mysql-bin", 231, "./test/test-mysql-bin-dump"); nil != err {
|
||||||
|
t.Errorf("expect no err, but got %v", err)
|
||||||
|
}
|
||||||
|
if err := exec.Command("sh", "-c", "./test/mysqlbinlog ./test/test-mysql-bin-dump > /dev/null").Run(); nil != err {
|
||||||
|
t.Errorf("expect dump log could be parsed by mysqlbinlog, but failed with err=%v", err)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
const (
|
||||||
|
UNKNOWN_EVENT = 0
|
||||||
|
START_EVENT_V3 = 1
|
||||||
|
QUERY_EVENT = 2
|
||||||
|
STOP_EVENT = 3
|
||||||
|
ROTATE_EVENT = 4
|
||||||
|
INTVAR_EVENT = 5
|
||||||
|
LOAD_EVENT = 6
|
||||||
|
SLAVE_EVENT = 7
|
||||||
|
CREATE_FILE_EVENT = 8
|
||||||
|
APPEND_BLOCK_EVENT = 9
|
||||||
|
EXEC_LOAD_EVENT = 10
|
||||||
|
DELETE_FILE_EVENT = 11
|
||||||
|
NEW_LOAD_EVENT = 12
|
||||||
|
RAND_EVENT = 13
|
||||||
|
USER_VAR_EVENT = 14
|
||||||
|
FORMAT_DESCRIPTION_EVENT = 15
|
||||||
|
XID_EVENT = 16
|
||||||
|
BEGIN_LOAD_QUERY_EVENT = 17
|
||||||
|
EXECUTE_LOAD_QUERY_EVENT = 18
|
||||||
|
TABLE_MAP_EVENT = 19
|
||||||
|
PRE_GA_WRITE_ROWS_EVENT = 20
|
||||||
|
PRE_GA_UPDATE_ROWS_EVENT = 21
|
||||||
|
PRE_GA_DELETE_ROWS_EVENT = 22
|
||||||
|
WRITE_ROWS_EVENT_V1 = 23
|
||||||
|
UPDATE_ROWS_EVENT_V1 = 24
|
||||||
|
DELETE_ROWS_EVENT_V1 = 25
|
||||||
|
INCIDENT_EVENT = 26
|
||||||
|
HEARTBEAT_LOG_EVENT = 27
|
||||||
|
IGNORABLE_LOG_EVENT = 28
|
||||||
|
ROWS_QUERY_LOG_EVENT = 29
|
||||||
|
WRITE_ROWS_EVENT = 30
|
||||||
|
UPDATE_ROWS_EVENT = 31
|
||||||
|
DELETE_ROWS_EVENT = 32
|
||||||
|
GTID_LOG_EVENT = 33
|
||||||
|
ANONYMOUS_GTID_LOG_EVENT = 34
|
||||||
|
PREVIOUS_GTIDS_LOG_EVENT = 35
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
LOG_EVENT_FIXED_HEADER_LEN = 19
|
||||||
|
MAX_ALLOWED_PACKET = 1024 * 1024 * 1024
|
||||||
|
)
|
||||||
|
|
||||||
|
type EventFixedHeader struct {
|
||||||
|
Bytes []byte
|
||||||
|
Timestamp int
|
||||||
|
EventType int
|
||||||
|
ServerId int
|
||||||
|
EventLength uint
|
||||||
|
NextPosition int
|
||||||
|
Flags int
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventFixedData struct {
|
||||||
|
Bytes []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventVariableData struct {
|
||||||
|
Bytes []byte
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"b612.me/mysql/gtid"
|
||||||
|
"io/ioutil"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetAllGtidOfBinlogDir(binlogDir, binlogBaseName string) (gtidDesc string, err error) {
|
||||||
|
files, err := ioutil.ReadDir(binlogDir)
|
||||||
|
if nil != err {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
var binlogFiles []string
|
||||||
|
for _, file := range files {
|
||||||
|
if strings.HasPrefix(file.Name(), binlogBaseName+".") && binlogFileSuffixPattern.MatchString(file.Name()) {
|
||||||
|
binlogFiles = append(binlogFiles, file.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if 0 == len(binlogFiles) {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
lastFile := filepath.Join(binlogDir, binlogFiles[len(binlogFiles)-1])
|
||||||
|
lastPreviousGtid, err := GetPreviousGtids(lastFile)
|
||||||
|
if nil != err {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
lastBinlogGtid, err := GetGtidOfBinlog(lastFile)
|
||||||
|
if nil != err {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
sum, err := gtid.Add(lastPreviousGtid, lastBinlogGtid)
|
||||||
|
if nil != err {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return sum, nil
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetAllGtidOfBinlogDir(t *testing.T) {
|
||||||
|
desc, err := GetAllGtidOfBinlogDir("./test", "mysql-bin56")
|
||||||
|
if nil != err {
|
||||||
|
t.Fatalf("unexpected error %v", err)
|
||||||
|
}
|
||||||
|
if "7E23401AC60311E38E135E10E6A05CFB:1-6,8186FC1EC5FF11E38DF9E66CCF50DB66:1-11,A6CE328CC60211E38E0DE66CCF50DB66:1-6,B7009920C60111E38E075E10E6A05CFB:1-6,F60AB33CC60411E38E1CE66CCF50DB66:1-136" != desc {
|
||||||
|
t.Fatalf("wrong gtid %v", desc)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetFirstPreviousGtidOfBinlogDir(binlogDir, binlogBaseName string) (gtidDesc string, err error) {
|
||||||
|
files, err := ioutil.ReadDir(binlogDir)
|
||||||
|
if nil != err {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
var binlogFiles []string
|
||||||
|
for _, file := range files {
|
||||||
|
if strings.HasPrefix(file.Name(), binlogBaseName+".") && binlogFileSuffixPattern.MatchString(file.Name()) {
|
||||||
|
binlogFiles = append(binlogFiles, file.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if 0 == len(binlogFiles) {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
firstFile := filepath.Join(binlogDir, binlogFiles[0])
|
||||||
|
ret, err := GetPreviousGtids(firstFile)
|
||||||
|
return ret, err
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetFirstPreviousGtidOfBinlogDir(t *testing.T) {
|
||||||
|
gtidDesc, err := GetFirstPreviousGtidOfBinlogDir("./test", "mysql-bin56")
|
||||||
|
if nil != err {
|
||||||
|
t.Fatalf("unexpected error %v", err)
|
||||||
|
}
|
||||||
|
if "" != gtidDesc {
|
||||||
|
t.Fatalf("wrong gtid %v", gtidDesc)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"b612.me/mysql/gtid"
|
||||||
|
"encoding/binary"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetGtidOfBinlog(binlogPath string) (gtidDesc string, err error) {
|
||||||
|
file, err := os.Open(binlogPath)
|
||||||
|
if nil != err {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
p := uint32(4)
|
||||||
|
headerBs := make([]byte, 19)
|
||||||
|
gtidBs := make([]byte, 25)
|
||||||
|
myGtid, err := gtid.Parse(gtidDesc)
|
||||||
|
if err != nil {
|
||||||
|
return gtidDesc, err
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
if _, err := file.Seek(int64(p), 0); nil != err {
|
||||||
|
if "EOF" == err.Error() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return myGtid.String(), err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.ReadFull(file, headerBs); nil != err {
|
||||||
|
if "EOF" == err.Error() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return myGtid.String(), err
|
||||||
|
}
|
||||||
|
|
||||||
|
length := binary.LittleEndian.Uint32(headerBs[9:13])
|
||||||
|
eventType := int(headerBs[4])
|
||||||
|
|
||||||
|
if GTID_LOG_EVENT != eventType {
|
||||||
|
p += length
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.ReadFull(file, gtidBs); nil != err {
|
||||||
|
if "EOF" == err.Error() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return myGtid.String(), err
|
||||||
|
}
|
||||||
|
|
||||||
|
uuid := bytesToUuid(gtidBs[1:17])
|
||||||
|
number := bytesToUint64(gtidBs[17:])
|
||||||
|
if err = myGtid.AddGtid(uuid, number); nil != err {
|
||||||
|
return myGtid.String(), err
|
||||||
|
}
|
||||||
|
|
||||||
|
p += length
|
||||||
|
}
|
||||||
|
return myGtid.String(), nil
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetGtidOfBinlog(t *testing.T) {
|
||||||
|
desc, err := GetGtidOfBinlog("./test/mysql-bin56.000003")
|
||||||
|
if nil != err {
|
||||||
|
t.Fatalf("unexpected error %v", err)
|
||||||
|
}
|
||||||
|
if "F60AB33CC60411E38E1CE66CCF50DB66:1-136" != desc {
|
||||||
|
t.Fatalf("wrong gtid %v", desc)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetPreviousGtids(binlogPath string) (gtidDesc string, err error) {
|
||||||
|
file, err := os.Open(binlogPath)
|
||||||
|
if nil != err {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
p := uint32(4)
|
||||||
|
headerBs := make([]byte, 19)
|
||||||
|
payloadBs := make([]byte, 1024)
|
||||||
|
|
||||||
|
for {
|
||||||
|
if _, err := file.Seek(int64(p), 0); nil != err {
|
||||||
|
if "EOF" == err.Error() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return gtidDesc, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.ReadFull(file, headerBs); nil != err {
|
||||||
|
if "EOF" == err.Error() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return gtidDesc, err
|
||||||
|
}
|
||||||
|
|
||||||
|
length := binary.LittleEndian.Uint32(headerBs[9:13])
|
||||||
|
eventType := int(headerBs[4])
|
||||||
|
|
||||||
|
if PREVIOUS_GTIDS_LOG_EVENT != eventType {
|
||||||
|
p += length
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
payloadLength := length - 19
|
||||||
|
|
||||||
|
if payloadLength > uint32(len(payloadBs)) {
|
||||||
|
payloadBs = make([]byte, payloadLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.ReadFull(file, payloadBs[:payloadLength]); nil != err {
|
||||||
|
if "EOF" == err.Error() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return gtidDesc, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ret := ""
|
||||||
|
sidNumberCount := bytesToUint(payloadBs[0:8])
|
||||||
|
pos := 8
|
||||||
|
for i := uint(0); i < sidNumberCount; i++ {
|
||||||
|
if "" != ret {
|
||||||
|
ret = ret + ","
|
||||||
|
}
|
||||||
|
uuid := bytesToUuid(payloadBs[pos : pos+16])
|
||||||
|
ret = ret + uuid
|
||||||
|
internalCount := bytesToUint(payloadBs[pos+16 : pos+16+8])
|
||||||
|
pos = pos + 16 + 8
|
||||||
|
for i := uint(0); i < internalCount; i++ {
|
||||||
|
from := bytesToUint64(payloadBs[pos : pos+8])
|
||||||
|
to := bytesToUint64(payloadBs[pos+8:pos+16]) - 1
|
||||||
|
pos = pos + 16
|
||||||
|
ret = ret + ":" + strconv.FormatUint(from, 10) + "-" + strconv.FormatUint(to, 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret, nil
|
||||||
|
}
|
||||||
|
return gtidDesc, nil
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetPreviousGtids(t *testing.T) {
|
||||||
|
gtid, err := GetPreviousGtids("./test/mysql-bin56.000002")
|
||||||
|
if nil != err {
|
||||||
|
t.Fatalf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
if "7E23401AC60311E38E135E10E6A05CFB:1-5,8186FC1EC5FF11E38DF9E66CCF50DB66:1-11,A6CE328CC60211E38E0DE66CCF50DB66:1-6,B7009920C60111E38E075E10E6A05CFB:1-6" != gtid {
|
||||||
|
t.Fatalf("wrong gtid %v", gtid)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"b612.me/mysql/gtid"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetUnexecutedBinlogFilesByGtid(binlogDir string, binlogBaseName string, executedGtidDesc string, includeEventBeforeFirst bool) (
|
||||||
|
ret []string, err error) {
|
||||||
|
files, err := ioutil.ReadDir(binlogDir)
|
||||||
|
if nil != err {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var binlogFiles []string
|
||||||
|
for _, file := range files {
|
||||||
|
if strings.HasPrefix(file.Name(), binlogBaseName+".") && binlogFileSuffixPattern.MatchString(file.Name()) {
|
||||||
|
binlogFiles = append(binlogFiles, file.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if 0 == len(binlogFiles) {
|
||||||
|
return make([]string, 0), nil
|
||||||
|
}
|
||||||
|
executedGtid, err := gtid.Parse(executedGtidDesc)
|
||||||
|
if nil != err {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for i := len(binlogFiles) - 1; i >= 0; i-- {
|
||||||
|
binlogFile := binlogFiles[i]
|
||||||
|
previousGtids, err := GetPreviousGtids(filepath.Join(binlogDir, binlogFile))
|
||||||
|
if nil != err {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
contain, err := executedGtid.Contain(previousGtids)
|
||||||
|
if nil != err {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
eql, err := executedGtid.Equal(previousGtids)
|
||||||
|
if nil != err {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if contain && !(includeEventBeforeFirst && eql && "" != executedGtidDesc) {
|
||||||
|
for j := i; j < len(binlogFiles); j++ {
|
||||||
|
ret = append(ret, binlogFiles[j])
|
||||||
|
}
|
||||||
|
return ret, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("Found unexecuted gtid comparing with previousGtids of even first binlog")
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetUnexecutedBinlogFilesByGtid(t *testing.T) {
|
||||||
|
files, err := GetUnexecutedBinlogFilesByGtid("./test", "mysql-bin56",
|
||||||
|
"7e23401a-c603-11e3-8e13-5e10e6a05cfb:1-6,8186fc1e-c5ff-11e3-8df9-e66ccf50db66:1-11,a6ce328c-c602-11e3-8e0d-e66ccf50db66:1-6,b7009920-c601-11e3-8e07-5e10e6a05cfb:1-6,f60ab33c-c604-11e3-8e1c-e66ccf50db66:1-3",
|
||||||
|
false)
|
||||||
|
if nil != err {
|
||||||
|
t.Fatalf("unexpected err, %v", err)
|
||||||
|
}
|
||||||
|
if 1 != len(files) || "mysql-bin56.000003" != files[0] {
|
||||||
|
t.Fatalf("wrong result: %v", files)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetUnexecutedBinlogFilesByGtid2(t *testing.T) {
|
||||||
|
files, err := GetUnexecutedBinlogFilesByGtid("./test", "mysql-bin56",
|
||||||
|
"7e23401a-c603-11e3-8e13-5e10e6a05cfb:1-5,8186fc1e-c5ff-11e3-8df9-e66ccf50db66:1-11,a6ce328c-c602-11e3-8e0d-e66ccf50db66:1-6,b7009920-c601-11e3-8e07-5e10e6a05cfb:1-6,f60ab33c-c604-11e3-8e1c-e66ccf50db66:1-3",
|
||||||
|
false)
|
||||||
|
if nil != err {
|
||||||
|
t.Fatalf("unexpected err, %v", err)
|
||||||
|
}
|
||||||
|
if 2 != len(files) || "mysql-bin56.000002" != files[0] || "mysql-bin56.000003" != files[1] {
|
||||||
|
t.Fatalf("wrong result: %v", files)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,147 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"b612.me/mysql/gtid"
|
||||||
|
"encoding/binary"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetUnexecutedBinlogPosByGtidAndAllGtid(binlogPath string, executedGtidDesc string, includeEventBeforeFirst bool) (pos uint, allgtid string, err error) {
|
||||||
|
file, err := os.Open(binlogPath)
|
||||||
|
if nil != err {
|
||||||
|
return 0, "", err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
myGtid, err := gtid.Parse(allgtid)
|
||||||
|
if err != nil {
|
||||||
|
return 0, "", err
|
||||||
|
}
|
||||||
|
p := uint32(4)
|
||||||
|
finUnexec := false
|
||||||
|
retPos := uint32(0)
|
||||||
|
headerBs := make([]byte, 19)
|
||||||
|
payloadBs := make([]byte, 1024)
|
||||||
|
lastExecutedGtidPos := uint32(0)
|
||||||
|
executedGtid, err := gtid.Parse(executedGtidDesc)
|
||||||
|
if nil != err {
|
||||||
|
return 0, "", err
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
if _, err := file.Seek(int64(p), 0); nil != err {
|
||||||
|
return 0, "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.ReadFull(file, headerBs); nil != err {
|
||||||
|
if err == io.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return 0, "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
length := binary.LittleEndian.Uint32(headerBs[9:13])
|
||||||
|
eventType := int(headerBs[4])
|
||||||
|
|
||||||
|
if GTID_LOG_EVENT != eventType {
|
||||||
|
p += length
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
payloadLength := length - 19
|
||||||
|
if payloadLength > uint32(len(payloadBs)) {
|
||||||
|
payloadBs = make([]byte, payloadLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.ReadFull(file, payloadBs[:payloadLength]); nil != err {
|
||||||
|
return 0, "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
uuid := bytesToUuid(payloadBs[1:17])
|
||||||
|
number := bytesToUint64(payloadBs[17:25])
|
||||||
|
if !finUnexec {
|
||||||
|
contain, err := executedGtid.ContainGtid(uuid, number)
|
||||||
|
if nil != err {
|
||||||
|
return 0, "", err
|
||||||
|
}
|
||||||
|
if contain {
|
||||||
|
lastExecutedGtidPos = p
|
||||||
|
p += length
|
||||||
|
} else {
|
||||||
|
retPos = p
|
||||||
|
if includeEventBeforeFirst && 0 != lastExecutedGtidPos {
|
||||||
|
retPos = lastExecutedGtidPos
|
||||||
|
}
|
||||||
|
finUnexec = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p += length
|
||||||
|
}
|
||||||
|
if err = myGtid.AddGtid(uuid, number); nil != err {
|
||||||
|
return 0, "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !finUnexec {
|
||||||
|
return 0, myGtid.String(), io.EOF
|
||||||
|
}
|
||||||
|
return uint(retPos), myGtid.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUnexecutedBinlogPosByGtid(binlogPath string, executedGtidDesc string, includeEventBeforeFirst bool) (pos uint, err error) {
|
||||||
|
file, err := os.Open(binlogPath)
|
||||||
|
if nil != err {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
p := uint32(4)
|
||||||
|
headerBs := make([]byte, 19)
|
||||||
|
payloadBs := make([]byte, 1024)
|
||||||
|
lastExecutedGtidPos := uint32(0)
|
||||||
|
executedGtid, err := gtid.Parse(executedGtidDesc)
|
||||||
|
if nil != err {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
if _, err := file.Seek(int64(p), 0); nil != err {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.ReadFull(file, headerBs); nil != err {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
length := binary.LittleEndian.Uint32(headerBs[9:13])
|
||||||
|
eventType := int(headerBs[4])
|
||||||
|
|
||||||
|
if GTID_LOG_EVENT != eventType {
|
||||||
|
p += length
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
payloadLength := length - 19
|
||||||
|
if payloadLength > uint32(len(payloadBs)) {
|
||||||
|
payloadBs = make([]byte, payloadLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.ReadFull(file, payloadBs[:payloadLength]); nil != err {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
uuid := bytesToUuid(payloadBs[1:17])
|
||||||
|
number := bytesToUint64(payloadBs[17:25])
|
||||||
|
contain, err := executedGtid.ContainGtid(uuid, number)
|
||||||
|
if nil != err {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if contain {
|
||||||
|
lastExecutedGtidPos = p
|
||||||
|
p += length
|
||||||
|
} else {
|
||||||
|
retPos := p
|
||||||
|
if includeEventBeforeFirst && 0 != lastExecutedGtidPos {
|
||||||
|
retPos = lastExecutedGtidPos
|
||||||
|
}
|
||||||
|
return uint(retPos), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetUnexecutedBinlogPosByGtid(t *testing.T) {
|
||||||
|
executedGtid := "f60ab33c-c604-11e3-8e1c-e66ccf50db66:1-124"
|
||||||
|
pos, err := GetUnexecutedBinlogPosByGtid("./test/mysql-bin56.000003", executedGtid, false)
|
||||||
|
if nil != err {
|
||||||
|
t.Fatalf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
if 125553 != pos {
|
||||||
|
t.Fatalf("wrong pos %v", pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetUnexecutedBinlogPosByGtid2(t *testing.T) {
|
||||||
|
executedGtid := "f60ab33c-c604-11e3-8e1c-e66ccf50db66:1-136"
|
||||||
|
_, err := GetUnexecutedBinlogPosByGtid("./test/mysql-bin56.000003", executedGtid, false)
|
||||||
|
if nil == err || "EOF" != err.Error() {
|
||||||
|
t.Fatalf("wrong err %v", err)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
type Logger interface {
|
||||||
|
Tracef(fmt string, args ...interface{})
|
||||||
|
}
|
||||||
|
|
||||||
|
var l Logger
|
||||||
|
|
||||||
|
func tracef(fmt string, args ...interface{}) {
|
||||||
|
if nil != l {
|
||||||
|
l.Tracef(fmt+"\n", args...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetLogger(logger Logger) {
|
||||||
|
l = logger
|
||||||
|
}
|
@ -0,0 +1,253 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"b612.me/mysql/gtid"
|
||||||
|
"b612.me/staros"
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"github.com/starainrt/go-mysql/replication"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TxDetail struct {
|
||||||
|
StartPos int
|
||||||
|
EndPos int
|
||||||
|
Db string
|
||||||
|
Table string
|
||||||
|
SqlType string
|
||||||
|
RowCount int
|
||||||
|
}
|
||||||
|
|
||||||
|
type Transaction struct {
|
||||||
|
GTID string
|
||||||
|
StartPos int
|
||||||
|
EndPos int
|
||||||
|
Size int
|
||||||
|
SQLOrigin string
|
||||||
|
Timestamp int64
|
||||||
|
RowsCount int
|
||||||
|
Txs []TxDetail
|
||||||
|
}
|
||||||
|
|
||||||
|
func ParseBinlogFile(path string, fx func(transaction Transaction)) error {
|
||||||
|
return parseOneBinlog(path, fx)
|
||||||
|
}
|
||||||
|
func parseOneBinlog(path string, fx func(Transaction)) error {
|
||||||
|
if !staros.Exists(path) {
|
||||||
|
return os.ErrNotExist
|
||||||
|
}
|
||||||
|
f, err := os.Open(path)
|
||||||
|
if f != nil {
|
||||||
|
defer f.Close()
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fileTypeBytes := int64(4)
|
||||||
|
|
||||||
|
b := make([]byte, fileTypeBytes)
|
||||||
|
// 读取binlog头
|
||||||
|
if _, err = f.Read(b); err != nil {
|
||||||
|
return err
|
||||||
|
} else if !bytes.Equal(b, replication.BinLogFileHeader) {
|
||||||
|
//不是binlog格式
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// must not seek to other position, otherwise the program may panic because formatevent, table map event is skipped
|
||||||
|
if _, err = f.Seek(fileTypeBytes, os.SEEK_SET); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return parseBinlogDetail(f, fx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseBinlogDetail(r io.Reader, f func(Transaction)) error {
|
||||||
|
parse := replication.NewBinlogParser()
|
||||||
|
parse.SetParseTime(false)
|
||||||
|
parse.SetUseDecimal(false)
|
||||||
|
// process: 0, continue: 1, break: 2, EOF: 3
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
n int64
|
||||||
|
db string = ""
|
||||||
|
tb string = ""
|
||||||
|
sql string = ""
|
||||||
|
sqlType string = ""
|
||||||
|
rowCnt uint32 = 0
|
||||||
|
tbMapPos uint32 = 0
|
||||||
|
)
|
||||||
|
var tx Transaction
|
||||||
|
for {
|
||||||
|
headBuf := make([]byte, replication.EventHeaderSize)
|
||||||
|
if _, err = io.ReadFull(r, headBuf); err == io.EOF {
|
||||||
|
return nil
|
||||||
|
} else if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var h *replication.EventHeader
|
||||||
|
h, err = parse.ParseHeader(headBuf)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//fmt.Printf("parsing %s %d %s\n", *binlog, h.LogPos, GetDatetimeStr(int64(h.Timestamp), int64(0), DATETIME_FORMAT))
|
||||||
|
|
||||||
|
if h.EventSize <= uint32(replication.EventHeaderSize) {
|
||||||
|
err = fmt.Errorf("invalid event header, event size is %d, too small", h.EventSize)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
if n, err = io.CopyN(&buf, r, int64(h.EventSize)-int64(replication.EventHeaderSize)); err != nil {
|
||||||
|
err = fmt.Errorf("get event body err %v, need %d - %d, but got %d", err, h.EventSize, replication.EventHeaderSize, n)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
//h.Dump(os.Stdout)
|
||||||
|
|
||||||
|
data := buf.Bytes()
|
||||||
|
var rawData []byte
|
||||||
|
rawData = append(rawData, headBuf...)
|
||||||
|
rawData = append(rawData, data...)
|
||||||
|
|
||||||
|
eventLen := int(h.EventSize) - replication.EventHeaderSize
|
||||||
|
|
||||||
|
if len(data) != eventLen {
|
||||||
|
err = fmt.Errorf("invalid data size %d in event %s, less event length %d", len(data), h.EventType, eventLen)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var e replication.Event
|
||||||
|
e, err = parse.ParseEvent(h, data, rawData)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if h.EventType == replication.TABLE_MAP_EVENT {
|
||||||
|
tbMapPos = h.LogPos - h.EventSize // avoid mysqlbing mask the row event as unknown table row event
|
||||||
|
}
|
||||||
|
|
||||||
|
//e.Dump(os.Stdout)
|
||||||
|
|
||||||
|
//binEvent := &replication.BinlogEvent{RawData: rawData, Header: h, Event: e}
|
||||||
|
binEvent := &replication.BinlogEvent{Header: h, Event: e} // we donnot need raw data
|
||||||
|
|
||||||
|
db, tb, sqlType, sql, rowCnt = GetDbTbAndQueryAndRowCntFromBinevent(binEvent)
|
||||||
|
startPos := 0
|
||||||
|
if sqlType == "query" {
|
||||||
|
startPos = int(h.LogPos - h.EventSize)
|
||||||
|
//fmt.Println(h.Timestamp, h.LogPos-h.EventSize, h.LogPos, db, tb, "sql="+sql, rowCnt, sqlType)
|
||||||
|
// cfg.StatChan <- BinEventStats{Timestamp: h.Timestamp, Binlog: *binlog, StartPos: h.LogPos - h.EventSize, StopPos: h.LogPos,
|
||||||
|
// Database: db, Table: tb, QuerySql: sql, RowCnt: rowCnt, QueryType: sqlType}
|
||||||
|
} else {
|
||||||
|
startPos = int(tbMapPos)
|
||||||
|
//fmt.Println(h.Timestamp, tbMapPos, h.LogPos, db, tb, "sql="+sql, rowCnt, sqlType)
|
||||||
|
// cfg.StatChan <- BinEventStats{Timestamp: h.Timestamp, Binlog: *binlog, StartPos: tbMapPos, StopPos: h.LogPos,
|
||||||
|
// Database: db, Table: tb, QuerySql: sql, RowCnt: rowCnt, QueryType: sqlType}
|
||||||
|
}
|
||||||
|
switch sqlType {
|
||||||
|
case "gtid":
|
||||||
|
if tx.StartPos != 0 {
|
||||||
|
for _, v := range tx.Txs {
|
||||||
|
tx.RowsCount += v.RowCount
|
||||||
|
}
|
||||||
|
tx.Size = tx.EndPos - tx.StartPos
|
||||||
|
if f != nil {
|
||||||
|
f(tx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tx = Transaction{
|
||||||
|
GTID: sql,
|
||||||
|
StartPos: startPos,
|
||||||
|
}
|
||||||
|
case "":
|
||||||
|
tx.EndPos = int(h.LogPos)
|
||||||
|
continue
|
||||||
|
case "rowsquery":
|
||||||
|
tx.EndPos = int(h.LogPos)
|
||||||
|
tx.SQLOrigin = sql
|
||||||
|
default:
|
||||||
|
tx.EndPos = int(h.LogPos)
|
||||||
|
tx.Txs = append(tx.Txs, TxDetail{
|
||||||
|
StartPos: startPos,
|
||||||
|
EndPos: int(h.LogPos),
|
||||||
|
Db: db,
|
||||||
|
Table: tb,
|
||||||
|
SqlType: sqlType,
|
||||||
|
RowCount: int(rowCnt),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetDbTbAndQueryAndRowCntFromBinevent(ev *replication.BinlogEvent) (string, string, string, string, uint32) {
|
||||||
|
var (
|
||||||
|
db string = ""
|
||||||
|
tb string = ""
|
||||||
|
sql string = ""
|
||||||
|
sqlType string = ""
|
||||||
|
rowCnt uint32 = 0
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ev.Header.EventType {
|
||||||
|
|
||||||
|
case replication.WRITE_ROWS_EVENTv1,
|
||||||
|
replication.WRITE_ROWS_EVENTv2:
|
||||||
|
|
||||||
|
wrEvent := ev.Event.(*replication.RowsEvent)
|
||||||
|
db = string(wrEvent.Table.Schema)
|
||||||
|
tb = string(wrEvent.Table.Table)
|
||||||
|
sqlType = "insert"
|
||||||
|
rowCnt = uint32(len(wrEvent.Rows))
|
||||||
|
|
||||||
|
case replication.UPDATE_ROWS_EVENTv1,
|
||||||
|
replication.UPDATE_ROWS_EVENTv2:
|
||||||
|
wrEvent := ev.Event.(*replication.RowsEvent)
|
||||||
|
db = string(wrEvent.Table.Schema)
|
||||||
|
tb = string(wrEvent.Table.Table)
|
||||||
|
sqlType = "update"
|
||||||
|
rowCnt = uint32(len(wrEvent.Rows)) / 2
|
||||||
|
|
||||||
|
case replication.DELETE_ROWS_EVENTv1,
|
||||||
|
replication.DELETE_ROWS_EVENTv2:
|
||||||
|
|
||||||
|
//replication.XID_EVENT,
|
||||||
|
//replication.TABLE_MAP_EVENT:
|
||||||
|
|
||||||
|
wrEvent := ev.Event.(*replication.RowsEvent)
|
||||||
|
db = string(wrEvent.Table.Schema)
|
||||||
|
tb = string(wrEvent.Table.Table)
|
||||||
|
sqlType = "delete"
|
||||||
|
rowCnt = uint32(len(wrEvent.Rows))
|
||||||
|
case replication.ROWS_QUERY_EVENT:
|
||||||
|
queryEvent := ev.Event.(*replication.RowsQueryEvent)
|
||||||
|
sql = string(queryEvent.Query)
|
||||||
|
sqlType = "rowsquery"
|
||||||
|
case replication.QUERY_EVENT:
|
||||||
|
queryEvent := ev.Event.(*replication.QueryEvent)
|
||||||
|
db = string(queryEvent.Schema)
|
||||||
|
sql = string(queryEvent.Query)
|
||||||
|
sqlType = "query"
|
||||||
|
|
||||||
|
case replication.MARIADB_GTID_EVENT:
|
||||||
|
// For global transaction ID, used to start a new transaction event group, instead of the old BEGIN query event, and also to mark stand-alone (ddl).
|
||||||
|
//https://mariadb.com/kb/en/library/gtid_event/
|
||||||
|
sql = "begin"
|
||||||
|
sqlType = "query"
|
||||||
|
|
||||||
|
case replication.XID_EVENT:
|
||||||
|
// XID_EVENT represents commit。rollback transaction not in binlog
|
||||||
|
sql = "commit"
|
||||||
|
sqlType = "query"
|
||||||
|
case replication.GTID_EVENT:
|
||||||
|
ge := ev.Event.(*replication.GTIDEvent)
|
||||||
|
gid, err := gtid.Parse(fmt.Sprintf("%s:%d", bytesToUuid(ge.SID), ge.SequenceNumber))
|
||||||
|
if err == nil {
|
||||||
|
sql = gid.String()
|
||||||
|
}
|
||||||
|
sqlType = "gtid"
|
||||||
|
}
|
||||||
|
return db, tb, sqlType, sql, rowCnt
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestParse(t *testing.T) {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
|
||||||
|
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
|
||||||
|
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||||
|
DELIMITER /*!*/;
|
||||||
|
# at 4
|
||||||
|
#140417 15:50:36 server id 904898000 end_log_pos 120 CRC32 0x96973caa
|
||||||
|
# Position Timestamp Type Master ID Size Master Pos Flags
|
||||||
|
# 4 cc 87 4f 53 0f d0 a5 ef 35 74 00 00 00 78 00 00 00 00 00
|
||||||
|
# 17 04 00 35 2e 36 2e 31 37 2d 6c 6f 67 00 00 00 00 |..5.6.17.log....|
|
||||||
|
# 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
|
||||||
|
# 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
|
||||||
|
# 47 00 00 00 00 cc 87 4f 53 13 38 0d 00 08 00 12 00 |......OS.8......|
|
||||||
|
# 57 04 04 04 04 12 00 00 5c 00 04 1a 08 00 00 00 08 |................|
|
||||||
|
# 67 08 08 02 00 00 00 0a 0a 0a 19 19 00 01 aa 3c 97 |................|
|
||||||
|
# 77 96 |.|
|
||||||
|
# Start: binlog v 4, server v 5.6.17-log created 140417 15:50:36 at startup
|
||||||
|
ROLLBACK/*!*/;
|
||||||
|
BINLOG '
|
||||||
|
zIdPUw/Qpe81dAAAAHgAAAAAAAQANS42LjE3LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
AAAAAAAAAAAAAAAAAADMh09TEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAao8
|
||||||
|
l5Y=
|
||||||
|
'/*!*/;
|
||||||
|
# at 120
|
||||||
|
#140417 15:50:36 server id 904898000 end_log_pos 151 CRC32 0x4c0fdc5d
|
||||||
|
# Position Timestamp Type Master ID Size Master Pos Flags
|
||||||
|
# 78 cc 87 4f 53 23 d0 a5 ef 35 1f 00 00 00 97 00 00 00 00 00
|
||||||
|
# 8b 00 00 00 00 00 00 00 00 5d dc 0f 4c |...........L|
|
||||||
|
# Previous-GTIDs
|
||||||
|
# [empty]
|
||||||
|
# at 151
|
||||||
|
#140417 15:50:36 server id 904898000 end_log_pos 198 CRC32 0x17701320
|
||||||
|
# Position Timestamp Type Master ID Size Master Pos Flags
|
||||||
|
# 97 cc 87 4f 53 04 d0 a5 ef 35 2f 00 00 00 c6 00 00 00 00 00
|
||||||
|
# aa 04 00 00 00 00 00 00 00 6d 79 73 71 6c 2d 62 69 |........mysql.bi|
|
||||||
|
# ba 6e 2e 30 30 30 30 30 32 20 13 70 17 |n.000002..p.|
|
||||||
|
# Rotate to mysql-bin.000002 pos: 4
|
||||||
|
DELIMITER ;
|
||||||
|
# End of log file
|
||||||
|
ROLLBACK /* added by mysqlbinlog */;
|
||||||
|
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
|
||||||
|
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
|
@ -0,0 +1,86 @@
|
|||||||
|
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
|
||||||
|
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
|
||||||
|
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||||
|
DELIMITER /*!*/;
|
||||||
|
# at 4
|
||||||
|
#140417 15:50:36 server id 904898000 end_log_pos 120 CRC32 0x31f0dc91
|
||||||
|
# Position Timestamp Type Master ID Size Master Pos Flags
|
||||||
|
# 4 cc 87 4f 53 0f d0 a5 ef 35 74 00 00 00 78 00 00 00 00 00
|
||||||
|
# 17 04 00 35 2e 36 2e 31 37 2d 6c 6f 67 00 00 00 00 |..5.6.17.log....|
|
||||||
|
# 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
|
||||||
|
# 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
|
||||||
|
# 47 00 00 00 00 00 00 00 00 13 38 0d 00 08 00 12 00 |.........8......|
|
||||||
|
# 57 04 04 04 04 12 00 00 5c 00 04 1a 08 00 00 00 08 |................|
|
||||||
|
# 67 08 08 02 00 00 00 0a 0a 0a 19 19 00 01 91 dc f0 |................|
|
||||||
|
# 77 31 |1|
|
||||||
|
# Start: binlog v 4, server v 5.6.17-log created 140417 15:50:36
|
||||||
|
BINLOG '
|
||||||
|
zIdPUw/Qpe81dAAAAHgAAAAAAAQANS42LjE3LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAZHc
|
||||||
|
8DE=
|
||||||
|
'/*!*/;
|
||||||
|
# at 120
|
||||||
|
#140417 15:50:36 server id 904898000 end_log_pos 311 CRC32 0x311ec069
|
||||||
|
# Position Timestamp Type Master ID Size Master Pos Flags
|
||||||
|
# 78 cc 87 4f 53 23 d0 a5 ef 35 bf 00 00 00 37 01 00 00 00 00
|
||||||
|
# 8b 04 00 00 00 00 00 00 00 7e 23 40 1a c6 03 11 e3 |................|
|
||||||
|
# 9b 8e 13 5e 10 e6 a0 5c fb 01 00 00 00 00 00 00 00 |................|
|
||||||
|
# ab 01 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 |................|
|
||||||
|
# bb 81 86 fc 1e c5 ff 11 e3 8d f9 e6 6c cf 50 db 66 |...........l.P.f|
|
||||||
|
# cb 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 |................|
|
||||||
|
# db 0c 00 00 00 00 00 00 00 a6 ce 32 8c c6 02 11 e3 |..........2.....|
|
||||||
|
# eb 8e 0d e6 6c cf 50 db 66 01 00 00 00 00 00 00 00 |...l.P.f........|
|
||||||
|
# fb 01 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 |................|
|
||||||
|
# 10b b7 00 99 20 c6 01 11 e3 8e 07 5e 10 e6 a0 5c fb |................|
|
||||||
|
# 11b 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 |................|
|
||||||
|
# 12b 07 00 00 00 00 00 00 00 69 c0 1e 31 |........i..1|
|
||||||
|
# Previous-GTIDs
|
||||||
|
# 7e23401a-c603-11e3-8e13-5e10e6a05cfb:1-5,
|
||||||
|
# 8186fc1e-c5ff-11e3-8df9-e66ccf50db66:1-11,
|
||||||
|
# a6ce328c-c602-11e3-8e0d-e66ccf50db66:1-6,
|
||||||
|
# b7009920-c601-11e3-8e07-5e10e6a05cfb:1-6
|
||||||
|
# at 311
|
||||||
|
#140417 15:42:20 server id 163651000 end_log_pos 359 CRC32 0x584291b8
|
||||||
|
# Position Timestamp Type Master ID Size Master Pos Flags
|
||||||
|
# 137 dc 85 4f 53 21 b8 1d c1 09 30 00 00 00 67 01 00 00 00 00
|
||||||
|
# 14a 01 7e 23 40 1a c6 03 11 e3 8e 13 5e 10 e6 a0 5c |................|
|
||||||
|
# 15a fb 06 00 00 00 00 00 00 00 b8 91 42 58 |...........BX|
|
||||||
|
# GTID [commit=yes]
|
||||||
|
SET @@SESSION.GTID_NEXT= '7e23401a-c603-11e3-8e13-5e10e6a05cfb:6'/*!*/;
|
||||||
|
# at 359
|
||||||
|
#140417 15:42:20 server id 163651000 end_log_pos 524 CRC32 0x07fa8283
|
||||||
|
# Position Timestamp Type Master ID Size Master Pos Flags
|
||||||
|
# 167 dc 85 4f 53 02 b8 1d c1 09 a5 00 00 00 0c 02 00 00 0c 00
|
||||||
|
# 17a 25 00 00 00 f1 01 00 00 05 00 00 22 00 00 00 00 |................|
|
||||||
|
# 18a 00 00 01 00 00 00 40 00 00 00 00 06 03 73 74 64 |.............std|
|
||||||
|
# 19a 04 08 00 08 00 21 00 0c 01 6d 79 73 71 6c 00 6d |.........mysql.m|
|
||||||
|
# 1aa 79 73 71 6c 00 44 52 4f 50 20 54 45 4d 50 4f 52 |ysql.DROP.TEMPOR|
|
||||||
|
# 1ba 41 52 59 20 54 41 42 4c 45 20 49 46 20 45 58 49 |ARY.TABLE.IF.EXI|
|
||||||
|
# 1ca 53 54 53 20 60 6d 79 73 71 6c 60 2e 60 69 62 62 |STS..mysql...ibb|
|
||||||
|
# 1da 61 63 6b 75 70 5f 62 69 6e 6c 6f 67 5f 6d 61 72 |ackup.binlog.mar|
|
||||||
|
# 1ea 6b 65 72 60 20 2f 2a 20 67 65 6e 65 72 61 74 65 |ker.....generate|
|
||||||
|
# 1fa 64 20 62 79 20 73 65 72 76 65 72 20 2a 2f 83 82 |d.by.server.....|
|
||||||
|
# 20a fa 07 |..|
|
||||||
|
# Query thread_id=37 exec_time=497 error_code=0
|
||||||
|
SET TIMESTAMP=1397720540/*!*/;
|
||||||
|
SET @@session.pseudo_thread_id=37/*!*/;
|
||||||
|
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
|
||||||
|
SET @@session.sql_mode=1073741824/*!*/;
|
||||||
|
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
|
||||||
|
/*!\C latin1 *//*!*/;
|
||||||
|
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=33/*!*/;
|
||||||
|
SET @@session.lc_time_names=0/*!*/;
|
||||||
|
SET @@session.collation_database=DEFAULT/*!*/;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS `mysql`.`ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 524
|
||||||
|
#140417 15:51:20 server id 904898000 end_log_pos 547 CRC32 0xe2ee3d87
|
||||||
|
# Position Timestamp Type Master ID Size Master Pos Flags
|
||||||
|
# 20c f8 87 4f 53 03 d0 a5 ef 35 17 00 00 00 23 02 00 00 00 00
|
||||||
|
# 21f 87 3d ee e2 |....|
|
||||||
|
# Stop
|
||||||
|
DELIMITER ;
|
||||||
|
# End of log file
|
||||||
|
ROLLBACK /* added by mysqlbinlog */;
|
||||||
|
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
|
||||||
|
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,16 @@
|
|||||||
|
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
|
||||||
|
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
|
||||||
|
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||||
|
DELIMITER /*!*/;
|
||||||
|
# at 4
|
||||||
|
#140529 15:45:54 server id 1318224853 end_log_pos 120 CRC32 0x66b2abd3 Start: binlog v 4, server v 5.6.17-log created 140529 15:45:54
|
||||||
|
# Warning: this binlog is either in use or was not closed properly.
|
||||||
|
# at 120
|
||||||
|
#140529 15:45:54 server id 1318224853 end_log_pos 231 CRC32 0xde0f0e71 Previous-GTIDs
|
||||||
|
# 5ade491e-e611-11e3-9f17-e66ccf50db66:1-186,
|
||||||
|
# e57ada8e-e610-11e3-9f14-5e10e6a05cfb:6
|
||||||
|
DELIMITER ;
|
||||||
|
# End of log file
|
||||||
|
ROLLBACK /* added by mysqlbinlog */;
|
||||||
|
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
|
||||||
|
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
|
Binary file not shown.
@ -0,0 +1,753 @@
|
|||||||
|
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
|
||||||
|
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
|
||||||
|
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||||
|
DELIMITER /*!*/;
|
||||||
|
# at 4
|
||||||
|
#140315 11:05:43 server id 8798000 end_log_pos 107 Start: binlog v 4, server v 5.5.33-log created 140315 11:05:43
|
||||||
|
# Warning: this binlog is either in use or was not closed properly.
|
||||||
|
# at 107
|
||||||
|
#140315 11:05:58 server id 8798000 end_log_pos 194 Query thread_id=25643 exec_time=0 error_code=0
|
||||||
|
use `test`/*!*/;
|
||||||
|
SET TIMESTAMP=1394852758/*!*/;
|
||||||
|
SET @@session.pseudo_thread_id=25643/*!*/;
|
||||||
|
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
|
||||||
|
SET @@session.sql_mode=0/*!*/;
|
||||||
|
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
|
||||||
|
/*!\C utf8 *//*!*/;
|
||||||
|
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
|
||||||
|
SET @@session.lc_time_names=0/*!*/;
|
||||||
|
SET @@session.collation_database=DEFAULT/*!*/;
|
||||||
|
create table test(a int)
|
||||||
|
/*!*/;
|
||||||
|
# at 194
|
||||||
|
#140315 11:06:03 server id 8798000 end_log_pos 262 Query thread_id=25643 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394852763/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 262
|
||||||
|
#140315 11:06:03 server id 8798000 end_log_pos 351 Query thread_id=25643 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394852763/*!*/;
|
||||||
|
insert into test values(1)
|
||||||
|
/*!*/;
|
||||||
|
# at 351
|
||||||
|
#140315 11:06:03 server id 8798000 end_log_pos 378 Xid = 77731
|
||||||
|
COMMIT/*!*/;
|
||||||
|
# at 378
|
||||||
|
#140315 11:06:08 server id 8798000 end_log_pos 446 Query thread_id=25643 exec_time=1 error_code=0
|
||||||
|
SET TIMESTAMP=1394852768/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 446
|
||||||
|
#140315 11:06:08 server id 8798000 end_log_pos 535 Query thread_id=25643 exec_time=1 error_code=0
|
||||||
|
SET TIMESTAMP=1394852768/*!*/;
|
||||||
|
insert into test values(2)
|
||||||
|
/*!*/;
|
||||||
|
# at 535
|
||||||
|
#140315 11:06:08 server id 8798000 end_log_pos 562 Xid = 77748
|
||||||
|
COMMIT/*!*/;
|
||||||
|
# at 562
|
||||||
|
#140315 11:30:00 server id 8798000 end_log_pos 998 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
use `mysql`/*!*/;
|
||||||
|
SET TIMESTAMP=1394854200/*!*/;
|
||||||
|
/*!\C latin1 *//*!*/;
|
||||||
|
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=33/*!*/;
|
||||||
|
CREATE TABLE IF NOT EXISTS mysql.backup_progress( `backup_id` BIGINT NOT NULL, `tool_name` VARCHAR(4096) NOT NULL, `error_code` INT NOT NULL, `error_message` VARCHAR(4096) NOT NULL, `current_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,`current_state` VARCHAR(200) NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COLLATE=utf8_bin
|
||||||
|
/*!*/;
|
||||||
|
# at 998
|
||||||
|
#140315 11:30:02 server id 8798000 end_log_pos 1075 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854202/*!*/;
|
||||||
|
SET @@session.time_zone='SYSTEM'/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 1075
|
||||||
|
#140315 11:30:02 server id 8798000 end_log_pos 1323 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854202/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948542000487620,'mysqlbackup',0,'NO_ERROR','Started mysqlbackup.')
|
||||||
|
/*!*/;
|
||||||
|
# at 1323
|
||||||
|
#140315 11:30:02 server id 8798000 end_log_pos 1401 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854202/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 1401
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 1478 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 1478
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 1771 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948542000487620,'mysqlbackup',0,'NO_ERROR','mysqlbackup locking tables and copying .frm + other engines data.')
|
||||||
|
/*!*/;
|
||||||
|
# at 1771
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 1849 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 1849
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 1984 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
DROP TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 1984
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 2117 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
SET @@session.pseudo_thread_id=27063/*!*/;
|
||||||
|
CREATE TEMPORARY TABLE ibbackup_binlog_marker (a INT) ENGINE = INNODB
|
||||||
|
/*!*/;
|
||||||
|
# at 2117
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 2186 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 2186
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 2294 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(1)
|
||||||
|
/*!*/;
|
||||||
|
# at 2294
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 2364 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 2364
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 2433 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 2433
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 2541 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(2)
|
||||||
|
/*!*/;
|
||||||
|
# at 2541
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 2611 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 2611
|
||||||
|
#140315 11:30:03 server id 8798000 end_log_pos 2692 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854203/*!*/;
|
||||||
|
FLUSH ENGINE LOGS
|
||||||
|
/*!*/;
|
||||||
|
# at 2692
|
||||||
|
#140315 11:30:04 server id 8798000 end_log_pos 2837 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854204/*!*/;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 2837
|
||||||
|
#140315 11:30:04 server id 8798000 end_log_pos 2914 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854204/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 2914
|
||||||
|
#140315 11:30:04 server id 8798000 end_log_pos 3174 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854204/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948542000487620,'mysqlbackup',0,'NO_ERROR','mysqlbackup unlocked the tables.')
|
||||||
|
/*!*/;
|
||||||
|
# at 3174
|
||||||
|
#140315 11:30:04 server id 8798000 end_log_pos 3252 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854204/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 3252
|
||||||
|
#140315 11:30:07 server id 8798000 end_log_pos 4430 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854207/*!*/;
|
||||||
|
CREATE TABLE IF NOT EXISTS mysql.backup_history( `backup_id` BIGINT NOT NULL, `tool_name` VARCHAR(4096) NOT NULL, `start_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `end_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `binlog_pos` BIGINT NOT NULL, `binlog_file` VARCHAR(255) NOT NULL, `compression_level` INT NOT NULL, `engines` VARCHAR(100) NOT NULL, `innodb_data_file_path` VARCHAR(2048) NOT NULL, `innodb_file_format` VARCHAR(100) NOT NULL, `start_lsn` BIGINT NOT NULL, `end_lsn` BIGINT NOT NULL, `incremental_base_lsn` BIGINT NOT NULL, `backup_type` VARCHAR(50) NOT NULL, `backup_format` VARCHAR(50) NOT NULL, `mysql_data_dir` VARCHAR(2048) NOT NULL, `innodb_data_home_dir` VARCHAR(2048) NOT NULL, `innodb_log_group_home_dir` VARCHAR(2048) NOT NULL, `innodb_log_files_in_group` VARCHAR(100) NOT NULL, `innodb_log_file_size` VARCHAR(100) NOT NULL, `backup_destination` VARCHAR(4096) NOT NULL, `lock_time` DOUBLE PRECISION (7,3) NOT NULL, `exit_state` VARCHAR(10) NOT NULL, `last_error` VARCHAR(4096) NOT NULL, `last_error_code` INT NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COLLATE=utf8_bin
|
||||||
|
/*!*/;
|
||||||
|
# at 4430
|
||||||
|
#140315 11:30:07 server id 8798000 end_log_pos 4507 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854207/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 4507
|
||||||
|
#140315 11:30:07 server id 8798000 end_log_pos 4763 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854207/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948542000487620,'mysqlbackup',0,'NO_ERROR','mysqlbackup returns success.')
|
||||||
|
/*!*/;
|
||||||
|
# at 4763
|
||||||
|
#140315 11:30:07 server id 8798000 end_log_pos 4841 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854207/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 4841
|
||||||
|
#140315 11:30:07 server id 8798000 end_log_pos 4918 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854207/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 4918
|
||||||
|
#140315 11:30:07 server id 8798000 end_log_pos 6201 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854207/*!*/;
|
||||||
|
INSERT INTO mysql.backup_history(backup_id, tool_name, start_time, end_time, binlog_pos, binlog_file, compression_level, engines, innodb_data_file_path, innodb_file_format, start_lsn, end_lsn, incremental_base_lsn, backup_type, backup_format, mysql_data_dir, innodb_data_home_dir, innodb_log_group_home_dir, innodb_log_files_in_group, innodb_log_file_size, backup_destination, lock_time, exit_state, last_error, last_error_code ) VALUES(13948542000487620,'/opt/actiontech-ha/bin/mysqlbackup --user=root --password=xxxx --host=127.0.0.1 --port=3333 --incremental --start-lsn=1328227120 --backup-dir=/tmp/mysql-477023939/2014-03-15_11-30-00 --backup-image=/opt/actiontech-ha/mysql-backup/2014-03-15_04-30-00/2014-03-15_11-30-00 --slave-info --skip-messages-logdir --read-threads=3 --process-threads=6 --write-threads=3 backup-to-image ','2014-03-15 11:30:00','2014-03-15 11:30:05',2692,'mysql-bin.000004',0,'MEMORY:MyISAM:CSV:PERFORMANCE_SCHEMA:InnoDB:','ibdata1:1G:autoextend','Barracuda',1328227121,1328246519,0,'INCREMENTAL','IMAGE','/home/ACTIONTECH-HA/mysql-install/data/','','/home/ACTIONTECH-HA/mysql-install/data/','2','268435456','/tmp/mysql-477023939/2014-03-15_11-30-00',0.67457,'SUCCESS','NO_ERROR',0)
|
||||||
|
/*!*/;
|
||||||
|
# at 6201
|
||||||
|
#140315 11:30:07 server id 8798000 end_log_pos 6279 Query thread_id=27063 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394854207/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 6279
|
||||||
|
#140315 12:00:03 server id 154063000 end_log_pos 6414 Query thread_id=29450 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394856003/*!*/;
|
||||||
|
DROP TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 6414
|
||||||
|
#140315 12:00:03 server id 154063000 end_log_pos 6547 Query thread_id=29450 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394856003/*!*/;
|
||||||
|
SET @@session.pseudo_thread_id=29450/*!*/;
|
||||||
|
CREATE TEMPORARY TABLE ibbackup_binlog_marker (a INT) ENGINE = INNODB
|
||||||
|
/*!*/;
|
||||||
|
# at 6547
|
||||||
|
#140315 12:00:03 server id 154063000 end_log_pos 6616 Query thread_id=29450 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394856003/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 6616
|
||||||
|
#140315 12:00:03 server id 154063000 end_log_pos 6724 Query thread_id=29450 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394856003/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(1)
|
||||||
|
/*!*/;
|
||||||
|
# at 6724
|
||||||
|
#140315 12:00:03 server id 154063000 end_log_pos 6794 Query thread_id=29450 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394856003/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 6794
|
||||||
|
#140315 12:00:03 server id 154063000 end_log_pos 6863 Query thread_id=29450 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394856003/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 6863
|
||||||
|
#140315 12:00:03 server id 154063000 end_log_pos 6971 Query thread_id=29450 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394856003/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(2)
|
||||||
|
/*!*/;
|
||||||
|
# at 6971
|
||||||
|
#140315 12:00:03 server id 154063000 end_log_pos 7041 Query thread_id=29450 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394856003/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 7041
|
||||||
|
#140315 12:00:03 server id 154063000 end_log_pos 7122 Query thread_id=29450 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394856003/*!*/;
|
||||||
|
FLUSH ENGINE LOGS
|
||||||
|
/*!*/;
|
||||||
|
# at 7122
|
||||||
|
#140315 12:00:04 server id 154063000 end_log_pos 7267 Query thread_id=29450 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394856004/*!*/;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 7267
|
||||||
|
#140315 12:30:00 server id 8798000 end_log_pos 7703 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857800/*!*/;
|
||||||
|
CREATE TABLE IF NOT EXISTS mysql.backup_progress( `backup_id` BIGINT NOT NULL, `tool_name` VARCHAR(4096) NOT NULL, `error_code` INT NOT NULL, `error_message` VARCHAR(4096) NOT NULL, `current_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,`current_state` VARCHAR(200) NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COLLATE=utf8_bin
|
||||||
|
/*!*/;
|
||||||
|
# at 7703
|
||||||
|
#140315 12:30:02 server id 8798000 end_log_pos 7780 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857802/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 7780
|
||||||
|
#140315 12:30:02 server id 8798000 end_log_pos 8028 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857802/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948578000536710,'mysqlbackup',0,'NO_ERROR','Started mysqlbackup.')
|
||||||
|
/*!*/;
|
||||||
|
# at 8028
|
||||||
|
#140315 12:30:02 server id 8798000 end_log_pos 8106 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857802/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 8106
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 8183 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 8183
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 8476 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948578000536710,'mysqlbackup',0,'NO_ERROR','mysqlbackup locking tables and copying .frm + other engines data.')
|
||||||
|
/*!*/;
|
||||||
|
# at 8476
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 8554 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 8554
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 8689 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
DROP TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 8689
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 8822 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
SET @@session.pseudo_thread_id=30565/*!*/;
|
||||||
|
CREATE TEMPORARY TABLE ibbackup_binlog_marker (a INT) ENGINE = INNODB
|
||||||
|
/*!*/;
|
||||||
|
# at 8822
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 8891 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 8891
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 8999 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(1)
|
||||||
|
/*!*/;
|
||||||
|
# at 8999
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 9069 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 9069
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 9138 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 9138
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 9246 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(2)
|
||||||
|
/*!*/;
|
||||||
|
# at 9246
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 9316 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 9316
|
||||||
|
#140315 12:30:03 server id 8798000 end_log_pos 9397 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857803/*!*/;
|
||||||
|
FLUSH ENGINE LOGS
|
||||||
|
/*!*/;
|
||||||
|
# at 9397
|
||||||
|
#140315 12:30:04 server id 8798000 end_log_pos 9542 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857804/*!*/;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 9542
|
||||||
|
#140315 12:30:04 server id 8798000 end_log_pos 9619 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857804/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 9619
|
||||||
|
#140315 12:30:04 server id 8798000 end_log_pos 9879 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857804/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948578000536710,'mysqlbackup',0,'NO_ERROR','mysqlbackup unlocked the tables.')
|
||||||
|
/*!*/;
|
||||||
|
# at 9879
|
||||||
|
#140315 12:30:04 server id 8798000 end_log_pos 9957 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857804/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 9957
|
||||||
|
#140315 12:30:07 server id 8798000 end_log_pos 11135 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857807/*!*/;
|
||||||
|
CREATE TABLE IF NOT EXISTS mysql.backup_history( `backup_id` BIGINT NOT NULL, `tool_name` VARCHAR(4096) NOT NULL, `start_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `end_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `binlog_pos` BIGINT NOT NULL, `binlog_file` VARCHAR(255) NOT NULL, `compression_level` INT NOT NULL, `engines` VARCHAR(100) NOT NULL, `innodb_data_file_path` VARCHAR(2048) NOT NULL, `innodb_file_format` VARCHAR(100) NOT NULL, `start_lsn` BIGINT NOT NULL, `end_lsn` BIGINT NOT NULL, `incremental_base_lsn` BIGINT NOT NULL, `backup_type` VARCHAR(50) NOT NULL, `backup_format` VARCHAR(50) NOT NULL, `mysql_data_dir` VARCHAR(2048) NOT NULL, `innodb_data_home_dir` VARCHAR(2048) NOT NULL, `innodb_log_group_home_dir` VARCHAR(2048) NOT NULL, `innodb_log_files_in_group` VARCHAR(100) NOT NULL, `innodb_log_file_size` VARCHAR(100) NOT NULL, `backup_destination` VARCHAR(4096) NOT NULL, `lock_time` DOUBLE PRECISION (7,3) NOT NULL, `exit_state` VARCHAR(10) NOT NULL, `last_error` VARCHAR(4096) NOT NULL, `last_error_code` INT NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COLLATE=utf8_bin
|
||||||
|
/*!*/;
|
||||||
|
# at 11135
|
||||||
|
#140315 12:30:07 server id 8798000 end_log_pos 11212 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857807/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 11212
|
||||||
|
#140315 12:30:07 server id 8798000 end_log_pos 11468 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857807/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948578000536710,'mysqlbackup',0,'NO_ERROR','mysqlbackup returns success.')
|
||||||
|
/*!*/;
|
||||||
|
# at 11468
|
||||||
|
#140315 12:30:07 server id 8798000 end_log_pos 11546 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857807/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 11546
|
||||||
|
#140315 12:30:07 server id 8798000 end_log_pos 11623 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857807/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 11623
|
||||||
|
#140315 12:30:07 server id 8798000 end_log_pos 12907 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857807/*!*/;
|
||||||
|
INSERT INTO mysql.backup_history(backup_id, tool_name, start_time, end_time, binlog_pos, binlog_file, compression_level, engines, innodb_data_file_path, innodb_file_format, start_lsn, end_lsn, incremental_base_lsn, backup_type, backup_format, mysql_data_dir, innodb_data_home_dir, innodb_log_group_home_dir, innodb_log_files_in_group, innodb_log_file_size, backup_destination, lock_time, exit_state, last_error, last_error_code ) VALUES(13948578000536710,'/opt/actiontech-ha/bin/mysqlbackup --user=root --password=xxxx --host=127.0.0.1 --port=3333 --incremental --start-lsn=1328246519 --backup-dir=/tmp/mysql-926522694/2014-03-15_12-30-00 --backup-image=/opt/actiontech-ha/mysql-backup/2014-03-15_04-30-00/2014-03-15_12-30-00 --slave-info --skip-messages-logdir --read-threads=3 --process-threads=6 --write-threads=3 backup-to-image ','2014-03-15 12:30:00','2014-03-15 12:30:05',9397,'mysql-bin.000004',0,'MEMORY:MyISAM:CSV:PERFORMANCE_SCHEMA:InnoDB:','ibdata1:1G:autoextend','Barracuda',1328246520,1328260035,0,'INCREMENTAL','IMAGE','/home/ACTIONTECH-HA/mysql-install/data/','','/home/ACTIONTECH-HA/mysql-install/data/','2','268435456','/tmp/mysql-926522694/2014-03-15_12-30-00',0.623682,'SUCCESS','NO_ERROR',0)
|
||||||
|
/*!*/;
|
||||||
|
# at 12907
|
||||||
|
#140315 12:30:07 server id 8798000 end_log_pos 12985 Query thread_id=30565 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394857807/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 12985
|
||||||
|
#140315 13:00:03 server id 154063000 end_log_pos 13120 Query thread_id=32959 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394859603/*!*/;
|
||||||
|
DROP TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 13120
|
||||||
|
#140315 13:00:03 server id 154063000 end_log_pos 13253 Query thread_id=32959 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394859603/*!*/;
|
||||||
|
SET @@session.pseudo_thread_id=32959/*!*/;
|
||||||
|
CREATE TEMPORARY TABLE ibbackup_binlog_marker (a INT) ENGINE = INNODB
|
||||||
|
/*!*/;
|
||||||
|
# at 13253
|
||||||
|
#140315 13:00:03 server id 154063000 end_log_pos 13322 Query thread_id=32959 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394859603/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 13322
|
||||||
|
#140315 13:00:03 server id 154063000 end_log_pos 13430 Query thread_id=32959 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394859603/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(1)
|
||||||
|
/*!*/;
|
||||||
|
# at 13430
|
||||||
|
#140315 13:00:03 server id 154063000 end_log_pos 13500 Query thread_id=32959 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394859603/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 13500
|
||||||
|
#140315 13:00:03 server id 154063000 end_log_pos 13569 Query thread_id=32959 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394859603/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 13569
|
||||||
|
#140315 13:00:03 server id 154063000 end_log_pos 13677 Query thread_id=32959 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394859603/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(2)
|
||||||
|
/*!*/;
|
||||||
|
# at 13677
|
||||||
|
#140315 13:00:03 server id 154063000 end_log_pos 13747 Query thread_id=32959 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394859603/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 13747
|
||||||
|
#140315 13:00:03 server id 154063000 end_log_pos 13828 Query thread_id=32959 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394859603/*!*/;
|
||||||
|
FLUSH ENGINE LOGS
|
||||||
|
/*!*/;
|
||||||
|
# at 13828
|
||||||
|
#140315 13:00:05 server id 154063000 end_log_pos 13973 Query thread_id=32959 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394859605/*!*/;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 13973
|
||||||
|
#140315 13:30:00 server id 8798000 end_log_pos 14409 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861400/*!*/;
|
||||||
|
CREATE TABLE IF NOT EXISTS mysql.backup_progress( `backup_id` BIGINT NOT NULL, `tool_name` VARCHAR(4096) NOT NULL, `error_code` INT NOT NULL, `error_message` VARCHAR(4096) NOT NULL, `current_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,`current_state` VARCHAR(200) NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COLLATE=utf8_bin
|
||||||
|
/*!*/;
|
||||||
|
# at 14409
|
||||||
|
#140315 13:30:02 server id 8798000 end_log_pos 14486 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861402/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 14486
|
||||||
|
#140315 13:30:02 server id 8798000 end_log_pos 14734 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861402/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948614000558290,'mysqlbackup',0,'NO_ERROR','Started mysqlbackup.')
|
||||||
|
/*!*/;
|
||||||
|
# at 14734
|
||||||
|
#140315 13:30:02 server id 8798000 end_log_pos 14812 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861402/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 14812
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 14889 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 14889
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 15182 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948614000558290,'mysqlbackup',0,'NO_ERROR','mysqlbackup locking tables and copying .frm + other engines data.')
|
||||||
|
/*!*/;
|
||||||
|
# at 15182
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 15260 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 15260
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 15395 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
DROP TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 15395
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 15528 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
SET @@session.pseudo_thread_id=34066/*!*/;
|
||||||
|
CREATE TEMPORARY TABLE ibbackup_binlog_marker (a INT) ENGINE = INNODB
|
||||||
|
/*!*/;
|
||||||
|
# at 15528
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 15597 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 15597
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 15705 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(1)
|
||||||
|
/*!*/;
|
||||||
|
# at 15705
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 15775 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 15775
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 15844 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 15844
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 15952 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(2)
|
||||||
|
/*!*/;
|
||||||
|
# at 15952
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 16022 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 16022
|
||||||
|
#140315 13:30:03 server id 8798000 end_log_pos 16103 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861403/*!*/;
|
||||||
|
FLUSH ENGINE LOGS
|
||||||
|
/*!*/;
|
||||||
|
# at 16103
|
||||||
|
#140315 13:30:05 server id 8798000 end_log_pos 16248 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861405/*!*/;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 16248
|
||||||
|
#140315 13:30:05 server id 8798000 end_log_pos 16325 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861405/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 16325
|
||||||
|
#140315 13:30:05 server id 8798000 end_log_pos 16585 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861405/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948614000558290,'mysqlbackup',0,'NO_ERROR','mysqlbackup unlocked the tables.')
|
||||||
|
/*!*/;
|
||||||
|
# at 16585
|
||||||
|
#140315 13:30:05 server id 8798000 end_log_pos 16663 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861405/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 16663
|
||||||
|
#140315 13:30:08 server id 8798000 end_log_pos 17841 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861408/*!*/;
|
||||||
|
CREATE TABLE IF NOT EXISTS mysql.backup_history( `backup_id` BIGINT NOT NULL, `tool_name` VARCHAR(4096) NOT NULL, `start_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `end_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `binlog_pos` BIGINT NOT NULL, `binlog_file` VARCHAR(255) NOT NULL, `compression_level` INT NOT NULL, `engines` VARCHAR(100) NOT NULL, `innodb_data_file_path` VARCHAR(2048) NOT NULL, `innodb_file_format` VARCHAR(100) NOT NULL, `start_lsn` BIGINT NOT NULL, `end_lsn` BIGINT NOT NULL, `incremental_base_lsn` BIGINT NOT NULL, `backup_type` VARCHAR(50) NOT NULL, `backup_format` VARCHAR(50) NOT NULL, `mysql_data_dir` VARCHAR(2048) NOT NULL, `innodb_data_home_dir` VARCHAR(2048) NOT NULL, `innodb_log_group_home_dir` VARCHAR(2048) NOT NULL, `innodb_log_files_in_group` VARCHAR(100) NOT NULL, `innodb_log_file_size` VARCHAR(100) NOT NULL, `backup_destination` VARCHAR(4096) NOT NULL, `lock_time` DOUBLE PRECISION (7,3) NOT NULL, `exit_state` VARCHAR(10) NOT NULL, `last_error` VARCHAR(4096) NOT NULL, `last_error_code` INT NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COLLATE=utf8_bin
|
||||||
|
/*!*/;
|
||||||
|
# at 17841
|
||||||
|
#140315 13:30:08 server id 8798000 end_log_pos 17918 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861408/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 17918
|
||||||
|
#140315 13:30:08 server id 8798000 end_log_pos 18174 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861408/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948614000558290,'mysqlbackup',0,'NO_ERROR','mysqlbackup returns success.')
|
||||||
|
/*!*/;
|
||||||
|
# at 18174
|
||||||
|
#140315 13:30:08 server id 8798000 end_log_pos 18252 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861408/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 18252
|
||||||
|
#140315 13:30:08 server id 8798000 end_log_pos 18329 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861408/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 18329
|
||||||
|
#140315 13:30:08 server id 8798000 end_log_pos 19614 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861408/*!*/;
|
||||||
|
INSERT INTO mysql.backup_history(backup_id, tool_name, start_time, end_time, binlog_pos, binlog_file, compression_level, engines, innodb_data_file_path, innodb_file_format, start_lsn, end_lsn, incremental_base_lsn, backup_type, backup_format, mysql_data_dir, innodb_data_home_dir, innodb_log_group_home_dir, innodb_log_files_in_group, innodb_log_file_size, backup_destination, lock_time, exit_state, last_error, last_error_code ) VALUES(13948614000558290,'/opt/actiontech-ha/bin/mysqlbackup --user=root --password=xxxx --host=127.0.0.1 --port=3333 --incremental --start-lsn=1328260035 --backup-dir=/tmp/mysql-358856685/2014-03-15_13-30-00 --backup-image=/opt/actiontech-ha/mysql-backup/2014-03-15_04-30-00/2014-03-15_13-30-00 --slave-info --skip-messages-logdir --read-threads=3 --process-threads=6 --write-threads=3 backup-to-image ','2014-03-15 13:30:00','2014-03-15 13:30:06',16103,'mysql-bin.000004',0,'MEMORY:MyISAM:CSV:PERFORMANCE_SCHEMA:InnoDB:','ibdata1:1G:autoextend','Barracuda',1328260036,1328273462,0,'INCREMENTAL','IMAGE','/home/ACTIONTECH-HA/mysql-install/data/','','/home/ACTIONTECH-HA/mysql-install/data/','2','268435456','/tmp/mysql-358856685/2014-03-15_13-30-00',1.707628,'SUCCESS','NO_ERROR',0)
|
||||||
|
/*!*/;
|
||||||
|
# at 19614
|
||||||
|
#140315 13:30:08 server id 8798000 end_log_pos 19692 Query thread_id=34066 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394861408/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 19692
|
||||||
|
#140315 14:00:03 server id 154063000 end_log_pos 19827 Query thread_id=36469 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394863203/*!*/;
|
||||||
|
DROP TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 19827
|
||||||
|
#140315 14:00:03 server id 154063000 end_log_pos 19960 Query thread_id=36469 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394863203/*!*/;
|
||||||
|
SET @@session.pseudo_thread_id=36469/*!*/;
|
||||||
|
CREATE TEMPORARY TABLE ibbackup_binlog_marker (a INT) ENGINE = INNODB
|
||||||
|
/*!*/;
|
||||||
|
# at 19960
|
||||||
|
#140315 14:00:03 server id 154063000 end_log_pos 20029 Query thread_id=36469 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394863203/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 20029
|
||||||
|
#140315 14:00:03 server id 154063000 end_log_pos 20137 Query thread_id=36469 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394863203/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(1)
|
||||||
|
/*!*/;
|
||||||
|
# at 20137
|
||||||
|
#140315 14:00:03 server id 154063000 end_log_pos 20207 Query thread_id=36469 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394863203/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 20207
|
||||||
|
#140315 14:00:03 server id 154063000 end_log_pos 20276 Query thread_id=36469 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394863203/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 20276
|
||||||
|
#140315 14:00:03 server id 154063000 end_log_pos 20384 Query thread_id=36469 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394863203/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(2)
|
||||||
|
/*!*/;
|
||||||
|
# at 20384
|
||||||
|
#140315 14:00:03 server id 154063000 end_log_pos 20454 Query thread_id=36469 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394863203/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 20454
|
||||||
|
#140315 14:00:03 server id 154063000 end_log_pos 20535 Query thread_id=36469 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394863203/*!*/;
|
||||||
|
FLUSH ENGINE LOGS
|
||||||
|
/*!*/;
|
||||||
|
# at 20535
|
||||||
|
#140315 14:00:04 server id 154063000 end_log_pos 20680 Query thread_id=36469 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394863204/*!*/;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 20680
|
||||||
|
#140315 14:30:00 server id 8798000 end_log_pos 21116 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865000/*!*/;
|
||||||
|
CREATE TABLE IF NOT EXISTS mysql.backup_progress( `backup_id` BIGINT NOT NULL, `tool_name` VARCHAR(4096) NOT NULL, `error_code` INT NOT NULL, `error_message` VARCHAR(4096) NOT NULL, `current_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,`current_state` VARCHAR(200) NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COLLATE=utf8_bin
|
||||||
|
/*!*/;
|
||||||
|
# at 21116
|
||||||
|
#140315 14:30:02 server id 8798000 end_log_pos 21193 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865002/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 21193
|
||||||
|
#140315 14:30:02 server id 8798000 end_log_pos 21441 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865002/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948650000487610,'mysqlbackup',0,'NO_ERROR','Started mysqlbackup.')
|
||||||
|
/*!*/;
|
||||||
|
# at 21441
|
||||||
|
#140315 14:30:02 server id 8798000 end_log_pos 21519 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865002/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 21519
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 21596 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 21596
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 21889 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948650000487610,'mysqlbackup',0,'NO_ERROR','mysqlbackup locking tables and copying .frm + other engines data.')
|
||||||
|
/*!*/;
|
||||||
|
# at 21889
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 21967 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 21967
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 22102 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
DROP TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 22102
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 22235 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
SET @@session.pseudo_thread_id=37568/*!*/;
|
||||||
|
CREATE TEMPORARY TABLE ibbackup_binlog_marker (a INT) ENGINE = INNODB
|
||||||
|
/*!*/;
|
||||||
|
# at 22235
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 22304 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 22304
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 22412 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(1)
|
||||||
|
/*!*/;
|
||||||
|
# at 22412
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 22482 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 22482
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 22551 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 22551
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 22659 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
INSERT INTO ibbackup_binlog_marker VALUES(2)
|
||||||
|
/*!*/;
|
||||||
|
# at 22659
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 22729 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 22729
|
||||||
|
#140315 14:30:03 server id 8798000 end_log_pos 22810 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865003/*!*/;
|
||||||
|
FLUSH ENGINE LOGS
|
||||||
|
/*!*/;
|
||||||
|
# at 22810
|
||||||
|
#140315 14:30:05 server id 8798000 end_log_pos 22955 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865005/*!*/;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS `ibbackup_binlog_marker` /* generated by server */
|
||||||
|
/*!*/;
|
||||||
|
# at 22955
|
||||||
|
#140315 14:30:05 server id 8798000 end_log_pos 23032 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865005/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 23032
|
||||||
|
#140315 14:30:05 server id 8798000 end_log_pos 23292 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865005/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948650000487610,'mysqlbackup',0,'NO_ERROR','mysqlbackup unlocked the tables.')
|
||||||
|
/*!*/;
|
||||||
|
# at 23292
|
||||||
|
#140315 14:30:05 server id 8798000 end_log_pos 23370 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865005/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 23370
|
||||||
|
#140315 14:30:08 server id 8798000 end_log_pos 24548 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865008/*!*/;
|
||||||
|
CREATE TABLE IF NOT EXISTS mysql.backup_history( `backup_id` BIGINT NOT NULL, `tool_name` VARCHAR(4096) NOT NULL, `start_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `end_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `binlog_pos` BIGINT NOT NULL, `binlog_file` VARCHAR(255) NOT NULL, `compression_level` INT NOT NULL, `engines` VARCHAR(100) NOT NULL, `innodb_data_file_path` VARCHAR(2048) NOT NULL, `innodb_file_format` VARCHAR(100) NOT NULL, `start_lsn` BIGINT NOT NULL, `end_lsn` BIGINT NOT NULL, `incremental_base_lsn` BIGINT NOT NULL, `backup_type` VARCHAR(50) NOT NULL, `backup_format` VARCHAR(50) NOT NULL, `mysql_data_dir` VARCHAR(2048) NOT NULL, `innodb_data_home_dir` VARCHAR(2048) NOT NULL, `innodb_log_group_home_dir` VARCHAR(2048) NOT NULL, `innodb_log_files_in_group` VARCHAR(100) NOT NULL, `innodb_log_file_size` VARCHAR(100) NOT NULL, `backup_destination` VARCHAR(4096) NOT NULL, `lock_time` DOUBLE PRECISION (7,3) NOT NULL, `exit_state` VARCHAR(10) NOT NULL, `last_error` VARCHAR(4096) NOT NULL, `last_error_code` INT NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COLLATE=utf8_bin
|
||||||
|
/*!*/;
|
||||||
|
# at 24548
|
||||||
|
#140315 14:30:08 server id 8798000 end_log_pos 24625 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865008/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 24625
|
||||||
|
#140315 14:30:08 server id 8798000 end_log_pos 24881 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865008/*!*/;
|
||||||
|
INSERT INTO mysql.backup_progress( backup_id, tool_name, error_code, error_message, current_state ) VALUES (13948650000487610,'mysqlbackup',0,'NO_ERROR','mysqlbackup returns success.')
|
||||||
|
/*!*/;
|
||||||
|
# at 24881
|
||||||
|
#140315 14:30:08 server id 8798000 end_log_pos 24959 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865008/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
# at 24959
|
||||||
|
#140315 14:30:08 server id 8798000 end_log_pos 25036 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865008/*!*/;
|
||||||
|
BEGIN
|
||||||
|
/*!*/;
|
||||||
|
# at 25036
|
||||||
|
#140315 14:30:08 server id 8798000 end_log_pos 26321 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865008/*!*/;
|
||||||
|
INSERT INTO mysql.backup_history(backup_id, tool_name, start_time, end_time, binlog_pos, binlog_file, compression_level, engines, innodb_data_file_path, innodb_file_format, start_lsn, end_lsn, incremental_base_lsn, backup_type, backup_format, mysql_data_dir, innodb_data_home_dir, innodb_log_group_home_dir, innodb_log_files_in_group, innodb_log_file_size, backup_destination, lock_time, exit_state, last_error, last_error_code ) VALUES(13948650000487610,'/opt/actiontech-ha/bin/mysqlbackup --user=root --password=xxxx --host=127.0.0.1 --port=3333 --incremental --start-lsn=1328273462 --backup-dir=/tmp/mysql-274379880/2014-03-15_14-30-00 --backup-image=/opt/actiontech-ha/mysql-backup/2014-03-15_04-30-00/2014-03-15_14-30-00 --slave-info --skip-messages-logdir --read-threads=3 --process-threads=6 --write-threads=3 backup-to-image ','2014-03-15 14:30:00','2014-03-15 14:30:06',22810,'mysql-bin.000004',0,'MEMORY:MyISAM:CSV:PERFORMANCE_SCHEMA:InnoDB:','ibdata1:1G:autoextend','Barracuda',1328273463,1328286877,0,'INCREMENTAL','IMAGE','/home/ACTIONTECH-HA/mysql-install/data/','','/home/ACTIONTECH-HA/mysql-install/data/','2','268435456','/tmp/mysql-274379880/2014-03-15_14-30-00',1.636068,'SUCCESS','NO_ERROR',0)
|
||||||
|
/*!*/;
|
||||||
|
# at 26321
|
||||||
|
#140315 14:30:08 server id 8798000 end_log_pos 26399 Query thread_id=37568 exec_time=0 error_code=0
|
||||||
|
SET TIMESTAMP=1394865008/*!*/;
|
||||||
|
COMMIT
|
||||||
|
/*!*/;
|
||||||
|
DELIMITER ;
|
||||||
|
# End of log file
|
||||||
|
ROLLBACK /* added by mysqlbinlog */;
|
||||||
|
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
|
||||||
|
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
|
@ -0,0 +1,73 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/hex"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
func intToBytes(num int, buf []byte) []byte {
|
||||||
|
for i := 0; i < len(buf); i++ {
|
||||||
|
buf[i] = byte(num & 0xff)
|
||||||
|
num = num >> 8
|
||||||
|
}
|
||||||
|
return buf
|
||||||
|
}
|
||||||
|
func uintToBytes(num uint, buf []byte) []byte {
|
||||||
|
for i := 0; i < len(buf); i++ {
|
||||||
|
buf[i] = byte(num & 0xff)
|
||||||
|
num = num >> 8
|
||||||
|
}
|
||||||
|
return buf
|
||||||
|
}
|
||||||
|
|
||||||
|
func stringNullToBytes(a string) []byte {
|
||||||
|
ret := []byte(a)
|
||||||
|
ret = append(ret, byte(0))
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func bytesToUint(buf []byte) uint {
|
||||||
|
var a uint
|
||||||
|
var i uint
|
||||||
|
for _, b := range buf {
|
||||||
|
a += uint(b) << i
|
||||||
|
i += 8
|
||||||
|
}
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func bytesToUint64(buf []byte) uint64 {
|
||||||
|
var a uint64
|
||||||
|
var i uint
|
||||||
|
for _, b := range buf {
|
||||||
|
a += uint64(b) << i
|
||||||
|
i += 8
|
||||||
|
}
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
type tBytesToUuidCache struct {
|
||||||
|
mutex sync.RWMutex
|
||||||
|
bs []byte
|
||||||
|
uuid string
|
||||||
|
}
|
||||||
|
|
||||||
|
var bytesToUuidCache tBytesToUuidCache
|
||||||
|
|
||||||
|
func bytesToUuid(buf []byte) (ret string) {
|
||||||
|
bytesToUuidCache.mutex.RLock()
|
||||||
|
if 0 == bytes.Compare(buf, bytesToUuidCache.bs) {
|
||||||
|
bytesToUuidCache.mutex.RUnlock()
|
||||||
|
return bytesToUuidCache.uuid
|
||||||
|
}
|
||||||
|
bytesToUuidCache.mutex.RUnlock()
|
||||||
|
uuid := strings.ToUpper(hex.EncodeToString(buf))
|
||||||
|
bytesToUuidCache.mutex.Lock()
|
||||||
|
bytesToUuidCache.bs = make([]byte, len(buf))
|
||||||
|
copy(bytesToUuidCache.bs, buf)
|
||||||
|
bytesToUuidCache.uuid = uuid
|
||||||
|
bytesToUuidCache.mutex.Unlock()
|
||||||
|
return uuid
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package binlog
|
||||||
|
|
||||||
|
func GenBinlogEventBytes(fh EventFixedHeader, fd EventFixedData, vd EventVariableData) ([]byte, error) {
|
||||||
|
eventLength := LOG_EVENT_FIXED_HEADER_LEN + len(fd.Bytes) + len(vd.Bytes)
|
||||||
|
fh.EventLength = uint(eventLength)
|
||||||
|
|
||||||
|
buf := make([]byte, eventLength)
|
||||||
|
intToBytes(fh.Timestamp, buf[0:4])
|
||||||
|
intToBytes(fh.EventType, buf[4:5])
|
||||||
|
intToBytes(fh.ServerId, buf[5:9])
|
||||||
|
uintToBytes(fh.EventLength, buf[9:13])
|
||||||
|
intToBytes(fh.NextPosition, buf[13:17])
|
||||||
|
intToBytes(fh.Flags, buf[17:19])
|
||||||
|
copy(buf[19:19+len(fd.Bytes)-1], fd.Bytes)
|
||||||
|
copy(buf[19+len(fd.Bytes):], vd.Bytes)
|
||||||
|
return buf, nil
|
||||||
|
}
|
Loading…
Reference in New Issue