- 浏览: 2550787 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Redis Cluster 2019(3)Redis Cluster on CentOS
Current release is still 5.0.5
> sudo yum install wget
> sudo yum groupinstall "Development tools"
> wget http://download.redis.io/releases/redis-5.0.5.tar.gz
> tar zxvf redis-5.0.5.tar.gz
> cd redis-5.0.5
> make distclean
> make
During make, we may have these issues
jemalloc/jemalloc.h: No such file or directory
If so, we may need to run the make distclean again and then make.
Prepare the installation directory
> mkdir ~/tool/redis-5.0.5
> mkdir ~/tool/redis-5.0.5/bin
> cp src/redis-server ~/tool/redis-5.0.5/bin/
> cp src/redis-cli ~/tool/redis-5.0.5/bin/
> cp src/redis-benchmark ~/tool/redis-5.0.5/bin/
> mkdir ~/tool/redis-5.0.5/conf
> cp redis.conf ~/tool/redis-5.0.5/conf/
Soft link
> sudo ln -s /home/carl/tool/redis-5.0.5 /opt/redis-5.0.5
> sudo ln -s /opt/redis-5.0.5 /opt/redis
Go to the Redis directory
> cd /opt/redis
Prepare the cluster conf
> mkdir cluster-conf
> mkdir cluster-conf/7001
> mkdir cluster-conf/7002
Prepare the default configuration to the cluster
> cp conf/redis.conf cluster-conf/7001/
> cp conf/redis.conf cluster-conf/7002/
Edit the configuration
> vi cluster-conf/7001/redis.conf
port 7001
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7001.conf
cluster-node-timeout 15000
bind 0.0.0.0
> vi cluster-conf/7002/redis.conf
port 7002
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7002.conf
cluster-node-timeout 15000
bind 0.0.0.0
Do the similar things to centos-dev1, centos-dev2, centos-dev3, or we can just copy them to other machines
> scp centos-dev1:/opt/redis/cluster-conf/7001/redis.conf ./cluster-conf/7001/redis.conf
> scp centos-dev1:/opt/redis/cluster-conf/7002/redis.conf ./cluster-conf/7002/redis.conf
Start the redis server on all 3 machines
> bin/redis-server ./cluster-conf/7001/redis.conf
> bin/redis-server ./cluster-conf/7002/redis.conf
After start 6 nodes across 3 machines, we need to init the cluster, my network information is as follow:
192.168.56.102 centos-dev1
192.168.56.111 centos-dev2
192.168.56.112 centos-dev3
On my virtual box machines, I may need to stop the firewall or disable the firewall
> sudo systemctl stop firewalld
> sudo systemctl disable firewalld
> bin/redis-cli --cluster create 192.168.56.102:7001 192.168.56.102:7002 192.168.56.111:7001 192.168.56.111:7002 192.168.56.112:7001 192.168.56.112:7002 --cluster-replicas 1
>>> Performing Cluster Check (using node 192.168.56.102:7001)
M: fc80c3e30badbc2a0e2ec025caaf5709f52090dc 192.168.56.102:7001
slots:[0-5460] (5461 slots) master
1 additional replica(s)
M: 6f4aae743cf544c03b00cf91b50c97f61fc72c91 192.168.56.112:7001
slots:[10923-16383] (5461 slots) master
1 additional replica(s)
S: a32cf75ace9e645d1040699097f3f68965e1f3c9 192.168.56.112:7002
slots: (0 slots) slave
replicates de80b1038ab53c35b16ee010f7576ef50788fc81
S: 8f157bb59e184fe04e1a0654cefb7ca72c904234 192.168.56.111:7002
slots: (0 slots) slave
replicates fc80c3e30badbc2a0e2ec025caaf5709f52090dc
S: a1f8b4433acf6b8b9a09852aafa028cd4534590e 192.168.56.102:7002
slots: (0 slots) slave
replicates 6f4aae743cf544c03b00cf91b50c97f61fc72c91
M: de80b1038ab53c35b16ee010f7576ef50788fc81 192.168.56.111:7001
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.
Then the cluster is ready.
Add the bin to the PATH to make my life easier
> vi ~/.bash_profile
PATH=$PATH:/opt/redis/bin
Apply the change
> . ~/.bash_profile
Connect to verify
> redis-cli -c -h centos-dev1 -p 7001
centos-dev1:7001> set foo bar
-> Redirected to slot [12182] located at 192.168.56.112:7001
OK
192.168.56.112:7001> get foo
"bar"
192.168.56.112:7001>
Show all the cluster nodes
192.168.56.112:7001> cluster nodes
6f4aae743cf544c03b00cf91b50c97f61fc72c91 192.168.56.112:7001@17001 myself,master - 0 1565981164000 5 connected 10923-16383
8f157bb59e184fe04e1a0654cefb7ca72c904234 192.168.56.111:7002@17002 slave fc80c3e30badbc2a0e2ec025caaf5709f52090dc 0 1565981165000 4 connected
fc80c3e30badbc2a0e2ec025caaf5709f52090dc 192.168.56.102:7001@17001 master - 0 1565981167640 1 connected 0-5460
a1f8b4433acf6b8b9a09852aafa028cd4534590e 192.168.56.102:7002@17002 slave 6f4aae743cf544c03b00cf91b50c97f61fc72c91 0 1565981166000 5 connected
de80b1038ab53c35b16ee010f7576ef50788fc81 192.168.56.111:7001@17001 master - 0 1565981166000 3 connected 5461-10922
a32cf75ace9e645d1040699097f3f68965e1f3c9 192.168.56.112:7002@17002 slave de80b1038ab53c35b16ee010f7576ef50788fc81 0 1565981166627 6 connected
Some warnings need to care:
Warning #1
5976:M 16 Aug 2019 01:01:24.396 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
Solution:
https://www.jianshu.com/p/7319c6d6f365
> sudo vi /etc/sysctl.conf
net.core.somaxconn=2048
Verify the change
> sudo sysctl -p
net.core.somaxconn = 2048
Warning #2
5976:M 16 Aug 2019 01:01:24.396 # 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.
Solution:
https://stackoverflow.com/questions/41203492/solving-redis-warnings-on-overcommit-memory-and-transparent-huge-pages-for-ubunt
> sudo vi /etc/sysctl.conf
vm.overcommit_memory=1
Verify the change
> sudo sysctl -p
net.core.somaxconn = 2048
vm.overcommit_memory = 1
Warning #3
5976:M 16 Aug 2019 01:01:24.396 # 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.
Solution:
https://github.com/docker-library/redis/issues/55
Need to su to root user to do this
> echo never > /sys/kernel/mm/transparent_hugepage/enabled
> echo never > /sys/kernel/mm/transparent_hugepage/defrag
> cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
> cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]
References:
https://www.psychz.net/client/question/en/turn-off-firewall-centos-7.html
https://github.com/junegunn/redis-stat
https://www.jianshu.com/p/7319c6d6f365
Current release is still 5.0.5
> sudo yum install wget
> sudo yum groupinstall "Development tools"
> wget http://download.redis.io/releases/redis-5.0.5.tar.gz
> tar zxvf redis-5.0.5.tar.gz
> cd redis-5.0.5
> make distclean
> make
During make, we may have these issues
jemalloc/jemalloc.h: No such file or directory
If so, we may need to run the make distclean again and then make.
Prepare the installation directory
> mkdir ~/tool/redis-5.0.5
> mkdir ~/tool/redis-5.0.5/bin
> cp src/redis-server ~/tool/redis-5.0.5/bin/
> cp src/redis-cli ~/tool/redis-5.0.5/bin/
> cp src/redis-benchmark ~/tool/redis-5.0.5/bin/
> mkdir ~/tool/redis-5.0.5/conf
> cp redis.conf ~/tool/redis-5.0.5/conf/
Soft link
> sudo ln -s /home/carl/tool/redis-5.0.5 /opt/redis-5.0.5
> sudo ln -s /opt/redis-5.0.5 /opt/redis
Go to the Redis directory
> cd /opt/redis
Prepare the cluster conf
> mkdir cluster-conf
> mkdir cluster-conf/7001
> mkdir cluster-conf/7002
Prepare the default configuration to the cluster
> cp conf/redis.conf cluster-conf/7001/
> cp conf/redis.conf cluster-conf/7002/
Edit the configuration
> vi cluster-conf/7001/redis.conf
port 7001
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7001.conf
cluster-node-timeout 15000
bind 0.0.0.0
> vi cluster-conf/7002/redis.conf
port 7002
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7002.conf
cluster-node-timeout 15000
bind 0.0.0.0
Do the similar things to centos-dev1, centos-dev2, centos-dev3, or we can just copy them to other machines
> scp centos-dev1:/opt/redis/cluster-conf/7001/redis.conf ./cluster-conf/7001/redis.conf
> scp centos-dev1:/opt/redis/cluster-conf/7002/redis.conf ./cluster-conf/7002/redis.conf
Start the redis server on all 3 machines
> bin/redis-server ./cluster-conf/7001/redis.conf
> bin/redis-server ./cluster-conf/7002/redis.conf
After start 6 nodes across 3 machines, we need to init the cluster, my network information is as follow:
192.168.56.102 centos-dev1
192.168.56.111 centos-dev2
192.168.56.112 centos-dev3
On my virtual box machines, I may need to stop the firewall or disable the firewall
> sudo systemctl stop firewalld
> sudo systemctl disable firewalld
> bin/redis-cli --cluster create 192.168.56.102:7001 192.168.56.102:7002 192.168.56.111:7001 192.168.56.111:7002 192.168.56.112:7001 192.168.56.112:7002 --cluster-replicas 1
>>> Performing Cluster Check (using node 192.168.56.102:7001)
M: fc80c3e30badbc2a0e2ec025caaf5709f52090dc 192.168.56.102:7001
slots:[0-5460] (5461 slots) master
1 additional replica(s)
M: 6f4aae743cf544c03b00cf91b50c97f61fc72c91 192.168.56.112:7001
slots:[10923-16383] (5461 slots) master
1 additional replica(s)
S: a32cf75ace9e645d1040699097f3f68965e1f3c9 192.168.56.112:7002
slots: (0 slots) slave
replicates de80b1038ab53c35b16ee010f7576ef50788fc81
S: 8f157bb59e184fe04e1a0654cefb7ca72c904234 192.168.56.111:7002
slots: (0 slots) slave
replicates fc80c3e30badbc2a0e2ec025caaf5709f52090dc
S: a1f8b4433acf6b8b9a09852aafa028cd4534590e 192.168.56.102:7002
slots: (0 slots) slave
replicates 6f4aae743cf544c03b00cf91b50c97f61fc72c91
M: de80b1038ab53c35b16ee010f7576ef50788fc81 192.168.56.111:7001
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.
Then the cluster is ready.
Add the bin to the PATH to make my life easier
> vi ~/.bash_profile
PATH=$PATH:/opt/redis/bin
Apply the change
> . ~/.bash_profile
Connect to verify
> redis-cli -c -h centos-dev1 -p 7001
centos-dev1:7001> set foo bar
-> Redirected to slot [12182] located at 192.168.56.112:7001
OK
192.168.56.112:7001> get foo
"bar"
192.168.56.112:7001>
Show all the cluster nodes
192.168.56.112:7001> cluster nodes
6f4aae743cf544c03b00cf91b50c97f61fc72c91 192.168.56.112:7001@17001 myself,master - 0 1565981164000 5 connected 10923-16383
8f157bb59e184fe04e1a0654cefb7ca72c904234 192.168.56.111:7002@17002 slave fc80c3e30badbc2a0e2ec025caaf5709f52090dc 0 1565981165000 4 connected
fc80c3e30badbc2a0e2ec025caaf5709f52090dc 192.168.56.102:7001@17001 master - 0 1565981167640 1 connected 0-5460
a1f8b4433acf6b8b9a09852aafa028cd4534590e 192.168.56.102:7002@17002 slave 6f4aae743cf544c03b00cf91b50c97f61fc72c91 0 1565981166000 5 connected
de80b1038ab53c35b16ee010f7576ef50788fc81 192.168.56.111:7001@17001 master - 0 1565981166000 3 connected 5461-10922
a32cf75ace9e645d1040699097f3f68965e1f3c9 192.168.56.112:7002@17002 slave de80b1038ab53c35b16ee010f7576ef50788fc81 0 1565981166627 6 connected
Some warnings need to care:
Warning #1
5976:M 16 Aug 2019 01:01:24.396 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
Solution:
https://www.jianshu.com/p/7319c6d6f365
> sudo vi /etc/sysctl.conf
net.core.somaxconn=2048
Verify the change
> sudo sysctl -p
net.core.somaxconn = 2048
Warning #2
5976:M 16 Aug 2019 01:01:24.396 # 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.
Solution:
https://stackoverflow.com/questions/41203492/solving-redis-warnings-on-overcommit-memory-and-transparent-huge-pages-for-ubunt
> sudo vi /etc/sysctl.conf
vm.overcommit_memory=1
Verify the change
> sudo sysctl -p
net.core.somaxconn = 2048
vm.overcommit_memory = 1
Warning #3
5976:M 16 Aug 2019 01:01:24.396 # 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.
Solution:
https://github.com/docker-library/redis/issues/55
Need to su to root user to do this
> echo never > /sys/kernel/mm/transparent_hugepage/enabled
> echo never > /sys/kernel/mm/transparent_hugepage/defrag
> cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
> cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]
References:
https://www.psychz.net/client/question/en/turn-off-firewall-centos-7.html
https://github.com/junegunn/redis-stat
https://www.jianshu.com/p/7319c6d6f365
发表评论
-
Update Site will come soon
2021-06-02 04:10 1677I am still keep notes my tech n ... -
Stop Update Here
2020-04-28 09:00 315I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 474NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 367Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 367Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 335Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 429Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 434Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 373Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 454VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 384Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 475NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 421Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 336Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 246GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 450GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 325GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 312Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 317Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 291Serverless with NodeJS and Tenc ...
相关推荐
以下是对"Linux-CentOS中redisCluster部署指南(redis-5.0.3)"的详细解释和相关知识点: 一、Redis Cluster简介 Redis Cluster是Redis官方提供的分布式解决方案,通过数据分片技术实现了数据的自动分发和容灾,支持...
改压缩包中含了centos7.x离线安装redis-cluster的所有相关文件,包括ruby-2.4.1.tar.gz,rubygems-2.7.6.tgz,zlib-1.2.11.tar.gz,redis-4.0.2.gem,tcl8.6.8-src.tar.gz
本文档描述redis-cluster在centos7上面的集群搭建,从源码编译、环境准备、安装redis、修改配置文件、启动集群、关闭集群等各个地方进行详细描述不走
Redis Cluster是Redis官方提供的分布式解决方案,它通过分片(Sharding)的方式实现了数据在多个节点间的自动分布,从而实现高可用性和水平扩展性。在Redis Cluster中,数据被分割成多个槽(Slots),每个节点负责一...
3. **重新分配槽**:当添加或移除节点时,可能需要手动调整槽的分配,使用`redis-cli --cluster rebalance`进行自动平衡。 4. **配置文件**:每个集群节点需要有自己的配置文件,其中包含`cluster-enabled yes`和`...
### Redis Cluster 4.0.8 配置与管理知识点详解 #### 一、环境准备与Redis安装 **1.1 Redis安装包获取** - **版本选择:** 文档推荐使用Redis 4.0.8版本。 - **下载地址:** ...
RedisCluster + SpringBoot演示案例 本案例所用的Redis是5.0.8所以和旧版的4.0.X不同的地方在于创建集群的方式的变化 所用系统:Centos7.7 64位 本案例设置的统一密码为:shunleite Spring Boot 2.0+ 原文地址:...
Redis 集群部署在 CentOS 7.4 上的详细操作步骤 在本教程中,我们将学习如何在 CentOS 7.4 上部署 Redis 集群。Redis 集群是一种高可用性的解决方案,它可以将多个 Redis 实例组合成一个集群,以便提供更高的性能和...
Redis Cluster是Redis官方提供的分布式集群解决方案,它允许用户在多个节点之间分发数据,实现高可用性和可扩展性。在Linux环境下安装Redis Cluster时,离线安装包是针对那些无法直接连接到互联网或者网络环境受限的...
Centos7 Redis-cluster for Docker.md 存放这里,让大家下载快捷一点
在本文中,我们将详细讨论如何在CentOS 7环境下配置一个由三台主机组成的Redis分布式集群,每台主机上都有一个主节点和一个从节点,总计六个节点。这个过程涵盖了安装Redis、创建服务、配置集群、启动集群以及测试...
本指南详细介绍了在 CentOS 服务器上安装 Redis 服务的两种方法:通过 yum 安装和源码安装。无论是哪种方式,都需要注意配置 Redis 服务以满足项目需求,包括设置访问权限、持久化策略、最大内存限制等。此外,还...
Redis是一款高性能的键值存储系统,...总的来说,"redis-3.0.0.tar"和"redis-3.0.0.gem"提供了在CentOS上搭建和管理Redis集群的全部工具。正确理解和运用这些工具,能够帮助开发者构建高效、稳定的分布式数据存储系统。
redis-cli --cluster create node1_ip:port node2_ip:port node3_ip:port ... --cluster-replicas 1 ``` 其中,`--cluster-replicas 1`表示为每个主节点分配一个副本节点。 4. **分配槽位** 集群中的数据分布在...
在Linux服务器上安装Redis,尤其是处于离线环境的CentOS 7.5系统,需要一些必要的依赖包,...此外,根据实际需求,可能还需要安装其他相关软件,如Redis Sentinel(用于高可用性)或Redis Cluster(用于分布式存储)。
在本文中,我们将深入探讨如何使用Ruby脚本来部署Redis Cluster集群。Redis Cluster是Redis的分布式解决方案,它允许数据在多个节点之间分散,提供高可用性和容错性。使用Ruby脚本进行部署可以简化这一过程,使得...
3. 创建节点,创建 7000 和 7001 文件夹用于存放 redis 节点的配置文件(redis.conf)。 4. 配置 redis 节点,创建日志、配置、数据存放目录,配置 redis 节点的 IP 地址、保护模式、后台运行、日志、db 目录、密码...
本节将详细介绍如何在 CentOS 5.8 x64 系统上安装 Redis 3.0.2 的分布式集群。 ##### 1. 下载 Redis 从 Redis 官方网站下载 Redis 3.0.2 版本,下载地址为:http://download.redis.io/releases/redis-3.0.2.tar.gz...
在您选择的节点上安装 ansible(这适用于 CentOS,Ubuntu 分支可用): yum install ansible sshpass 编辑 hosts.yml 文件,并确保您的密钥存在于所有节点(即将推出,此代码将为您添加所有内容),然后只需运行:...
系统是基于centos:6.6的,redis的版本是3.01 通过Dockerfile创建redis cluster的image,然后通过创建的镜像批量的生成容器... 可以传递指定IP和端口 docker build -t redis_cluster --rm . docker run -it --...