I currently have one master server and want to add another master server for fail over.
On the primary server I've added the following to "my.ini"
server-id = 1
replicate-same-server-id = 0
auto-increment-increment = 2
auto-increment-offset = 1
log_bin=mysql-bin
log_error=mysql-bin.err
binlog_do_db=1
binlog_do_db=2
binlog_do_db=3
binlog_do_db=4
Once adding:
master-host = [IP]
master-user = [usernameslaveuser]
master-password = [password]
master-connect-retry = 30
The mysql server no longer starts up...
So I decided to first get the secondary server to work properly.
Problem 2:
On the new server I've copied over my user files from the "data"/mysql dir of the primary.
I've also imported all databases with MySQL work bench.
Then I added this to "my.ini":
server-id=2
replicate-same-server-id = 0
auto-increment-increment = 2
auto-increment-offset = 2
master-host = [IP]
master-user = [usernameslaveuser]
master-password = [password]
master-connect-retry = 30
log_bin=mysql-bin
log_error=mysql-bin.err
binlog_do_db=1
binlog_do_db=2
binlog_do_db=3
binlog_do_db=4
The server starts up fine, so I decided to add a table inside a replicating database on the master but the changes where not copied over to the secondary server...
I googled a bit and found that I have to run some commands in the mysql command line to make replication work.
But when I open this on the secondary server it doesn't start...
When opening it in the command prompt it says mysql.exe: unknown variable 'server-id=2"
Both servers are running Windows Server 2012 R2 and have MySQL 5.6.15 64bit installed.
Can someone guide me true the last part of setting this up?
Specifying as below in my.cnf(linux) or my.ini(windows) file is no longer supported in latest versions of MySQL
master-host = [IP]
master-user = [usernameslaveuser]
master-password = [password]
master-connect-retry = 30
You should execute this query instead:
CHANGE MASTER TO MASTER_HOST='host name/ip',MASTER_USER='user',MASTER_PASSWORD='pwd', MASTER_PORT=3306, MASTER_CONNECT_RETRY=30;
I've resolved problem 2: I wasn't putting it in the mysqld part but in the mysql part of the my.ini
Resolved problem 1: had to run it in the MySQL command line.
Related
The question is about MySQL-Master-Master replication. I have read a lot on the Internet, but there is a problem.
Source data:
A. MySQL 5.7.
Part of my. cnf about replication:
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
log_bin_index = /var/log/mysql/mysql-bin.log.index
relay-log = /var/log/mysql/mysql-relay-bin
relay-log-index = /var/log/mysql/mysql-relay-bin.index
binlog_do_db = example
expire-logs-days = 7
auto_increment_increment = 2
auto_increment_offset = 1
log-slave-updates = 1
B. MySQL 5.7.
Part of my.cnf about replication:
server-id = 2
log_bin = /var/log/mysql/mysql-bin. log
log_bin_index = /var/log/mysql/mysql-bin.log.index
relay-log = /var/log/mysql/mysql-relay-bin
relay-log-index = /var/log/mysql/mysql-relay-bin.index
binlog_do_db = example
expire-logs-days = 7
auto_increment_increment = 2
auto_increment_offset = 2
log-slave-updates = 1
Server A is the active (primary) database server. Server B connects when server A is disabled / unavailable. In the beginning, the Master-Master replication was assembled (replication worked in both directions) and successfully worked for 2 days until I decided to test it. I started blocking access to server A to switch to server B and back. After several switches replication error 1062 appeared (Could not execute Write_rows event on table...).
And now question. What is incorrectly configured in my replication configuration? I understand that a lot depends on the product and the requests to it, but is there a universal Master-Master config?
Please consider below steps to test connection or failover:
let's assume, server A is active. So
enable read only first on server A.
then wait for couple of seconds and check show slave status twice
if positions are not changing. then move traffic on server B.
Follow same steps to reverse traffic on server A.
I have 3 servers configured with multi-source replication (my replication topology). It worked fine for 2 weeks, but now I getting error on a slave (server C at image):
Error executing row event: '##SESSION.GTID_NEXT cannot be set to ANONYMOUS when ##GLOBAL.GTID_MODE = ON.'
I tried to set GTID_NEXT/GTID_PURGED but it not worked.
Is possible to up this slave without reseting the master of server A (I reseted the master of server C)?
When I created the replication I setted AUTO_POSITION to 0, then if I get
the slave to run again the server C will read the missing log.
The version of MySQL is 5.7.17.
Add this line to my.cnf
slave-skip-errors = 1782
MySQL won't restart when I try "service mysqld restart"because I'm using this part in my.cnf
master-host = [private-IP-of-db01]
master-user = [replication-username]
master-password = [replication-password]
master-connect-retry = 60
when I comment out these parts! MySQL restarts fine. Why is that so? Also I have to include these lines in my.cnf because of master slave replication and I can't omit them out.
Usually master host information on the slave mysql server is stored in "master.info" file and maintained there. You may want to start mysql without adding the configuration to your "my.cnf" file, the only configuration you may want to add is a "server_id" , Once mysql is up and running, you should setup slave with 'change master command....'.
I'm testing MySQL replication on two virtual machines with VirtualBox running Debian 8.2.
Following tutorials, this is how I set the slave's /etc/mysql/my.cnf:
server-id = 2
master-host = 192.168.56.101
master-connect-retry = 60
master-user = slave
master-password = 123
replicate-do-db = base1
replicate-do-db = base2
relay-log = /var/lib/mysql/slave-relay.log
relay-log-index = /var/lib/mysql/slave-relay-log.index
However, doing so also won't let me start mysql. When I run /etc/init.d/mysql start, it fails. These are the two errors that appear on the logs:
error: Can't connect to local MySQL server through socket '/var/run/mysql/mysqld.sock' (2)
Failed to start LSB: Start and stop the mysql server database daemon
Commenting the master-zzz lines allow mysql to start without a hitch.
The virtual machines can see each other and ping without loss. I've tried changing the my.cnf's master-user and password, as well as creating different replication slave users on the master server, to no avail. What am I doing wrong?
Well, turns out the tutorials I was following were a bit outdated. These are the final configurations of my.cnf files:
#master
bind-address = 0.0.0.0
server-id = 1
log-bin= /var/log/mysql/mysql-bin.log
#slave
server-id = 2
Instead of setting the slave's my.cnf, I used the mysql console:
CHANGE MASTER TO master_host='master_ip', master_user='slave', master_password='slavepass';
As per this manual's instructions: https://downloads.mysql.com/docs/mysql-replication-excerpt-5.0-en.pdf
I have two MySQL servers configured in a Master-Slave relationship.
Master -> my.cnf:
server-id=1283522287
log-bin = /var/log/mysql/binary.log // There are write permissions here.
binlog_do_db= foo,bar
Slave -> my.cnf:
server-id = 1283706035
master-host = {master internal IP}
master-port = 3306
master-user = {master slave user}
master-password = {master slave user password}
However, although MySQL reports that replication is up and running, that is:
"show master status;" gives a valid position and file
"show slave status\G" reports that Slave_IO_Running and Slave_SQL_Running are both "Yes".
The slave is shown in the list of connected slaves, as viewed from the master.
Replication doesn't work. Whenever a change is made, the master file log position doesn't change. It stays at the starting size of 106 (bytes?).
Anybody have any idea what I'm missing?
... and I seem to have answered my own question, proving furthermore that one should NEVER ask questions on SO on Monday morning, after you'd had a weekend's sleep.
I had replication working great without the binlog-do-db statement, but it looked as though that would synchronize the mysql and information_schema, so I added that line:
binlog-do-db = foo,bar
Apparently, you can't comma delimit this (from the MySQL Manual):
Important
To log multiple databases, use this option multiple times, specifying the option once for each database to be logged. Because database names can contain commas, the list will be treated as the name of a single database if you supply a comma-separated list.
Great.