redis clusters stepped pit

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:

  1. 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.
  2. Get confirmation operation and maintenance node status, a node indicates a failure, automatically replaced from the master before.
  3. Before service restarts operating normally, restart problems, can not be rolled back.

Find:

  1. 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
  2. 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.

Published 20 original articles · won praise 0 · views 10000 +

Guess you like

Origin blog.csdn.net/u011248560/article/details/105069126