Redis 3.0.7 Cluster cluster deployment

Source: Internet
Author: User
Tags redis version

I. Description of the Environment

Db:redis 3.0.7 Latest stable version

Os:centos 6.6_x64


Second, installation steps

1. Basic Package Installation

[[email protected] ~]# yum-y install Ruby

[Email protected] ~]# yum-y install RubyGems

Download path, upload to/tmp path

https://rubygems.org/gems/redis/versions/3.0.0

[Email protected] ~]# cd/tmp

[[email protected] tmp]# ls

ORBIT-GDM PULSE-HNVCTNUHWLDW Pulse-ua8dxn7r5ga8 Redis-3.0.0.gem

[Email protected] tmp]# gem install-l redis-3.0.0.gem

[Email protected] tmp]# cd/tmp

[email protected] tmp]# LL

Total 1360

DRWX------2 GDM GDM 4096 Sep 1 09:13 ORBIT-GDM

DRWX------. 2 GDM GDM 4096 Sep 1 09:13 PULSE-HNVCTNUHWLDW

DRWX------. 2 root root 4096 1 17:07 pulse-ua8dxn7r5ga8

Drwxrwxr-x 6 root root 4096 Jan redis-3.0.7

-rw-r--r--1 root root 1375200 Nov 10:01 redis-3.0.7.tar.gz

[Email protected] tmp]#


2. Unzip

[Email protected] tmp]# TAR-ZXVF redis-3.0.7.tar.gz

3. Compiling

[Email protected] tmp]# CD redis-3.0.7

[Email protected] redis-3.0.7]#

[[email protected] redis-3.0.7]# make

4. Installation

[[email protected] redis-3.0.7]# make install

5. Testing

[email protected] redis-3.0.7]# Yum install Tcl

[[email protected] redis-3.0.7]# make test

6. Executable Command Unified Path

[Email protected] src]# CD/TMP/REDIS-3.0.7/SRC

[email protected] src]# CP Redis-trib.rb/usr/local/bin

[Email protected] src]# Cd/usr/local/bin

[email protected] bin]# LL

Total 15968

-rwxr-xr-x 1 root root 4587299 Nov 17:43 Redis-benchmark

-rwxr-xr-x 1 root root 22177 Nov 17:43 redis-check-aof

-rwxr-xr-x 1 root root 45387 Nov 17:43 redis-check-dump

-rwxr-xr-x 1 root root 4696506 Nov 17:43 redis-cli

lrwxrwxrwx 1 root root 17:43 redis-sentinel-Redis-server

-rwxr-xr-x 1 root root 6469255 Nov 17:43 redis-server

-rwxr-xr-x 1 root root 60527 Nov 17:55 redis-trib.rb


7. Create a Directory

[Email protected] bin]# mkdir-p/data/redis/conf

[Email protected] bin]# mkdir-p/data/redis/log

[Email protected] bin]# mkdir-p/data/redis/data


8. Configuration parameters

[email protected] redis-3.0.7]# CP redis.conf/data/redis/conf/redis_6379.conf

[email protected] redis-3.0.7]# CP redis.conf/data/redis/conf/redis_6380.conf

[email protected] redis-3.0.7]# CP redis.conf/data/redis/conf/redis_6381.conf

[email protected] redis-3.0.7]# CP redis.conf/data/redis/conf/redis_6382.conf

[email protected] redis-3.0.7]# CP redis.conf/data/redis/conf/redis_6383.conf

[email protected] redis-3.0.7]# CP redis.conf/data/redis/conf/redis_6384.conf


[Email protected] redis-3.0.7]# cd/data/redis/conf/

[Email protected] conf]# grep-v-E ' (^#|^$) ' redis_6379.conf


VI redis_6379.conf

######### #general ##########

Daemonize Yes

Pidfile/data/redis/data/redis_6379.pid

Port 6379

Tcp-backlog 511

Timeout 0

Tcp-keepalive 0

LogLevel Notice

LogFile "/data/redis/log/redis_6379.log"

######### #rdb ##########

Databases 16

Save 900 1

Save 300 10

Save 60 10000

Stop-writes-on-bgsave-error Yes

Rdbcompression Yes

Rdbchecksum Yes

Dbfilename Dump_6379.rdb

dir/data/redis/data/

######### #slave ##########

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

######### #aof ##########

AppendOnly Yes

Appendfilename "Appendonly_6379.aof"

Appendfsync everysec

No-appendfsync-on-rewrite No

Auto-aof-rewrite-percentage 100

Auto-aof-rewrite-min-size 64MB

aof-load-truncated Yes

######### #lua ##########

Lua-time-limit 5000

######### #cluster ##########

cluster-enabled Yes

Cluster-config-file nodes_6379.conf

Cluster-node-timeout 15000

Cluster-slave-validity-factor 10

Cluster-migration-barrier 1

Cluster-require-full-coverage No

######### #slowlog ##########

Slowlog-log-slower-than 10000

Slowlog-max-len 128

######### #optimize ##########

Latency-monitor-threshold 0

Notify-keyspace-events ""

Hash-max-ziplist-entries 512

Hash-max-ziplist-value 64

List-max-ziplist-entries 512

List-max-ziplist-value 64

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

###########################################

VI redis_6379.conf Replacement:%s/6379/6380

VI redis_6379.conf Replacement:%s/6379/6381, etc.


Third, create the cluster

1. Start cluster-related nodes (must be empty nodes)

[Email protected] conf]# redis-server/data/redis/conf/redis_6379.conf

[Email protected] conf]# redis-server/data/redis/conf/redis_6380.conf

[Email protected] conf]# redis-server/data/redis/conf/redis_6381.conf

[Email protected] conf]# redis-server/data/redis/conf/redis_6382.conf

[Email protected] conf]# redis-server/data/redis/conf/redis_6383.conf

[Email protected] conf]# redis-server/data/redis/conf/redis_6384.conf

[Email protected] conf]# Ps-ef |grep Redis

Root 7702 1 0 18:36? 00:00:00 redis-server *:6379 [cluster]

Root 7708 1 0 18:37? 00:00:00 redis-server *:6380 [cluster]

Root 7712 1 0 18:37? 00:00:00 redis-server *:6381 [cluster]

Root 7716 1 0 18:37? 00:00:00 redis-server *:6382 [cluster]

Root 7720 1 0 18:37? 00:00:00 redis-server *:6383 [cluster]

Root 7724 1 0 18:37? 00:00:00 redis-server *:6384 [cluster]


2. Build a cluster with your own Ruby tools (REDIS-TRIB.RB)

[Email protected] ~]# REDIS-TRIB.RB Help

[[email protected] ~]# redis-trib.rb create--replicas 1 192.168.80.121:6379 192.168.80.121:6380 192.168.80.121:6381 192.168.80.121:6382 192.168.80.121:6383 192.168.80.121:6384

>>> Creating Cluster

>>> performing hash slots allocation on 6 nodes ...

Using 3 Masters:

192.168.80.121:6379

192.168.80.121:6380

192.168.80.121:6381

Adding replica 192.168.80.121:6382 to 192.168.80.121:6379

Adding replica 192.168.80.121:6383 to 192.168.80.121:6380

Adding replica 192.168.80.121:6384 to 192.168.80.121:6381

m:b2e0265c1ae983c339eaa362235455d3cc54a025 192.168.80.121:6379

slots:0-5460 (5461 slots) Master

M:DEDFFE5AD37787D4CAD6CC2D2426BA4D504B3C44 192.168.80.121:6380

slots:5461-10922 (5462 slots) Master

m:e6af78beb2457fa34b9530c7e11d6caeac579732 192.168.80.121:6381

slots:10923-16383 (5461 slots) Master

s:41ca12c81e4acd7212b550904e8050c9b604734c 192.168.80.121:6382

Replicates b2e0265c1ae983c339eaa362235455d3cc54a025

s:3e3afb6769c4bdfbd8373f058dc54f18baeba585 192.168.80.121:6383

Replicates dedffe5ad37787d4cad6cc2d2426ba4d504b3c44

S:31feff8d759aa78699d428546b0d775457626ac6 192.168.80.121:6384

Replicates e6af78beb2457fa34b9530c7e11d6caeac579732

Can I Set the above configuration? (Type ' yes ' to accept): Yes

>>> Nodes Configuration Updated

>>> Assign a different config epoch to each node

>>> sending CLUSTER MEET messages to join the CLUSTER

Waiting for the cluster to join ...

>>> performing Cluster Check (using node 192.168.80.121:6379)

m:b2e0265c1ae983c339eaa362235455d3cc54a025 192.168.80.121:6379

slots:0-5460 (5461 slots) Master

M:DEDFFE5AD37787D4CAD6CC2D2426BA4D504B3C44 192.168.80.121:6380

slots:5461-10922 (5462 slots) Master

m:e6af78beb2457fa34b9530c7e11d6caeac579732 192.168.80.121:6381

slots:10923-16383 (5461 slots) Master

m:41ca12c81e4acd7212b550904e8050c9b604734c 192.168.80.121:6382

Slots: (0 slots) Master

Replicates b2e0265c1ae983c339eaa362235455d3cc54a025

m:3e3afb6769c4bdfbd8373f058dc54f18baeba585 192.168.80.121:6383

Slots: (0 slots) Master

Replicates dedffe5ad37787d4cad6cc2d2426ba4d504b3c44

M:31feff8d759aa78699d428546b0d775457626ac6 192.168.80.121:6384

Slots: (0 slots) Master

Replicates e6af78beb2457fa34b9530c7e11d6caeac579732

[OK] All nodes agree about slots configuration.

>>> Check for open Slots ...

>>> Check Slots Coverage ...

[OK] All 16384 slots covered.


3. Check cluster status

[Email protected] ~]# redis-trib.rb check 192.168.80.121:6379

>>> performing Cluster Check (using node 192.168.80.121:6379)

m:b2e0265c1ae983c339eaa362235455d3cc54a025 192.168.80.121:6379

slots:0-5460 (5461 slots) Master

1 additional replica (s)

m:e6af78beb2457fa34b9530c7e11d6caeac579732 192.168.80.121:6381

slots:10923-16383 (5461 slots) Master

1 additional replica (s)

S:31feff8d759aa78699d428546b0d775457626ac6 192.168.80.121:6384

Slots: (0 slots) Slave

Replicates e6af78beb2457fa34b9530c7e11d6caeac579732

s:3e3afb6769c4bdfbd8373f058dc54f18baeba585 192.168.80.121:6383

Slots: (0 slots) Slave

Replicates dedffe5ad37787d4cad6cc2d2426ba4d504b3c44

s:41ca12c81e4acd7212b550904e8050c9b604734c 192.168.80.121:6382

Slots: (0 slots) Slave

Replicates b2e0265c1ae983c339eaa362235455d3cc54a025

M:DEDFFE5AD37787D4CAD6CC2D2426BA4D504B3C44 192.168.80.121:6380

slots:5461-10922 (5462 slots) Master

1 additional replica (s)

[OK] All nodes agree about slots configuration.

>>> Check for open Slots ...

>>> Check Slots Coverage ...

[OK] All 16384 slots covered.


4. Login Cluster

[[email protected] ~]# redis-cli-c-P 6379

127.0.0.1:6379> Cluster Info

Cluster_state:ok

cluster_slots_assigned:16384

cluster_slots_ok:16384

cluster_slots_pfail:0

cluster_slots_fail:0

Cluster_known_nodes:6

Cluster_size:3

Cluster_current_epoch:6

Cluster_my_epoch:1

cluster_stats_messages_sent:1089

cluster_stats_messages_received:1089

127.0.0.1:6379> cluster Nodes

e6af78beb2457fa34b9530c7e11d6caeac579732 192.168.80.121:6381 master-0 1480417102632 3 connected 10923-16383

31feff8d759aa78699d428546b0d775457626ac6 192.168.80.121:6384 Slave e6af78beb2457fa34b9530c7e11d6caeac579732 0 1480417101630 6 Connected

3e3afb6769c4bdfbd8373f058dc54f18baeba585 192.168.80.121:6383 Slave dedffe5ad37787d4cad6cc2d2426ba4d504b3c44 0 1480417102632 5 Connected

41ca12c81e4acd7212b550904e8050c9b604734c 192.168.80.121:6382 Slave b2e0265c1ae983c339eaa362235455d3cc54a025 0 1480417099627 4 Connected

DEDFFE5AD37787D4CAD6CC2D2426BA4D504B3C44 192.168.80.121:6380 master-0 1480417100630 2 connected 5461-10922

b2e0265c1ae983c339eaa362235455d3cc54a025 192.168.80.121:6379 myself,master-0 0 1 connected 0-5460

127.0.0.1:6379>

127.0.0.1:6379> Cluster Slots

1) 1) (integer) 10923

2) (integer) 16383

3) 1) "192.168.80.121"

2) (integer) 6381

4) 1) "192.168.80.121"

2) (integer) 6384

2) 1) (integer) 5461

2) (integer) 10922

3) 1) "192.168.80.121"

2) (integer) 6380

4) 1) "192.168.80.121"

2) (integer) 6383

3) 1) (integer) 0

2) (integer) 5460

3) 1) "192.168.80.121"

2) (integer) 6379

4) 1) "192.168.80.121"

2) (integer) 6382


Iv.. Alarm Handling


1. Alarms

7702:m 18:36:50.952 # warning:the TCP Backlog setting of 511 cannot be enforced

Because/proc/sys/net/core/somaxconn is set to the lower value of 128.

7702:m 18:36:50.952 # Server started, Redis version 3.0.7

7702:m 18:36:50.952 # WARNING Overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ' vm.overcommit_memory = 1 ' to/etc/sysctl.conf and then reboot or run the command ' Sysctl vm.overcom Mit_memory=1 ' for the take effect.

7702:m 18:36:50.952 # WARNING you are Transparent Huge Pages (THP) support for enabled in your kernel. This would create latency and memory usage issues with Redis. To fix this issue run the command ' echo never >/sys/kernel/mm/transparent_hugepage/enabled ' as root, and add it to you R/etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.


2. Handling Methods

1) Backlog

Echo 511 >/proc/sys/net/core/somaxconn

echo "Net.core.somaxconn = 511" >>/etc/sysctl.conf

2) Overcommit_memory

Echo 1 >/proc/sys/vm/overcommit_memory

echo "Vm.overcommit_memory=1" >>/etc/sysctl.conf

3) Transparent Huge Pages (THP)

echo Never >/sys/kernel/mm/transparent_hugepage/enabled

Vi/etc/rc.local

If Test-f/sys/kernel/mm/transparent_hugepage/enabled; Then

echo Never >/sys/kernel/mm/transparent_hugepage/enabled

Fi

If Test-f/sys/kernel/mm/transparent_hugepage/defrag; Then

echo Never >/sys/kernel/mm/transparent_hugepage/defrag

Fi

Sysctl-p


#################################################################################


This article is from the "dba003" blog, make sure to keep this source http://dba003.blog.51cto.com/12318731/1877894

Redis 3.0.7 Cluster cluster deployment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.