In mysql,
i have Configured Two master to single slave.
i want to replicate from different db to single db.
so i mentioned replicate-rewrite-db=TEST->TEST1
I INSERTED IN TABLE test in ONE OF THE MASTER WITH DB NAME TEST.
slave has TEST1 DB and test table.
replication is not happenning.
i think this is due to Multi-source replication..i mean we can;t do it with multiple master configured to single slave?
any one idea how to achieve replicate-rewrite-db=TEST->TEST1 in multi-source replication
when use multi source replication, you should write your config as:
[mysqld]
master_usa.replicate-rewrite-db=customer->customer_usa
master_emea.replicate-rewrite-db=customer->customer_emea
here master_usa and master_emea are channel name.
the example above is introduced by Claudio Nanni in mariadb blog
Related
I am trying to configure MySQL databases using the Master-Slave replication. Before I realized that I had to set up my environment using this replication, I already have 2 separate servers running their own MySQL DB. Each of these servers are configured the exact same. The MySQL DB are configured with hundreds of tables.
Is there a way that i can set up (Master-Slave) Replication using the configured DB's? Or will i have to start from scratch and configure the replication first and then load in all the DB tables?
You can delete all data from one of the servers. Remaining one with the data will be your Master. Then use mysqldump to backup all the data and insert it to the slave.
Take a look for the detailed instructions on the page below:
https://livecaller.io/blog/how-to-set-up-mysql-master-slave-replication/
If the data is exactly same in both the MySQL database then you can start master slave replication, but you need to be sure that the data is same. MySQL will not check that, and if there is some discrepancy in the primary key then it will throw error immediately after next DML statement.
To be on a safer side, drop the database from one server, and restore it using the MySQL dump of another server. This will give the surety that database is same on both the server.
Take the reference from the below link to establish replication between two MySQL servers.
https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql
I 'd like to get an answer to this question guiding our actions:
Do we have a fundamental rule that the slave db must be identically same with master db on both count of columns and the orders?
We are using Tungsten replicators connecting a master and slave db.
But we recently have a special requirement that we considering adding one more columns only to slave db ( at the 1st position ).
Thus we would get a different table structure in slave db compared to master db on the same table.
We would like to know if this is workable solution.
Thanks
Martin
Yes, It should be same.
Master and Slave replication run by forwarding the queries. If any insert , update, delete (DML) queries is run on Master database server, Master forward that query to slave server. If the slave don't have same schema (table name , column name) it crash the requested query from master and ultimately it crash the replication.
If you want to change table name on slave just to select data you can use views.
Hope this helps.
I have a MySQL Replication setup up and running:
Database A (Server 1 as master) --> Database A (Server Z, acting as the slave)
I now want to use the same Slave Server (Z) to be a slave of two other databases; totally different databases (e.g. B and C), not other copies if Database A.
I've followed this simple guide:
https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql
But when it comes to adding the second database to the slave server in /etc/my.cnf, I don't see how it's possible to have more than one profile.
Basically I am thinking I need both of these blocks in my.cnf on the slave server but it won't be that simple, right?
log_error="/var/log/mysql/error.log"
server-id=2
log_bin="/var/log/mysql/mysql-bin.log"
binlog_do_db=database_a
log_error="/var/log/mysql/error.log"
server-id=3
log_bin="/var/log/mysql/mysql-bin.log"
binlog_do_db=database_b
Is it possible, or do I literally need a new slave server for each unique database I want to replicate?
Is it possible to, on the slave server, have specific conf files for each database, e.g. /etc/databasea.cnf and /etc/databaseb.cnf so I can specify different settings for each database?
Thanks in advance
Multi-source replication is only available in MySQL starting with 5.7.6 or MariaDB starting with 10.0.1.
Multi-Source Replication enables a replication slave to receive transactions from multiple sources simultaneously. Multi-source replication can be used to back up multiple servers to a single server, to merge table shards, and consolidate data from multiple servers to a single server. Multi-source replication does not implement any conflict detection or resolution when applying the transactions, and those tasks are left to the application if required. In a multi-source replication topology, a slave creates a replication channel for each master that it should receive transactions from.
Source:
MySQL : http://dev.mysql.com/doc/refman/5.7/en/replication-multi-source.html
MariaDB: https://mariadb.com/kb/en/mariadb/multi-source-replication/
I have 2 MYSQL server.
MySQL#1
and
MySQL#2
MySQL#1 hosts a database which has been replicated thanks to this tutorial https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql to MySQL#2. Let's name this first database DATABASE1
MySQL#2 hosts another database DATABASE2 which has nothing to do with DATABASE1.
Is it possible to replicate as master-slave without creating conflict with the first replication, to let MySQL#1 becoming the slave for MySQL#2 ?
Thanks for any tips.
It is possible. I used to do that myself. There are several ways to do so.
At slave server configuration file, add replicate-ignore-db = DATABASE_YOU_WANT_TO_IGNORE
At master server configuration file, only log the database you want replicate to slave. binlog_do_db = DATABASE_YOU_WANT_TO_REPLICATE
Not only you can specified what database to repliace, you can even specified only what table in particular database that you want to replicate. See also replicate_wild_do_table
Further Reading
Replication Slave Options and Variables
How To Set Up Selective Master Slave Replication in MySQL
Why MySQL’s binlog-do-db option is dangerous
I want to make a dedicated SLAVE machine for data replication of three database on three different servers. In other words, I want to do Multiple Master => SIngle Slave replication.
Is there any way to do this, as simple as it can be ?
Thanks !
Multi-master replication (a slave with more than one master) is not supported by MySQL (besides MySQL Cluster). You can do a master-master replication of a circular (ring) replication (described here or here).
In High performance MySQL 2nd edition the authors describe a way to emulate multi-master replication using a clever combination of master-master replication and the Blackhole storage engine (Chapter 8 Replication > Replication Topologies > Custom Replication Solutions > Emulating multimaster replication p. 373 - 375).
They show two possibly topologies:
Using two co-masters (allowing to switch the master of the slave from Master 1 to Master 2)
Master 1: hosts DB1 and replicates DB2 from Master 2; the storage engine for all tables in DB2 is changed to Blackhole so that the data is not effectively stored on Master 1.
Master 2: hosts DB2 and replicates DB1 from Master 1; the storage engine for all tables in DB1 is changed to Blackhole so that the data is not effectively stored on Master 2
Slave 1: replicates DB1 and DB2 from either Master 1 or Master 2 (allowing to switch masters); the result is that Slave 1 replicates both databases that are effectively hosted on two different masters.
Using a master-chain
Master 1: only hosts DB1
Master 2: hosts DB2 and replicates DB1 from Master 1; the storage engine for all tables in DB1 is changed to Blackhole so that the data is not effectively stored on Master 2
Slave 1: replicates DB1 and DB2 from Master 2; the result is that Slave 1 replicates both databases that are effectively hosted on two different masters.
Please note that this setup only allows you to send updates to DB1 through Master 1 and updates to DB2 to Master 2. You cannot send updates to either table to arbitrary masters.
Pehaps it's possible to combine the described solution with the hack for a true master-master replication (allowing updates to both masters) that uses some sort of autoincrement-mangling and is described here or here.
No way that I'm aware of.
However, if the requirement here is simply to have a single replication-based backup machine, you can easily enough run three MySQL servers (on different addresses and/or ports) - we do that here, with two replication rings that each include our in-house staging server as a node.
An off-the-wall idea, if you really do want all the data into a single server and the table schemas are either fixed, or pretty much static and under your control: set up one server with the three databases on and link all the tables using the federated engine. In theory (huge caveat: I've never tried it!), you can then replicate off those federated tables on to a second server (again, possibly on the same machine), giving you genuine live copies of the data on a single MySQL instance. You could even try replicating back again, but that way possibly lies madness :)
I do not know a lot about MySQL, but don't you have the possibility to set an 'upload only' replication configuration, where the role of the master/publisher is only to collect updates made at the slave/subscriber level.
Might be worth a look at maatkit's table sync -- it's not "real" replication but it might be good enough.