Score:0

How to add a new database on replication?

as flag

I have a mysql replication with two servers. There are actually 3 databases on it.

On master :

server-id               = 1
log_bin                 = /var/log/mysql/mysql-bin.log
expire_logs_days        = 4
max_binlog_size         = 1G
bind-address            = 0.0.0.0
port                    = 3306

binlog_do_db            = database1
binlog_do_db            = database2
binlog_do_db            = database3

And on slave:

server-id               = 2
log_bin                 = /var/log/mysql/mysql-bin.log
expire_logs_days        = 4
max_binlog_size         = 1G
bind-address            = 127.0.0.1
port                    = 3306

replicate_do_db            = database1
replicate_do_db            = database2
replicate_do_db            = database3

But i need to add a new one, database4. Do I have to stop servers for this ? By simply adding the base in the cnf file, can this be taken into account dynamically?

Thanks

Score:1
ua flag

There is no way to ask the Primary to send a database that it has not always been configured to send. So...

Plan A: Add the rows to configs before creating the database. Yes, a restart of each is needed.

Plan B (you already have the database on the Primary):

  1. stop writing to the Primary
  2. Dump db4
  3. update both config files
  4. Load the dump on Replica
  5. Restart both

Notes on config:

  • If you have no binlog/replica_do/ignore configuration, all will be replicated.
  • binlog_do says what to send out from the Primary; replicate_do says what to allow into the Replica. That is, they have the same effect. (The settings become useful when only some Replicas need to receive the data.)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.