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
This commit is contained in:
parent
56c1e86d2d
commit
1ab28e5ea9
@ -188,6 +188,8 @@ I_List<i_string> replicate_do_db, replicate_ignore_db;
|
|||||||
I_List<i_string> binlog_do_db, binlog_ignore_db;
|
I_List<i_string> binlog_do_db, binlog_ignore_db;
|
||||||
|
|
||||||
uint32 server_id = 0; // server id for replication
|
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 mysql_port;
|
||||||
uint test_flags, select_errors=0, dropping_tables=0,ha_open_options=0;
|
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,
|
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, "",
|
open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
|
||||||
LOG_NEW);
|
LOG_NEW);
|
||||||
|
|
||||||
if (!server_id)
|
if (opt_bin_log && !server_id)
|
||||||
|
{
|
||||||
server_id= !master_host ? 1 : 2;
|
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_log)
|
||||||
{
|
{
|
||||||
if (!opt_bin_logname)
|
if (!opt_bin_logname)
|
||||||
@ -3181,6 +3197,7 @@ static void get_options(int argc,char **argv)
|
|||||||
}
|
}
|
||||||
case OPT_SERVER_ID:
|
case OPT_SERVER_ID:
|
||||||
server_id = atoi(optarg);
|
server_id = atoi(optarg);
|
||||||
|
server_id_supplied = 1;
|
||||||
break;
|
break;
|
||||||
case OPT_DELAY_KEY_WRITE:
|
case OPT_DELAY_KEY_WRITE:
|
||||||
ha_open_options|=HA_OPEN_DELAY_KEY_WRITE;
|
ha_open_options|=HA_OPEN_DELAY_KEY_WRITE;
|
||||||
|
@ -243,6 +243,11 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
|
|||||||
errmsg = "Binary log is not open";
|
errmsg = "Binary log is not open";
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
if(!server_id_supplied)
|
||||||
|
{
|
||||||
|
errmsg = "Misconfigured master - server id was not set";
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
if (log_ident[0])
|
if (log_ident[0])
|
||||||
mysql_bin_log.make_log_name(search_file_name, log_ident);
|
mysql_bin_log.make_log_name(search_file_name, log_ident);
|
||||||
@ -498,7 +503,7 @@ int start_slave(THD* thd , bool net_report)
|
|||||||
return 1;
|
return 1;
|
||||||
pthread_mutex_lock(&LOCK_slave);
|
pthread_mutex_lock(&LOCK_slave);
|
||||||
if(!slave_running)
|
if(!slave_running)
|
||||||
if(glob_mi.inited && glob_mi.host)
|
if(glob_mi.inited && glob_mi.host && server_id_supplied)
|
||||||
{
|
{
|
||||||
pthread_t hThread;
|
pthread_t hThread;
|
||||||
if(pthread_create(&hThread, &connection_attrib, handle_slave, 0))
|
if(pthread_create(&hThread, &connection_attrib, handle_slave, 0))
|
||||||
@ -507,7 +512,8 @@ int start_slave(THD* thd , bool net_report)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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
|
else
|
||||||
err = "Slave already running";
|
err = "Slave already running";
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
extern char* master_host;
|
extern char* master_host;
|
||||||
extern my_string opt_bin_logname, master_info_file;
|
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;
|
extern I_List<i_string> binlog_do_db, binlog_ignore_db;
|
||||||
|
|
||||||
int start_slave(THD* thd = 0, bool net_report = 1);
|
int start_slave(THD* thd = 0, bool net_report = 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user