当前位置:网站首页>Redis cluster messages

Redis cluster messages

2022-06-26 15:00:00 Hua Weiyun

Redis Cluster message

redis There are five types of cluster messages .

1. PING news

This message is used to detect whether the node is online . Each node in the cluster randomly selects five nodes from the list and sends PING news

2. MEET news

MEET The message is sent by the client CLUSTER MEET ip port command , The node receiving the command sends a message to ip The host and port Host send MEET news , To join the host to the cluster

3. PONG news

PONG A message is when you receive MEET or PING After the news , Send to sender PONG Message to confirm receipt of the sender's message . When a node becomes a master from a slave , This node can be accessed through PONG The message updates the perception of other nodes .

This is a cluster.h Upper clusterMsgData, This is the body of the message

union clusterMsgData {    /* PING, MEET and PONG */    struct {        /* Array of N clusterMsgDataGossip structures */        clusterMsgDataGossip gossip[1];    } ping;    /* FAIL */    struct {        clusterMsgDataFail about;    } fail;    /* PUBLISH */    struct {        clusterMsgDataPublish msg;    } publish;    /* UPDATE */    struct {        clusterMsgDataUpdate nodecfg;    } update;};

You can see from the structure that these three messages are generated by clusterMsgDataGossip Composed of

4. Release the news

When the node receives PUBLISH On command , The node broadcasts to the cluster while running the command PUBLISH news , This enables other nodes to run the command .

clusterMsgDataPublish The structure of the body

typedef struct {    //  Channel name length     uint32_t channel_len;    //  The length of the message     uint32_t message_len;    /* We can't reclare bulk_data as bulk_data[] since this structure is * nested. The 8 bytes are removed from the count during the message * length computation. */    //  The message content     unsigned char bulk_data[8];} clusterMsgDataPublish;

5. Fault message

When a master node determines that another master node is offline , The fault message will broadcast the fault message to the cluster , To notify another node that the node is offline .

clusterMsgDataFail Structure

typedef struct {    //  The name of the failed node     char nodename[CLUSTER_NAMELEN];} clusterMsgDataFail;

summary

This is it. redis frequently-used 5 A message , Let's conclude by PING Cancellation message 、PONG news 、MEET news 、 Release messages and fault messages ,PING Messages are used to detect whether nodes are online ,PONG The message is to receive PING News or MEET Feedback from the message , The table name message has been received ,MEET Messages are used to get hosts to join the cluster , Publishing news is used to broadcast , The fault message is published when the node is offline , Indicates that the host has failed .

Well, that's what we're talking about today , Like friends, welcome to give me some praise , Hey

️ Thank you for your

If you think this is helpful for you :

  1. Welcome to follow me ️, give the thumbs-up , Comment on , forward
  2. Focus on Panpan small class , Push good articles for you regularly , There are also group chat and irregular lottery activities , You can say what you want , Communicate with the great gods , Learning together .
  3. If there is anything inappropriate, you are welcome to criticize and correct .
原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261438086246.html