MySQL Replication

Can anyone refer me to a good 'How To' regarding MySQL database replication? I have read a number of them but they are all for only one database on a MySQL server, I'd like to replicate every database on my MySQL server to a second Linode, where I will then be running a MySQL Dump backup script. I've tried to go with the MySQL docs on this topic, but they are not very good and seem to make lots of assumptions regarding existing knowledge.

Thanks

3 Replies

Sounds like a great plan.

You can replicate multiple databases simply by having multiple "replicate-do-db" lines in the slave's my.cnf.

Of course you'll also need multiple "binlog-do-db" lines in the master's.

We do the same kind of thing on http://FootySX.com.au using Linodes.

If you're using MySQL 5.0+, the basic things you'll probably need are:

–-----------------

my.cnf (MASTER):


[mysqld]

… your other settings …

log-bin=mysql-bin


my.cnf (SLAVES):


[mysqld]

Nothing special needed

–-----------------

On your Master:

  • Create a new user that has global replication permissions.

  • Load the initial data that you need (if any).

  • At the shell: mysqldump -uroot -p --all-databases --master-data > whatever.dump

  • Transfer whatever.dump to the slave Linode.

On your Slaves:

Login to MySQL and execute the commands: STOP SLAVE; CHANGE MASTER TO MASTERHOST='THEMASTERIPADDRESSORHOSTNAME', MASTERPORT=THEMASTERPORT(PROBABLY3306), MASTERUSER='THEREPLICATIONUSERYOUCREATED', MASTERPASSWORD='REPLICATIONUSER_PASSWORD'

At the shell: mysql -uroot -p < whatever.dump

Execute the MySQL command: START SLAVE;

That's from memory, I might have missed a step or two so let me know if it's not working.

I finally got it working, with the assistance of about 6 tutorials, MySQL docs, and your posts pointed me in the correct direction for all databases.

Cheers

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct