In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Redis Cluster deployment documentation
Updated: 09/05/2019
1 description
The main features of Redis Cluster are as follows:
No central structure, the client is directly connected to the redis node, there is no need for redundant design of intermediate agent layer nodes, slave- > master election, cluster fault-tolerant data sharding storage, and support online shard ASK / MOVED steering mechanism, through any node, you can read and write data that does not belong to this node.
This paper takes the deployment of a minimum cluster that can achieve high availability as an example, the cluster is deployed on three hosts, including M1, M2, M3, S1, S2, S3 six nodes.
M1, M2, M3 primary nodes correspond to Redis instances: 7000pr 7001pr 7002
S1, S2, S3 correspond to Redis instances of slave nodes: 7003, 7004, 7005
Master-slave nodes are cross-connected, and the corresponding relations are:
M1-> S2
M2-> S3
M3-> S1
2 Environmental preparation
System environment:
Host IP node-role-instance (port) redis1192.168.0.100M1-master-7000, S1-slave-7003redis2192.168.0.101M2-master-7001, S2-slave-7004redis3192.168.0.102M3-master-7002, S3-slave-70053 installation software
Compile and install redis version 5.0.4 on three hosts.
After installation, it is recommended to add the redis bin directory to the PATH environment variable.
4 configure the cluster
Refer to steps 4. 1-4. 3 for Redis cluster configuration on three hosts.
4.1 create a cluster directory
Create each node configuration and data directory of the cluster.
Mkdir-p / data/redis-cluster/ {70001.7001}
Take redis1 as an example, the directory structure is as follows:
/ data/redis-cluster/ ├── 7000 │ ├── redis.conf # redis instance profile │ └── nodes.conf # redis Cluster Node profile (created automatically by the cluster) └── 7003 │ ├── redis.conf # redis instance profile │ └── nodes.conf # redis Cluster Node profile (automatically created by the cluster) 4.2 create instance profile
Copy the redis.conf-to-node configuration and the data directory under the redis source directory respectively.
Edit the configurations in the redis instance configuration file. Redis does not enable the cluster feature by default. You need to modify the following configurations to enable it:
Port 7000bind 0.0.0.0 # allows other hosts to connect to dir / data/redis-cluster/7000 # Node instance configuration directory cluster-enabled yes # Open cluster cluster-config-file nodes.conf # cluster configuration file cluster-node-timeout 5000 # timeout appendonly yes # and turn on AOF mode
Please modify the relevant configuration items according to the performance requirements of the production environment and the actual deployment, and note that the ports in the instance configuration file of each node are different.
4.3 Firewall Settings
Modify the server firewall configuration according to the situation to allow Redis hosts to connect ports 7000-7005 and 17000-17005, and allow all business servers to connect to ports 7000-7005 of the Redis server.
5 start cluster 5.1 start the instance
Start all six redis node instances on each of the three hosts, specifying that the configuration file is the redis.conf in the respective node configuration directory.
5.2 start the cluster
Execute the following command on any of the redis node hosts to start the cluster:
Redis-cli-- cluster create\-- cluster-replicas 1\ 192.168.0.100 cluster-replicas 7000\ 192.168.0.100 purl 7001\ 192.168.0.101 purl 7002\ 192.168.0.101 Vera 7003\ 192.168.0.102 Vuits7004\ 192.168.0.102 purl 7005
Note that the IP in the modification command is the real host IP corresponding to the port of the redis node instance.
Enter yes when prompted, and the following message indicates that the cluster has been created successfully.
[OK] All nodes agree about slots configuration. > > Check for open slots... > Check slots coverage... [OK] All 16384 slots covered.6 Test View Cluster Information
Execute the following command on the host of any redis node:
# redis-cli-c-h 192.168.0.100-p 7000 cluster info
The following information of type should be output:
Cluster_state:okcluster_slots_assigned:16384cluster_slots_ok:16384cluster_slots_pfail:0cluster_slots_fail:0cluster_known_nodes:6cluster_size:3cluster_current_epoch:6cluster_my_epoch:1cluster_stats_messages_ping_sent:101cluster_stats_messages_pong_sent:98cluster_stats_messages_sent:199cluster_stats_messages_ping_received:93cluster_stats_messages_pong_received:101cluster_stats_messages_meet_received:5cluster_stats_messages_received:199 lists cluster nodes
Execute the following command on the host of any redis node to list all the nodes (node) currently known to the cluster and related information about those nodes.
# redis-cli-c-h 192.168.0.100-p 7000 cluster nodes
Output information similar to the following:
50725018cd7f5f20214b0ed462975258397dfe29 192.168.0.102 connected8874f69c2f5747cce3a02387167a00cdaba43d3c 7005 "17005 slave 39e335386bb48f012f433287ed853174009114e5 01554876136000 6 connected8874f69c2f5747cce3a02387167a00cdaba43d3c 192.168.0.100 connected8874f69c2f5747cce3a02387167a00cdaba43d3c 700117001 master-01554876137380 2 connected 5461-10922c9cb48efbc1a83098cb730a5295402d9cdb343c2 192.168.0.101VOV 7003" 17003 slave 917301c74a9ed1ed52918b8e4c7f88de9743c361 01554876136375 4 connected5633e918818033552b1adc089d99fbe9bcf36589 192.168.0.102Ranger 7004 "17004 slave 8874f69c2f5747cce3a02387167a00cdaba43d3c 01554876136072 5 connected917301c74a9ed1ed52918b8e4c7f88de9743c361 192.168.0.100 7000000" 17000 myself,master-01554876136000 1 connected 0-546039e335386bb48f012f433287ed853174009114e5 192.168.0.101Rist 700217002 master-01554876136878 3 connected 10923-16383 View Cluster data slot allocation
Execute the following command on the host of any redis node to display the current allocation of all data slots in the cluster.
# redis-cli-c-h 192.168.0.100-p 7000 cluster slots
Output information similar to the following:
1) 1) (integer) 5461 2) (integer) 10922 3) 1) "127.0.0.1" 2) (integer) 7001 4) 1) "127.0.0.1" 2) (integer) 70042) 1) (integer) 02) (integer) 5460 3) 1) "127.0.0.1" 2) (integer) 7000 4) 1) "127.0.0" .1 "2) (integer) 70033) 1) (integer) 10923 2) (integer) 16383 3) 1)" 127.0.0.1 "2) (integer) 7002 4) 1)" 127.0.0.1 "2) (integer) 7005
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.