redis集群cluster简单设置
环境:
这里参考官方使用一台服务器:Centos 7 redis-5.0.4 192.168.10.10
redis集群cluster最少要3个主节点,所以本次需要创建6个实例:3个主节点,3个从节点。
1、创建cluster工作目录
[root@localhost ~]# mkdir -p /opt/redis-5.0.4/cluster-test/{7000,7001,7002,7003,7004,7005}
2、创建cluster的配置文件
[root@localhost ~]# cd /opt/redis-5.0./cluster-test/
[root@localhost cluster-test]# vim /redis.conf
port // 端口号
daemonize yes // 开启守护进程
dir "/opt/redis-5.0.4/cluster-test/data" // 集群的工作目录
logfile "/opt/redis-5.0.4/cluster-test/log/cluster-7000.log" // 日志文件
dbfilename "dump-7000.rdb"
cluster-enabled yes // 启用集群功能
cluster-config-file nodes-.conf // 集群配置文件的名字
cluster-require-full-coverage no // #redis cluster需要16384个slot都正常的时候才能对外提供服务,换句话说,只要任何一个slot异常那么整个cluster不对外提供服务。 因此生产环境一般为no
cluster-node-timeout //请求超时 默认15秒,可自行设置
appendonly yes //aof日志开启 有需要就开启,它会每次写操作都记录一条日志
由于这6个实例的配置文件除了端口以外基本相同。所以我们将redis.conf分别复制一份到剩下的7001、7002、7003、7004、7005的目录下然后修改对应的端口。
最终的配置文件看起来向下面这样
[root@localhost cluster-test]# vim /redis.conf
port
daemonize yes
dir "/opt/redis-5.0.4/cluster-test/data"
logfile "/opt/redis-5.0.4/cluster-test/log/cluster-7000.log"
dbfilename "dump-7000.rdb"
cluster-enabled yes
cluster-config-file nodes-.conf
cluster-require-full-coverage no
cluster-node-timeout
appendonly yes --------------------------------------------------------------------- [root@localhost cluster-test]# vim /redis.conf
port
daemonize yes
dir "/opt/redis-5.0.4/cluster-test/data"
logfile "/opt/redis-5.0.4/cluster-test/log/cluster-7001.log"
dbfilename "dump-7001.rdb"
cluster-enabled yes
cluster-config-file nodes-.conf
cluster-require-full-coverage no
cluster-node-timeout
appendonly yes ------------------------------------------------------------------------ [root@localhost cluster-test]# vim /redis.conf
port
daemonize yes
dir "/opt/redis-5.0.4/cluster-test/data"
logfile "/opt/redis-5.0.4/cluster-test/log/cluster-7002.log"
dbfilename "dump-7002.rdb"
cluster-enabled yes
cluster-config-file nodes-.conf
cluster-require-full-coverage no
cluster-node-timeout
appendonly yes ------------------------------------------------------------------------ [root@localhost cluster-test]# vim /redis.conf
port
daemonize yes
dir "/opt/redis-5.0.4/cluster-test/data"
logfile "/opt/redis-5.0.4/cluster-test/log/cluster-7003.log"
dbfilename "dump-7003.rdb"
cluster-enabled yes
cluster-config-file nodes-.conf
cluster-require-full-coverage no
cluster-node-timeout
appendonly yes ------------------------------------------------------------------------ [root@localhost cluster-test]# vim /redis.conf
port
daemonize yes
dir "/opt/redis-5.0.4/cluster-test/data"
logfile "/opt/redis-5.0.4/cluster-test/log/cluster-7004.log"
dbfilename "dump-7004.rdb"
cluster-enabled yes
cluster-config-file nodes-.conf
cluster-require-full-coverage no
cluster-node-timeout
appendonly yes ------------------------------------------------------------------------ [root@localhost cluster-test]# vim /redis.conf
port
daemonize yes
dir "/opt/redis-5.0.4/cluster-test/data"
logfile "/opt/redis-5.0.4/cluster-test/log/cluster-7005.log"
dbfilename "dump-7005.rdb"
cluster-enabled yes
cluster-config-file nodes-.conf
cluster-require-full-coverage no
cluster-node-timeout
appendonly yes
redis.conf
创建好配置文件,在创建对应的cluster工作目录和日志文件目录
[root@localhost ~]# mkdir -p /opt/redis-5.0./cluster-test/data
[root@localhost ~]# mkdir -p /opt/redis-5.0./cluster-test/log
3、运行集群
这里需要注意:
如果你使用的是Redis 5,我们可以使用redis-cli中的Redis集群命令行实用程序来创建新的集群、检查或重新分割现有集群,等等。
对于Redis版本3或4,需要使用redis-trib。可以在Redis源代码发行版的src目录中找到它。需要安装redis gem才能运行redis-trib,而gem需要reby环境,所以需要安装reby
如果是redis版本5以下的请按照下面安装reby环境和redis.gem。
3.1安装reby环境
[root@localhost cluster-test]# wget -P /opt/source https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz
[root@localhost cluster-test]# tar -zxvf /opt/source/ruby-2.3.1.tar.gz -C /opt/
[root@localhost cluster-test]# cd /opt/ruby-2.3.1/
[root@localhost ruby-2.3.1]# ./configure --prefix=/opt/ruby231
[root@localhost ruby-2.3.1]# make && make install
[root@localhost bin]# vim /etc/profile // 添加环境变量
PATH="/opt/python362/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/tngx230/sbin:/opt/node-v8.6.0-linux-x64/bin:/opt/ruby231/bin"
[root@localhost src]# cp /opt/ruby231/bin/ruby /usr/local/ // redis-trib.rb会到这里去找reby
[root@localhost src]# cp /opt/ruby231/bin/gem /usr/local/
[root@localhost bin]# source /etc/profile // 使配置立即生效
3.2安装redis.gem
[root@localhost ~]# gem install redis
3.3开启redis实例
[root@localhost ~]# redis-server /opt/redis-5.0./cluster-test//redis.conf
[root@localhost ~]# redis-server /opt/redis-5.0./cluster-test//redis.conf
[root@localhost ~]# redis-server /opt/redis-5.0./cluster-test//redis.conf
[root@localhost ~]# redis-server /opt/redis-5.0./cluster-test//redis.conf
[root@localhost ~]# redis-server /opt/redis-5.0./cluster-test//redis.conf
[root@localhost ~]# redis-server /opt/redis-5.0./cluster-test//redis.conf
开启成功后,看起来像下面这样:
3.3运行集群
[root@localhost src]# ./redis-trib.rb create --replicas 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1:
如果是redis5.0以上版本会有如下提示信息:
对于3或4版本的盆友,我也就只能走到这里了,下面我将以5.0版本进行操作。
4、运行集群
[root@localhost src]# redis-cli --cluster create 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1: --cluster-replicas
命令执行成功后,会看到如下界面:
输入yes根据上面的配置进行设置开启集群,集群开启成功后如下所示:
5、查看集群状态
redis-cli -p cluster info // 查看节点详细信息
redis-cli -p cluster nodes // 查看所有节点
redis-cli -p cluster nodes | grep master // 过滤出主节点
redis-cli -p cluster nodes | grep slave // 过滤出从节点
6、验证集群
开两个shell登陆redis实例
[root@localhost ~]# redis-cli -c -p // 登陆7000的实例
[root@localhost ~]# redis-cli -c -p // 登陆7003的实例
--------------------------------------------------------------------------------到此redis集群就算简单的实现了-----------------------------------------------------------------
参考文档:https://redis.io/topics/cluster-tutorial
redis集群cluster简单设置的更多相关文章
- redis单点、redis主从、redis哨兵sentinel,redis集群cluster配置搭建与使用
目录 redis单点.redis主从.redis哨兵 sentinel,redis集群cluster配置搭建与使用 1 .redis 安装及配置 1.1 redis 单点 1.1.2 在命令窗口操作r ...
- Docker快速构建Redis集群(cluster)
Docker快速构建Redis集群(cluster) 以所有redis实例运行在同一台宿主机上为例子 搭建步骤 redis集群目录清单 . ├── Dockerfile ├── make_master ...
- redis集群搭建及设置账户(转)
Redis集群搭建以及为集群设置密码 介绍安装环境与版本 用两台虚拟机模拟6个节点,一台机器3个节点,创建出3 master.3 salve 环境. redis 采用 redis-3.2.4 版本. ...
- redis集群cluster模式搭建
实验服务器 :192.168.44.139 192.168.44.138 192.168.44.144 在 192.168.44.139上操作: 将redis的包上传的新建的目录newtouc ...
- redis 集群的密码设置
redis的密码设置有2种方式 1, 这个方法我没试 修改所有Redis集群中的redis.conf文件加入: masterauth passwd123 requirepass passwd123 ...
- Redis集群-Cluster模式
我理解的此模式与哨兵模式根本区别: 哨兵模式采用主从复制模式,主和从数据都是一致的.全量数据: Cluster模式采用数据分片存储,对每个 key 计算 CRC16 值,然后对 16384 取模,可以 ...
- Spring Boot集成Redis集群(Cluster模式)
目录 集成jedis 引入依赖 配置绑定 注册 获取redis客户端 使用 验证 集成spring-data-redis 引入依赖 配置绑定 注册 获取redis客户端 使用 验证 异常处理 同样的, ...
- [个人翻译]Redis 集群教程(中)
上一篇:http://www.cnblogs.com/li-peng/p/6143709.html 官方原文地址:https://redis.io/topics/cluster-tutorial 水 ...
- Python 检测系统时间,k8s版本,redis集群,etcd,mysql,ceph,kafka
一.概述 线上有一套k8s集群,部署了很多应用.现在需要对一些基础服务做一些常规检测,比如: 系统时间,要求:k8s的每一个节点的时间,差值上下不超过2秒 k8s版本,要求:k8s的每一个节点的版本必 ...
随机推荐
- ubuntu 16.04下node和pm2安装
一.安装node,这里安装9.0的版本,安装其它版本直接到https://deb.nodesource.com/setup_9.x找相应版本的更改既可 1.sudo apt-get remove no ...
- vue-router路由传参之query和params
首先简单来说明一下$router和$route的区别 //$router : 是路由操作对象,只写对象 //$route : 路由信息对象,只读对象 //操作 路由跳转 this.$router.pu ...
- 201871010121-王方-《面向对象程序开发设计java》第十四周实验总结
4 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/ ...
- 10-tensorflow-tf.concat()
Concatenates tensors along one dimension. t1 = [[1, 2, 3], [4, 5, 6]] t2 = [[7, 8, 9], [10, 11, 12]] ...
- 02-人脸识别-基于MTCNN,框选人脸区域-detect_face
(本系列随笔持续更新) 这部分代码是基于参考中的链接,修改后适用于TensorFlow1.6.0版本的代码.由于TensorFlow的频繁更新,所以不一定支持后续新或者就版本,特此说明. 程序的最初版 ...
- 洛谷 U86564 排队形
洛谷 U86564 排队形 题目传送门 题目背景 \(JDFZ2019\)秋季运动会开始辣!为了使强大的高一 · \(6\)班有一个更好的精神面貌,班主任\(T\)老师和体委\(LY\),\(LYB\ ...
- hzoi欢乐时刻(持续更新)
%%NC哥 %%Dybala %%cbx吐露(bei ji can)真相 %%skyh×2 不愿透露姓名的群众无意间发现惊人秘密, skyh默默坦白真相, 这究竟是人性的沦丧还是道德的泯灭? %%kx ...
- 【LG4437】[HNOI/AHOI2018]排列
[LG4437][HNOI/AHOI2018]排列 题面 洛谷 题解 题面里这个毒瘤的东西我们转化一下: 对于\(\forall k,j\),若\(p_k=a_{p_j}\),则\(k<j\). ...
- 8.19 NOIP模拟测试26(B) 嚎叫响彻在贪婪的厂房+主仆见证了 Hobo 的离别+征途堆积出友情的永恒
T1 嚎叫响彻在贪婪的厂房 以前做过一个等比数列的题「序列」,这个类似 是等差数列且公差不为1的条件就是各项差的绝对值的$gcd!=1$,每次拿出序列前两个数,求出差值,插入到set里,每次向后扩展, ...
- [LeetCode] 879. Profitable Schemes 盈利方案
There are G people in a gang, and a list of various crimes they could commit. The i-th crime generat ...