初识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集群的同学要仔细看了哦. 相信大家很多人 ...
随机推荐
- 打印BroadcastReceiver的所有接受者
Android中收到短信等事件都是通过广播发送给应用程序的,手机卫士等程序都是通过注册高优先级的BroadcastReceiver来实现短信防火墙等功能.对于我们来说很想知道系统中都有哪些程序注册了B ...
- 整理一下postgresql的扩展功能postgis和pgrouting的使用
postgis windows的下的安装使用postgresql的bin目录下的stackbuiler Ubuntu14.04下的安装: apt-get install postgresql-9.3- ...
- ACM-ICPC 2018 南京赛区网络预赛 B. The writing on the wall
题目链接:https://nanti.jisuanke.com/t/30991 2000ms 262144K Feeling hungry, a cute hamster decides to o ...
- Python3基础(6)面向对象编程、异常处理
---------------个人学习笔记--------------- ----------------本文作者吴疆-------------- ------点击此处链接至博客园原文------ 1 ...
- SpringBoot | 第零章:前言
缘起 前段时间公司领导叫编写一两课关于springboot的基础知识培训课程,说实话,也是今年年初才开始接触了SpringBoot这个脚手架,使用了之后才发现打开了一个新世界.再之后也没有一些系统的学 ...
- 【干货】JavaScript DOM编程艺术学习笔记7-9
七.动态创建标记 在文档中不写占位图片和文字代码,在能调用js的情况下动态创建,文档支持性更好. 在原来的addLoadEvent prepareGallery showPic的基础上增加函数prep ...
- ubuntu 自动启动程序
首先打开终端ctrl + alt + t sudo -i 输入密码:ubuntu chmod 777 /etc/rc.local 打开 vi /etc/rc.local 按 i 键进入输入 ...
- C# ,通用内存集合对象分页、筛选(lambda那点事)
通常呢我们需要翻页的数据大多都是从数据库中取,翻页.筛选.排序啥的都是通过SQL语句由数据库帮我搞定,那么有些需求没有数据库呢?或者有些数据只存在于内存中不存到数据库呢?怎么实现内存里面的对象集合的通 ...
- 使用SAP云平台 + JNDI访问Internet Service
以Internet Service http://maps.googleapis.com/maps/api/distancematrix/xml?origins=Walldorf&destin ...
- WMAppPRHeader.xml文件的作用
对于很多开发者来说直接通过Visual Studio 2010生成的XAP文件和上传至App Hub通过Windows Phone Marketplace Technical Certificatio ...