Adding new table to mysql replication - mysql

Hi I have an existing mysql master-master replication between 3 servers and all the servers are connected to each other. I'm replicating some tables in a specific database. there is about 80 tables in this database and only 10 of them is replicating. I'm using replicate-do-table option in my mysql config file to tell mysql which tables should be replicated.
In this stage I found that I need another table to be replicated which was not replicated before. When I add new table to mysql config file, Newly added data are coming to all the server but old existing data are not coming. what should I do to bring older data to all the servers.
this is my mysql config file
default_table_encryption=ON
table_encryption_privilege_check=ON
replica_parallel_workers=4
enforce_gtid_consistency=ON
gtid_mode=ON
keyring_file_data=.....
early-plugin-load=keyring_file.so
skip_replica_start=OFF
auto_increment_increment=50
auto_increment_offset=1
server_id=3
replicate_same_server_id=0
replicate-do-db=db
replicate-do-table=db.table1
replicate-do-table=db.table2
replicate-do-table=db.table3
replicate-do-table=db.table4
replicate-do-table=db.table5
replicate-do-table=db.table6
replicate-do-table=db.table7
replicate-do-table=db.table8
replicate-do-table=db.table9
replicate-do-table=db.table10
replicate-do-table=db.table11
replicate-do-table=db.table12
slave-skip-errors=1032

Related

Setting up MySQL (Master-Slave) replication with all ready configured databases/tables

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

MySql Master-Slave Repllication with Sync of existing data

I am using MySQL 5.5
I have successfully configured master slave. It is working for all new updates.
But,I want to configure master slave with existing data
My database contains huge data. It has xmls and PDFs stored in DB. So taking dump and importing in slave will take more time.
I want to configured with no down time.

MySQL 5.7 vs 5.5 and .ibd files

We recently did a migration from MySQL 5.5 to MySQL 5.7, on two different servers. For the migration, we used a master-slave replication. The old DB (5.5) was set as master, the new one as slave (5.7).
Everything went well and the migration was successful. The DB is large, about 600G of data.
The problem we have now is that on the new DB, ther is one large .ibd file of 82G. Let's asume the DB name is my_database. This file is located under:
/var/lib/mysql/my_database:
-rw-r----- 1 mysql mysql 82G Apr 20 10:28 articles.ibd
The articles table is big, but why there is such large ibd file on the new MySQL server, and was not there on the old one.
As we have now some storage limits (SSD), we would like to somehow delete this file. How to do it and why this file is created there on MySQL5.7?
Basically just run ALTER TABLE [TABLENAME] ENGINE=InnoDB ALGORITHM=COPY; after disabling innodb_file_per_table.
cf. https://dev.mysql.com/doc/refman/5.7/en/tablespace-copying.html and https://dba.stackexchange.com/questions/136250/migrate-from-innodb-file-per-table-to-off-in-mysql-alter-table-removing-ibd-file, https://dev.mysql.com/doc/refman/5.7/en/innodb-multiple-tablespaces.html

Mysql Replicated database not updating properly

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.%

Add a table to an existing mysql replication?

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.