Free Newsletters:
DatabaseJournal  
DBANews
Database Journal
Search Database Journal:
 
HOME News MS SQL Oracle DB2 Access MySQL PostgreSQL PHP SQL Etc Scripts Links Discussion
internet.com

» HOME
» NEWS
» FEATURES
» SERIES
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Products
Scripts
Links
» DISCUSSION
» TECH JOBS

Marketplace Partners
Be a Marketplace Partner



Read “The Oracle DBA of Tomorrow”

Click for Technology & Business providers

Compare Project Management Software Now!



Webcast:Implementing a Green Data Center


Meeting the Challenge of SMB Storage


Webcast: Governing IT in a Green World




internet.commerce
Be a Commerce Partner
Logo Design
Logo Design
Web Design
Auto Insurance Quote
Computer Deals
Memory
Best Price
KVM Switch over IP
Home Improvement
Promotional Items
KVM Switches
Baby Photo Contest
Find Software
Compare Prices




Blue Coat: We Grow One Packet at a Time

Rhapsody Bets DRM-Free Downloads Can Foil iTunes

Heavies Joining Against Patent Suits?

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Intel Whitepaper: Comparing Multi-Core Processors for Server Virtualization


Solaris 8 Migration Assistant
Rapidly move your Solaris 8 application environments to new systems running Solaris 10 with the Solaris 8 Migration Assistant. Reduce migration risk while taking advantage of increased performance, reliability and security of the latest SPARC hardware platforms and Solaris 10 OS. »

 
Sun Partner Survey
Please take a quick 3 minute survey from Sun. Click here to take the survey. Your feedback will help Sun improve on their solution center and be more useful for you and your peers. Thank you for your time and consideration. »

 
Sun Eco Innovation: Power Calculators
Power consumption has increasingly become a priority in customer's minds when purchasing new systems or storage. Sun's Power Calculators provide data on power consumption of Sun products allowing IT managers to better plan the power requirements in the datacenter to achieve better energy and cost savings. »

 
Optimize the Web Tier: Consolidate to Get More Performance in Less Space and Lower Power Consumption
Expansion in the Web tier is generally accomplished by adding more servers whenever extra capacity is needed. As the pool of servers grows larger, however, the complexity of the environment can grow exponentially. »

.Net Developer
Isys Technologies
US-NM-Los Alamos

Justtechjobs.com Post A Job | Post A Resume
MySQL
May 18, 2004
Database Replication in MySQL
By Ian Gilfillan

An introduction to replication

Recently, while having the knots pounded out of my body during a particularly painful shiatsu lesson, I reflected on what put them there in the first place. Yes, 'the database' was once more to blame. A busy database I work with saw one of its tables jump from 3GB to 7GB overnight, as we imported archive data. As expected, this had some performance impact. Unfortunately, I had not expected quite the knock, and it turned out that this single database server could no longer handle the load. No matter how much more I tried to optimize the queries, tweak the variables or bump up the query cache, it was not enough. The machine could not take any more memory, and a hardware upgrade would do little good (at least with the kind of budget I have to play with). However, MySQL does not claim to be enterprise-ready for nothing, and Yahoo and other high-volume users of MySQL certainly do not run on one database server. There are a number of techniques to handle high volumes, one of which I will introduce this month - MySQL replication (I will look at others in future articles).

Replication allows you to take one database, make an exact copy of it on another server, and set one of them (the slave) to take all its updates from the other (the master). The slave reads the master's binary logs, which store all statements that change a database, and repeats these on its database, keeping the two in exact sync. Since a replicating database simply repeats statements, the databases are not necessarily exactly in sync, and advanced users can take advantage of this. That is a topic for another article however, and we will look at simple replication this month - getting one database to be an exact copy of another one.

What replication is not

  • Replication is not a backup policy. A mistyped DELETE statement will be replicated on the slave too, and you could end up with two, perfectly synchronized, empty databases. Replication can help protect against hardware failure though.
  • Replication is not an answer to all performance problems. Although updates on the slave are more optimized than if you ran the updates normally, if you use MyISAM tables, table-locking will still occur, and databases under high-load could still struggle.
  • Replication is not a guarantee that the slave will be in sync with the master at any one point in time. Even assuming the connection is always up, a busy slave may not yet have caught up with the master, so you can't simply interchange SELECT queries across master and slave servers.

How to start replicating - the master server

  • Grant the slave permission to replicate with the REPLICATION SLAVE privilege, for example as follows: GRANT REPLICATION SLAVE ON *.* TO slave_user IDENTIFIED BY 'slave_password'
  • If the master is not using the binary update log, add the following lines to the my.cnf or my.ini configuration file, and restart the server:
     
    log-bin
    server-id=1
    

    By convention, the master is usually server-id 1, and any slaves from 2 onwards, though you can change this if you wish. If the master is already using the binary update log, either take note of the offset at the moment of the backup (the next step), or use the RESET MASTER statement to clear all binary logs and immediately begin the backup. You may want to make a copy of the binary logs before doing this, in case you need to use the binary logs to restore from backup.

  • Make a backup of the database. You will use this to start the slave server. Note the comments about the binary log above. You can also skip this step if you use the LOAD DATA FROM MASTER statement, but see the comments about locking the master below first.

Go to page: 1  2  Next  

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

MySQL Archives

Whitepaper: The Cost Advantages of Blade Servers. Sponsored by HP.
Whitepaper: Rightsizing Blades for the Midmarket. Sponsored by HP.
Try the SQL Toolbelt and get a copy of Grant Fritcheys’s book on the art of high-performance SQL code.
Intel eBook: Managing the Evolving Data Center
Intel Whitepaper: Improve Security and Control of Your PCs


Latest Forum Threads
MySQL Forum
Topic By Replies Updated
MySQL WHERE clause using LIKE devel95 0 July 2nd, 02:08 PM
JOIN with multiple WHERE cjjubb 0 June 20th, 11:12 AM
Insert Array 2 Dimensional Into Database warhead2020 0 June 17th, 09:18 PM
Transfer information from an access database to MySQl database sculptor44 3 May 23rd, 08:31 AM







JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM eBook: Planning a Service Oriented Architecture
IBM eBook: Choosing the Right Architecture--What It Means for You and Your Business
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Avaya Article: Using Intelligent Presence to Create Smarter Business Applications
Intel Go Parallel Article: Getting Started with TBB on Windows
Microsoft Article: 7.0, Microsoft's Lucky Version?
Avaya Article: How to Feed Data into the Avaya Event Processor
IBM Article: Developing a Software Policy for Your Organization
Microsoft Article: Managing Virtual Machines with Microsoft System Center
Intel Go Parallel Article: Intel Threading Tools and OpenMP
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Silverlight 2 App and Walkthrough: Leverage Silverlight 2 with SQL Server and XML
IBM Article: Enterprise Search--Do You Know What's Out There?
HP Demo: StorageWorks EVA4400
Microsoft Article: The Progress and Promise of Deep Zoom
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES