Failover MID server for LDAP Integrations

nicholasmayo
Kilo Contributor

Hey there folks,

I couldn't find anything on the documentation so I was wondering if anyone could help me. We're moving over to a MID server integration with our LDAP server to populate our user base, and I was wondering what the best practice is for redundancy?

I don't want to set up two entries that simultaneously run, but I would like to have an automatic failover in case the MID server goes down. Ideally, if the MID server goes down and the integration is severed, another MID -> LDAP integration becomes active in it's place.

Any idea if this is possible OOB? Or would I have to set up some event queuing and scripts to set a different MID -> LDAP entry to active?

Thanks!

1 ACCEPTED SOLUTION

rlatorre
Kilo Sage

We do the same thing for all integrations that utilize a MID server. We have an alternate (BCP) server with mirrored MID servers installed.



We have a business rule on the MID server table that does the switch-over if a "Production" MID server's status changes from "Up" to another value.



It searches these tables for records referencing the downed MID server and switches to the BCP counterpart. These meet our needs.


sys_soap_message_function


sys_data_source



Then it creates an Incident for investigating the issue.



If you want an example of the code let me know and I'll try to provide a generic version for you.


View solution in original post

5 REPLIES 5

Here's an example of the onAfter update Business Rule on the MID Server [ecc_agent] table although I recommend looking into setting up Clusters per the comment by @Admin Pro.

Condition: Status changes from "Up" && Name is one of <names of MID Servers to monitor>

Advanced script:

function onAfter(current, previous) {
	// Create Incident
	var inc = new GlideRecord('incident');
	inc.initialize();
	inc.applyTemplate('MID Server BCP Switchover');
	var incDesc = '';
	
	// Identify BCP MID Server
	var midBCP = '';
	if (current.name == 'mid_01'){
		midBCP = 'mids_bcp_01';
	} else if (current.name == 'mid_02'){
		midBCP = 'mid_bcp_02';
	}
	
	// Switch to BCP MID Server
	var mid = new GlideRecord('ecc_agent');
	mid.addQuery('name', midBCP);
	mid.addQuery('status', 'Up');
	mid.query();
	if (!mid.next()){
		// If alternate server is not available
		incDesc = 'BCP switchover for downed MID server ' + current.name + ' to ' + midBCP + ' failed. BCP MID Server was not available or is Down.\n\n';
	} else {
		incDesc = 'BCP switchover for downed MID server ' + current.name + ' to ' + mid.name + '.\n\n';
		
		// =============================================================
		// Update Data Sources
		var ds = new GlideRecord('sys_data_source');
		ds.addQuery('mid_server', current.sys_id);
		ds.query();
		
		// If no data sources found to switchover
		if (!ds.next()){
			incDesc = incDesc + 'Found no Data Sources using downed MID Server.\n';
		}
		
		// Switch to BCP MID Server
		while (ds.next()){
			ds.mid_server = mid.sys_id;
			ds.update();
			incDesc = incDesc + 'Switchewd Data Source ' + ds.name + ' to BCP MID Server.\n';
		}
		
		// =============================================================
		// Update SOAP Messages
		var soap = new GlideRecord('sys_soap_message_function');
		soap.addQuery('use_mid_server', current.sys_id);
		soap.query();
		
		// If no SOAP Messages found to switchover
		if (!soap.next()){
			incDesc = incDesc + 'Found no SOAP Messages using downed MID Server.\n';
		}
		
		// Switch to BCP MID Server
		while (soap.next()){
			soap.use_mid_server = mid.sys_id;
			soap.update();
			incDesc = incDesc + 'Switchewd SOAP Message ' + soap.soap_message.getDisplayValue() + ' to BCP MID Server.\n';
		}
	}
	inc.description = incDesc + '\nCheck status of downed MID server (https://[your_instance].service-now.com/ecc_agent_list.do?sysparm_query=) and on <name of MID Server VM>. <We have monitoring configured on our MID Server VMs> If the MID server service is not running ensure we received an alert from MONITORING ENGINEERING.';
	inc.insert();
}