try {
// 连接本地的Redis服务
//redis.clients.jedis.exceptions.JedisConnectionException这个是Redis数据库没有启动的异常,重新启动即可
jedis = new Jedis("134.32.50.6", 7001);
jedis.auth("as1df@#$3%Mk4Io9Ps");
// 查看本地Redis服务状态
jedis.connect();
logger.info("======= ClusterNodeMonitorJob: redis:" + nodeInfo.getHOST_IP() + "连接成功了");
logger.info("======= ClusterNodeMonitorJob: redis服务状态:" + jedis.ping());
} catch (Exception e) {
logger.info("======= ClusterNodeMonitorJob: redis:" + nodeInfo.getHOST_IP() + "连接异常---" + e.getMessage());
String sysOwn = "Redis:" + nodeInfo.getHOST_IP();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmm");
java.util.Date now = new Date();
String opTime = sdf.format(now);
String smsContext = "【重要】" + opTime +"检测实时数据Redis服务器:" + "hostIpOfEspMain" + "节点状态异常 ,请审核";
SmsUtil.sendSms(opTime, sysOwn, smsContext);
logger.info(" ==================== 节点状态异常: " + smsContext);
} finally {
if (jedis != null) {
try {
jedis.close();
logger.info("======= ClusterNodeMonitorJob: redis:" + nodeInfo.getHOST_IP() + "关闭正常");
} catch (Exception e) {
logger.info("======= ClusterNodeMonitorJob: redis:" + nodeInfo.getHOST_IP() + "关闭异常" + e.getMessage());
}
} else {
logger.info("======= ClusterNodeMonitorJob: redis:" + nodeInfo.getHOST_IP() + "null异常");
}
}