redis-5.0.3集群搭建
首先部署redis-5.0.3,请参考我的另一篇文章
https://www.cnblogs.com/djlsunshine/p/10592174.html
启动redis服务
# redis-server /root/redis-5.0.3/redis.conf
[root@localhost ~]# redis-server /root/redis-5.0./redis.conf
:C Mar ::01.274 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::01.274 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Mar ::01.274 # Configuration loaded
查看进程
# ps aux | grep redis
[root@localhost ~]# ps aux | grep redis
root 0.0 0.4 ? Ssl : : redis-server 192.168.2.80:
root 0.0 0.0 pts/ S+ : : grep --color=auto redis
创建6个节点
# mkdir cluster-test
# cd cluster-test/
# mkdir 7000 7001 7002 7003 7004 7005
[root@localhost redis-5.0.]# mkdir cluster-test
[root@localhost redis-5.0.]#
[root@localhost redis-5.0.]# ls
-RELEASENOTES cluster-test COPYING dump.rdb Makefile README.md runtest runtest-sentinel src utils
BUGS CONTRIBUTING deps INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests
[root@localhost redis-5.0.]#
[root@localhost redis-5.0.]# cd cluster-test/
[root@localhost cluster-test]#
[root@localhost cluster-test]# mkdir
[root@localhost cluster-test]# ls
分别在这6个节点文件夹下写入redis配置文件
以节点7000为例
port //端口7000,7002,7003
daemonize yes //redis后台运行
bind 192.168.2.80 //设置节点的IP
requirepass 123456 //设置连接节点的密码
appendfilename "appendonly.aof" //aof模式持久化文件的名字(appendonly默认是no,yes就是打开aof持久化)
pidfile /var/run/redis_7000.pid //pidfile文件对应7000,7002,7003
cluster-enabled yes //开启集群
cluster-config-file nodes_7000.conf //集群的配置 配置文件首次启动自动生成 7000,7001,7002
cluster-node-timeout //请求超时 设置5秒够了
appendonly yes //aof日志开启 有需要就开启,它会每次写操作都记录一条日志
启动各节点
[root@localhost ~]# redis-server redis-5.0./cluster-test//redis.conf
:C Mar ::32.393 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::32.393 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Mar ::32.393 # Configuration loaded
[root@localhost ~]# redis-server redis-5.0./cluster-test//redis.conf
:C Mar ::37.603 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::37.603 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Mar ::37.603 # Configuration loaded
[root@localhost ~]# redis-server redis-5.0./cluster-test//redis.conf
:C Mar ::41.394 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::41.394 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Mar ::41.394 # Configuration loaded
[root@localhost ~]# redis-server redis-5.0./cluster-test//redis.conf
:C Mar ::44.487 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::44.487 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Mar ::44.487 # Configuration loaded
[root@localhost ~]# redis-server redis-5.0./cluster-test//redis.conf
:C Mar ::26.168 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::26.168 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Mar ::26.168 # Configuration loaded
[root@localhost ~]#
[root@localhost ~]# redis-server redis-5.0./cluster-test//redis.conf
:C Mar ::31.677 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::31.677 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Mar ::31.677 # Configuration loaded
[root@localhost ~]#
查看进程信息
[root@localhost ~]# ps aux | grep redis
root 0.2 0.4 ? Ssl Mar25 : redis-server 192.168.2.80:
root 0.1 0.4 ? Ssl : : redis-server *: [cluster]
root 0.1 0.4 ? Ssl : : redis-server *: [cluster]
root 0.1 0.4 ? Ssl : : redis-server *: [cluster]
root 0.1 0.4 ? Ssl : : redis-server *: [cluster]
root 0.2 0.4 ? Ssl : : redis-server *: [cluster]
root 0.1 0.4 ? Ssl : : redis-server *: [cluster]
root 0.0 0.0 pts/ R+ : : grep --color=auto redis
集群创建
# redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 1
# redis-cli -a 123456 --cluster create 192.168.2.80:7000 192.168.2.80:7001 192.168.2.80:7002 192.168.2.80:7003 192.168.2.80:7004 192.168.2.80:7005 --cluster-replicas 1
--cluster-replicas 1(每个创建的主服务器都有一个从服)
[root@localhost ~]# redis-cli -a --cluster create 192.168.2.80: 192.168.2.80: 192.168.2.80: 192.168.2.80: 192.168.2.80: 192.168.2.80: --cluster-replicas
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing hash slots allocation on nodes...
Master[] -> Slots -
Master[] -> Slots -
Master[] -> Slots -
Adding replica 192.168.2.80: to 192.168.2.80:
Adding replica 192.168.2.80: to 192.168.2.80:
Adding replica 192.168.2.80: to 192.168.2.80:
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 69f17d424b855c3e18265d2c807a7b8e1ad9328d 192.168.2.80:
slots:[-] ( slots) master
M: d59b01f910c2adb972bd380ec07458e1866a248d 192.168.2.80:
slots:[-] ( slots) master
M: 137f1ccf4be0c6479e76befd6b96a72dd642ce75 192.168.2.80:
slots:[-] ( slots) master
S: 83bf3a15381bd624669b3e7f964b1ce26a87e619 192.168.2.80:
replicates 137f1ccf4be0c6479e76befd6b96a72dd642ce75
S: df8c31bc9c417571aa38745349607a366309d208 192.168.2.80:
replicates 69f17d424b855c3e18265d2c807a7b8e1ad9328d
S: 70193c889ce1ea1a4fbd811c101af3208691264f 192.168.2.80:
replicates d59b01f910c2adb972bd380ec07458e1866a248d
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.2.80:)
M: 69f17d424b855c3e18265d2c807a7b8e1ad9328d 192.168.2.80:
slots:[-] ( slots) master
additional replica(s)
M: d59b01f910c2adb972bd380ec07458e1866a248d 192.168.2.80:
slots:[-] ( slots) master
additional replica(s)
S: 70193c889ce1ea1a4fbd811c101af3208691264f 192.168.2.80:
slots: ( slots) slave
replicates d59b01f910c2adb972bd380ec07458e1866a248d
M: 137f1ccf4be0c6479e76befd6b96a72dd642ce75 192.168.2.80:
slots:[-] ( slots) master
additional replica(s)
S: df8c31bc9c417571aa38745349607a366309d208 192.168.2.80:
slots: ( slots) slave
replicates 69f17d424b855c3e18265d2c807a7b8e1ad9328d
S: 83bf3a15381bd624669b3e7f964b1ce26a87e619 192.168.2.80:
slots: ( slots) slave
replicates 137f1ccf4be0c6479e76befd6b96a72dd642ce75
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All slots covered.
查看redis监听端口
# netstat -tnlp | grep redis
[root@localhost ~]# netstat -tnlp | grep redis
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp 192.168.2.80: 0.0.0.0:* LISTEN /redis-server
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp 0.0.0.0: 0.0.0.0:* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
tcp6 ::: :::* LISTEN /redis-server *
查看集群节点的常用参数
# redis-cli --cluster help
[root@localhost ~]# redis-cli --cluster help
Cluster Manager Commands:
create host1:port1 ... hostN:portN
--cluster-replicas <arg>
check host:port
--cluster-search-multiple-owners
info host:port
fix host:port
--cluster-search-multiple-owners
reshard host:port
--cluster-from <arg>
--cluster-to <arg>
--cluster-slots <arg>
--cluster-yes
--cluster-timeout <arg>
--cluster-pipeline <arg>
--cluster-replace
rebalance host:port
--cluster-weight <node1=w1...nodeN=wN>
--cluster-use-empty-masters
--cluster-timeout <arg>
--cluster-simulate
--cluster-pipeline <arg>
--cluster-threshold <arg>
--cluster-replace
add-node new_host:new_port existing_host:existing_port
--cluster-slave
--cluster-master-id <arg>
del-node host:port node_id
call host:port command arg arg .. arg
set-timeout host:port milliseconds
import host:port
--cluster-from <arg>
--cluster-copy
--cluster-replace
help For check, fix, reshard, del-node, set-timeout you can specify the host and port of any working node in the cluster. [root@localhost ~]#
官方文档地址:
https://redis.io/topics/cluster-tutorial
参考文章:
https://www.cnblogs.com/yuanermen/p/5717885.html
redis-5.0.3集群搭建的更多相关文章
- Redis 5.0.5集群搭建
		Redis 5.0.5集群搭建 一.概述 Redis3.0版本之后支持Cluster. 1.1.redis cluster的现状 目前redis支持的cluster特性: 1):节点自动发现 2):s ... 
- Redis 3.0.2集群搭建以及相关问题汇总
		Redis3 正式支持了 cluster,是为了解决构建redis集群时的诸多不便 (1)像操作单个redis一样操作key,不用操心key在哪个节点上(2)在线动态添加.删除redis节点,不用停止 ... 
- 转:Redis 3.2.1集群搭建
		Redis 3.2.1集群搭建 一.概述 Redis3.0版本之后支持Cluster. 1.1.redis cluster的现状 目前redis支持的cluster特性: 1):节点自动发现 2) ... 
- Redis单机安装以及集群搭建
		今天主要来看一下Redis的安装以及集群搭建(我也是第一次搭建). 环境:CentOS 7.1,redis-5.0.7 一.单机安装 1.将Redis安装包放置服务器并解压 2.进入redis安装目录 ... 
- Redis 3.0 Cluster集群配置
		Redis 3.0 Cluster集群配置 安装环境依赖 安装gcc:yum install gcc 安装zlib:yum install zib 安装ruby:yum install ruby 安装 ... 
- 配置redis 4.0.11 集群
		配置redis 4.0.11 集群 准备redis 软件和redis配置文件 启动Redis服务 /data/soft/redis/src/redis-check-aof --fix /log/red ... 
- 分布式缓存技术redis学习系列(四)——redis高级应用(集群搭建、集群分区原理、集群操作)
		本文是redis学习系列的第四篇,前面我们学习了redis的数据结构和一些高级特性,点击下面链接可回看 <详细讲解redis数据结构(内存模型)以及常用命令> <redis高级应用( ... 
- Redis 3.2.1集群搭建
		一.概述 Redis3.0版本之后支持Cluster. 1.1.redis cluster的现状 目前redis支持的cluster特性: 1):节点自动发现 2):slave->master ... 
- 分布式缓存技术redis学习(四)——redis高级应用(集群搭建、集群分区原理、集群操作)
		本文是redis学习系列的第四篇,前面我们学习了redis的数据结构和一些高级特性,点击下面链接可回看 <详细讲解redis数据结构(内存模型)以及常用命令> <redis高级应用( ... 
- java_redis3.0.3集群搭建
		redis3.0版本之后支持Cluster,具体介绍redis集群我就不多说,了解请看redis中文简介. 首先,直接访问redis.io官网,下载redis.tar.gz,现在版本3.0.3,我下面 ... 
随机推荐
- 【NOI2014】【BZOJ3669】【UOJ#3】魔法森林
			我学会lct辣 原题: 为了得到书法大家的真传,小E同学下定决心去拜访住在魔法森林中的隐士.魔法森林可以被看成一个包含个N节点M条边的无向图,节点标号为 1…n1…n,边标号为1…m1…m.初始时小E ... 
- PHP 获取上月,本月,近15天,近30天日期
			<?php //echo $_SERVER['PHP_SELF']; //define('ROOT_PATH',str_replace($_SERVER['PHP_SELF'],'',str_r ... 
- sublime 安装插件出现问题
			一. 解决package Install不能安装 If for some reason the console installation instructions do not work for ... 
- JDK8中的时间API
			在Java 1.0中,对日期和时间的支持只能依赖java.util.Date类.正如类名所表达的,这个类无法表示日期,只能以毫秒的精度表示时间.更糟糕的是它的易用性,由于某些原因未知的设计决策,这个类 ... 
- 两个简单的API限流实现方案
			1, Ngnix限流 Nginx在架构中起到请求转发与负载均衡器的作用.外部req首先到Nginx监听的80端口,然后Nginx将req交给到监听8080端口的APP服务器处理.处理结果再经由Ngin ... 
- taro 微信小程序原生作用域获取
			在 Taro 的页面和组件类中,this 指向的是 Taro页面或组件实例. 但是一般我们需要获取 Taro的页面和组件 所对应的 小程序原生页面和组件实例,这个时候我们可以通过 this.$scop ... 
- mybatis 一对多,(多对一,一对一
			多对一,和一对一是同一种写法,每种写法又分在数据库关联和在mybatis关联 1,多对一,一对一数据库关联 2,多对一,一对一mybatis关联 3,一对多,数据库关联,注意,Java type改of ... 
- MySQL跨库查询例子
			库1 gxjob 库2 funshixi SELECT a.`company_id`,b.`companyname` FROM `gxjob`.`qj_activity_thousands_of_sc ... 
- 1、Zookeeper安装及问题与集群
			1.下载zookeeper.tat.gz压缩包 2.解压 tar –xvf file.tar //解压 tar包 tar -xzvf file.tar.gz //解压tar.gz tar -xjvf ... 
- LOJ 2587 「APIO2018」铁人两项——圆方树
			题目:https://loj.ac/problem/2587 先写了 47 分暴力. 对于 n<=50 的部分, n3 枚举三个点,把图的圆方树建出来,合法条件是 c 是 s -> f 路 ... 
