Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

[patch 3/6] WL3127 slave side TCP address binding

From: <stewart(at)mysql.com>
Date: Fri Jun 01 2007 - 04:27:54 EDT


Add option to CHANGE MASTER TO MASTER_BIND Add Master_Bind to SHOW SLAVE STATUS
Set OPT_BIND_ADDR for client connection in slave thread default bind of all interfaces

  • sql/lex.h 1.148 vs edited ===== Index: telco-new/sql/lex.h
    • telco-new.orig/sql/lex.h 2007-05-31 22:28:07.940809000 +1000 +++ telco-new/sql/lex.h 2007-05-31 22:28:16.761360250 +1000
      @@ -301,6 +301,7 @@ static SYMBOL symbols[] = {
      { "MASTER", SYM(MASTER_SYM)}, { "MASTER_CONNECT_RETRY", SYM(MASTER_CONNECT_RETRY_SYM)}, { "MASTER_HOST", SYM(MASTER_HOST_SYM)}, + { "MASTER_BIND", SYM(MASTER_BIND_SYM)}, { "MASTER_LOG_FILE", SYM(MASTER_LOG_FILE_SYM)}, { "MASTER_LOG_POS", SYM(MASTER_LOG_POS_SYM)}, { "MASTER_PASSWORD", SYM(MASTER_PASSWORD_SYM)}, Index: telco-new/sql/log_event.h
    • telco-new.orig/sql/log_event.h 2007-05-31 22:28:07.960810250 +1000 +++ telco-new/sql/log_event.h 2007-05-31 22:28:16.765360500 +1000
      @@ -1111,6 +1111,7 @@ public:
      int master_host_len; int master_log_len; uint16 master_port; + /* TODO add mysql_bind_addr here ? */

 #ifndef MYSQL_CLIENT
   Slave_log_event(THD* thd_arg, RELAY_LOG_INFO* rli); Index: telco-new/sql/repl_failsafe.cc


  • telco-new.orig/sql/repl_failsafe.cc 2007-05-31 22:28:07.968810750 +1000 +++ telco-new/sql/repl_failsafe.cc 2007-05-31 22:28:16.765360500 +1000
    @@ -691,6 +691,12 @@ int connect_to_master(THD *thd, MYSQL* m
    mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout); mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout);
+  if (mi->bind_addr)
+  {
+    DBUG_PRINT("info",("rpl failsafe BIND ADDR: %s",mi->bind_addr));
+    mysql_options(mysql, MYSQL_OPT_BIND, mi->bind_addr);
+  }
+

 #ifdef HAVE_OPENSSL
   if (mi->ssl)
   {
Index: telco-new/sql/slave.cc
  • telco-new.orig/sql/slave.cc 2007-05-31 22:28:07.972811000 +1000 +++ telco-new/sql/slave.cc 2007-05-31 22:28:16.765360500 +1000
    @@ -1210,6 +1210,8 @@ bool show_master_info(THD* thd, MASTER_I
    sizeof(mi->user))); field_list.push_back(new Item_return_int("Master_Port", 7, MYSQL_TYPE_LONG)); + field_list.push_back(new Item_empty_string("Master_Bind", + sizeof(mi->bind_addr))); field_list.push_back(new Item_return_int("Connect_Retry", 10, MYSQL_TYPE_LONG)); field_list.push_back(new Item_empty_string("Master_Log_File",
    @@ -1281,6 +1283,7 @@ bool show_master_info(THD* thd, MASTER_I
    protocol->store(mi->host, &my_charset_bin); protocol->store(mi->user, &my_charset_bin); protocol->store((uint32) mi->port); + protocol->store((mi->bind_addr)?mi->bind_addr:"", &my_charset_bin); protocol->store((uint32) mi->connect_retry); protocol->store(mi->master_log_name, &my_charset_bin); protocol->store((ulonglong) mi->master_log_pos);
    @@ -1368,6 +1371,8 @@ bool show_master_info(THD* thd, MASTER_I
    } protocol->store(mi->ssl_verify_server_cert? "Yes":"No", &my_charset_bin);

+ protocol->store(mi->bind_addr, &my_charset_bin); +

     pthread_mutex_unlock(&mi->rli.data_lock);
     pthread_mutex_unlock(&mi->data_lock);
 

@@ -3150,6 +3155,12 @@ static int connect_to_master(THD* thd, M

   mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout);    mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout);  

+  if (mi->bind_addr)
+  {
+    DBUG_PRINT("info",("BIND ADDR: %s",mi->bind_addr));
+    mysql_options(mysql, MYSQL_OPT_BIND, mi->bind_addr);
+  }
+

 #ifdef HAVE_OPENSSL
   if (mi->ssl)
   {
Index: telco-new/sql/slave.h
  • telco-new.orig/sql/slave.h 2007-05-31 22:28:07.976811250 +1000 +++ telco-new/sql/slave.h 2007-05-31 22:28:16.765360500 +1000
    @@ -201,9 +201,9 @@ extern int disconnect_slave_event_count,

 /* the master variables are defaults read from my.cnf or command line */

 extern uint master_port, master_connect_retry, report_port;
-extern my_string master_user, master_password, master_host,
+extern my_string master_user, master_password, master_host, master_bind_addr,
        master_info_file, relay_log_info_file, report_user, report_host,
-       report_password;
+       report_password, report_bind_addr;
 

 extern my_bool master_ssl;
 extern my_string master_ssl_ca, master_ssl_capath, master_ssl_cert, Index: telco-new/sql/sql_lex.h


  • telco-new.orig/sql/sql_lex.h 2007-05-31 22:28:07.992812250 +1000 +++ telco-new/sql/sql_lex.h 2007-05-31 22:28:16.765360500 +1000
    @@ -184,7 +184,7 @@ typedef struct st_lex_server_options

 typedef struct st_lex_master_info
 {
- char *host, *user, *password, *log_file_name; + char *host, *user, *password, *log_file_name, *bind_addr;

Do you need help?X

   uint port, connect_retry;
   ulonglong pos;
   ulong server_id;
Index: telco-new/sql/sql_repl.cc


  • telco-new.orig/sql/sql_repl.cc 2007-05-31 22:28:07.996812500 +1000 +++ telco-new/sql/sql_repl.cc 2007-05-31 22:28:16.765360500 +1000
    @@ -1120,6 +1120,8 @@ bool change_master(THD* thd, MASTER_INFO

   if (lex_mi->host)
     strmake(mi->host, lex_mi->host, sizeof(mi->host)-1); + if (lex_mi->bind_addr)
+ strmake(mi->bind_addr, lex_mi->bind_addr, sizeof(mi->host)-1);

   if (lex_mi->user)
     strmake(mi->user, lex_mi->user, sizeof(mi->user)-1);    if (lex_mi->password)
Index: telco-new/sql/sql_yacc.yy


  • telco-new.orig/sql/sql_yacc.yy 2007-05-31 22:28:08.004813000 +1000 +++ telco-new/sql/sql_yacc.yy 2007-05-31 22:28:16.773361000 +1000
    @@ -770,6 +770,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
    %token LT /* OPERATOR */ %token MASTER_CONNECT_RETRY_SYM %token MASTER_HOST_SYM +%token MASTER_BIND_SYM %token MASTER_LOG_FILE_SYM %token MASTER_LOG_POS_SYM %token MASTER_PASSWORD_SYM
    @@ -1471,6 +1472,11 @@ master_def:
    Lex->mi.host = $3.str; } | + MASTER_BIND_SYM EQ TEXT_STRING_sys + { + Lex->mi.bind_addr = $3.str; + } + | MASTER_USER_SYM EQ TEXT_STRING_sys { Lex->mi.user = $3.str; Index: telco-new/sql/rpl_mi.cc
  • telco-new.orig/sql/rpl_mi.cc 2007-05-31 22:28:08.016813750 +1000 +++ telco-new/sql/rpl_mi.cc 2007-05-31 22:29:21.685417750 +1000
    @@ -32,7 +32,7 @@ MASTER_INFO::MASTER_INFO()
    abort_slave(0),slave_running(0), ssl_verify_server_cert(0), slave_run_id(0) { - host[0] = 0; user[0] = 0; password[0] = 0; + host[0] = 0; user[0] = 0; password[0] = 0; bind_addr[0] = 0; ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0; ssl_cipher[0]= 0; ssl_key[0]= 0;

@@ -61,6 +61,8 @@ void init_master_info_with_options(MASTE

   mi->master_log_name[0] = 0;
   mi->master_log_pos = BIN_LOG_HEADER_SIZE; // skip magic number  

+ strmake(mi->bind_addr, "0.0.0.0", sizeof(mi->bind_addr)); +

   if (master_host)
     strmake(mi->host, master_host, sizeof(mi->host) - 1);    if (master_user)
@@ -89,6 +91,7 @@ void init_master_info_with_options(MASTE
 

 enum {
   LINES_IN_MASTER_INFO_WITH_SSL= 14,
+ LINES_IN_MASTER_INFO_WITH_SSL_AND_BIND_ADDR= 15,      /* 5.1.16 added value of master_ssl_verify_server_cert */    LINE_FOR_MASTER_SSL_VERIFY_SERVER_CERT= 15,
@@ -289,7 +292,10 @@ file '%s')", fname);

                       "('%s') are ignored because this MySQL slave was compiled "
                       "without SSL support.", fname);
 #endif /* HAVE_OPENSSL */
-
+    if (lines >= LINES_IN_MASTER_INFO_WITH_SSL_AND_BIND_ADDR &&
+        init_strvar_from_file(mi->bind_addr, sizeof(mi->bind_addr), &mi->file,
+                              ""))
+      goto errwithmsg;
     /*
       This has to be handled here as init_intvar_from_file can't handle
       my_off_t types

Index: telco-new/sql/rpl_mi.h
  • telco-new.orig/sql/rpl_mi.h 2007-05-31 22:28:08.024814250 +1000 +++ telco-new/sql/rpl_mi.h 2007-05-31 22:28:16.773361000 +1000
    @@ -63,6 +63,7 @@ class MASTER_INFO
    /* the variables below are needed because we can change masters on the fly */ char master_log_name[FN_REFLEN]; char host[HOSTNAME_LENGTH+1]; + char bind_addr[HOSTNAME_LENGTH+1]; char user[USERNAME_LENGTH+1]; char password[MAX_PASSWORD_LENGTH+1]; my_bool ssl; // enables use of SSL connection if true
--
Stewart Smith

-- 
MySQL Internals Mailing List
For list archives: 
http://lists.mysql.com/internals
To unsubscribe:    
http://lists.mysql.com/internals?unsub=lists@pantek.com
Received on Fri Jun 1 04:35:22 2007
Do you need more help?X

This archive was generated by hypermail 2.1.8 : Fri Jun 01 2007 - 04:40:02 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library