Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Getting started with redis5 cluster Cluster

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

I. modify the configuration file

# Startup port

Port 5001

# running in the background

Daemonize yes

# location where process ID files are stored

Pidfile / var/run/redis_6379.pid

# location of log ID files

Logfile / home/whqlkj/redis-cluster/5001/redis-server.log

# location of data files

Dir / home/whqlkj/redis-cluster/5001/

# AOF persistence

Appendonly yes

# Open the cluster

Cluster-enabled yes

# Cluster configuration file

Cluster-config-file nodes-6379.conf

# Cluster configuration file

Cluster-config-file nodes-5001.conf

# Cluster node timeout

Cluster-node-timeout 15000

Start the service of each node

This article gives only one example.

$redis-server / home/zrj/redis-cluster/5001/redis.conf

Third, create a cluster

$redis-cli-- cluster create 192.168.8.196purl 5001\

192.168.196purl 5002\

192.168.196purl 5003\

192.168.196purl 5004\

192.168.196purl 5005\

192.168.196purl 5006\

-- cluster-replicas 1

Use and check the status of the cluster

# client enters cluster mode

Redis-cli

-c Enable cluster mode enables cluster mode

-h Server hostname (default: 127.0.0.1).

-p Server port (default: 6379).

# using practical exercises

$redis-cli-c-h 192.168.8.196-p 5001

192.168.196 set name zhangsan 5001 >

-> Redirected to slot [5798] located at 192.168.196pur5002

OK

192.168.196pur5002 > get name

"zhangsan"

# View cluster status

$cluster info

Explanation:

Cluster_state:ok

# clusterstate: ok status indicates that the cluster can accept query requests normally. The fail status indicates that at least one hash slot is not bound (indicating that there is a hash slot that is not bound to any node), or is in the wrong state (the node can provide services but is marked with FAIL), or the node cannot contact most master nodes.

Cluster_slots_assigned:16384

# cluster_slots_assigned: the number of hash slots assigned to the cluster node (not the number of unbound ones). The allocation of all 16384 hash slots to the cluster nodes is a necessary condition for the normal operation of the cluster.

Cluster_slots_ok:16384

# cluster_slots_ok: the hash slot status is not the number of FAIL and PFAIL.

Cluster_slots_pfail:0

# Hash slot status is the number of PFAIL. As long as the hash slot state is not upgraded to the FAIL state, these hash slots can still be handled normally. The PFAIL status indicates that we cannot currently interact with the node, but this state is only a temporary error state.

Cluster_slots_fail:0

# Hash slot status is the number of FAIL. If the value is not 0, the cluster node cannot provide query services unless cluster-require-full-coverage is set to no.

Cluster_known_nodes:6

# the number of nodes in the cluster, including those that are shaking hands and have not yet become full members of the cluster.

Cluster_size:3

# the number of master nodes that contain at least one hash slot and can provide services.

Cluster_current_epoch:6

Cluster_my_epoch:1

Cluster_stats_messages_ping_sent:44701

Cluster_stats_messages_pong_sent:39531

Cluster_stats_messages_sent:84232

Cluster_stats_messages_ping_received:39526

Cluster_stats_messages_pong_received:44701

Cluster_stats_messages_meet_received:5

Cluster_stats_messages_received:84232

# View cluster nodes

$cluster nodes

Through this information, you can view the master-slave relationship before each node.

B3363a81c3c59d57143cd3323481259c044e66d2 192.168.196Vera 5006 "15006 slave 1b7aa419065c5477c0def9d5e25106963fbdda76 01572917132045 6 connected9dc870942555447543694e42e40061823ed91271 192.168.196VO5004" 15004 slave d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 01572917130038 4 connected1b7aa419065c5477c0def9d5e25106963fbdda76 192.168.196VOV 5003 "15003 master-01572917131041 3 connected 10923-16383b1b67d4e554e29605bdbe40deab6670a42dd8836 192.168.196Ranger 5002" 15002 master-01572917130000 2 connected 5461-10922fbf9f23ecf0fea399debf7db42c73fece04b98fd 192.168.196155150015005 slave b1b67d4e554e29605bdbe40deab6670a42dd8836 01572917131000 5 connectedd1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 192.168.1961919151001 myself,master-0157291770001 connected 0-5460

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report