I have done replication set up between 2 database in mysql
One is master and second is slave.
Now whenever I do any change on master database on same machine it works fine and data is getting replicated to slave .
Now when I connect to master database from different machine using tools like Toad , workbench and perform any action (insert , update etc) this is not getting replicated to slave .
Does mysql support replication this scenario.
IF yes please share the steps ?
Thanks.
change data through gui tool todd etc in below manner-
first select database by use for an example-
use mydb;
update mytable set mycol='value' where mycol2='value';
Now check if data is replicating..
Also execute below command on slave and provide results if not replicating-
show slave status;
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 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 have been trying to start replication in a mysql database. I followed all the steps from the mysql manual to setup and configure the replication.
http://dev.mysql.com/doc/refman/5.1/en/replication-howto.html
I could start the replication without any trouble. Newly inserted data was replicated properly.
But after a while I observed that though INSERT are working, the UPDATEs are not replicating. So, my replicated database contains data just as it was inserted first time.
My master database is on an UNIX server with MYSQL-5.1.56. The slave is used in Windows using WAMP package with MYSQL 5.5.8. I have also tried a slave with lower version mysql with WAMP5, with same effect.
Please share your ideas and experience on this. Thanks.
I have similar problem. I know it's old thread but it can help others:
link: mysql replication works only if I choose database by USE database
I sorted it out a few months ago. The problem was, I tried to replicate only one single database, and set binlog_do_db and binlog-ignore-db options in master to select only that database. But that left out any statement which was executed without selecting database by USE database, as kayn said. Using replicate-ignore-db and replicate-do-db options in slave would do the same. So I finally fixed it by using the replicate-wild-do-table option in the slave, referenced here. Added the following line in the configuration of the slave server.
replicate-wild-do-table=mydb.%
I have an existing mysql replication set up (Windows 2008 to Ubuntu 9.04) and created several new tables in the master database. These are not showing up in the slave database.
Do new tables automatically get copied to the slave DB, or do I need to set up replication again?
Thanks!
I'm going to assume that other data is successfully replicating.
Replication in mysql is per-server, so the most likely problems are that either you aren't binloging the events, or that the slave is ignoring them.
For binglogs, verify you aren't turning sql_log_bin off for the connection (which would require SUPER) and that the various options binary-log options are set correctly. You can verify this by running mysqlbinlog on the server's binlogs.
On the slave side, check the replication options.