Astahost.com   Mar 21, 2010
Open Discussion & Free Web Hosting > Computers & Tech > Databases

MySQL Data Replication, How? - MySQL Data Replication, how??

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Databases

MySQL Data Replication, How? - MySQL Data Replication, how??

jvizueta
How can I make data Replication in MySQL??, I'm making a web based software that's going to be used in 5 different drugstores of the same company, how can I make it so all 5 stablishments see the same data in real time?? is that possible? all 5 drugstores are in the same city but not so near one of each other, what kind of hardware should I use? where can I find a guide to it? what is the first step? can anyone help me please?

Comment/Reply (w/o sign-up)

jvizueta
is there a program that makes it easier to replicate data? what is the better way to do it? what is fastest way?

I've got another question that can be related to this topic, is replication the way website mirrors in internet work?

Comment/Reply (w/o sign-up)

yordan
We need some more info. How big is the database ? Are the five drugstores on the same network ? Can the five drugstores access the same central database ?

Comment/Reply (w/o sign-up)

jvizueta
database is not so big, and the drugstores are going to work in the same network of course, but the problem is that when someone is selling something to a customer they want the page to load very fast, and I don't know how fast it's going to get it if server is in some other neighborhood, maybe it sounds like a goofy question but I haven't done this before, please help me

thank you

Comment/Reply (w/o sign-up)

miCRoSCoPiC^eaRthLinG
Why do you need to replicate ?? Have one Central Server that can be accessed by all these drugstores. Put all of them into a Virtual private network (VPN) over the internet - and all of them would behave as if they're part of a big LAN, with the data being transmitted in a secure encrypted manner over the internet.

And in case you still want to replicate the same data all over - setup individual replication servers at the drugstore ends and have one central mysql server, which handles the feedbacks and changes from all the stores. This server should have binary logging enabled - allowing it to disperse the changes to all the replication servers allowed to connect to it. The actual steps are quite simple and can be found out throug a simple google on MySQL Replication Server. But the fact still remains, that when some data needs to be modified, it has to be done on the Primary server, in order for the change to be reflected to all the drugstores - which in effect, is the same as having just one central server. The only reason you might want to have such a setup, is that having the replicators will allow you to prefetch all changes thus accelerating local access speeds..

 

 

 


Comment/Reply (w/o sign-up)

ruben
Hi,

I don't know how much you know about MySQL, but if I get you right, you are wondering if it will really be "realtime" update, when Shop A sells something, can Shop E see directly "Oh, Item sold".
If I got you right. Realise this with MySql, but be sure to set up your database in a way that it can't be accessed when a change is being made, then they should always get up-to-date information.
The only relevant point left would be the clerks speed, how fast he types the request in and so on, but well that's not you to worry about that.
I hope this answers your question (in combination with the other replies it should ^^)


Ruben

Comment/Reply (w/o sign-up)

miCRoSCoPiC^eaRthLinG
QUOTE(ruben @ Oct 22 2005, 03:08 AM)
Hi,

I don't know how much you know about MySQL, but if I get you right, you are wondering if it will really be "realtime" update, when Shop A sells something, can Shop E see directly "Oh, Item sold".
If I got you right. Realise this with MySql, but be sure to set up your database in a way that it can't be accessed when a change is being made, then they should always get up-to-date information.
The only relevant point left would be the clerks speed, how fast he types the request in and so on, but well that's not you to worry about that.
I hope this answers your question (in combination with the other replies it should ^^)
Ruben
*



Good point smile.gif And MySQL does indeed provide a very easy way of doing this. All you need to do, before you start writing out your data is issue a command like: LOCK TABLES mytablename WRITE and once you are done issue another command: UNLOCK TABLES. This see's to your need that the same record/table is not being modified by two different connections at the same time. While the lock is in order, another connection cannot access that table.

But even for the realtime updates, a single centralized server will do. You don't need to create replications as such. Anyway, when you check up the data for a single item, the data transfer can be reduced to as minimal as possible with good planning of data normalization. Hence, even over the internet it'll produce a lag of at the most a couple of milliseconds - hardly noticeable to the end-users. But for the data to be instantly upgraded in your applications interface is another thing altogether. There's no concrete way of announcing that a certain data has changed. Thus your client application needs to constantly monitor those fields at regular intervals - by maintaining what is known as a Persistent Connection in mysql terms, where the client app connects once and always stays connected. Some event that is fired at the client's end at regular intervals polls the required databases and updates the user's screen accordingly. That's the only way of doing it I guess.

Any further questions - feel free to ask.

Regards,
m^e

Comment/Reply (w/o sign-up)

ruben
QUOTE(microscopic^earthling @ Oct 23 2005, 09:50 AM)
Good point smile.gif

thanks ^^ nice to know the command too. I'm not exactly an mySQL pro so this will help me ^^
QUOTE(microscopic^earthling @ Oct 23 2005, 09:50 AM)
it'll produce a lag of at the most a couple of milliseconds - hardly noticeable

Hey, we are talking about a drug store here!
They aren't selling the cure for cancer there, and it is not like it is important who gives the last bid for an item, right? :-P
You probably need the database only for stuff which is not in "very small store C" but maybe in "giant store A".
You just sell some toothpaste and other stuff, so a request to update data from "in stack" too "sold" should take you no time. I guess the only think you have to be careful about that there are no requests which take a lot of time and lock the table. I mean, if store E is doing a stocktaking the others must be able to access the database anyway.
But I'm pretty sure that MySQL will do the job well.

Comment/Reply (w/o sign-up)

miCRoSCoPiC^eaRthLinG
Forgot to mention - (if you're familiar with the various MySQL Storage Engines) - the LOCK TABLES/UNLOCK etc. work the best with InnoDB storage engine - which offers Transactional capabilities. In other words you can send in a block of instructions as an atomic transaction - where either the whole block gets successfully executed, or in case there occurs some error midway, the whole series of statements is rolled back and all updates are wiped out till the beginning of the transaction.

This offers a tremendous advantage in say for example, cases where you're updating 5 different tables (in some banking transaction - updating accounts of some person).. and midway there's an error. With non-transactional tables, like MyISAM, half of the statements will be executed and the other half aborted. This can lead to severe discrepancy in the accounts. On the other hand, if you use InnoDB and face an error midway - nothing to worry about. You simply rollback to the beginning point, analyze the cause of the error + fix it and then try updating all the same again.

As for the drug store thingy - I think there might be a solution in the to-be-released MySQL 5.0 - something known as Triggers. Triggers are procedures/events that you associate with tables/rows that trigger an event when this table is modified. What the trigger function will do is entirely on you - but in this case, the trigger might be effectively used to somehow update the drugstore db's as soon as the items are marked sold in the central server.

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : mysql, data, replication, mysql, data, replication

  1. Some Help With Data Basing
    (2)
  2. Login System
    I want to make a login system using Mysql. I am amateur in these thing (12)
    I want to make a login system using Mysql. I am amateur in these things so please explain in detail
    like spoon feeding. I have already made a database in http://www.sitebooth.com now what type of
    table I should make and and the website or PHP for it . If you think i hav chosen wrong site please
    give any better database hosting site. Please help me Best Regards Pritesh Gupta....
  3. Mysql Overhead
    (3)
    Sometimes in a table especially if i do alot of things in it i start seeing overhead then a size
    near it? what is overhead? and is it essential to optimize the table to fix it? I know its just a
    press of a button but i'd like to know what happens when i optimize a table. Also when you make
    a new table you can limit the size of VARCHAR to a number, that number would be the number
    characters allowed in that column per entry. I'd like to know how the limit works for texts, is
    it in KB? or number of characters? Cuz i made a messaging system. And i remember reading s....
  4. Mysql Multiple Tables
    (3)
    It is good practice to use multiple tables to sort out big amounts of data. But once you do that it
    becomes increasingly hard to cross reference the tables. Mysql has a little beautiful command
    structure that they have added. You can select multiple tables within one sql query. Example of a
    basic sql query CODE $sql = "SELECT * FROM table WHERE row=1"; If you noticed that I selected
    all of the rows in the table. Normally you will try to not select the entire table from the database
    unless you absolutely want all of the table. I would recommend against it; just gra....
  5. Any Website Provide Free Host Mysql Host?
    (4)
    any website provide free host mysql host? i need it because i am using 000webhost.com now but it
    only provide 2 mysql database... can i know where or how can i get more databases regards....
  6. Mysql On Computer
    XD (9)
    I posted PHP on computer? , but for some reason it doesn't show :/. Anyways I am wondering if
    there is MYSQL on my computer, meaning can i make a data base on my computer? that way i make what i
    want and upload it when i get hosted =)....
  7. Mysql Database Entry By Excel Sheets
    (3)
    Hello .. I would like to ask if i can use use Microsoft excel files in order to make entries to
    mysql database. Thanks....
  8. Mysql Database Management
    (1)
    Hi i am new, I have a problem in understanding the query decomposition in D-DB. Can anyone help me
    to understand the first question of the exercise 25.21 of Elmasri-Navath 4th edition? Consider the
    following relations: BOOKS (Book#, Primary_author, Topic, Total_stock, $price) BOOKSTORE (Store#,
    City, State, Zip, Inventory_value) STOCK (Store#, Book#, Qty) Consider a distributed database for a
    bookstore chain called National Books with 3 sites called EAST, MIDDLE, and WEST. Consider that
    BOOKS are fragmented by $price amounts into: B1:BOOK1:up to $20. B2:BOOK2:from ....
  9. Mysql And User File_priv
    (0)
    HI, I've hit the grain while trying to import file to mysql database - I need to enable file
    permissions of the database user but this seems not possible with most of the hosting providers.
    The problem is to set file_priv of the database user to "Y" . This is done in the "user" table of
    the maintanance database named "mysql". cPanel doesn't allow this. Via the cPanel you can only
    allow privileges on table querries but you cannot grant host file privileges to the database user -
    which makes querries like: "LOAD DATA INFILE 'filename' INTO TABLE tablen....
  10. I Have An Error With My Mysql Connection
    mysql connection error (7)
    ok so here's my web page... http://lacrossems.t35.org/ it only lags cause its trying to
    connect to the my sql server...i followed this guide
    http://forum.ragezone.com/showthread.php?t=387249 and when i edit my config.php to my host and
    login info i always get the error cannot connect to the database here is my config.php if you can
    help me CODE $host = 'CENSORED';                // my host $host =
    'righto';       // my database username $host = 'CENSORED';   // my database
    password $host = 'odinms';       // my datab....
  11. Mysql - So Hard
    Come in here if you think MySQL is soo hard! (14)
    Doesn't anybody think MySQL is so hard to code? I mean think about it, you need loads of
    databases just for one little script and you have to type things in like ;Host-Username:
    (blahblah) ;Host-Password: (blahblah) ;Host-DatabaseName: (blahblah) Ok, that MySQL code was
    random, and it is alot harder than that. If you have expierenced it being hard, you are free to
    post right in here, mate.....
  12. Subqueries In Mysql
    Using subqueries in MySQL. Very helpful. (2)
    This method is very useful. I always use this when simple queries of linking two tables is not
    enough. This method is putting a query inside a query. Example: SELECT * FROM table1 LEFT JOIN
    (SELECT * FROM table2 WHERE field1='id') AS subtable or joining multiple queries SELECT *
    FROM (SELECT * FROM table1 WHERE userid='001') AS subtable1 LEFT JOIN (SELECT * FROM table2
    WHERE field1='id') AS subtable2 You can join more than two queries depending on the output
    you want. If someone already posted this topic here I'm sorry I don't know.....
  13. Mysql Query Question
    MySQL Select query problem (4)
    Hii Guyz, I am having this little problem creating a query in MySQL. Problem description: Table:
    mytable Table Structure: IssueId | ToolName | Status 01 | Tool1 | Open 02 | Tool1 | Closed 03 |
    Tool2 | Closed 04 | Tool3 | Open Now, I want to get the results in the following form: ToolName |
    Count(Open) | Count(Closed) For the above input, result will be: Tool1 | 1 | 1 Tool2 | 0 | 1 Tool3
    | 1 | 0 There should be NO duplicate toolName in output. Thnaks, Manu.....
  14. Login System Using A Mysql Db
    How do i do this? (5)
    Hi guys, ive got a registration system that looks something like the one below: Firstname:
    Lastname: Then i have inset.php, which looks like the following: $con =
    mysql_connect("localhost","autobot","abc123"); if (!$con) { die('Could not connect: ' .
    mysql_error()); }mysql_select_db("my_db", $con);$sql="INSERT INTO person (username, password) VALUES
    ('$_POST ','$_POST ')";if (!mysql_query($sql,$con)) { die('Error: ' .
    mysql_error()); } echo "1 record added";mysql_close($con) ?> Now my question is, how do i creat....
  15. Data Base For Online Games
    (1)
    Iam thinking of starting an online game, I have some knowledge in PHP and C++ skills. But I am still
    new to mysql. I have 2 things to ask, the first is a bit of topic but does this sight allow me to
    host a game?. 2, how do i make a data base. You know units hp, attack and other characteristics. +
    people making acounts (sign up by email and verify) and all other things. Can any one help me?
    /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />....
  16. Mysql And Php
    When trying to install Joomla (16)
    I don't know if this is the correct forum, but here is my question: I'm trying to test
    Joomla and some forums in my computer, I have already installed MySQL with the GUI tools, Apache,
    and PHP with the MySQL and MySQLi extensions, but when I'm trying to install Joomla I get this
    error: Required Settings Check: ------------------------------------- PHP version >= 4.1.0
    Yes - zlib compression support Available - XML support Available - MySQL support
    Unavailable configuration.php Writeable Session save path Unwriteable Not ....
  17. Navcat For MySQL
    is Navcat any good? (9)
    Hello all, i ve recently come across NavCat (GUI tool) for MySQL. I have not bought a copy yet, just
    played around with the demo. Has any one used it beore, if so please let me know if its worth
    buying. I already have PhpMyadmin, Just wanna know if NavCat is better than PhpMyAdmin in usibility
    and functionality. Regards....
  18. Is It A Good Practice To Store Image Or Other Binary Files Directly In A Mysql Database
    (6)
    Hello to all of you beautifull people out there, I am new to MySQL, i just wanted to know if its a
    good practice to directly store images and other binary files in a MySQL database. Any one with
    help? Thanks....
  19. MySQL, Multiple Tables
    (27)
    Ok, I'm coding a project which is a leap than what I'd normally do. Before, I've always
    learned ONE table... put EVERYTHING in one database table. I'm making a profile system so there
    needs to be at least two tables: 1 for users, 1 for content. My problem is, how do I link the two
    together? I could probably figure this out faster if someone explained and posted sample SQL code
    that shows how the two are linked together. Thanks!! F....
  20. MySQL Output Database Question
    (19)
    I am new to MySql and have just created a database after using a script. My problem is not the
    script, but what it says about putting it into the output file. I cant figure out the right terms
    to put it in, I keep getting errors. I try using; SELECT*FROM 'database name' WHERE
    'location' but it isnt working. I'm lost with this stuff, I really am. Can someone
    please help me out?....
  21. MS-database To MySQL
    I'd like to batch them (6)
    Hi, maybe one of you already came across this, so I ask. I'll continue searching on. I've
    got two vocable trainers, one is Windows-native, the other one is on the web. While I can't
    control the output of the Windows-thing (so I can't export them to a *csv or something), I can
    write an import script. But since I'm not that great with Regular Expressions and don't know
    anything about *.mdb (that is MS SQL, isn't it?) files, I would need some finished thing to make
    out the field information and put it in arrays or something more readable. It wou....
  22. What Are The Alternatives To MySQL
    (7)
    Hi. i'm interested in alternatives to MySql combined with php. what database else can i use to
    create a webbased managment system with a lot of entries. maybe more than mysql can handle fast
    enough. it should be more powerful than mysql and should have nearly the same features. i hope
    there is a webbased administration program like phpmysqladmin thanks for your help ! greetings c.....
  23. Mirror My MySQL Database To Another Mysql Server
    (7)
    Hi..I want to ask if its possible to automatically mirror my mysql databases into another mysql
    server?or create a small php script to do this? The reason is because, we all know that database is
    very improtant if we have dynamic website. I have my forum hosted and i want to automatically
    mirror this or backup into another mysql server(free). Like in freesql.org. So that im not afraid
    that i forgot to backup my database..also i have one central backup database. Thanks for the
    help..Im looking forward for this posibility.....
  24. Recover Tables From A MySQL .frm File
    (9)
    I have a couple of .frm files with no corresponding data or index files. Is it possible to recover
    the table structure (field names, types, sizes, rows,col, etc) from these files? The table type is
    innodb....
  25. MySQL Database Problems
    (10)
    My friends have a little forum running here . The problem is that quite often we get the following
    message when we try to open the page: QUOTE Warning: mysql_connect(): Can't connect to
    local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in
    /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 48 Warning: mysql_error(): supplied
    argument is not a valid MySQL-Link resource in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on
    line 330 Warning: mysql_errno(): supplied argument is not a valid MySQL-Link resource in
    /home/vhosts/roh....
  26. Error In Installing MySQL Server
    MySQL server cannot be started (10)
    I try to upgrade my MySQL server from 4.018 to 4.1.10a. Firstly, I downloaded mysql-4.1.10a (not the
    essential one) for win XP Then I install the new version after the old version was uninstalled.
    After the installation process, Instance Configurator comes up to help for the configuration. But an
    error occured when it try to start the MySQL service. Error messageis "cannot create windows
    service for MySQL. Error:0" So my MySQL server cannot be started. It is running win XP on my
    computer. Does anybody can tell me what is wrong?. Thanks (sorry for my bad english)....
  27. How Can I Import Csv Files To My MySQL Database?
    I was able to export but where's import? (7)
    I am having hard times finding that import csv in the mysql phpmyadmin. I once worked on some csv
    files and someone imported it on the mysql server. I was not able to ask him. Does someone know how
    can I import csv files in mysql server?....
  28. MySQL Datetime --> VB.NET Datetime Conversion Prob
    Any solutions ?? (4)
    Hi, Can anyone provide me with a quick example of fetching a MySQL Datetime Field and converting it
    into native VB.NET DateTime format ?? Say for example my db contains a couple of fields: Field1,
    Field2, DateField... one of which is the default MySQL DateTime. Say I'm using the following
    code to connect... CODE ConnectionString = "....." QueryString = "SELECT * FROM SomeTable" Dim
    myConnection As New MySql.Data.MySqlClient.MySqlConnection(ConnectionString) Dim myCommand As New
    MySql.Data.MySqlClient.MySqlCommand(QueryString, myConnection) Dim myReader As MySq....
  29. MySQL Realtime Replication
    how to replicate mysql in realtime (4)
    i dont know if this might be useful to ppl here, but this is a very good knowledge for serious
    siteadmins. while i was digging for mysql backup techniques, i've found that mysql is able to
    do realtime replication. the idea is that there are master server and slave server. both are having
    the same version of mysql installed. the data flows; Master >copy> Slave ( in realtime!)
    you'll never have to manually copy the database file of wasting your time to manually use the
    mysqldump command. here are the links; http://dev.mysql.com/doc/mysql/en/Replication_HOWTO.h....
  30. MySQL - Trouble With Bulk Insert Statements
    (3)
    I'm trying to insert about 500 rows into mysql, but I keep getting errors. If I copy and paste
    too many (about 50) insert statements at a time I get errors sometimes. I sometimes even get errors
    but then the row is skipped so I don't know there was an error (I'm using linux and SSH).
    What's the best way to get my insert statements to put the data in MySQL? Is there anyway that I
    can have it tell me if there where any errors all the statements are executed? Thanks for your
    help.....

    1. Looking for mysql, data, replication, mysql, data, replication



See Also,

*SIMILAR VIDEOS*
Searching Video's for mysql, data, replication, mysql, data, replication
advertisement




MySQL Data Replication, How? - MySQL Data Replication, how??

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com



Creative Commons License