diff options
author | unknown <sasha@mysql.sashanet.com> | 2000-12-08 12:50:57 -0700 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2000-12-08 12:50:57 -0700 |
commit | 1ab28e5ea91466bd422bd9fef2973533252a04e1 (patch) | |
tree | 4344926e48c2b0783056c1ce3f3c8100349f28ce /sql | |
parent | 56c1e86d2db760a86a0e28e3769ffc5318c5f23d (diff) | |
download | mariadb-git-1ab28e5ea91466bd422bd9fef2973533252a04e1.tar.gz |
sql/mysqld.cc
fixed auto set of server id
sql/sql_repl.cc
do not allow slave to replicate if master id was not supplied
sql/sql_repl.h
fix for server_id
sql/mysqld.cc:
fixed auto set of server id
sql/sql_repl.cc:
do not allow slave to replicate if master id was not supplied
sql/sql_repl.h:
fix for server_id
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysqld.cc | 21 | ||||
-rw-r--r-- | sql/sql_repl.cc | 12 | ||||
-rw-r--r-- | sql/sql_repl.h | 2 |
3 files changed, 30 insertions, 5 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1122a770523..4f3d31f5aa6 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -188,6 +188,8 @@ I_List<i_string> replicate_do_db, replicate_ignore_db; I_List<i_string> binlog_do_db, binlog_ignore_db; uint32 server_id = 0; // server id for replication +bool server_id_supplied = 0; // if we guessed server_id , we need to know +// about it uint mysql_port; uint test_flags, select_errors=0, dropping_tables=0,ha_open_options=0; uint volatile thread_count=0, thread_running=0, kill_cached_threads=0, @@ -1497,8 +1499,22 @@ int main(int argc, char **argv) open_log(&mysql_update_log, glob_hostname, opt_update_logname, "", LOG_NEW); - if (!server_id) - server_id= !master_host ? 1 : 2; + if (opt_bin_log && !server_id) + { + server_id= !master_host ? 1 : 2; + switch(server_id) + { + case 1: + sql_print_error("Warning: one should set \ +server_id to a non-0 value if log-bin is enabled. Will log updates to \ + binary log, but will not accept connections from slaves"); + break; + default: + sql_print_error("Warning: one should set server_id to a non-0 value\ +if master_host is set. The server will not act as a slave"); + break; + } + } if (opt_bin_log) { if (!opt_bin_logname) @@ -3181,6 +3197,7 @@ static void get_options(int argc,char **argv) } case OPT_SERVER_ID: server_id = atoi(optarg); + server_id_supplied = 1; break; case OPT_DELAY_KEY_WRITE: ha_open_options|=HA_OPEN_DELAY_KEY_WRITE; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index e0f98b9e0bd..72d83419fe3 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -243,7 +243,12 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags) errmsg = "Binary log is not open"; goto err; } - + if(!server_id_supplied) + { + errmsg = "Misconfigured master - server id was not set"; + goto err; + } + if (log_ident[0]) mysql_bin_log.make_log_name(search_file_name, log_ident); else @@ -498,7 +503,7 @@ int start_slave(THD* thd , bool net_report) return 1; pthread_mutex_lock(&LOCK_slave); if(!slave_running) - if(glob_mi.inited && glob_mi.host) + if(glob_mi.inited && glob_mi.host && server_id_supplied) { pthread_t hThread; if(pthread_create(&hThread, &connection_attrib, handle_slave, 0)) @@ -507,7 +512,8 @@ int start_slave(THD* thd , bool net_report) } } else - err = "Master host not set or master info not initialized"; + err = "Master host not set, master info not initialized, or server id \ +not configured"; else err = "Slave already running"; diff --git a/sql/sql_repl.h b/sql/sql_repl.h index 240efb81fe4..f8a67f51aa2 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -5,6 +5,8 @@ extern char* master_host; extern my_string opt_bin_logname, master_info_file; +extern uint32 server_id; +extern bool server_id_supplied; extern I_List<i_string> binlog_do_db, binlog_ignore_db; int start_slave(THD* thd = 0, bool net_report = 1); |