Merge branch '2.1' into develop
This commit is contained in:
@ -211,6 +211,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{"master_uuid", MXS_MODULE_PARAM_STRING},
|
||||
{"master_version", MXS_MODULE_PARAM_STRING},
|
||||
{"master_hostname", MXS_MODULE_PARAM_STRING},
|
||||
{"slave_hostname", MXS_MODULE_PARAM_STRING},
|
||||
{"mariadb10-compatibility", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"maxwell-compatibility", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"filestem", MXS_MODULE_PARAM_STRING, BINLOG_NAME_ROOT},
|
||||
@ -372,6 +373,7 @@ createInstance(SERVICE *service, char **options)
|
||||
inst->trx_safe = config_get_bool(params, "transaction_safety");
|
||||
inst->set_master_version = config_copy_string(params, "master_version");
|
||||
inst->set_master_hostname = config_copy_string(params, "master_hostname");
|
||||
inst->set_slave_hostname = config_copy_string(params, "slave_hostname");
|
||||
inst->fileroot = config_copy_string(params, "filestem");
|
||||
|
||||
inst->serverid = config_get_integer(params, "server_id");
|
||||
@ -382,8 +384,6 @@ createInstance(SERVICE *service, char **options)
|
||||
inst->master_uuid = config_copy_string(params, "master_uuid");
|
||||
inst->set_master_uuid = inst->master_uuid != NULL;
|
||||
|
||||
inst->set_master_version = NULL;
|
||||
inst->set_master_hostname = NULL;
|
||||
inst->send_slave_heartbeat = config_get_bool(params, "send_slave_heartbeat");
|
||||
|
||||
/* Semi-Sync support */
|
||||
@ -538,6 +538,11 @@ createInstance(SERVICE *service, char **options)
|
||||
MXS_FREE(inst->set_master_hostname);
|
||||
inst->set_master_hostname = MXS_STRDUP_A(value);
|
||||
}
|
||||
else if (strcmp(options[i], "slave_hostname") == 0)
|
||||
{
|
||||
MXS_FREE(inst->set_slave_hostname);
|
||||
inst->set_slave_hostname = MXS_STRDUP_A(value);
|
||||
}
|
||||
else if (strcmp(options[i], "mariadb10-compatibility") == 0)
|
||||
{
|
||||
inst->mariadb10_compat = config_truth_value(value);
|
||||
@ -1154,6 +1159,7 @@ free_instance(ROUTER_INSTANCE *instance)
|
||||
MXS_FREE(instance->password);
|
||||
MXS_FREE(instance->set_master_version);
|
||||
MXS_FREE(instance->set_master_hostname);
|
||||
MXS_FREE(instance->set_slave_hostname);
|
||||
MXS_FREE(instance->fileroot);
|
||||
MXS_FREE(instance->binlogdir);
|
||||
/* SSL options */
|
||||
|
@ -731,6 +731,7 @@ typedef struct router_instance
|
||||
uint32_t mariadb10_gtid_domain;/*< MariaDB 10 GTID Domain ID */
|
||||
sqlite3 *gtid_maps; /*< MariaDB 10 GTID storage */
|
||||
enum binlog_storage_type storage_type;/*< Enables hierachical binlog file storage */
|
||||
char *set_slave_hostname; /*< Send custom Hostname to Master */
|
||||
struct router_instance *next;
|
||||
} ROUTER_INSTANCE;
|
||||
|
||||
|
@ -616,28 +616,55 @@ blr_make_registration(ROUTER_INSTANCE *router)
|
||||
{
|
||||
GWBUF *buf;
|
||||
unsigned char *data;
|
||||
int len = 18;
|
||||
int len = 18; // Min size of COM_REGISTER_SLAVE payload
|
||||
int port = 3306;
|
||||
int hostname_len = 0;
|
||||
|
||||
// Send router->set_slave_hostname
|
||||
if (router->set_slave_hostname && router->set_slave_hostname[0])
|
||||
{
|
||||
hostname_len = strlen(router->set_slave_hostname);
|
||||
}
|
||||
|
||||
// Add hostname len
|
||||
len += hostname_len;
|
||||
|
||||
if ((buf = gwbuf_alloc(len + MYSQL_HEADER_LEN)) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = GWBUF_DATA(buf);
|
||||
encode_value(&data[0], len, 24); // Payload length
|
||||
data[3] = 0; // Sequence ID
|
||||
data[4] = COM_REGISTER_SLAVE; // Command
|
||||
encode_value(&data[5], router->serverid, 32); // Slave Server ID
|
||||
data[9] = 0; // Slave hostname length
|
||||
data[10] = 0; // Slave username length
|
||||
data[11] = 0; // Slave password length
|
||||
|
||||
// Point to hostname len offset
|
||||
data += 9;
|
||||
|
||||
*data++ = hostname_len; // Slave hostname length
|
||||
|
||||
// Copy hostname
|
||||
if (hostname_len)
|
||||
{
|
||||
memcpy(data, router->set_slave_hostname, hostname_len);
|
||||
}
|
||||
|
||||
// Point to user
|
||||
data += hostname_len;
|
||||
// Set empty user
|
||||
*data++ = 0; // Slave username length
|
||||
// Set empty password
|
||||
*data++ = 0; // Slave password length
|
||||
// Add port
|
||||
if (router->service->ports)
|
||||
{
|
||||
port = router->service->ports->port;
|
||||
}
|
||||
encode_value(&data[12], port, 16); // Slave master port
|
||||
encode_value(&data[14], 0, 32); // Replication rank
|
||||
encode_value(&data[18], router->masterid, 32); // Master server-id
|
||||
encode_value(&data[0], port, 16); // Slave master port, 2 bytes
|
||||
encode_value(&data[2], 0, 32); // Replication rank, 4 bytes
|
||||
encode_value(&data[6], router->masterid, 32); // Master server-id, 4 bytes
|
||||
|
||||
// This is hack to get the result set processing in order for binlogrouter
|
||||
MySQLProtocol *proto = (MySQLProtocol*)router->master->protocol;
|
||||
@ -1891,10 +1918,15 @@ static void blr_log_identity(ROUTER_INSTANCE *router)
|
||||
|
||||
/* Seen by the master */
|
||||
MXS_NOTICE("%s: identity seen by the master: "
|
||||
"server_id: %d, uuid: %s",
|
||||
"Server_id: %d, Slave_UUID: %s, Host: %s",
|
||||
router->service->name,
|
||||
router->serverid,
|
||||
(router->uuid == NULL ? "not available" : router->uuid));
|
||||
router->uuid == NULL ?
|
||||
"not available" :
|
||||
router->uuid,
|
||||
(router->set_slave_hostname && router->set_slave_hostname[0]) ?
|
||||
router->set_slave_hostname :
|
||||
"not set");
|
||||
|
||||
/* Seen by the slaves */
|
||||
|
||||
|
Reference in New Issue
Block a user