redis3.0.7 cluster 集群部署

一、环境描述

DB:redis 3.0.7 最新稳定版

OS:centos 6.6_x64

二、安装步骤

1.基本软件包安装

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

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

下载路径,上传到/tmp路径下

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 Aug  1 17:07 pulse-ua8DXn7r5gA8

drwxrwxr-x  6 root root    4096 Jan 25  2016 redis-3.0.7

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

[[email protected] tmp]#

2.解压缩

[[email protected] tmp]# tar -zxvf redis-3.0.7.tar.gz

3.编译

[[email protected] tmp]# cd redis-3.0.7

[[email protected] redis-3.0.7]#

[[email protected] redis-3.0.7]# make

4.安装

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

5.测试

[[email protected] redis-3.0.7]# yum install tcl

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

6.可执行命令统一路径

[[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 29 17:43 redis-benchmark

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

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

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

lrwxrwxrwx 1 root root      12 Nov 29 17:43 redis-sentinel -> redis-server

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

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

7.创建目录

[[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.配置参数

[[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 替换  :%s/6379/6380

vi redis_6379.conf 替换  :%s/6379/6381 以此类推

三、创建集群

1.启动集群相关节点(必须是空节点)

[[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.使用自带的ruby工具(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.检查集群状态

[[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.登陆集群

[[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

四、告警处理

1.告警

7702:M 29 Nov 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 29 Nov 18:36:50.952 # Server started, Redis version 3.0.7

7702:M 29 Nov 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.overcommit_memory=1‘ for this to take effect.

7702:M 29 Nov 18:36:50.952 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will 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 your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

2.处理方法

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

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

时间: 2024-10-17 09:41:43

redis3.0.7 cluster 集群部署的相关文章

redis 3.0.7 cluster 集群部署

一.环境描述 DB:redis 3.0.7 最新稳定版 OS:centos 6.6_x64 二.安装步骤 1.基本软件包安装 [[email protected] ~]# yum -y install ruby [[email protected] ~]# yum -y install rubygems 下载路径,上传到/tmp路径下 https://rubygems.org/gems/redis/versions/3.0.0 [[email protected] ~]# cd /tmp [[e

redis3.0.2 分布式集群安装详细步骤

redis3.0.2 分布式集群安装详细步骤 --(centos5.8 X64系统) 版本历史 时间 版本 说明 编写者 2015-06-5 1.0 redis3.0.2 分布式集群安装详细步骤 csc 一: redis cluster介绍篇 1:redis cluster的现状 目前redis支持的cluster特性(已亲测): 1):节点自动发现 2):slave->master 选举,集群容错 3):Hot resharding:在线分片 4):进群管理:cluster xxx 5):基于

centos6下redis cluster集群部署过程

一般来说,redis主从和mysql主从目的差不多,但redis主从配置很简单,主要在从节点配置文件指定主节点ip和端口,比如:slaveof 192.168.10.10 6379,然后启动主从,主从就搭建好了.redis主从中如果主节点发生故障,不会自动切换,需要借助redis的Sentinel(哨兵模式)或者keepalive来实现主的故障转移. 今天介绍下redis cluster集群模式:redis集群是一个无中心的分布式redis存储架构,可以在多个节点之间进行数据共享,解决了redi

Kubernetes v1.14.0 之 kube-apiserver集群部署

kube-apiserver集群准备 1.kube-apiserver 服务器配置 对外ip 内网ip cpu 内存 硬盘 192.168.3.10 172.172.1.1 64 256 1T 192.168.3.11 172.172.1.2 64 256 1T 192.168.3.12 172.172.1.3 64 256 1T 192.168.3.13 172.172.1.4 64 256 1T 192.168.3.14 172.172.1.5 64 256 1T 2.kube-apiser

k8s1.9.0安装--完整集群部署

三.完整集群部署 - kubernetes-with-ca 1. 理解认证授权 1.1 为什么要认证 想理解认证,我们得从认证解决什么问题.防止什么问题的发生入手.防止什么问题呢?是防止有人入侵你的集群,root你的机器后让我们集群依然安全吗?不是吧,root都到手了,那就为所欲为,防不胜防了.其实网络安全本身就是为了解决在某些假设成立的条件下如何防范的问题.比如一个非常重要的假设就是两个节点或者ip之间的通讯网络是不可信任的,可能会被第三方窃取,也可能会被第三方篡改.就像我们上学时候给心仪的女

Redis Cluster集群部署搭建

在Oracle的路上走了许多年,换换感觉,尝试一下新的知识,也是一个不错的感觉.Redis,一个超轻量化的内存数据库,只做一小块数据库功能实现,却非常优秀的一个产品.今天,就分享一下安装Redis集群的过程. 搭建redis集群,建议至少需要准备3台服务器,共搭建6个节点,3个master,3个slave,并且要求3个master节点不能全部跑到同一台服务器上,保证节点安全,3台服务器的配置相同,使用redistest账号搭建,对应的端口是7000/7001/7002端口 我的集群分配如下,每个

GaussDB T 1.0.2分布式集群部署故障总结

之前安装GaussDB T 1.0.2分布式集群的时候,安装过程中会报segmentation fault错误,如下: [[email protected] ~]$ gs_install -X /mnt/Huawei/db/clusterconfig.xml Parsing the configuration file. Check preinstall on every node. Successfully checked preinstall on every node. Creating

redis 4.0.1 | cluster集群

安装: cd /opt wget http://download.redis.io/releases/redis-4.0.1.tar.gz tar zxf redis-4.0.1.tar.gz cd redis-4.0.1 make 集群搭建: 2台机器                   3 master      --         3slave master: cd src cp redis-trib.rb /usr/local/bin/ mkdir redis_cluster mkdi

Redis Cluster集群部署方案

什么是 Redis 集群 Redis 集群是一个分布式(distributed).容错(fault-tolerant)的 Redis 实现,集群可以使用的功能是普通单机 Redis 所能使用的功能的一个子集(subset). Redis 集群中不存在中心(central)节点或者代理(proxy)节点,集群的其中一个主要设计目标是达到线性可扩展性(linear scalability). Redis 集群为了保证一致性(consistency)而牺牲了一部分容错性:系统会在保证对网络断线(net