安装环境: 6台 centos7.4node
在各个节点下载官网release包,能够本身去官网找: wget http://download.redis.io/releases/redis-5.0.5.tar.gz
redis
解压:tar -zxvf redis-5.0.5.tar.gzcentos
进入目录:cd redis-5.0.5,若是自定义了解压目录的话须要另外指定缓存
编译:make ,编译便可,会在src目录下生成二进制文件,便可运行redisruby
若是编译时出现提示jemalloc/jemalloc.h: No such file or directory 从新使用make MALLOC=libc安装app
编译完成便可运行单机centos7
修改redis.conf的配置,使用一个最简配置:能够把原先的作一个备份,而后生成一个新的
port 6379
cluster-enabled yes
cluster-config-file nodes.conf //启动的时候会由redis生成和管理 cluster-node-timeout 5000
appendonly yes
daemonize yes //后台运行
bind 10.99.32.16 //须要绑定本身的ip,不然外部不能访问,每一个节点都须要修改配置 不要添加//里面的内容code
每一个节点运行实例:src/redis-server ./redis.conf,启动成功会提示
1467:C 28 Jun 2019 20:22:30.943 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1467:C 28 Jun 2019 20:22:30.943 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=1467, just started
1467:C 28 Jun 2019 20:22:30.943 # Configuration loadedserver
启动脚本:(以前的版本须要使用ruby脚本须要更多一些操做,5.0的能够使用redis-cli命令)
src/redis-cli --cluster create 10.99.32.3:6379 10.99.32.9:6379 10.99.32.31:6379 10.99.32.10:6379 10.99.32.12:6379 10.99.32.13:6379 --cluster-replicas 1ip
启动成功后会有节点显示:
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered. 六台节点一个副本则有3M3S
链接到集群src/redis-cli -h 10.99.32.3 -c,若是不使用-c,设置key时会报:redis (error) MOVED 7638
设置缓存后,只有一个M和它的Slave有这个数据,其余节点没有这个数据
src/redis-cli --cluster add-node 10.99.32.32:6379 10.99.32.3:6379
src/redis-cli -h 10.99.32.9 -c cluster nodes
src/redis-cli --cluster del-node 10.99.32.9:6379 08859612fdf824fd07c538c65073a86ca7d522cb
须要先获取节点node-id