初识redis-cluster
安装redis
[root@localhost ~]# cd /datas/soft/
[root@localhost soft]# ll redis-5.0..tar.gz // 已经下载的最新版
-rwxrwxrwx www www Oct : redis-5.0..tar.gz
[root@localhost soft]# tar -xzf redis-5.0..tar.gz
[root@localhost soft]# cd redis-5.0.
[root@localhost redis-5.0.]# make
[root@localhost redis-5.0.]# cd src
[root@localhost src]# make install PREFIX=/datas/soft/redis5
[root@localhost src]# mkdir /datas/soft/redis5/etc
[root@localhost src]# cp ../redis.conf /datas/soft/redis5/etc/
[root@localhost src]# vim redis.conf
daemonize yes // 后台运行
[root@localhost src]# cd /datas/soft/redis5/bin/
[root@localhost bin]# ./redis-server ../etc/redis.conf
:C Oct ::42.406 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Oct ::42.406 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Oct ::42.406 # Configuration loaded
[root@localhost bin]# ps auxf | grep redis
root 0.0 0.0 pts/ S+ : : | \_ grep redis
root 0.1 0.7 ? Ssl : : ./redis-server 127.0.0.1:
[root@localhost bin]# ./redis-cli -p
127.0.0.1:> set a hahaha6379
OK
127.0.0.1:> get a
"hahaha6379"
部署集群
[root@localhost bin]# cd ../etc
[root@localhost etc]# mkdir redis-cluster
[root@localhost etc]# cd redis-cluster
[root@localhost redis-cluster]# mkdir
[root@localhost redis-cluster]# cd
[root@localhost ]# cp ../../redis.conf ./
[root@localhost ]# vim redis.conf
port // 绑定端口号
daemonize yes // 后台运行
pidfile /datas/soft/redis5/etc/redis-cluster//redis.pid // 修改pid进程文件名
logfile /datas/soft/redis5/etc/redis-cluster//redis.log // 修改日志文件名称
dir /datas/soft/redis5/etc/redis-cluster// // 修改数据文件存放地址
cluster-enabled yes // 启用集群
cluster-config-file nodes-.conf // 配置每个节点的配置文件,同样以端口号为名称
cluster-node-timeout // 配置集群节点的超时时间,可改可不改
appendonly yes // 启动AOF增量持久化策略
appendfsync always // 发生改变就记录日志
[root@localhost redis-cluster]# ll // 相同步骤配置其他端口
total
drwxr-xr-x root root Oct :
drwxr-xr-x root root Oct :
drwxr-xr-x root root Oct :
drwxr-xr-x root root Oct :
drwxr-xr-x root root Oct :
drwxr-xr-x root root Oct :
[root@localhost redis-cluster]# /datas/soft/redis5/bin/redis-server /datas/soft/redis5/etc/redis-cluster//redis.conf // 启动
[root@localhost redis-cluster]# /datas/soft/redis5/bin/redis-server /datas/soft/redis5/etc/redis-cluster//redis.conf
[root@localhost redis-cluster]# /datas/soft/redis5/bin/redis-server /datas/soft/redis5/etc/redis-cluster//redis.conf
[root@localhost redis-cluster]# /datas/soft/redis5/bin/redis-server /datas/soft/redis5/etc/redis-cluster//redis.conf
[root@localhost redis-cluster]# /datas/soft/redis5/bin/redis-server /datas/soft/redis5/etc/redis-cluster//redis.conf
[root@localhost redis-cluster]# /datas/soft/redis5/bin/redis-server /datas/soft/redis5/etc/redis-cluster//redis.conf
[root@localhost redis-cluster]# ps auxf | grep redis
root 0.0 0.0 pts/ S+ : : | \_ grep redis
root 0.2 1.0 ? Ssl : : ./redis-server 127.0.0.1:
root 0.9 0.7 ? Ssl : : /datas/soft/redis5/bin/redis-server 127.0.0.1: [cluster]
root 0.6 0.7 ? Ssl : : /datas/soft/redis5/bin/redis-server 127.0.0.1: [cluster]
root 0.6 0.7 ? Ssl : : /datas/soft/redis5/bin/redis-server 127.0.0.1: [cluster]
root 0.6 1.2 ? Ssl : : /datas/soft/redis5/bin/redis-server 127.0.0.1: [cluster]
root 0.4 1.2 ? Ssl : : /datas/soft/redis5/bin/redis-server 127.0.0.1: [cluster]
root 0.7 1.2 ? Ssl : : /datas/soft/redis5/bin/redis-server 127.0.0.1: [cluster]
[root@localhost redis-cluster]# ll /datas/soft/redis5/etc/redis-cluster//
total
-rw-r--r-- root root Oct : appendonly.aof
-rw-r--r-- root root Oct : dump.rdb
-rw-r--r-- root root Oct : nodes-.conf
-rwxr-xr-x root root Oct : redis.conf
-rw-r--r-- root root Oct : redis.log
-rw-r--r-- root root Oct : redis.pid [root@localhost redis-cluster]# cd ../../bin/
[root@localhost bin]# yum install -y ruby
[root@localhost bin]# yum install -y rubygems
[root@localhost bin]# cp /datas/soft/redis-5.0./src/redis-trib.rb ./
[root@localhost bin]# ruby 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:
redis-trib.rb:: odd number list for Hash
white: ,
^
redis-trib.rb:: syntax error, unexpected ':', expecting '}'
white: ,
^
redis-trib.rb:: syntax error, unexpected ',', expecting kEND
[root@localhost bin]# ruby -v
ruby 1.8. (-- patchlevel ) [x86_64-linux]
[root@localhost bin]# yum remove -y ruby
[root@localhost bin]# yum remove -y rubygems
[root@localhost bin]# cd /datas/soft/
[root@localhost soft]# ll ruby-2.4..tar.gz // ruby最新版
-rwxr-xr-x root root Oct : ruby-2.4..tar.gz
[root@localhost soft]# tar -xzf ruby-2.4..tar.gz
[root@localhost soft]# cd ruby-2.4.
[root@localhost ruby-2.4.]# ./configure
[root@localhost ruby-2.4.]# make
[root@localhost ruby-2.4.]# make install
[root@localhost ruby-2.4.]# ruby -v
ruby 2.4.5p335 (-- revision ) [x86_64-linux]
[root@localhost ruby-2.4.]# cd /datas/soft/redis5/bin/
[root@localhost bin]# ruby 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:
WARNING: redis-trib.rb is not longer available!
You should use redis-cli instead. All commands and features belonging to redis-trib.rb have been moved
to redis-cli.
In order to use them you should call redis-cli with the --cluster
option followed by the subcommand name, arguments and options. Use the following syntax:
redis-cli --cluster SUBCOMMAND [ARGUMENTS] [OPTIONS] Example:
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 To get help about all subcommands, type:
redis-cli --cluster help [root@localhost bin]# ./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
>>> Performing hash slots allocation on nodes...
Master[] -> Slots -
Master[] -> Slots -
Master[] -> Slots -
Adding replica 127.0.0.1: to 127.0.0.1:
Adding replica 127.0.0.1: to 127.0.0.1:
Adding replica 127.0.0.1: to 127.0.0.1:
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 0ef9bb46603bc2703e2f812316b2d17e4664a285 127.0.0.1:
slots:[-] ( slots) master
M: 1cce19c5b8f58666199445ee858b0a699cf523f9 127.0.0.1:
slots:[-] ( slots) master
M: 040afde427d4df0738b4705006309fc171403613 127.0.0.1:
slots:[-] ( slots) master
S: 7bb7a15f22730493cd7c66954a39e4008788c879 127.0.0.1:
replicates 1cce19c5b8f58666199445ee858b0a699cf523f9
S: c08daea6c990cb2732d95ae03c201c94523c0eff 127.0.0.1:
replicates 040afde427d4df0738b4705006309fc171403613
S: 7acc8a1f489ec954f069f998792eea8982653e70 127.0.0.1:
replicates 0ef9bb46603bc2703e2f812316b2d17e4664a285
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 127.0.0.1:)
M: 0ef9bb46603bc2703e2f812316b2d17e4664a285 127.0.0.1:
slots:[-] ( slots) master
additional replica(s)
S: 7bb7a15f22730493cd7c66954a39e4008788c879 127.0.0.1:
slots: ( slots) slave
replicates 1cce19c5b8f58666199445ee858b0a699cf523f9
M: 1cce19c5b8f58666199445ee858b0a699cf523f9 127.0.0.1:
slots:[-] ( slots) master
additional replica(s)
S: 7acc8a1f489ec954f069f998792eea8982653e70 127.0.0.1:
slots: ( slots) slave
replicates 0ef9bb46603bc2703e2f812316b2d17e4664a285
S: c08daea6c990cb2732d95ae03c201c94523c0eff 127.0.0.1:
slots: ( slots) slave
replicates 040afde427d4df0738b4705006309fc171403613
M: 040afde427d4df0738b4705006309fc171403613 127.0.0.1:
slots:[-] ( slots) master
additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All slots covered.
[root@localhost bin]# ./redis-cli -c -p
127.0.0.1:> set a hahahaha30001
-> Redirected to slot [] located at 127.0.0.1:
OK
127.0.0.1:> get a
"hahahaha30001"
127.0.0.1:>
[root@localhost bin]# ./redis-cli -c -p
127.0.0.1:> get a
-> Redirected to slot [] located at 127.0.0.1:
"hahahaha30001"
127.0.0.1:>
参考资料
https://www.cnblogs.com/it-cen/p/4295984.html
https://blog.csdn.net/naixiyi/article/details/51346880
https://www.cnblogs.com/PatrickLiu/p/8458788.html
http://www.runoob.com/ruby/ruby-installation-unix.html
https://blog.csdn.net/vtopqx/article/details/50235737
------------------------------- 2019-08-12 -----------------------------------------
单实例数据迁移到Cluster
https://cloud.tencent.com/developer/article/1433055
https://www.18188.org/articles/2016/04/23/1461374145366.html
初识redis-cluster的更多相关文章
- Redis——学习之路二(初识redis服务器命令)
上一章我们已经知道了如果启动redis服务器,现在我们来学习一下,以及如何用客户端连接服务器.接下来我们来学习一下查看操作服务器的命令. 服务器命令: 1.info——当前redis服务器信息 s ...
- 1.初识Redis
作者 微信:tangy8080 电子邮箱:914661180@qq.com 更新时间:2019-08-14 20:35:36 星期三 欢迎您订阅和分享我的订阅号,订阅号内会不定期分享一些我自己学习过程 ...
- window下使用Redis Cluster部署Redis集群
日常的项目很多时候都需要用到缓存.redis算是一个比较好的选择.一般情况下做一个主从就可以满足一些比较小的项目需要.在一些并发量比较大的项目可能就需要用到集群了,redis在Windows下做集群可 ...
- 初识redis数据类型
初识redis数据类型 1.String(字符串) string是redis最基本的类型,一个key对应一个value. string类型是二进制安全的.意思是redis的string可以包含任何数据 ...
- Redis Cluster 分区实现原理
Redis Cluster本身提供了自动将数据分散到Redis Cluster不同节点的能力,分区实现的关键点问题包括:如何将数据自动地打散到不同的节点,使得不同节点的存储数据相对均匀:如何保证客户端 ...
- Redis Cluster
使用 Redis Cluster Redis 3.0 在2015年出了Stable版本,3.0版本相对于2.8版本带来的主要新特性包括: 实现了Redis Cluster,从而做到了对集群的支持: 引 ...
- Redis Cluster 介绍与使用
Redis Cluster 功能特性 Redis 集群是分布式的redis 实现,具有以下特性: 1. 高可用性与可线性扩张到1000个节点 2. 数据自动路由到多个节点 3. 节点间数据共享 4. ...
- Redis——学习之路三(初识redis config配置)
我们先看看config 默认情况下系统是怎么配置的.在命令行中输入 config get *(如图) 默认情况下有61配置信息,每一个命令占两行,第一行为配置名称信息,第二行为配置的具体信息. ...
- Redis Cluster原理
Redis Cluster 是Redis的集群实现,内置数据自动分片机制,集群内部将所有的key映射到16384个Slot中,集群中的每个Redis Instance负责其中的一部分的Slot的读写. ...
- 安全稳定实现redis cluster自动化迁移
背景 目前redis集群最火的是codis和redis cluster(官方),但官方自带工具并没有支持密码操作.那么需要密码认证使用redis cluster集群的同学要仔细看了哦. 相信大家很多人 ...
随机推荐
- LeetCode 233 Number of Digit One 某一范围内的整数包含1的数量
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less th ...
- ubuntu网络已禁用解决办法
1.首先停掉network-manager这个服务 sudo service network-manager stop 2.删除掉NetworkManager.state这个文件 sudo rm /v ...
- 美国一家科技公司毕威拓(Pivotal)规定员工在早上9点06分准时上班,以提高工作效率。
美国一家科技公司毕威拓(Pivotal)规定员工在早上9点06分准时上班,以提高工作效率. 据<英国广播公司BBC>报道,美国科技公司毕威拓(Pivotal)的员工每天都要在9点06分准时 ...
- 使用:/usr/bin/phpize 报错
使用:/usr/bin/phpize 出现下面错误提示 Can't find PHP headers in /usr/include/php The php-devel package is requ ...
- jquery的.get方法说解
·Customer类 public class Customer { public int Unid { get; set; } public string CustomerName { get; s ...
- 在Magento中用MySQL模拟队列发送电子邮件
1. 需求 顾客在网站上购买特定商品并且这些商品的总金额超过特定金额后,使用email给顾客发送一个优惠券:假如某件商品已经降价了,则此商品的金额不计算在目标总金额内: 2. 需求分析 ①发送优惠券的 ...
- Day6 盒模型
Day6 盒模型 1.一.标准盒模型(w3c盒模型) 1)组成部分: content + padding + border + margin 内容 ...
- 在Ubuntu中安装MySQL
在Ubuntu中安装MySQL Ubuntu实用工具系列文章,将介绍基于Linux ubuntu的各种工具软件的配置和使用.有些工具大家早已耳熟能详,有些工具经常用到但确依然陌生.我将记录我在使用操作 ...
- JSP对象和JavaBean
1. JSP 客户端请求 当浏览器请求一个网页时,它会向网络服务器发送一系列不能被直接读取的信息,因为这些信息是作为HTTP信息头的一部分来传送的,如下图所示: Http请求头对应的内容如下: 对应方 ...
- Java正则表达式—小应用—简易爬虫
在上一篇中,学习了正则表达式的四个功能.即匹配.分割.替换.获取. 利用获取功能,可以实现简单的网页爬虫. 4,获取:将字符串中的符合规则的子串取出. 获取功能的操作步骤: 1,将正则表达式 ...