Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database Replication

How do I go about setting up replication on the same mysql server, i.e master and slave both will be the same server?

My requirement is this: I want to replicate few tables on db2 with db1 located on the same server but not all the tables.

I searched the whole the net there are few example like shown here http://www.ruturaj.net/tutorials/mysql/replication/same-server-rewrite-database but doesn't work for me.

And many examples which explain about the replication setup on two different server Can anybody please redirect me to the right link, if any available?

Thanks

like image 973
Riz Avatar asked Jul 18 '11 13:07

Riz


People also ask

What is data replication process?

Data replication is the process by which data residing on a physical/virtual server(s) or cloud instance (primary instance) is continuously replicated or copied to a secondary server(s) or cloud instance (standby instance). Organizations replicate data to support high availability, backup, and/or disaster recovery.

What is data replication explain with an example?

How data replication works. Replication involves writing or copying the same data to different locations. For example, data can be copied between two on-premises hosts, between hosts in different locations, to multiple storage devices on the same host, or to or from a cloud-based host.


1 Answers

Not a big deal; just set up two mysql servers on two different port number. I've used to choose 3306 for master, and 3307 for slave.

  1. Create a new my.cnf for slave server. ( name it my_slave.cnf )
  2. Edit my_slave.cnf : make it using another port, and put slave settings in it.
  3. Duplicate startup script : /etc/init.d/mysqld to /etc/init.d/mysqld_slave ( or add new commands slavestart, slavestop in it. )

And this is my - very - subjective opinion : separate to-be-replicated and not-to-be-replicated on [database] level not on table level. MySQL supports detailed configuration for replication level, but it'll be very complicated and make others confused after months, years later.

like image 73
lqez Avatar answered Oct 05 '22 07:10

lqez