Scene: redis from the three main clusters three, jedis access, only the master node arranged three
Question: Service update deployments, found Rom redis clusters package connection refused..
Troubleshooting:
- Redis node first determines whether there is a problem, redis-cli not currently installed in the server, using the test telnet ip port, some nodes discover problems in the three nodes, can not be connected.
- Get confirmation operation and maintenance node status, a node indicates a failure, automatically replaced from the master before.
- Before service restarts operating normally, restart problems, can not be rolled back.
Find:
- redis automatic main cluster will automatically and a new node to establish a connection from the connection between the replacement service without perception, and offline node
- Restart the service, and the service will re-establish a connection configuration of ip, this step is wrong
solution:
jedis cluster when adding a node, the node does not verify the availability, we need at initialization, verify itself, so before adding the Cluster Node, Connection using redis verify packet comes.
import redis.clients.jedis.Connection;
private boolean validateConnection(String host, int port) {
Connection connection = new Connection(host, port);
try {
connection.connect();
} catch (Exception e) {
log.error("failed get connection with ip {}, port {}", host, port);
return false;
} finally {
connection.close();
}
return true;
}
You may establish a connection node added to the cluster.