Commit a5cb0d2c authored by unknown's avatar unknown

Encourage user to specify a name for the binlog index file (either by giving...

Encourage user to specify a name for the binlog index file (either by giving an argument to --log-bin,
or by using --log-bin-index). This is so that he does not have a replication break when his master's
hostname changes. Plus binary logging options consistency checks.


sql/mysqld.cc:
  * Encourage user to specify a name for the binlog index file (either by giving an argument to --log-bin,
  or by using --log-bin-index). This is so that he does not have a replication break when his master's
  hostname changes. Why not a fatal error? To not break existing many-machine setups.
  * --log-bin-index without --log-bin does not make sense.
  * --log-slave-updates without --log-bin does not either.
support-files/my-huge.cnf.sh:
  encourage providing an argument to log-bin
support-files/my-innodb-heavy-4G.cnf.sh:
  encourage providing an argument to log-bin
support-files/my-large.cnf.sh:
  encourage providing an argument to log-bin
support-files/my-medium.cnf.sh:
  encourage providing an argument to log-bin
support-files/my-small.cnf.sh:
  encourage providing an argument to log-bin
parent 00ac0479
...@@ -2681,6 +2681,20 @@ with --log-bin instead."); ...@@ -2681,6 +2681,20 @@ with --log-bin instead.");
if (opt_bin_log) if (opt_bin_log)
{ {
if (!opt_bin_logname && !opt_binlog_index_name)
{
/*
User didn't give us info to name the binlog index file.
Picking `hostname`-bin.index like did in 4.x, causes replication to
fail if the hostname is changed later. So, we would like to instead
require a name. But as we don't want to break many existing setups, we
only give warning, not error.
*/
sql_print_warning("\
No argument was provided to --log-bin, and --log-bin-index was not used. "
"Replication may break when this MySQL server acts as a master and has his "
"hostname changed.");
}
/* If we fail to open binlog, it's going to hinder our recovery, so die */ /* If we fail to open binlog, it's going to hinder our recovery, so die */
if (open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin", if (open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
opt_binlog_index_name, LOG_BIN, 0, 0, max_binlog_size)) opt_binlog_index_name, LOG_BIN, 0, 0, max_binlog_size))
...@@ -2695,11 +2709,20 @@ with --log-bin instead."); ...@@ -2695,11 +2709,20 @@ with --log-bin instead.");
} }
#endif #endif
} }
else if (opt_log_slave_updates) else
{ {
sql_print_warning("\ if (opt_log_slave_updates)
you need to use --log-bin to make --log-slave-updates work. \ {
Now disabling --log-slave-updates."); sql_print_error("\
You need to use --log-bin=# to make --log-slave-updates work.");
unireg_abort(1);
}
if (opt_binlog_index_name)
{
sql_print_error("\
You need to use --log-bin=# to make --log-bin-index work.");
unireg_abort(1);
}
} }
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
...@@ -4493,14 +4516,16 @@ Disable with --skip-isam.", ...@@ -4493,14 +4516,16 @@ Disable with --skip-isam.",
{"log", 'l', "Log connections and queries to file.", (gptr*) &opt_logname, {"log", 'l', "Log connections and queries to file.", (gptr*) &opt_logname,
(gptr*) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"log-bin", OPT_BIN_LOG, {"log-bin", OPT_BIN_LOG,
"Log update queries in binary format.", "Log update queries in binary format. Optional (but strongly recommended "
"to avoid replication problems if server's hostname changes) argument "
"should be the chosen location for the binary log files.",
(gptr*) &opt_bin_logname, (gptr*) &opt_bin_logname, 0, GET_STR_ALLOC, (gptr*) &opt_bin_logname, (gptr*) &opt_bin_logname, 0, GET_STR_ALLOC,
OPT_ARG, 0, 0, 0, 0, 0, 0}, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"log-bin-index", OPT_BIN_LOG_INDEX, {"log-bin-index", OPT_BIN_LOG_INDEX,
"File that holds the names for last binary log files.", "File that holds the names for last binary log files.",
(gptr*) &opt_binlog_index_name, (gptr*) &opt_binlog_index_name, 0, GET_STR, (gptr*) &opt_binlog_index_name, (gptr*) &opt_binlog_index_name, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"log-error", OPT_ERROR_LOG_FILE, "Log error file.", {"log-error", OPT_ERROR_LOG_FILE, "Error log file.",
(gptr*) &log_error_file_ptr, (gptr*) &log_error_file_ptr, 0, GET_STR, (gptr*) &log_error_file_ptr, (gptr*) &log_error_file_ptr, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0}, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.", {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.",
......
...@@ -48,7 +48,7 @@ thread_concurrency = 8 ...@@ -48,7 +48,7 @@ thread_concurrency = 8
# Replication Master Server (default) # Replication Master Server (default)
# binary logging is required for replication # binary logging is required for replication
log-bin log-bin=mysql-bin
# required unique id between 1 and 2^32 - 1 # required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set # defaults to 1 if master-host is not set
...@@ -108,7 +108,7 @@ server-id = 1 ...@@ -108,7 +108,7 @@ server-id = 1
#master-port = <port> #master-port = <port>
# #
# binary logging - not required for slaves, but recommended # binary logging - not required for slaves, but recommended
#log-bin #log-bin=mysql-bin
# Point the following paths to different dedicated disks # Point the following paths to different dedicated disks
#tmpdir = /tmp/ #tmpdir = /tmp/
......
...@@ -189,7 +189,7 @@ tmp_table_size = 64M ...@@ -189,7 +189,7 @@ tmp_table_size = 64M
# Enable binary logging. This is required for acting as a MASTER in a # Enable binary logging. This is required for acting as a MASTER in a
# replication configuration. You also need the binary log if you need # replication configuration. You also need the binary log if you need
# the ability to do point in time recovery from your latest backup. # the ability to do point in time recovery from your latest backup.
log_bin log-bin=mysql-bin
# If you're using replication with chained slaves (A->B->C), you need to # If you're using replication with chained slaves (A->B->C), you need to
# enable this option on server B. It enables logging of updates done by # enable this option on server B. It enables logging of updates done by
......
...@@ -48,7 +48,7 @@ thread_concurrency = 8 ...@@ -48,7 +48,7 @@ thread_concurrency = 8
# Replication Master Server (default) # Replication Master Server (default)
# binary logging is required for replication # binary logging is required for replication
log-bin log-bin=mysql-bin
# required unique id between 1 and 2^32 - 1 # required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set # defaults to 1 if master-host is not set
...@@ -108,7 +108,7 @@ server-id = 1 ...@@ -108,7 +108,7 @@ server-id = 1
#master-port = <port> #master-port = <port>
# #
# binary logging - not required for slaves, but recommended # binary logging - not required for slaves, but recommended
#log-bin #log-bin=mysql-bin
# Point the following paths to different dedicated disks # Point the following paths to different dedicated disks
#tmpdir = /tmp/ #tmpdir = /tmp/
......
...@@ -46,7 +46,7 @@ myisam_sort_buffer_size = 8M ...@@ -46,7 +46,7 @@ myisam_sort_buffer_size = 8M
# Replication Master Server (default) # Replication Master Server (default)
# binary logging is required for replication # binary logging is required for replication
log-bin log-bin=mysql-bin
# required unique id between 1 and 2^32 - 1 # required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set # defaults to 1 if master-host is not set
...@@ -106,7 +106,7 @@ server-id = 1 ...@@ -106,7 +106,7 @@ server-id = 1
#master-port = <port> #master-port = <port>
# #
# binary logging - not required for slaves, but recommended # binary logging - not required for slaves, but recommended
#log-bin #log-bin=mysql-bin
# Point the following paths to different dedicated disks # Point the following paths to different dedicated disks
#tmpdir = /tmp/ #tmpdir = /tmp/
......
...@@ -46,7 +46,7 @@ thread_stack = 64K ...@@ -46,7 +46,7 @@ thread_stack = 64K
server-id = 1 server-id = 1
# Uncomment the following if you want to log updates # Uncomment the following if you want to log updates
#log-bin #log-bin=mysql-bin
# Uncomment the following if you are NOT using BDB tables # Uncomment the following if you are NOT using BDB tables
#skip-bdb #skip-bdb
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment