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

How to deploy redis Cluster Cluster Mode

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will explain in detail how to deploy the redis cluster Cluster mode. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

I. Construction of Redis cluster mode

There are three types of redis cluster deployment: master-slave, Sentinel, and Cluster.

A few days ago, due to the launch of new applications, we need to deploy a set of redis cluster, which is now documented to record the deployment process.

Environment introduction

Ip

Software package

System version 10.1.112.248redis-4.0.11.tar.gzCentOS Linux release 7.6.1810 (Core) 10.1.112.249redis-4.0.11.tar.gzCentOS Linux release 7.6.1810 (Core)

1. Directory structure

[root@localhost local] # pwd/usr/local [root@localhost local] # tree redis-cluster/redis-cluster/ ├── redis-4.0.11-node1 │ ├── data │ └── logs ├── redis-4.0.11-node2 │ ├── data │ └── logs └── redis-4.0.11-node3 ├── data └── logs9 directories, 0 files

2. Download and decompress redis-4.0.11

Mkdir / usr/local/softwarecd / usr/local/software & & wget http://download.redis.io/releases/redis-4.0.11.tar.gztar xf redis-4.0.11.tar.gz

3. Install (both servers are installed)

[root@localhost software] # pwd/usr/local/software [root@localhost software] # tar xf redis-4.0.11.tar.gz [root@localhost software] # cd redis-4.0.1 [root@localhost redis-4.0.11] # make install can be screenshot as follows

4. Prepare the configuration file

[root@localhost redis-4.0.11] # cp src/redis-trib.rb / usr/local/bin/ [root@localhost redis-4.0.11] # cp redis.conf / usr/local/redis-cluster/redis-4.0.11-node1/ [root@localhost redis-4.0.11] # cp redis.conf / usr/local/redis-cluster/redis-4.0.11-node2/ [root@localhost redis-4.0.11] # cp redis.conf / usr/ Local/redis-cluster/redis-4.0.11-node3/ [root@localhost redis-4.0.11] # cp src/ {redis-cli Redis-server} / usr/local/redis-cluster/redis-4.0.11-node1/ [root@localhost redis-4.0.11] # cp src/ {redis-cli,redis-server} / usr/local/redis-cluster/redis-4.0.11-node2/ [root@localhost redis-4.0.11] # cp src/ {redis-cli Redis-server} / usr/local/redis-cluster/redis-4.0.11-node3/ [root@localhost redis-4.0.11-node1] # grep-Ev "^ # | ^ $" redis.conf bind 10.1.112.248 # one server is configured as 10.1.112.249protected-mode yesport 7000 # other nodes are configured as 7001/7002tcp-backlog 511timeout 0tcp-keepalive 300daemonize yessupervised nopidfile / usr/ Local/redis-cluster/redis-4.0.11-node1/redis_7000.pid # other nodes are configured as redis-4.0.11-node2/redis_7001.pid, Redis-4.0.11-node3/redis_7002.pidloglevel noticelogfile "/ usr/local/redis-cluster/redis-4.0.11-node1/logs/redis_7000.log" # ditto databases 16always-show-logo yessave 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir / usr/local/redis-cluster/redis-4.0.11-node1/data # redis-4.0.11-node3/data, Redis-4.0.11-node3/dataslave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100requirepass xxxlazyfree-lazy-eviction nolazyfree-lazy-expire nolazyfree-lazy-server-del noslave-lazy-flush noappendonly yesappendfilename "appendonly.aof" appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yesaof-use-rdb-preamble nolua-time-limit 5000cluster-enabled yescluster- Config-file nodes-7000.confcluster-node-timeout 15000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events "" hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size-2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 00 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes

5. Start 3 nodes respectively (the other server is also started)

Cd / usr/local/redis-cluster/redis-4.0.11-node1./redis.server redis.confcd / usr/local/redis-cluster/redis-4.0.11-node2./redis.server redis.confcd / usr/local/redis-cluster/redis-4.0.11-node3./redis.server redis.conf View process [root@localhost redis-4.0.11-node1] # ps-ef | grep redisroot 6015 5673 0 17:52 pts/1 00:00:00 Grep-- color=auto redisweblogic 28246 10 Oct21? 00:01:14. / redis-server 10.1.112.248 grep 7000 [cluster] weblogic 28284 10 Oct21? 00:01:14. / redis-server 10.1.112.248 Oct21 7001 [cluster] weblogic 28301 10 Oct21? 00:02:25. / redis-server 10.1.112.248 redis-server 7002 [cluster] [root@localhost redis-4.0.11-node1] # ps-ef | grep redisroot 6015 5673 0 17:52 pts/1 00:00:00 grep-- color=auto redisweblogic 28246 10 Oct21? 00:01:14. / redis-server 10.1.112.249 pts/1 7000 [cluster] weblogic 28284 10 Oct21? 00:01:14. / redis-server 10.1.112.249 redis-server 7001 [cluster] weblogic 28301 10 Oct21? 00:02:25. / redis-server 10.1.112.249 7002 [cluster]

6. Create a cluster using redis-trib.rb

[root@localhost redis-4.0.11-node1] # yum-y install ruby ruby-devel rubygems rpm-build [root@localhost redis-4.0.11-node1] # gem install redisFetching: redis-4.1.3.gem ERROR: Error installing redis: redis requires Ruby version > = 2.3.0. Indicates that the ruby version is too low. Upgrade ruby version [root@localhost redis-4.0.11-node1] # curl-L get.rvm.io | bash-s stable import the key as prompted Execute "curl-L get.rvm.io | bash-s stable" [root@localhost redis-4.0.11-node1] # source / usr/local/rvm/scripts/rvm again to see the available ruby version and install [root@localhost redis-4.0.11-node1] # rvm list known [root@localhost redis-4.0.11-node1] # rvm install 2.3.0 #, which takes a long time. Wait patiently for the installation to complete.

7. Install the gem redis interface

Rvm use 2.3.0ruby-versiongem install redis

8. Install rubygems

Yum install-y rubygems

At this point, the installation of Ruby and the environment required to run redis-trib.rb is complete, and then create a cluster using redis-trib.rb

9. Create a cluster

Redis-trib.rb create-- replicas 1 10.1.112.248V7 001 10.1.112.248 Vol 7001 10.1.112.248 Vol 7002 10.1.112.249 Vol 7000 10.1.112.249 Vol 7001 10.1.112.249 Vol 7002

10. View the cluster status

[weblogic@geb-redis1 ~] $redis-trib.rb check 10.1.112.248slots 7000 > Performing Cluster Check (using node 10.1.112.248VR 7000) M: 61d94b047e12679886991c7c6d225b471374a018 10.1.112.248v 7000 slots:0-5460 (5461 slots) master 1 additional replica (s) S: a582b9d7784d2f1b2e6a20d5352a19062dc29d4a 10.1.112.248 slots 7002 slots: (0 slots) slave replicates 0addc56bce940a659aa2ac4aa6d51677c1f2c523M: 0addc56bce940a659aa2ac4aa6d51677c1f2c523 10.1.112.249 7000 slots:5461-10922 (5462 slots) master 1 additional replica S: s: 087de17dafa03c361d87f7a4c4a5b2d7ce0555fc 10.1.112.249 slots 7001 slots: (0 slots) slave replicates fd9f572038a7504e088dde150b89beb2bac39e3cM: fd9f572038a7504e088dde150b89beb2bac39e3c 10.1.112.248 slots 7001 slots:10923-16383 (5461 slots) master 1 additional replica (s) S: 407d6ea2eb3725e142d2e5ae4e1eef4eee1a48ca 10.1.112.249 slots 7002 slots: (0 slots) slave replicates 61d94b047e12679886991c7c6d225b471374a018 [OK] All nodes agree about slots configuration. > > Check for open slots... > > Check slots coverage... [OK] All 16384 slots covered.

11. Overall directory structure

[root@geb-redis1 redis-cluster] # tree. ├── redis-4.0.11-node1 │ ├── data │ │ ├── appendonly.aof │ │ └── nodes-7000.conf │ ├── logs │ │ └── redis_7000.log │ ├── redis_7000.pid │ ├── redis-cli │ redis.conf redis-server Redis-4.0.11-node2 │ ├── data │ │ ├── appendonly.aof │ │ └── nodes-7001.conf │ ├── logs │ │ └── redis_7001.log │ ├── redis_7001.pid │ ├── redis-cli │ ├── redis.conf redis-server redis-4.0.11-node3 data │ ├── appendonly.aof │ └── nodes-7002.conf ├── logs │ └── redis_7002.log ├── redis_7002.pid ├── redis-cli ├── redis.conf └── redis-server9 directories 21 files [root@geb-redis2 redis-cluster] # tree. ├── redis-4.0.11-node1 │ ├── data │ │ ├── appendonly.aof │ │ └── nodes-7000.conf │ ├── logs │ │ └── redis_7000.log │ ├── redis_7000.pid │ ├── redis-cli │ redis.conf redis-server ── redis-4.0.11-node2 │ ├── data │ │ ├── appendonly.aof │ │ └── nodes-7001.conf │ ├── logs │ │ └── redis_7001.log │ ├── redis_7001.pid │ ├── redis-cli │ redis.conf redis-server redis-4.0.11-node3 Data │ ├── appendonly.aof │ └── nodes-7002.conf ├── logs │ └── redis_7002.log ├── redis_7002.pid ├── redis-cli ├── redis.conf └── redis-server9 directories 21 files

12. System parameters that need to be adjusted during deployment

# echo "vm.overcommit_memory = 1" > > / etc/sysctl.conf# echo "net.core.somaxconn = 2048" > > / etc/sysctl.conf# cat / etc/rc.localif test-f / sys/kernel/mm/transparent_hugepage/enabled; then echo never > / sys/kernel/mm/transparent_hugepage/enabledfiif test-f / sys/kernel/mm/transparent_hugepage/defrag Then echo never > / sys/kernel/mm/transparent_hugepage/defragfi this is the end of the article on "how to deploy the Cluster mode of redis clusters". I hope the above content can be helpful to you so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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

Servers

Wechat

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

12
Report