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,我下面 ...
随机推荐
- oracle 11g(64位)datebase 安装流程
软件版本:oracle 11g 64位 datebase(二合一,含client) 系统环境:windows 10 专业版 64位操作系统 1)根据自己的操作系统去官网下载相应的安装程序,oracle ...
- gorm-Duplicate-entry
gorm insert data to mysql tips: (Error 1062: Duplicate entry '267857' for key 'PRIMARY') reason: u ...
- zsh:no matches found 问题解决
解决方法: ~/.zshrc 文件加入: setopt no_nomatch 之后,更新配置 source ~/.zshrc
- wampserver变橙色,apache 服务无法启动!问题解决小记(安装失败亦可参考)
http://blog.csdn.net/haoaiqian/article/details/58147079 80端口被占用的可能性非常大,关掉IIS即可
- (转)mysql创建表时反引号的作用
试用navicat工具查看现网mysql建表语句时,发现表名和字段名都是反引号引起来的 CREATE TABLE `tab_notice_title_tv` ( `i_id` int(11) NOT ...
- RCC 和 RTC
RCC是STM32的时钟控制器,可开启或关闭各总线的时钟,在使用各外设功能必须先开启其对应的时钟,没有这个时钟内部的各器件就不能运行.RTC是STM32内部集成的一个简单的时钟(计时用),如果不用就关 ...
- OpenGL纹理
如果不用头文件,把所有东西堆在同一个cpp文件中,会出现“超出GPU内存的错误!” 1 //我们自己的着色器类 #ifndef SHADER_H #define SHADER_H #include & ...
- 4、Tomcat启用HTTPS协议配置
一.本地模拟 1.安装jdk,自行百度安装教程 2.打开mac终端,输入命令 keytool -genkeypair -alias "证书名字" -keyalg "RSA ...
- java-网页404(个例)
tomcat正常启动网址404问题 个例情况: 1.选择第二个 2.web.xml配置不对(是因为缺少相应jar包和配置错误,根据控制器显示的错误一步步解决错误,最后OK) 3.构建路径中有错误(更换 ...
- WyBox 7620a 启用第二个串口
要修改的文件有两个 mt7620a.dtsi MT7620a.dts 1.进入target/linux/ramips/dts/ mt7620a.dtsi 把”disabled”改为”ok”,添加两行 ...