Redis5.0 3台主机三主三从部署Cluster集群
1、下载安装
[root@ip101 redis-5.0.4]# pwd
/opt/app/redis-5.0.4
[root@ip101 redis-5.0.4]# ls
00-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README.md redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src tests utils
[root@ip101 redis-5.0.4]# pwd
/opt/app/redis-5.0.4
[root@ip101 redis-5.0.4]# make
........................................................
LINK redis-cli
CC redis-benchmark.o
LINK redis-benchmark
INSTALL redis-check-rdb
INSTALL redis-check-aof
Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory `/opt/app/redis-5.0.4/src'
[root@ip101 redis-5.0.4]# pwd
/opt/app/redis-5.0.4
[root@ip101 redis-5.0.4]# ls
00-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README.md redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src tests utils
[root@ip101 redis-5.0.4]# make install
[root@ip101 redis-5.0.4]# make uninstall#默认安装到了/usr/local/bin/目录下,更改为redis放置目录
cd src && make uninstall
make[1]: Entering directory `/opt/app/redis-5.0.4/src'
rm -f /usr/local/bin/{redis-server,redis-benchmark,redis-cli,redis-check-rdb,redis-check-aof,redis-sentinel}
make[1]: Leaving directory `/opt/app/redis-5.0.4/src'
[root@ip101 redis-5.0.4]#
[root@ip101 redis-5.0.4]# make PREFIX=/opt/app/redis-5.0.4 install
cd src && make install
make[1]: Entering directory `/opt/app/redis-5.0.4/src'
Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[1]: Leaving directory `/opt/app/redis-5.0.4/src'
[root@ip101 redis-5.0.4]# pwd
/opt/app/redis-5.0.4
[root@ip101 redis-5.0.4]# ls #安装了bin工具文件夹
00-RELEASENOTES bin BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README.md redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src tests utils
2、创建相关文件夹
[root@ip101 redis-5.0.4]# mkdir -p /opt/app/redis-5.0.4/cluster/6379
[root@ip101 redis-5.0.4]# mkdir -p /opt/app/redis-5.0.4/cluster/6380
[root@ip101 redis-5.0.4]# pwd
/opt/app/redis-5.0.4
[root@ip101 redis-5.0.4]# ls
00-RELEASENOTES BUGS CONTRIBUTING deps Makefile README.md runtest runtest-sentinel src utils
bin cluster COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests
[root@ip101 redis-5.0.4]# pwd
/opt/app/redis-5.0.4
[root@ip101 redis-5.0.4]# cp redis.conf /opt/app/redis-5.0.4/cluster/6379
[root@ip101 redis-5.0.4]# cp redis.conf /opt/app/redis-5.0.4/cluster/6380
[root@ip101 redis-5.0.4]#
3、vi /opt/app/redis-5.0.4/cluster/6379/redis.conf
# 绑定服务器IP地址
bind 192.168.8.101
# 绑定端口号,必须修改,以此来区分Redis实例
port 6379
# 后台运行
daemonize yes
# 修改pid进程文件名,以端口号命名
pidfile /var/run/redis-6379.pid
# 修改日志文件名称,以端口号为目录来区分
logfile /opt/app/redis-5.0.4/cluster/6379/redis.log
# 修改数据文件存放地址,以端口号为目录名来区分
dir /opt/app/redis-5.0.4/cluster/6379/
# 启用集群
cluster-enabled yes
# 配置每个节点的配置文件,同样以端口号为名称
cluster-config-file nodes-6379.conf
# 配置集群节点的超时时间,可改可不改
cluster-node-timeout 15000
# 启动AOF增量持久化策略
appendonly yes
# 发生改变就记录日志
appendfsync always
vi /opt/app/redis-5.0.4/cluster/6380/redis.conf
# 绑定服务器IP地址
bind 192.168.8.101
# 绑定端口号,必须修改,以此来区分Redis实例
port 6380
# 后台运行
daemonize yes
# 修改pid进程文件名,以端口号命名
pidfile /var/run/redis-6380.pid
# 修改日志文件名称,以端口号为目录来区分
logfile /opt/app/redis-5.0.4/cluster/6380/redis.log
# 修改数据文件存放地址,以端口号为目录名来区分
dir /opt/app/redis-5.0.4/cluster/6380/
# 启用集群
cluster-enabled yes
# 配置每个节点的配置文件,同样以端口号为名称
cluster-config-file nodes-6380.conf
# 配置集群节点的超时时间,可改可不改
cluster-node-timeout 15000
# 启动AOF增量持久化策略
appendonly yes
# 发生改变就记录日志
appendfsync always
4、ip102,ip103仿效ip101进行安装和配置
# 绑定服务器IP地址
bind 192.168.8.102
---------------
# 绑定服务器IP地址
bind 192.168.8.102
5、ip101,ip102,ip103配置环境变量
export REDIS_HOME=/opt/app/redis-5.0.4
export PATH=$REDIS_HOME/bin:$PATH
source /etc/profile
6、ip101、ip102、ip103启动redis
[root@ip101 redis-5.0.4]# redis-server /opt/app/redis-5.0.4/cluster/6379/redis.conf
[root@ip101 redis-5.0.4]# redis-server /opt/app/redis-5.0.4/cluster/6380/redis.conf
[root@ip101 redis-5.0.4]# ps aux|grep redis
root 12323 0.1 0.2 144480 2548 ? Ssl 05:01 0:00 redis-server 192.168.8.101:6379 [cluster]
root 12334 0.4 0.2 144480 2548 ? Ssl 05:01 0:00 redis-server 192.168.8.101:6380 [cluster]
root 12343 0.0 0.0 112660 976 pts/0 S+ 05:01 0:00 grep --color=auto redis
[root@ip101 redis-5.0.4]#
7、创建集群
redis-cli --cluster create 192.168.8.101:6379 192.168.8.101:6380 192.168.8.102:6379 192.168.8.102:6380 192.168.8.103:6379 192.168.8.103:6380 --cluster-replicas 1
#################################################################################
[root@ip101 redis-5.0.4]# redis-cli --cluster create 192.168.8.101:6379 192.168.8.101:6380 192.168.8.102:6379 192.168.8.102:6380 192.168.8.103:6379 192.168.8.103:6380 --cluster-replicas 1
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 192.168.8.102:6380 to 192.168.8.101:6379
Adding replica 192.168.8.103:6380 to 192.168.8.102:6379
Adding replica 192.168.8.101:6380 to 192.168.8.103:6379
M: 3784c7f8683faf1adce14c43c4274300fff33c79 192.168.8.101:6379
slots:[0-5460] (5461 slots) master
S: 8181ed88dd5fa1b1165a0b3a4c632de508d5766a 192.168.8.101:6380
replicates a88b9d61503decf0a4b599c169c693add15b2534
M: dfb1bf054d740fa7d3c5487278457034f17ca617 192.168.8.102:6379
slots:[5461-10922] (5462 slots) master
S: bb5ae386877fda949e10f88f051a9006299fba21 192.168.8.102:6380
replicates 3784c7f8683faf1adce14c43c4274300fff33c79
M: a88b9d61503decf0a4b599c169c693add15b2534 192.168.8.103:6379
slots:[10923-16383] (5461 slots) master
S: c36284d8e41f05352dbd4b9c8e88be3d9ef24aba 192.168.8.103:6380
replicates dfb1bf054d740fa7d3c5487278457034f17ca617
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.8.101:6379)
M: 3784c7f8683faf1adce14c43c4274300fff33c79 192.168.8.101:6379
slots:[0-5460] (5461 slots) master
1 additional replica(s)
S: 8181ed88dd5fa1b1165a0b3a4c632de508d5766a 192.168.8.101:6380
slots: (0 slots) slave
replicates a88b9d61503decf0a4b599c169c693add15b2534
S: bb5ae386877fda949e10f88f051a9006299fba21 192.168.8.102:6380
slots: (0 slots) slave
replicates 3784c7f8683faf1adce14c43c4274300fff33c79
S: c36284d8e41f05352dbd4b9c8e88be3d9ef24aba 192.168.8.103:6380
slots: (0 slots) slave
replicates dfb1bf054d740fa7d3c5487278457034f17ca617
M: dfb1bf054d740fa7d3c5487278457034f17ca617 192.168.8.102:6379
slots:[5461-10922] (5462 slots) master
1 additional replica(s)
M: a88b9d61503decf0a4b599c169c693add15b2534 192.168.8.103:6379
slots:[10923-16383] (5461 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.
8、查看集群状态
[root@ip101 redis-5.0.4]# redis-cli --cluster check 192.168.8.101:6379
192.168.8.101:6379 (3784c7f8...) -> 0 keys | 5461 slots | 1 slaves.
192.168.8.102:6379 (dfb1bf05...) -> 0 keys | 5462 slots | 1 slaves.
192.168.8.103:6379 (a88b9d61...) -> 0 keys | 5461 slots | 1 slaves.
[OK] 0 keys in 3 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.8.101:6379)
M: 3784c7f8683faf1adce14c43c4274300fff33c79 192.168.8.101:6379
slots:[0-5460] (5461 slots) master
1 additional replica(s)
S: 8181ed88dd5fa1b1165a0b3a4c632de508d5766a 192.168.8.101:6380
slots: (0 slots) slave
replicates a88b9d61503decf0a4b599c169c693add15b2534
S: bb5ae386877fda949e10f88f051a9006299fba21 192.168.8.102:6380
slots: (0 slots) slave
replicates 3784c7f8683faf1adce14c43c4274300fff33c79
S: c36284d8e41f05352dbd4b9c8e88be3d9ef24aba 192.168.8.103:6380
slots: (0 slots) slave
replicates dfb1bf054d740fa7d3c5487278457034f17ca617
M: dfb1bf054d740fa7d3c5487278457034f17ca617 192.168.8.102:6379
slots:[5461-10922] (5462 slots) master
1 additional replica(s)
M: a88b9d61503decf0a4b599c169c693add15b2534 192.168.8.103:6379
slots:[10923-16383] (5461 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.
[root@ip101 redis-5.0.4]#
9、使用集群
随意找到一个端口进行连接
[root@ip101 redis-5.0.4]# redis-cli -c -h 192.168.8.102 -p 6380
192.168.8.102:6380> set key1 value1
-> Redirected to slot [9189] located at 192.168.8.102:6379
OK
192.168.8.102:6379> get key1
"value1"
192.168.8.102:6379>
Redis5.0 3台主机三主三从部署Cluster集群的更多相关文章
- K8S部署Redis Cluster集群(三主三从模式) - 部署笔记
一.Redis 介绍 Redis代表REmote DIctionary Server是一种开源的内存中数据存储,通常用作数据库,缓存或消息代理.它可以存储和操作高级数据类型,例如列表,地图,集合和排序 ...
- centos 7 两台机器搭建三主三从 redis 集群
参考自:https://linux.cn/article-6719-1.htmlhttp://blog.csdn.net/xu470438000/article/details/42971091 ## ...
- 在三台服务器,搭建redis三主三从集群
一.资源准备 1.准备三台服务器H1.H2.H3 172.26.237.83 H1 172.26.237.84 H2 172.26.237.85 H3 二.配置服务器 1.在H1服务器设置SSH免密登 ...
- 搭建Redis三主三从集群
Redis三主三从集群规划 10.0.128.19 使用端口 7000 7001 10.0.128.22 使用端口 7002 7003 10.0.128.23 使用端口 7004 7 ...
- redis cluster + sentinel详细过程和错误处理三主三备三哨兵
redis cluster + sentinel详细过程和错误处理三主三备三哨兵1.基本架构192.168.70.215 7001 Master + sentinel 27001192.168.70. ...
- RocketMQ三主三从二命名服务平滑版本升级实操
本文介绍本次进行RocketMQ平滑过渡升级的实际操作 前文已经介绍过了升级基本原理,主要思想就是先升级NameSrv(命名服务)然后在升级broker节点.broker节点先升级master节点然 ...
- 配置redis三主三从
主从环境 centos7.6 redis4.0.1 主 从 192.168.181.139:6379 192.168.181.136:6379 192.168.181.136:6380 192.168 ...
- Redis Cluster 集群三主三从高可用环境搭建
前言 Redis 是我们目前大规模使用的缓存中间件,由于它强大高效而又便捷的功能,得到了广泛的使用. Window环境下载地址:https://github.com/tporadowski/redis ...
- Redis集群搭建 三主三从
Redis集群介绍 Redis 是一个开源的 key-value 存储系统,由于出众的性能,大部分互联网企业都用来做服务器端缓存.Redis在3.0版本之前只支持单实例模式 虽然支持主从模式,哨兵模式 ...
随机推荐
- Redis之过期策略
一.设置过期时间 Redis对存储值的过期处理实际上是针对该值的键(key)处理的,即时间的设置也是设置key的有效时间.Expires字典保存了所有键的过期时间,Expires也被称为过期字段. e ...
- 关于javascript的事件执行机制理解
理解javascript事件执行机制 众所周知,js是一个单线程的语言,这意味着同一时间只能做一件事,但是我们又说js是异步的.首先,单线程并不是没有优点.作为浏览器脚本语言,JavaScript 的 ...
- Anaconda--机器学习环境搭建
使用Anaconda为机器学习和深度学习设置Python环境 一.安装Anaconda,并更新到最新版本 1.Anaconda 安装: 官方网站下载地址 https://www.anaconda.co ...
- 1 .net将xml反序列化
public static T XmlToObject<T>(string str) where T : class { using (Stream stream = new Memory ...
- OLE使用
ABAP操作EXCEL有多重方法,今天记录一下OLE,具体步骤如下: 1. 首先要上载EXCEL模板 事物代码:SMW0,具体步骤参考 本博客 http://www.cnblogs.com/caizj ...
- js小功能3:一个简单的计算器功能
html: <input type='text' id='txt1' /> <select id='select'> <option value='+'>+< ...
- datePicker 及 timePicker 监听事件 获取用户选择 年月日分秒信息
public class MainActivity extends AppCompatActivity { private TimePicker timePicker; private DatePic ...
- Vim——替换命令
原创声明:本文系博主原创文章,转载或引用请注明出处. 1. 文本替换 #替换每一行的第一个a :%s/a/b/ #全部替换 :%s/a/b/g #替换/时需要转义"\/" 2. ...
- Easy UI 入门
Easy UI常用于企业级开发的UI和后台开发的UI,比较重. 以下组件中的加载方式,属性和事件,方法和组件种类并不全,只是作为参考和入门学习. 1.Draggable(拖动)组件 不依赖其他组件 1 ...
- Mybatis 解决问题的记录与博客
问题:mybatis 空值映射的问题Mybatis在使用resultMap来映射查询结果中的列,如果查询结果中包含空值的列(不是null),则Mybatis在映射的时候,不会映射这个字段 https: ...