Merge branch 'develop' into blr_mariadb10

This commit is contained in:
MassimilianoPinto
2015-03-18 12:01:03 +01:00
2 changed files with 37 additions and 19 deletions

View File

@ -21,7 +21,9 @@ Last Updated: 12th March 2015
# MaxScale Requirements # MaxScale Requirements
MaxScale must be configured with 'maxscaled' protocol for the administration interface MaxScale must be configured with 'maxscaled' protocol for the administration interface:
Example of MaxScale.cnf file:
[AdminInterface] [AdminInterface]
type=service type=service
@ -35,7 +37,7 @@ MaxScale must be configured with 'maxscaled' protocol for the administration int
## Prepare Nagios configuration files. ## Prepare Nagios configuration files.
Assuming plugins are in /usr/lib64/nagios/plugins and Nagios configuration in /etc/nagios: Assuming Nagios installed in its on server and the plugins are in /usr/lib64/nagios/plugins and configuration files are in /etc/nagios:
* Copy ./nagios/plugins/check_maxscale_*.pl under /usr/lib64/nagios/plugins * Copy ./nagios/plugins/check_maxscale_*.pl under /usr/lib64/nagios/plugins
* Copy ./nagios/plugins/maxscale_commands.cfg and server1.cfg to /etc/nagios/objects/ * Copy ./nagios/plugins/maxscale_commands.cfg and server1.cfg to /etc/nagios/objects/
@ -49,9 +51,10 @@ and add (just after localhost.cfg or commnads.cfg)
### Please note: ### Please note:
- modify server IP address in server1.cfg, pointing to MaxScale server - modify server IP address in server1.cfg, pointing to MaxScale server
- maxadmin executable must be in the nagios server - maxadmin executable must be in the nagios server
- default AdminInterface port is 6603 - default MaxScale AdminInterface port is 6603
- default maxadmin executable path is /usr/local/skysql/maxscale/bin/maxadmin - default maxadmin executable path is /usr/local/skysql/maxscale/bin/maxadmin
It can be changed by -m option It can be changed by -m option
- maxadmin executable could be copied from an existing maxscale setup (default location is /usr/local/skysql/maxscale/bin/maxadmin)
Example related to server1.cfg Example related to server1.cfg

View File

@ -416,8 +416,6 @@ int query_len;
else if (strcasecmp(word, "ALL") == 0) else if (strcasecmp(word, "ALL") == 0)
{ {
free(query_text); free(query_text);
spinlock_release(&router->lock);
return blr_slave_disconnect_all(router, slave); return blr_slave_disconnect_all(router, slave);
} }
else if (strcasecmp(word, "SERVER") == 0) else if (strcasecmp(word, "SERVER") == 0)
@ -1893,21 +1891,23 @@ char serverid[40];
uint8_t *ptr; uint8_t *ptr;
int len, id_len, seqno = 2; int len, id_len, seqno = 2;
blr_slave_send_fieldcount(router, slave, 2);
blr_slave_send_columndef(router, slave, "server_id", 0x03, 40, seqno++);
blr_slave_send_columndef(router, slave, "state", 0xf, 40, seqno++);
blr_slave_send_eof(router, slave, seqno++);
sprintf(serverid, "%d", server_id); sprintf(serverid, "%d", server_id);
id_len = strlen(serverid);
if (found) if (found)
strcpy(state, "disconnected"); strcpy(state, "disconnected");
else else
strcpy(state, "not found"); strcpy(state, "not found");
id_len = strlen(serverid);
len = 5 + id_len + strlen(state) + 1; len = 5 + id_len + strlen(state) + 1;
if ((pkt = gwbuf_alloc(len)) == NULL) if ((pkt = gwbuf_alloc(len)) == NULL)
return 0; return 0;
blr_slave_send_fieldcount(router, slave, 2);
blr_slave_send_columndef(router, slave, "server_id", 0x03, 40, seqno++);
blr_slave_send_columndef(router, slave, "state", 0xf, 40, seqno++);
blr_slave_send_eof(router, slave, seqno++);
ptr = GWBUF_DATA(pkt); ptr = GWBUF_DATA(pkt);
encode_value(ptr, id_len + 2 + strlen(state), 24); // Add length of data packet encode_value(ptr, id_len + 2 + strlen(state), 24); // Add length of data packet
ptr += 3; ptr += 3;
@ -1955,9 +1955,12 @@ blr_slave_disconnect_server(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, int se
{ {
/* server_id found */ /* server_id found */
server_found = 1; server_found = 1;
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "%s: Slave %s, server id %d, disconnected by %s@%s",
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "DISCONNECT SERVER: closing [%s], server id [%d]", router->service->name,
sptr->dcb->remote, server_id))); sptr->dcb->remote,
server_id,
slave->dcb->user,
slave->dcb->remote)));
/* send server_id with disconnect state to client */ /* send server_id with disconnect state to client */
n = blr_slave_send_disconnected_server(router, slave, server_id, 1); n = blr_slave_send_disconnected_server(router, slave, server_id, 1);
@ -1981,7 +1984,15 @@ blr_slave_disconnect_server(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, int se
n = blr_slave_send_disconnected_server(router, slave, server_id, 0); n = blr_slave_send_disconnected_server(router, slave, server_id, 0);
} }
return n; if (n == 0) {
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "Error: gwbuf memory allocation in "
"DISCONNECT SERVER server_id [%d]",
sptr->serverid)));
blr_slave_send_error(router, slave, "Memory allocation error for DISCONNECT SERVER");
}
return 1;
} }
/** /**
@ -2019,13 +2030,11 @@ blr_slave_disconnect_all(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
/* skip servers with state = 0 */ /* skip servers with state = 0 */
if (sptr->state != 0) if (sptr->state != 0)
{ {
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "DISCONNECT ALL: closing [%s], server_id [%d]",
sptr->dcb->remote, sptr->serverid)));
sprintf(server_id, "%d", sptr->serverid); sprintf(server_id, "%d", sptr->serverid);
sprintf(state, "disconnected"); sprintf(state, "disconnected");
len = 5 + strlen(server_id) + strlen(state) + 1; len = 5 + strlen(server_id) + strlen(state) + 1;
if ((pkt = gwbuf_alloc(len)) == NULL) { if ((pkt = gwbuf_alloc(len)) == NULL) {
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "Error: gwbuf memory allocation in " LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "Error: gwbuf memory allocation in "
"DISCONNECT ALL for [%s], server_id [%d]", "DISCONNECT ALL for [%s], server_id [%d]",
@ -2033,9 +2042,15 @@ blr_slave_disconnect_all(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
spinlock_release(&router->lock); spinlock_release(&router->lock);
blr_slave_send_error(router, slave, "Memory allocation error for DISCONNECT ALL");
return 1; return 1;
} }
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "%s: Slave %s, server id %d, disconnected by %s@%s",
router->service->name,
sptr->dcb->remote, sptr->serverid, slave->dcb->user, slave->dcb->remote)));
ptr = GWBUF_DATA(pkt); ptr = GWBUF_DATA(pkt);
encode_value(ptr, len - 4, 24); // Add length of data packet encode_value(ptr, len - 4, 24); // Add length of data packet
@ -2090,4 +2105,4 @@ uint8_t *ptr;
*ptr++ = 0; *ptr++ = 0;
*ptr++ = 0; *ptr++ = 0;
return slave->dcb->func.write(slave->dcb, pkt); return slave->dcb->func.write(slave->dcb, pkt);
} }