安装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的更多相关文章

  1. Redis——学习之路二(初识redis服务器命令)

    上一章我们已经知道了如果启动redis服务器,现在我们来学习一下,以及如何用客户端连接服务器.接下来我们来学习一下查看操作服务器的命令. 服务器命令: 1.info——当前redis服务器信息   s ...

  2. 1.初识Redis

    作者 微信:tangy8080 电子邮箱:914661180@qq.com 更新时间:2019-08-14 20:35:36 星期三 欢迎您订阅和分享我的订阅号,订阅号内会不定期分享一些我自己学习过程 ...

  3. window下使用Redis Cluster部署Redis集群

    日常的项目很多时候都需要用到缓存.redis算是一个比较好的选择.一般情况下做一个主从就可以满足一些比较小的项目需要.在一些并发量比较大的项目可能就需要用到集群了,redis在Windows下做集群可 ...

  4. 初识redis数据类型

    初识redis数据类型 1.String(字符串) string是redis最基本的类型,一个key对应一个value. string类型是二进制安全的.意思是redis的string可以包含任何数据 ...

  5. Redis Cluster 分区实现原理

    Redis Cluster本身提供了自动将数据分散到Redis Cluster不同节点的能力,分区实现的关键点问题包括:如何将数据自动地打散到不同的节点,使得不同节点的存储数据相对均匀:如何保证客户端 ...

  6. Redis Cluster

    使用 Redis Cluster Redis 3.0 在2015年出了Stable版本,3.0版本相对于2.8版本带来的主要新特性包括: 实现了Redis Cluster,从而做到了对集群的支持: 引 ...

  7. Redis Cluster 介绍与使用

    Redis Cluster 功能特性 Redis 集群是分布式的redis 实现,具有以下特性: 1. 高可用性与可线性扩张到1000个节点 2. 数据自动路由到多个节点 3. 节点间数据共享 4. ...

  8. Redis——学习之路三(初识redis config配置)

    我们先看看config 默认情况下系统是怎么配置的.在命令行中输入 config get *(如图) 默认情况下有61配置信息,每一个命令占两行,第一行为配置名称信息,第二行为配置的具体信息.     ...

  9. Redis Cluster原理

    Redis Cluster 是Redis的集群实现,内置数据自动分片机制,集群内部将所有的key映射到16384个Slot中,集群中的每个Redis Instance负责其中的一部分的Slot的读写. ...

  10. 安全稳定实现redis cluster自动化迁移

    背景 目前redis集群最火的是codis和redis cluster(官方),但官方自带工具并没有支持密码操作.那么需要密码认证使用redis cluster集群的同学要仔细看了哦. 相信大家很多人 ...

随机推荐

  1. hdu3949(线性基,求第k小的异或和

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3949 XOR Time Limit: 2000/1000 MS (Java/Others)    Me ...

  2. jQuery对ajax的支持

    有load,get,post和ajax四个方法都可以,其中后三个直接使用$.xx调用 使用方法大致相同,这里只介绍get和post方法 -------------------------------- ...

  3. SpringMVC核心技术---转发和重定向

    @Controller public class Mycontroller { //转发 @RequestMapping("/adduser") public String add ...

  4. Windbg .net内存调试有用的命令(笔记 )

    和.net内存调试相关的Windbg命令 首先.load sosex.dll加载ex调试扩展dll 1.!gcgen [obj地址] 显示对象属于gc代数 2.!dumpgen [0/1/2] dum ...

  5. 使用Set去除String中的重复字符

    使用Set去除String中的重复字符 public class test14 { public static void main(String[] args) { String str = &quo ...

  6. WPF动画的几种模式

    最近在用WPF做简单动画,以下是几点经验总结: 1. 使用DispatcherTimer做动画 VB6的年代大家就用Timer做动画了,不用多解释,这个DispatcherTimer和本身的Timer ...

  7. DB2常用函数详解

    (一) 字符串函数 VALUE函数  语法:VALUE(EXPRESSION1,EXPRESSION2) VALUE函数是用返回一个非空的值,当其第一个参数非空,直接返回该参数的值,如果第一个参数为空 ...

  8. 一些C/C++中的函数

    项目中使用到的C/C++中的一些函数,记录下来加以理解和掌握. 1.memset( ) memset是计算机中C/C++语言函数.将s所指向的某一块内存中的前n个 字节的内容全部设置为ch指定的ASC ...

  9. 【c++】用c++编写的求任意区间的素数的小程序

    #include using namespace std; int main() { cout<<"*************************************** ...

  10. GBase数据库存储过程——批量删除多个数据表的数据

    偶尔需要清空一下数据库,重装成本太高. --清空历史存储过程 DROP Procedure `dap_model`.`delete_datas` ; --创建存储过程 DELIMITER // CRE ...