MySQL Magazine. Issue 6 - Fall 2008

Embed Size (px)

Citation preview

  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    1/16

    MySSQQLL MMaaggaazziinnee

    INSIDE THIS ISSUE2 Decision Table-Driven Development

    12 Overview of Zmanda Recovery Manager

    Fal l 2008Issue 6

    REGULAR FEATURES6 Coding Corner

    17 Bookworm

    17 log-bin

    News, articles and feedback for MySQL database administrators and developersusing MySQL on a daily basis to provide some of the best database infrastructure

    available.

  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    2/16

    Page 2 Fall 2008 MySQL Magazine

    I have been trying for a while now to find ways to improve the data-driven applications I work on by

    leveraging the database. I begin with tweaking SQL queries. Then I replaced loops with complicated joinedSQL statements. The more I optimized towards the database, the more I improved performance of my overall

    application.

    Of course, this will not be news to many of you. So I tried to come up with some ways of improving the speed

    even more, but the only way I saw myself doing that is if I put some application logic in the database. At least

    to the point where the database could arrange itself to use the data more in-line with how I wanted it to be

    used.

    I did some research (actually a lot of research) and found out that the most convenient form of logic

    capturing tool was decision trees and decision tables. I developed a method that I want to share with you

    about how I believe decision tables can help you develop data-driven applications and speed up your

    database queries.

    How can developers use this?

    Decision Table-Driven Development

    Decision Table continues on next page

    By Jonathan Levin

  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    3/16

    Page 3 Fall 2008 MySQL Magazine

    STEPS:1) The business user would like a new application and develops a requirements list for you

    2) You start analyzing the system and write down what kind of data you need to keep. You then star

    designing an initial idea for a database.3) You ask what kind of decisions you need to have for the new application and then make decision tree

    diagrams. You can then show the diagrams to the business user to see if you are on the same page. Some

    examples:

    a) What discount should a new customer get?

    b) When is it ok to go outside and play a baseball game (according to the weather)?

    c) Does the hotel have available rooms?

    4) You can convert the decision tree into

    decision table, which naturally fits database table

    where you can store it:

    In this example, you can see all the possibl

    options for when a hotel will have available room

    or not. This can also be called a Truth Table

    because it only holds True or False.

    5) Now it is time to go to your application cod

    (or your database code).You write code to

    process the conditions and store the result i

    the database. You can store the results in

    separate table from the data you are referring

    it to because of versioning reasons. After yo

    have all the conditions processed and saved

    you can search the decision table for the result to the decision you are looking for and save it to your tabl

    6) There are also ways to create and search decision tables by minimizing the rows using All (meaning in

    cases for this condition) instead of True/False. In the event where you forgot a certain situation, or tr

    branch, you can configure your application to add a new row to your decision table for that situation and

    message you to fill it in later. This helps with debugging behaviour.

    7) It is important to note that there is an element of Test Driven-Development here. The idea of creating tes

    first is to help discover what your program should do, run the test to check if it works and then flesh ou

    the code to make the test pass. Here you use the conditions to help you create tests - Null for fail an

    True/False for pass. You also know what the application should do because you planned it when y

    Decision Tablefrom previous page

    Decision Table continues on next pa

  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    4/16

    Page 4 Fall 2008 MySQL Magazine

    8) Finally test the code again as well as the code behaviour.

    9) Youre done. Done is a very loose term, but for the purpose of this example, you are done.

    What are the Benefits?

    1) I already talked about the benefits for developers. It helps the coding process by defining what you

    should code and it sets up tests in a way to verify your code. Since you keep records of the results for the

    conditions, you have records for debugging.

    2) Because of the similarity of decision tables and database tables there is an opportunity to be able to alter

    them. By doing so you can change the behaviour of the application. In the events of larger changes, such

    as adding conditions and results, you have a lot of control for maintenance and testing.

    3) Finally, since the database has more information about your data and how it relates to what you need, you

    thought of which data types you need to store. Lastly, you are largely relieved from writing conditional If-

    Then-Else statements (which needs testing for possible side effects), because they are in your decision

    tables.

    Decision Tablefrom previous page

    Decision Table continues on next page

  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    5/16

    Page 5 Fall 2008 MySQL Magazine

    can produce very fast queries and reports. In the example of the hotel-reservation system, you can do

    search for which rooms are available according to WHERE available = True.

    4) It is also important to note that the logic is not necessarily held in the database if you are really agains

    that. The code is the logic which does the How and the database holds the results which is the What.

    Conclusion

    I see this method as similar to the way I have always developed my applications, but with a slight difference.

    usually grab data from different parts of the database, process the data, keep the results in memory and the

    throw them away when I am done. This time I just decide to keep the results in the database for later.

    While using this method, I really felt very surprised at the end of the development process and how easy i

    was to get to it. I felt a bit like I was cheating while I was working on the code, because I already knew al

    the answers. I am very happy with how this idea turned out. I am particularly happy with the testing elemen

    and the maintenance element which I know helps cut down on problems in development and keeps th

    application going for a long time.

    About the author

    Jonathan Levin lives in England with his wonderful new wife. He has been developing data-drive

    applications for over seven years and has been a project manager for over three years. Jonathan has recently

    moved over to MySQL and tries to be active in the community. He has been writing a blog for over a year thadiscusses database developing in MySQL.

    Decision Tablefrom previous page

  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    6/16

    Page 6 Fall 2008 MySQL Magazine

    C o d i n g

    o

    rn

    e

    r

    By Peter Brawleyhttp://www.artfulsoftware.com

    Together the two questions define what Ralph Kimball calls point-in-time architecture. Obviously manycomplex queries can be developed from them. The state of affairs recorded at time T did so over what period

    of time? Over what periods were particular database representations incorrect? Complexities multiply quickly.

    Question one concerns the problem ofhistoryall the information about a system, current and historical,

    that we now believe to be true. For some applicationsespecially accounting applicationshistory is integral

    to current data. An interest-rate view must show not only current rates but previous rates. Richard Snodgrass

    calls this temporal validity. It requires that we track the starting effective date and the ending effective date

    for every table value in the database. It occupies the largest part of a chapter in Get It Done With MySQL 5&6by myself and Arthur Fuller.

    Question two, the history of recorded values, is our subject here. What did we think this customer's name

    was last June 30th? What did we think her account balance was a month earlier? Snodgrass calls thistransaction time validitythe guarantee that the state of a table can be reported exactly as it existed at any

    time in its history.

    It is the problem of the audit trail: how to track change datetimes and authorship for all data in all rows.

    Transaction Time Validity in

    MySQL (Part I)Relational databases are terrific, but they implement

    amnesia. Unless we take steps to preserve old values, a simpleupdate to a column value in a row consigns the previously

    recorded value to oblivion. Sometimes that's OK. But what if

    users need access to those old values?

    Questions about overwritten and deleted values come in two

    basic varieties:

    1) What is the history of the correct facts, so far as we know

    them, as they affect a particular row in a particular column?

    2) What is the history of recorded values of a particular

    column in a particular row?

    There are two basic solutions:

    1) Maintain a log or logging table that tracks

    every database modification,

    2) Turn every table that needs an audit trail into

    a transaction state table by adding logging columns

    to it.

    If you have a correct tracking log, you can

    derive a transaction state table, and vice-versa, so

    you can guarantee transaction time validity with

    either approach. Logging preserves the current

    interface of the database, and that may be crucial if

    you are retrofitting transaction time validity to a

    running application. A transaction state table,

    though, may reduce disk space usage and will likely

    simplify querying of past table states.Time Va iditycontinues on next page

    Want to learn about MySQL?

    For free?

    Sessions scheduledThursdays at 15:00 CET

    MySQL University is in session!

    http://forge.mysql.com/wiki/MySQL_University

    http://www.artfulsoftware.com/http://www.artfulsoftware.com/http://www.artfulsoftware.com/http://www.artfulsoftware.com/http://forge.mysql.com/wiki/MySQL_Universityhttp://www.artfulsoftware.com/
  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    7/16

    Page 7 Fall 2008 MySQL Magazine

    This month's article discusses design and use of tracking log tables. Next month we will cover transaction

    state tables.

    Tracking logs

    In MySQL, the most basic logging method for any table, or set of tables, is to enable binary logging. Given

    a valid binary log, the state of any table (or combination of them) at any previous instant can be rebuil

    correctly with the mysqlbinlogutility.

    But if that's the only audit trail we have, then every time we run an audit report, we have to regenerate a

    least part of the database. This is not practical. An audit trail has to be directly available via straightforward

    queries. That requires a tracking log table.

    The simplest possible tracking log table has:

    1) Every column that exists in the tracked table,

    2) An action column to record the data-changing action (update, insertion or deletion),

    3) A time-of-change column with the desired datetime granularity

    4) A who-changed-this column (optional).

    What is the desired datetime tracking granularity? Whatever is guaranteed to distinguish all possible

    updates. In most systems including MySQL, two identical modification commands to the same table canno

    be executed in the same second, so change_time TIMESTAMP is reasonable.

    After creating the tracking table, we write triggers to save dated tracking copies of all row modifications

    and we prohibit deletions in the tracking table.

    This approach delivers two large benefitsit is simple, and all tracking logic remains under the hood

    invisible to an application using the tracked table. The downside is redundancy: every change is written twice

    once to the table and once to its tracking twin. Three times if you count the binary log.

    Consider this simplified table for tracking employees at a movie studio:

    Script 1: Create an employees tableCREATE TABLE emp (

    id INT PRIMARY KEY AUTO_INCREMENT,

    lastname CHAR(32) NOT NULL,

    firstname CHAR(32) NOT NULL,

    gender CHAR(1),

    dob datetime,

    marital CHAR(1),

    SSN CHAR(9)

    );

    Script 2: Populate empINSERT INTO emp VALUES

    (1, 'Black', 'Mary', 'F', '1972-10-31', 'M', '135792468'),

    (2, 'Higgins', 'Henry', 'M', '1955-2-28','W','246813579'),

    (3, 'Turunen', 'Raija', 'F', '1949-5-15','M','357902468'),

    (4, 'Garner', 'Sam', 'M', '1964-8-15','M','468013579');

    Time Validityfrom previous page

    Time Validitycontinues on next page

    Download previous editionsof MySQL Magazine at:

    http://www.mysqlzine.net

    http://www.mysqlzine.net/http://www.mysqlzine.net/
  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    8/16

    Page 8 Fall 2008 MySQL Magazine

    To create the tracking log table:

    1) Create it as a clone of the tracked table,

    2) Add an actionCHAR(1) column,3) Add a change_time TIMESTAMP column,

    4) Add a changed_by column to track the change author,

    5) Set the primary key to the current primary key plus the change_time column,

    6) Write three required triggers.

    We assume changed_by will contain a host@user value from the mysql.user table:

    Script 3: Create a tracking log table for empCREATE TABLE emplog LIKE emp;

    ALTER TABLE emplog ADD COLUMN action CHAR(1) DEFAULT '';

    ALTER TABLE emplog ADD COLUMN change_time TIMESTAMP DEFAULT NOW();

    ALTER TABLE emplog ADD COLUMN changed_by VARCHAR(77) NOT NULL;;

    ALTER TABLE emplog MODIFY COLUMN id INT DEFAULT 0;

    ALTER TABLE emplog DROP PRIMARY KEY;

    ALTER TABLE emplog ADD PRIMARY KEY (id, change_time );

    -- Insertion tracking trigger for emp table:

    CREATE TRIGGER emplog_insert AFTER INSERT ON emp

    FOR EACH ROW

    INSERT INTO emplog VALUES (NEW.id, NEW.lastname, NEW.firstname, NEW.gender, NEW.dob,

    NEW.marital, NEW.SSN, 'I', NULL, USER());

    -- Update tracking trigger for the emp table:

    CREATE TRIGGER emplog_update AFTER UPDATE ON empFOR EACH ROW

    INSERT INTO emplog VALUES (NEW.id, NEW.lastname, NEW.firstname, NEW.gender, NEW.dob,

    NEW.marital, NEW.SSN, 'U' ,NULL, USER());

    -- Deletion tracking trigger for the emp table:

    CREATE TRIGGER emplog_delete AFTER DELETE ON emp

    FOR EACH ROW

    INSERT INTO emplog VALUES (OLD.id, OLD.lastname, OLD.firstname, OLD.gender, OLD.dob,

    OLD.marital, old.SSN, 'D', NULL, USER());

    Given the tracking log's primary key, the update and deletion triggers will fail if two identical modification

    commands are attempted on the same row in the same second. That side-effect is probably desirable. If it isnot, since MySQL out of the box does not make fractions of seconds available at the query level, you will have

    to add the Milliseconds() function (http://www.artfulsoftware.com/infotree/mysqltips.php) to your server, or

    define transaction times as integers and populate them from a frontend application which can report time in

    fractions of seconds.

    Time Validityfrom previous page

    Time Validitycontinues on next page

    http://www.artfulsoftware.com/infotree/mysqltips.phpmailto:host@userhttp://www.artfulsoftware.com/infotree/mysqltips.phpmailto:host@user
  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    9/16

    Page 9 Fall 2008 MySQL Magazine

    For this to be complete, the tracking table and tracking triggers must be created before any rows are

    inserted into the tracked table. To set up tracking for an existing, populated table:

    1) Save the table definition and data with mysqldump.

    2) Write a tracking table and trigger creation script modeled on Script 3.

    3) Drop the table.4) Run the DDL portion of the dump script.

    5) Run the logging table and trigger creation script.

    6) Run the data portion of the dump script.

    Such retrofitting, of course, does not yield audit trails for any moment before the retrofit.

    For the emp table, just writeTRUNCATE emp;

    then run Script 2. To test this here, we cheat by backdating the log a month and add a subsequent

    trackable changewe learned today that actress Mary Black got divorced:

    UPDATE emplog SET change_time = change_time interval 30 day;

    UPDATE emp SET marital='D' WHERE id=1;

    How to reconstruct a dated table state from a tracking log table

    Given this setup, a query to reconstruct any previous state of a tracked table from its tracking log is dead

    simple:

    1) Find rows having no deletion action up to the target time, and for each of these,

    2) Find the row with the latest non-deletion action.

    This query varies only on one parameter, as-of date, so it is a natural for a MySQL stored procedure:

    Script 4: Snapshot of emp as of a specified historical instant

    CREATE PROCEDURE emp_asof( IN pdt TIMESTAMP )BEGIN

    SELECT id, lastname, firstname, gender, dob, marital, ssn

    FROM emplog As log1

    WHERE log1.action 'D'

    AND log1.change_time = (

    SELECT MAX( log2.change_time )

    FROM emplog AS log2

    WHERE log1.id = log2.id AND log2.change_time < pdt

    );

    END;

    You'd prefer a parameterized view? So would I. Are you desperate enough to accept a kluge? Here's one

    Assuming you have a sys database where you keep generic data tables and stored routines, execute this:

    USE sys;

    CREATE TABLE viewparams (

    id int(11) PRIMARY KEY AUTO_INCREMENT,

    db varchar(64) DEFAULT NULL,

    viewname varchar(64) DEFAULT NULL,

    paramname varchar(64) DEFAULT NULL,

    paramvalue varchar(128) DEFAULT NULL

    );

    Time Validityfrom previous page

    Time Validitycontinues on next page

  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    10/16

    Page 10 Fall 2008 MySQL Magazine

    Then if your emp table is in test ...

    USE test;

    DELETE FROM sys.viewparams WHERE db='test' AND viewname='vEmpHist';

    INSERT INTO sys.viewparams (db, viewname, paramname, paramvalue)VALUES ('test', 'vEmpHist', 'date', '2008-9-1' );

    DROP VIEW IF EXISTS vEmpHist;

    CREATE VIEW vEmpHist AS

    SELECT id, lastname,firstname,gender,dob,marital,ssn

    FROM emplog As log1

    WHERE log1.action 'D'

    AND log1.change_time = (

    SELECT MAX( log2.change_time )

    FROM emplog AS log2

    WHERE log1.id = log2.id

    AND log2.change_time < (

    SELECT paramvalue FROM sys.viewparamsWHERE db='test' AND viewname='vEmpHist' AND paramname='date'

    )

    );

    Or, until MySQL has proper parameterized Views, we can use sprocs like emp_asof() to retrieve any

    previous table state. For example, this is what the employees table looked like on 1 September 2008:

    CALL emp_asof('2008-9-1');

    +----+----------+-----------+--------+---------------------+---------+-----------+

    | id | lastname | firstname | gender | dob | marital | ssn |

    +----+----------+-----------+--------+---------------------+---------+-----------+

    | 1 | Black | Mary | F | 1972-10-31 00:00:00 | M

  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    11/16

    Page 11 Fall 2008 MySQL Magazine

    Read the Kickfire white paper to find out how to slash hardware buildout.

    http://www.kickfire.com/mysqlmag/fall08
  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    12/16

    Page 12 Fall 2008 MySQL Magazine

    Overview of Zmanda Recovery ManagerUntil not long ago, InnoDB's hot backup utility was the only tool to take an online consistent backup. For

    some time, ZRM for MySQL has seemed to be a viable alternative -- although it's not exactly hot backupbut

    online backup. The difference is subtle. A hot backup can be taken without stopping the server. An onlinebackup can be taken without stopping the server, but the database (or tables) is momentarily unavailable.

    ZRM does online backup and has several interesting characteristics that make it a very attractive tool to

    backup MySQL databases. In this article I will give an overview of the Community edition on a Linux server.

    RMcontinues on next page

    Are You Forging?

    The MySQL Forge is the premier place for code, tools, software

    previews, worklogs, and projects by and for the MySQL

    community.

    Visit http://forge.mysql.com/ to see whats being forged!

    http://forge.mysql.com

    DocumentationThe ZRM documentation is available on a wiki

    at http://mysqlbackup.zmanda.com/. This

    makes it easy to maintain updated versions, but

    on the other hand it is complicated to navigate.

    To go from one section to the next, you need to

    rely on your browsers back button. The

    documentation is pretty detailed, which might be

    daunting if you want to install quickly and start

    fiddling with the tool. In that case I highly

    recommend following the procedures described in

    the Quick MySQL Backup white paper at

    http://zmanda.com/quick-mysql-backup.html.

    InstallationInstallation requires some homework before

    starting.1) The tools require Perl and need to have

    two modules pre-installed: perl-DBI and perl-XML-parser. You can get these packages eitherstraight from your distribution repositories or

    CPAN.

    2) You also need to define a backup user

    within MySQL. The permissions that this user

    needs are detailed in the manual. You can create

    one user to backup all databases or one user for each database or group of databases. You also may have

    different users for backup and restore, or use a SUPER user to perform all these tasks. Probably for smallerenvironments, using a SUPER user is OK and for more complex ones you might need to define one or more

    backup users.

    3) ZRM also requires mailx to email the backup reports to the backup administrator. If you use a packagemanager like Debian's apt-get or Red Hat's yum to install from the Zmanda packages, chances are it will beinstalled automatically.

    4) Make sure that the path to the MySQL utilities are in the PATH environment variable since ZRM uses

    several of them.

    5) If you use snapshots for the raw backups the associated utilities should also be accessible.

    http://mysqlbackup.zmanda.com/http://zmanda.com/quick-mysql-backup.htmlhttp://mysqlbackup.zmanda.com/http://forge.mysql.com/http://forge.mysql.com/
  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    13/16

    Page 13 Fall 2008 MySQL Magazine

    Cant Get Enough?

    If a quarterly dose of MySQL news and technic

    articles is not enough, visit Planet MySQL

    http://planetmysql.org to read the MyS

    employee and community blogs. There a

    several new articles daily; bloggers can subm

    feeds as well.

    http://planetmysql.org

    Each backup set is identified by a given name. In

    the example above I enclosed each in parenthesis.

    The configuration files included in the installation

    are commented in great detail, which makes it really

    easy to use them as a reference to create your own

    configurations. As you plan the settings for each one

    of your sets keep in mind the order in which the

    configuration parameters are evaluated. The global

    configuration file is over-ridden by the backup set

    configuration which in turn is over ridden by the

    command line options. The backup set is identified

    by a unique name, which is the name of the directory

    where it's configuration file is stored.

    PARAMETERS OVERVIEWThere are numerous parameters to fine tune the

    ZRM configuration. Reviewing some of the basic ones

    gives us an idea of the tools capabilities:

    ZRMcontinued from previous page

    6) If you are going to do incremental backup and points in time recovery you will need to configure t

    server to write binlog files setting the MySQL bin-log option. Remember that setting this option requirrestarting the server.

    7) For remote backups using SSL the corresponding utilities and libraries have to be installed as well.

    The download and package installation is pretty straight forward. Zmanda offers packages in the mo

    popular formats or you can install from a tarball. The documentation includes a detailed explanation for all

    these alternatives.

    Configuring ZRMThe main concept around ZRM is the backup set. If the databases are midsize and bigger and ha

    regular traffic, it is not recommended to backup all of them at once, in which case you are going to crea

    groups of databases and / or tables to backup together. Also you will probably schedule different backu

    types with different frequencies at different times. The combination of databases, type of backup an

    schedule is what constitutes a backup set.For my examples I am going to include some of the options to backup the database used by the med

    player Amarok (http://amarok.kde.org/). I will define three backup sets:

    Monthly logical backup (music-monthly)

    Weekly raw backup (music-weekly)

    Daily incremental backup (music-daily)

    ZRMcontinues on next page

    http://planetmysql.org/http://amarok.kde.org/http://planetmysql.org/http://planetmysql.org/
  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    14/16

    Page 14 Fall 2008 MySQL Magazine

    backup-level: Full backup or incrementalbackup-mode: raw (ie: mysqlhotcopy or snapshot) or logical (ie: mysqldump)retention-policy: for how long are the backup sets going to be kept. It can specified in days, weeks or

    months.

    replication: This option needs to be specified when taking the backups from a slave, in which case allthe pertinent replication files will also be backed up.

    all-databases / databases / database / tables: Specify what to backup.Following is the set of examples for the 3 backups mentioned above:

    Monthly backup:# Full backupbackup-level = 0backup-mode = logicalretention-policy = 3Mdatabases = amarokcompression = 1Weekly backup:# Full backupbackup-level = 0backup-mode = rawretention-policy = 5Wdatabases = amarokcompression = 1Daily backup:# Incrementalbackup-level = 1backup-mode = rawretention-policy = 15Ddatabases = amarokcompression = 1

    It is also important to specify the different plug-ins. These specify the utilities that perform copies,

    compression, encryption, pre and post backup scripts, etc. This gives the tool a lot of flexibility. For

    example, it possible to include the my.cnf file along with the data backup.

    ReportsZRM offers a number of predefined reports and it is also possible to create custom ones. In addition to

    these, it is possible to create simple text reports and html. These reports can be stored in a web server

    RMcontinued from previous page

    ZRMcontinues on next page

  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    15/16

    Page 15 Fall 2008 MySQL Magazine

    RMcontinued from previous page

    Have a topic for a future editionof the MySQL Magazine?Send articles and ideas to Keith Murphy, Editor

    [email protected]

    directory, mailed and/or add to an RSS feed. The reports can be as short or detailed as needed.

    Two of the most interesting ones are the backup-performance-info and backup-app-performance-info.The first one will give you size and time information about the backup. It is a great way to plan for storage

    and/or time of day most adequate for doing the backups. The second one will give information that will

    affect the application performance, the time information includes for how long were the locks kept and how

    much time did the flush logs take.

    The following is an example of the html report output:

    REPORTTYPE: BACKUP-APP-PERFORMANCE-INFObackup_set backup_date backup_level backup_size backup_time read_locks_time

    amarok

    Tue 07 Oct

    2008 07:39:36

    AM PDT

    0 13.02 MB 00:00:03 00:00:01

    When you run the backup, the log includes very detailed information including the MySQL utilities it is

    running and which which parameters, which makes it useful for diagnosis in case you have any kind of

    problems. A copy of the log is stored in the backup setconfiguration directory.

    Selective RestoreZRM includes a binlog interpreter. With this tool it is possible to browse the incremental backup up to a

    given SQL statement. This way it is possible to recover not only from the regular situations, but from human

    error as well (ie: skip the TRUNCATE or ALTER TABLE command). It is also possible to restore based on

    timestamp or binlog position, which allows easy point-in-time recovery and restoring a slave up to a given

    point. There are specific reports to help with these tasks.

    ConclusionThe main points I like about this tool:

    Using snapshots will only lock the database for a few seconds, making it a good alternative to

    a hot backup utility.

    The plug-ins allow for a lot of flexibility to integrate different tools to perform the different

    steps of the backup.

    The number of predefined and custom reports use HTML format and create RSS feeds.

    The Selective Restore is definitively a life saver.

    Take it for a spin. The default configuration is easy to interpret and tune for small installation and it

    is also easy to customize to the needs of complex installations. It is storage engine independent (for

    snapshot backup it will work only with transactional engines), which means it will cover the current

    and future engines.

    About the Author

    Gerry Narvaja is a CMDBA for The Pythian Group and has previously worked at MySQL for six years.

    mailto:[email protected]
  • 8/14/2019 MySQL Magazine. Issue 6 - Fall 2008

    16/16

    Page 16 Fall 2008 MySQL Magazine

    BookwormThis month I went back to a book that has been around for a while. The book is MySQL Stored Procedures

    Programming (O'Reilly, 2006). Clocking in at just over 600 pages it is the definitive guide on programmingstored procedures. O'Reilly consistently puts out quality books and this one was no exception. Guy Harrison

    and Steven Feuerstein know their subject matter and it shows.

    Roughly half of the book is spent showing how to program custom procedures in SQL. It also covers

    programming with other languages such as Perl or PHP. In addition, a significant amount of space is devoted

    to showing how to optimize stored procedures. If you need to program stored procedure this book should

    definitely be on your shelf.

    Log-binThe end of July brought us the announcement that Brian Aker was essentially forking MySQL with the

    Drizzle project. The last two months have brought a flurry of activity with many of the heavyweights of the

    MySQL community getting involved. When this announcement was initially made some people wondered

    where this was going to leave MySQL.

    I have good news. It leaves MySQL (the company) and MySQL server in exactly the same place it was

    before the announcement. Drizzle isn't going to "replace" MySQL. Drizzle fundamentally has different

    objectives than MySQL server. If anything, cross-pollination between the two projects will most likely improve

    MySQL server. While it is too early to determine just where Drizzle is going, the future look brights for this

    project.

    If you are a MySQL DBA or a system administrator who spends significant time working with MySQL I

    would recommend that if you haven't already you begin following Drizzle development. As it becomes more

    stable you should probably even take it for a spin. MySQL Magazine will continue to follow the developmentof Drizzle and publish as much information as possible about it as I consider it to be an important part of the

    MySQL "sphere".

    Thanks,

    Keith

    [email protected]

    Mark Your Calendar

    MySQL Users Conference and ExpoApril 20-23Santa Clara, California, USAOnly days left until the call for proposals ends!

    Conference registration will begin in December.

    http://www.mysqlconf.com

    http://www.mysqlconf.com/mailto:[email protected]