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

Deploy Reids sharding clusters in the production environment of an enterprise

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

1. Environmental description

Redis will not be introduced in detail in this article. Friends who don't know much about redis can refer to this link http://www.runoob.com/redis/redis-tutorial.html.

At least 3 master nodes are required for the redis cluster to work properly. Here, we need to create 6 redis nodes, of which three are master nodes and three are slave nodes. The ip and port correspondence of the corresponding redis nodes are as follows:

Host and port 192.168.102.51, 192.168.102.51, 6380192.168.102.52, 192.168.102.52, 192.168.102.53, 192.168.102.53, 192.168.102.53

Description: 3 servers deploy redis cluster environment, if you are only used for test deployment, you can configure it on 1 server, but do not repeat the port.

2. Prepare redis-related dependency packages

(all three servers need to be installed)

Package name download address zlib-1.2.8.tar.gz http://nchc.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gzruby-2.2.4.tar.bz2https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.4.tar.bz2rubygems-2.5.1.tgzhttps://rubygems.global.ssl.fastly.net/rubygems/rubygems-2.5. 1.tgzredis-3.2.2.gem https://rubygems.global.ssl.fastly.net/gems/redis-3.2.2.gemredis-3.2.3.tar.gzhttp://download.redis.io/releases/redis-3.2.3.tar.gz

2.1 install zlib

# gunzip zlib-1.2.8.tar.gz

# tar-xvf zlib-1.2.8.tar

# cd zlib-1.2.8

#. / configure

# make

# make install

2.2 install ruby

# bunzip2 ruby-2.2.4.tar.bz2

# tar-xvf ruby-2.2.4.tar

# cd ruby-2.2.4

#. / configure-prefix=/usr/local/ruby

# make

Generating RDoc documentation

Parsing sources...

100% [967max 967] vsnprintf.c

Generating RI format into / root/ruby-2.2.4/.ext/rdoc...

Files: 967

Classes: 1411 (581undocumented)

Modules: 280,108 undocumented

Constants: 2160 (594 undocumented)

Attributes: 1156 (255undocumented)

Methods: 10488 (2187 undocumented)

Total: 15495 (3725 undocumented)

75.96% documented

Elapsed: 744.0s

# make install

# cp ruby / bin

2.3 install rubygems

# tar-zxvf rubygems-2.5.1.tgz

# cd rubygems-2.5.1

# ruby setup.rb

# cp bin/gem / bin Note: the solution to in 'require': cannot load such file-- json/pure (LoadError) appears in compilation:

# gem install json_pure

Fetching: json_pure-1.8.3.gem (100%)

Successfully installed json_pure-1.8.3

Parsing documentation for json_pure-1.8.3

Installing ri documentation for json_pure-1.8.3

1 gem installed

2.4 install gem-redis

# gem install-l redis-3.2.2.gem

Successfully installed redis-3.2.2

Parsing documentation for redis-3.2.2

Installing ri documentation for redis-3.2.2

1 gem installed

3. Install redis (all three servers need to be installed)

Decompress, compile

# tar-zxvf redis-3.2.3.tar.gz

# cd redis-3.2.3

# make

Create a directory required for redis

# mkdir-p / usr/local/redis/ {bin,conf,data,logs} # # create redis related directories

# cp src/redis-server / usr/local/redis/bin/ # # daemon launcher for Redis server

# cp src/redis-cli / usr/local/redis/bin/ # # Redis command line operation tool

# cp src/redis-trib.rb / usr/local/redis/bin/ # # Redis Cluster tool

# cp src/redis-benchmark / usr/local/redis/bin/ # # Redis performance testing tool

# cp src/redis-check-aof / usr/local/redis/bin/ # # repair corrupted aof files

# cp src/redis-check-dump / usr/local/redis/bin/ # # check the export utility

# cp src/redis-sentinel / usr/local/redis/bin/ # # Redis cluster management tools

Note: if you do not want to operate as troublesome as above, you can also directly copy all the files in the src directory to / usr/local/redis/bin/

For example: cp src/* / usr/local/redis/bin/

Copy the redis configuration file

# cp redis.conf / usr/local/redis/conf/redis-6379.conf

# cp redis.conf / usr/local/redis/conf/redis-6380.conf

Modify redis configuration file (modify red font section)

Bind 0.0.0.0 # address that the redis service listens to

Protected-mode yes

Port 6379 # if it is a redis-6380.conf configuration file, modify it to 6380

Tcp-backlog 511

Timeout 0

Tcp-keepalive 300

Change daemonize yes # to yes and let redis run in the background

Supervised no

Pidfile / var/run/redis_6379.pid # if it is a redis-6380.conf configuration file, modify it to redis_6380.pid

Loglevel notice

Logfile / usr/local/redis/logs/redis-6379.log # if it is a redis-6380.conf configuration file, modify it to redis_6380.pid

Databases 16

Save 900 1

Save 300 10

Save 60 10000

Stop-writes-on-bgsave-error yes

Rdbcompression yes

Rdbchecksum yes

Dbfilename dump.rdb

Dir. /

Slave-serve-stale-data yes

Slave-read-only yes

Repl-diskless-sync no

Repl-diskless-sync-delay 5

Repl-disable-tcp-nodelay no

Slave-priority 100

Appendonly no

Appendfilename "appendonly.aof"

Appendfsync everysec

No-appendfsync-on-rewrite no

Auto-aof-rewrite-percentage 100

Auto-aof-rewrite-min-size 64mb

Aof-load-truncated yes

Lua-time-limit 5000

Cluster-enabled yes

Cluster-config-file nodes-51-6379.conf # if it is a redis-6380.conf configuration file, modify it to nodes-51-6380.conf

Cluster-node-timeout 5000

Slowlog-log-slower-than 10000

Slowlog-max-len 128

Latency-monitor-threshold 0

Notify-keyspace-events ""

Hash-max-ziplist-entries 512

Hash-max-ziplist-value 64

List-max-ziplist-size-2

List-compress-depth 0

Set-max-intset-entries 512

Zset-max-ziplist-entries 128

Zset-max-ziplist-value 64

Hll-sparse-max-bytes 3000

Activerehashing yes

Client-output-buffer-limit normal 0 0 0

Client-output-buffer-limit slave 256mb 64mb 60

Client-output-buffer-limit pubsub 32mb 8mb 60

Hz 10

Aof-rewrite-incremental-fsync yes

The configuration of cluster-config-file nodes-51-6379.conf # needs to be explained in particular.

It is important to note that it is best not to use the same name for the configuration of these three servers. It is recommended to choose the name in the following way (of course, you can specify it yourself):

192.168.102.51:nodes-51-6379.conf nodes-51-6380.conf

192.168.102.52:nodes-52-6379.conf nodes-52-6380.conf

192.168.102.53:nodes-53-6379.conf nodes-53-6380.conf

Description: if you need to know more details about redis configuration files, please refer to the link below

Http://blog.csdn.net/neubuffer/article/details/17003909

4. Start the redis cluster

4.1 start redis instances (start 6379 first, then start 6380) one by one:

# / usr/local/redis/bin/redis-server / usr/local/redis/conf/redis-6379.conf # start 6379 instances of these three servers in phase order

# / usr/local/redis/bin/redis-server / usr/local/redis/conf/redis-6380.conf # launch 6380 instances of three servers in phase order

Then check whether the instance starts normally:

# ps-ef | grep redis

Create a cluster (on the first redis server and execute the following command)

# / usr/local/redis/bin//bin/redis-trib.rb create-- replicas 1 192.168.102.51 192.168.102.53:6380Can I set the above configuration 6379 192.168.102.52 192.168.102.53:6380Can I set the above configuration 6379 192.168.102.53 192.168.102.53:6380Can I set the above configuration? (type 'yes' to accept): yes # enter yes here

View the cluster nodes:

Detect the cluster:

View the cluster master node:

If the above information appears, the cluster is installed successfully.

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