`
sillycat
  • 浏览: 2542376 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Redis Cluster 2019(3)Redis Cluster on CentOS

 
阅读更多
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





分享到:
评论

相关推荐

    Linux-CentOS中redisCluster部署指南(redis-5.0.3)

    以下是对"Linux-CentOS中redisCluster部署指南(redis-5.0.3)"的详细解释和相关知识点: 一、Redis Cluster简介 Redis Cluster是Redis官方提供的分布式解决方案,通过数据分片技术实现了数据的自动分发和容灾,支持...

    CentOS7.x 离线安装redis-cluster所需包

    改压缩包中含了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搭建.md

    本文档描述redis-cluster在centos7上面的集群搭建,从源码编译、环境准备、安装redis、修改配置文件、启动集群、关闭集群等各个地方进行详细描述不走

    redis cluster集群

    Redis Cluster是Redis官方提供的分布式解决方案,它通过分片(Sharding)的方式实现了数据在多个节点间的自动分布,从而实现高可用性和水平扩展性。在Redis Cluster中,数据被分割成多个槽(Slots),每个节点负责一...

    centos安装redis集群

    3. **重新分配槽**:当添加或移除节点时,可能需要手动调整槽的分配,使用`redis-cli --cluster rebalance`进行自动平衡。 4. **配置文件**:每个集群节点需要有自己的配置文件,其中包含`cluster-enabled yes`和`...

    redis cluster 4.0.8 集群配置文档

    ### Redis Cluster 4.0.8 配置与管理知识点详解 #### 一、环境准备与Redis安装 **1.1 Redis安装包获取** - **版本选择:** 文档推荐使用Redis 4.0.8版本。 - **下载地址:** ...

    rediscluster.zip

    RedisCluster + SpringBoot演示案例 本案例所用的Redis是5.0.8所以和旧版的4.0.X不同的地方在于创建集群的方式的变化 所用系统:Centos7.7 64位 本案例设置的统一密码为:shunleite Spring Boot 2.0+ 原文地址:...

    redis-cluster集群部署

    Redis 集群部署在 CentOS 7.4 上的详细操作步骤 在本教程中,我们将学习如何在 CentOS 7.4 上部署 Redis 集群。Redis 集群是一种高可用性的解决方案,它可以将多个 Redis 实例组合成一个集群,以便提供更高的性能和...

    redis_cluster离线安装包及其安装手册

    Redis Cluster是Redis官方提供的分布式集群解决方案,它允许用户在多个节点之间分发数据,实现高可用性和可扩展性。在Linux环境下安装Redis Cluster时,离线安装包是针对那些无法直接连接到互联网或者网络环境受限的...

    Centos7 Redis-cluster for Docker.md

    Centos7 Redis-cluster for Docker.md 存放这里,让大家下载快捷一点

    Centos7 三台主机(配置三主三从)Redis分布式集群

    在本文中,我们将详细讨论如何在CentOS 7环境下配置一个由三台主机组成的Redis分布式集群,每台主机上都有一个主节点和一个从节点,总计六个节点。这个过程涵盖了安装Redis、创建服务、配置集群、启动集群以及测试...

    Centos下安装redis服务v1.0

    本指南详细介绍了在 CentOS 服务器上安装 Redis 服务的两种方法:通过 yum 安装和源码安装。无论是哪种方式,都需要注意配置 Redis 服务以满足项目需求,包括设置访问权限、持久化策略、最大内存限制等。此外,还...

    redis-3.0.0.tar和redis-3.0.0.gem.rar

    Redis是一款高性能的键值存储系统,...总的来说,"redis-3.0.0.tar"和"redis-3.0.0.gem"提供了在CentOS上搭建和管理Redis集群的全部工具。正确理解和运用这些工具,能够帮助开发者构建高效、稳定的分布式数据存储系统。

    centos服务器的phpredis-2.2.4.tar.gz

    为确保高可用性和扩展性,可以将Redis部署为集群模式,通过哨兵(Sentinel)系统监控和自动故障转移,或者使用Redis Cluster实现数据分片。 总之,PHPRedis扩展是PHP开发者连接和操作Redis的强大工具,它使得在...

    linux安装redis 单机版以及集群

    redis-cli --cluster create node1_ip:port node2_ip:port node3_ip:port ... --cluster-replicas 1 ``` 其中,`--cluster-replicas 1`表示为每个主节点分配一个副本节点。 4. **分配槽位** 集群中的数据分布在...

    linux服务器上centos7.5离线安装redis 所需要的gcc包

    在Linux服务器上安装Redis,尤其是处于离线环境的CentOS 7.5系统,需要一些必要的依赖包,...此外,根据实际需求,可能还需要安装其他相关软件,如Redis Sentinel(用于高可用性)或Redis Cluster(用于分布式存储)。

    使用Ruby脚本部署Redis Cluster集群步骤讲解

    在本文中,我们将深入探讨如何使用Ruby脚本来部署Redis Cluster集群。Redis Cluster是Redis的分布式解决方案,它允许数据在多个节点之间分散,提供高可用性和容错性。使用Ruby脚本进行部署可以简化这一过程,使得...

    CentOS7.5安装Redis集群.docx

    3. 创建节点,创建 7000 和 7001 文件夹用于存放 redis 节点的配置文件(redis.conf)。 4. 配置 redis 节点,创建日志、配置、数据存放目录,配置 redis 节点的 IP 地址、保护模式、后台运行、日志、db 目录、密码...

    Redis3.0.2 分布式集群安装手册

    本节将详细介绍如何在 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...

    redis_cluster:部署 redis 集群的 Ansible playbook

    在您选择的节点上安装 ansible(这适用于 CentOS,Ubuntu 分支可用): yum install ansible sshpass 编辑 hosts.yml 文件,并确保您的密钥存在于所有节点(即将推出,此代码将为您添加所有内容),然后只需运行:...

Global site tag (gtag.js) - Google Analytics