Redis4集群安装部署实战
来源:互联网 发布:知满天孙景民 编辑:程序博客网 时间:2024/05/17 21:55
redis服务器的集群主从配置,从redis的安装到实例开启,到集群创建。集群配置如图:
Redis集群优点摘自官网
So in practical terms, what you get with Redis Cluster?
The ability to automatically split your dataset among multiple nodes.
The ability to continue operations when a subset of the nodes are experiencing failures or are unable to communicate with the rest of the cluster.
1.安装redis,下载Redis并编译
在三台服务器上分别安装redis,进行如下操作:
ubuntu需要安装
sudo apt install tcl8.6
$ wget http://download.redis.io/releases/redis-4.0.1.tar.gz$ tar xzf redis-4.0.1.tar.gz$ cd redis-4.0.1$ make$ mv /opt/
$ make test
2.集群文件配置
resdis集群整体架构
三台服务器,配置如上图,在每台服务器上配置如下(以服务器3为列)
$ /opt/redis-4.0.1# mkdir redis-cluster$ /opt/redis-4.0.1# mkdir redis-cluster/nodes-7004$ /opt/redis-4.0.1# mkdir redis-cluster/nodes-7005$ /opt/redis-4.0.1# cp redis.conf redis-cluster/nodes-7004$ /opt/redis-4.0.1# cp redis.conf redis-cluster/nodes-7005
依次配置redis.conf(以nodes-7005为列)
$ /opt/redis-4.0.1# vim redis-cluster/nodes-7005/redis.conf
port 7005 #在不同的服务器和nodes-xx中,端口也不同cluster-enabled yesbind 10.80.67.238# daemonize yes #redis后台运行cluster-config-file nodes-7005.confcluster-node-timeout 5000appendonly yes
3.依次启动redis实例
src/redis-server redis-cluster/nodes-7000/redis.conf
后台启动
nohup src/redis-server redis-cluster/nodes-7000/redis.conf > redis-cluster/nodes-7000/redis-server.out 2>&1 &
nohup(no hang up) 不挂起,后台运行程序。并将输出信息重定向到
redis-cluster/nodes-7000/redis-server.out
如何关闭?
查看pidps aux | grep redis
关闭进程kill -9 pid
每个redis实例都有独立唯一都id,启动和关闭不会改变id。如上依次开启6个redis实例。
4.创建集群
只需在redis-cluster1服务器上操作
仅需要在redis-cluster1服务器上安装gem redis (为来redis-trib可以执行),其他服务器不用。
gem install redis #默认安装的版本上3.3(无所谓)
开启集群
src/redis-trib.rb create --replicas 1 10.80.67.225:7000 10.80.67.225:7001 10.80.67.230:7002 10.80.67.230:7003 10.80.67.238:7004 10.80.67.238:7005
在Can I set the above configuration? (type 'yes' to accept):
输入yes
集群创建完成,运行正常。
[OK] All 16384 slots covered.
意味着集群中的16384个槽至少有一个主节点在处理。
参考Redis集群官方文档
- Redis4集群安装部署实战
- redis4.0.0 集群安装详细步骤
- redis4.0集群安装配置(双节点)
- Redis4集群搭建
- redis4.0.2集群配置
- codis集群部署实战
- codis集群部署实战
- codis集群部署实战
- codis集群部署实战
- codis集群部署实战
- Redis4基于CentOS6集群搭建
- redis4.0.2版本集群搭建
- Linux 安装 Redis4
- redis4.0.1安装教程
- Centos安装Redis4.0.0
- Redis4.0.1 安装指南
- CentOS7安装Redis4.0.2
- Redis4.0.2安装
- 自己整理的水泥地雪地土地图片集
- hive内置函数和自定义函数的使用
- 完全用链表实现的贪吃蛇
- 组合数的一些知识
- webstorm快捷键大全
- Redis4集群安装部署实战
- 一个普通的 Zepto 源码分析(三)
- Shiro安全框架入门使用方法
- hdu3635 P
- HDU4635 Strongly connected【强连通】
- 小ho的01串 [字符串]
- 三个案例带你看懂LayoutInflater中inflate方法两个参数和三个参数的区别
- 色彩天气APP-MVP初体验
- 【Java学习笔记】二维数组模拟酒店管理系统