基于springsession构建一个session共享的模块。 这里,基于redis的集群(Redis-5.0.3版本),为了解决整个物联网平台的各个子系统之间共享session需求,且方便各个子系统使用,将这个模块设计为一个pom组件,直接在pom.xml文件里面配置为dependency。

今天的主题,就是redis 5.0.3环境的构建。

和我之前介绍过的redis 3.2.8 (https://www.cnblogs.com/shihuc/p/7882004.html)有些类似,只是redis 5里面,不再依赖ruby脚本进行集群配置,而是直接用c程序实现,直接基于redis-cli指令完成。这些就不做介绍,直接介绍如何配置。

首先,需要修改的配置项如下:

bind 10.95.200.12
protected-mode no
port
daemonize yes
pidfile /var/run/redis_7380.pid
dbfilename dump-.rdb
appendonly yes
appendfilename "appendonly-7380.aof"
cluster-enabled yes
cluster-config-file nodes-7380.conf
cluster-node-timeout
notify-keyspace-events "Ex"

我的配置环境,是3对主从,上面的配置项,是其中一个redis节点的信息,IP是10.95.200.12,端口为7380. 参照这个配置信息,将下面的几个节点都配置上,我这里一共有三台虚拟机,分别是IP:10.95.200.12,10.95.200.13, 10.95.200.14,每台机器上部署两个实例,分别为端口7380以及7381.

配置信息配置好后,需要将每一个实例启动起来。例如,下面启动10.95.200.12端口为7380的实例。

[tkiot@tkwh-kfcs-app2 redis]$ ./bin/redis-server redis-7380.conf
:C Jul ::05.607 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Jul ::05.607 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
:C Jul ::05.607 # Configuration loaded

这里有个小插曲

每个服务器上的redis的配置文件,能够正常运行的配置文件名称如上面:redis-7380.conf,刚开始,我没有太注意,或者说是自己的马虎,将这个配置文件命名为nodes-7380.conf,和配置文件内容配置项cluster-config-file的值搞成一样的了,真是想骂娘的这个坑,启动过程同样显示上面的输出,和正确的程序启动一样的效果,但是呢,ps查看进程后,发现没有redis的进程。。。。这个坑,让我查了一上午。。。。

上面指令启动redis-7380.conf的操作结束后,可以查看下启动状态(cluster nodes):

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli -c -h 10.95.200.12 -p
10.95.200.12:> cluster nodes
7f4cf1bffc7e42a0e2d15bcc5a0a5386711813e8 :@ myself,master - connected

先看看cluster相关的指令都有哪些:

[tkiot@tkwh-kfcs-app2 redis]$ 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

接下来,就是通过redis-cli创建集群,配置成为一个shell脚本

#!/bin/bash
/u02/redis/bin/redis-cli --cluster create 10.95.200.12: 10.95.200.13: 10.95.200.14: 10.95.200.12: 10.95.200.13: 10.95.200.14: --cluster-replicas

这里,脚本当中,一共6个节点,不能确定哪些是master,哪些是slave,主从关系,是在构建集群的时候,自动配置的。

集群查看节点常用指令:

CLUSTER INFO 打印集群的信息
CLUSTER NODES 列出集群当前已知的所有节点(node),以及这些节点的相关信息。
[tkiot@tkwh-kfcs-app2 redis]$ redis-cli -c -h 10.95.200.12 -p 7380
10.95.200.12:>
10.95.200.12:> cluster nodes
ed309033dbefe2b0b64ad7fb643c4d2531e53b95 10.95.200.13:@ master - connected -
2cb8c6a7c86f512db2c6ca88eb67449197f5b885 10.95.200.12:@ slave cf6ca00cb36850762fdff1223684edf1fb9bd4ba connected
cf6ca00cb36850762fdff1223684edf1fb9bd4ba 10.95.200.14:@ master - connected -
26c3a7cd48fe4bddf9cf0c60a3c30b6b1f273135 10.95.200.12:@ myself,slave 467d4c7508d1cb371ed52c4c6574506cba40c328 connected
467d4c7508d1cb371ed52c4c6574506cba40c328 10.95.200.13:@ master - connected -
fbece4571b50904d93a45afbcce66941d53a45b5 10.95.200.14:@ slave ed309033dbefe2b0b64ad7fb643c4d2531e53b95 connected

剔除掉一个指定的节点(通过nodeId进行指示要删除的节点,nodeId就是上面cluster nodes输出结果的最左边的那一列

10.95.200.12:> cluster forget ed309033dbefe2b0b64ad7fb643c4d2531e53b95
OK
10.95.200.12:>
10.95.200.12:> cluster nodes
2cb8c6a7c86f512db2c6ca88eb67449197f5b885 10.95.200.12:@ slave cf6ca00cb36850762fdff1223684edf1fb9bd4ba connected
cf6ca00cb36850762fdff1223684edf1fb9bd4ba 10.95.200.14:@ master - connected -
26c3a7cd48fe4bddf9cf0c60a3c30b6b1f273135 10.95.200.12:@ myself,slave 467d4c7508d1cb371ed52c4c6574506cba40c328 connected
467d4c7508d1cb371ed52c4c6574506cba40c328 10.95.200.13:@ master - connected -
fbece4571b50904d93a45afbcce66941d53a45b5 10.95.200.14:@ slave - connected
10.95.200.12:>

不能自己把自己忘记哟:

10.95.200.12:> cluster forget 26c3a7cd48fe4bddf9cf0c60a3c30b6b1f273135
(error) ERR I tried hard but I can't forget myself...
10.95.200.12:>

不能将自己的master忘记哟:

10.95.200.12:> cluster forget 467d4c7508d1cb371ed52c4c6574506cba40c328
(error) ERR Can't forget my master!
10.95.200.12:>

上面的forget指令是不能讲节点真实删除的,只是一段时间内forget遗忘而已。因为过一段时间后,再次执行cluster nodes指令,还是可以看到完整集群的节点。

删除集群节点,可以采用下面的指令:

redis-cli --cluster del-node <ip>:<port> <node_id>

下面看看我的操作,这里是一个错误的操作,结果如下:

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli --cluster del-node 10.95.200.12: ed309033dbefe2b0b64ad7fb643c4d2531e53b95
>>> Removing node ed309033dbefe2b0b64ad7fb643c4d2531e53b95 from cluster 10.95.200.12:
[ERR] Node 10.95.200.13: is not empty! Reshard data away and try again.

1)查看Node 10.95.200.13:7380上是否有信息:

10.95.200.13:> keys *
) "taikang#session:sessions:expires:b6cd8269-dff0-463e-aefb-03167a167292"

2)清除所有的内容:

10.95.200.13:> flushdb
OK

到此,继续执行redis-cli --cluster del-node 10.95.200.12:7380 ed309033dbefe2b0b64ad7fb643c4d2531e53b95,最终还是失败,不成功的原因一样,不是空节点。为何?原因是没有依据redis的指令说明在使用del-node指令

注意,删除节点,按照上面的操作,显然是不对的,提示Node不是空的,需要将数据重新分片到其他节点,这个提示,有点不是太好理解,依据redis的集群工作原理,是全对等(master之间)节点集群,删除节点有三个步骤:

A. 首先删除slave节点,命令:redis-cli --cluster del-node <ip>:<port> <node_id>
B. 将被删除的slave对应的master节点的slot进行reshard到其他节点,命令:redis-cli --cluster reshard <master的ip:port> --cluster-from <同一个master的node_id> --cluster-to <接收slot的master的node_id> --cluster-slots <将要参与分片的slot数量,这里就是待删除节点的全部slot> --cluster-yes
C. 将reshard后的master执行删除操作,命令:redis-cli --cluster del-node <ip>:<port> <node_id>

下面演示基本操作redis cluster

操作前的节点信息:

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli -c -h 10.95.200.12 -p  cluster nodes
ed309033dbefe2b0b64ad7fb643c4d2531e53b95 10.95.200.13:@ master - connected - -
2cb8c6a7c86f512db2c6ca88eb67449197f5b885 10.95.200.12:@ slave cf6ca00cb36850762fdff1223684edf1fb9bd4ba connected
cf6ca00cb36850762fdff1223684edf1fb9bd4ba 10.95.200.14:@ master - connected
26c3a7cd48fe4bddf9cf0c60a3c30b6b1f273135 10.95.200.12:@ myself,slave 467d4c7508d1cb371ed52c4c6574506cba40c328 connected
fbece4571b50904d93a45afbcce66941d53a45b5 10.95.200.14:@ slave ed309033dbefe2b0b64ad7fb643c4d2531e53b95 connected
467d4c7508d1cb371ed52c4c6574506cba40c328 10.95.200.13:@ master - connected

1. 删除节点:

1)先删除slave节点

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli --cluster del-node 10.95.200.14: fbece4571b50904d93a45afbcce66941d53a45b5
>>> Removing node fbece4571b50904d93a45afbcce66941d53a45b5 from cluster 10.95.200.14:
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.

slave节点删除后的结构:

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli -c -h 10.95.200.12 -p  cluster nodes
ed309033dbefe2b0b64ad7fb643c4d2531e53b95 10.95.200.13:@ master - connected - -
2cb8c6a7c86f512db2c6ca88eb67449197f5b885 10.95.200.12:@ slave cf6ca00cb36850762fdff1223684edf1fb9bd4ba connected
cf6ca00cb36850762fdff1223684edf1fb9bd4ba 10.95.200.14:@ master - connected
26c3a7cd48fe4bddf9cf0c60a3c30b6b1f273135 10.95.200.12:@ myself,slave 467d4c7508d1cb371ed52c4c6574506cba40c328 connected
467d4c7508d1cb371ed52c4c6574506cba40c328 10.95.200.13:7381@ master - connected 5460

2)再对刚才删除的slave的master进行slot的reshard:

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli --cluster reshard 10.95.200.13: --cluster-from 467d4c7508d1cb371ed52c4c6574506cba40c328 --cluster-to ed309033dbefe2b0b64ad7fb643c4d2531e53b95 --cluster-slots  --cluster-yes                
>>> Performing Cluster Check (using node 10.95.200.13:)
M: 467d4c7508d1cb371ed52c4c6574506cba40c328 10.95.200.13:
slots:[] ( slots) master
additional replica(s)
M: ed309033dbefe2b0b64ad7fb643c4d2531e53b95 10.95.200.13:
slots:[-],[-] ( slots) master
S: 26c3a7cd48fe4bddf9cf0c60a3c30b6b1f273135 10.95.200.12:
slots: ( slots) slave
replicates 467d4c7508d1cb371ed52c4c6574506cba40c328
M: cf6ca00cb36850762fdff1223684edf1fb9bd4ba 10.95.200.14:
slots:[] ( slots) master
additional replica(s)
S: 2cb8c6a7c86f512db2c6ca88eb67449197f5b885 10.95.200.12:
slots: ( slots) slave
replicates cf6ca00cb36850762fdff1223684edf1fb9bd4ba
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All slots covered. Ready to move slots.
Source nodes:
M: 467d4c7508d1cb371ed52c4c6574506cba40c328 10.95.200.13:
slots:[] ( slots) master
additional replica(s)
Destination node:
M: ed309033dbefe2b0b64ad7fb643c4d2531e53b95 10.95.200.13:
slots:[-],[-] ( slots) master
Resharding plan:
Moving slot from 467d4c7508d1cb371ed52c4c6574506cba40c328
Moving slot from 10.95.200.13: to 10.95.200.13::

参数基本说明:

--cluster-from:表示分片的源头节点,即从这个标识指定的参数节点上将分片分配出去给别的节点,参数节点可以有多个,用逗号分隔。

--cluster-to:和--cluster-from相对,标识接收分片的节点,这个参数指定的节点只能有一个。

--cluster-slots:参与重新分片的slot号。

--cluster-yes:不用显示分片的过程信息,直接后台操作。

操作后的集群信息:

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli -c -h 10.95.200.12 -p  cluster nodes
ed309033dbefe2b0b64ad7fb643c4d2531e53b95 10.95.200.13:@ master - connected -
2cb8c6a7c86f512db2c6ca88eb67449197f5b885 10.95.200.12:@ slave cf6ca00cb36850762fdff1223684edf1fb9bd4ba connected
cf6ca00cb36850762fdff1223684edf1fb9bd4ba 10.95.200.14:@ master - connected
26c3a7cd48fe4bddf9cf0c60a3c30b6b1f273135 10.95.200.12:@ myself,slave ed309033dbefe2b0b64ad7fb643c4d2531e53b95 connected
467d4c7508d1cb371ed52c4c6574506cba40c328 10.95.200.13:7381@17381 master - connected

标红的节点,已经connected的slot没有了,在reshard之前,他有5460

3)将master进行下线操作:

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli --cluster del-node 10.95.200.13: 467d4c7508d1cb371ed52c4c6574506cba40c328
>>> Removing node 467d4c7508d1cb371ed52c4c6574506cba40c328 from cluster 10.95.200.13:
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.

操作后的集群信息(是不是从原来的6个节点变成了现在的4个了):

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli -c -h 10.95.200.12 -p  cluster nodes
ed309033dbefe2b0b64ad7fb643c4d2531e53b95 10.95.200.13:@ master - connected -
2cb8c6a7c86f512db2c6ca88eb67449197f5b885 10.95.200.12:@ slave cf6ca00cb36850762fdff1223684edf1fb9bd4ba connected
cf6ca00cb36850762fdff1223684edf1fb9bd4ba 10.95.200.14:@ master - connected
26c3a7cd48fe4bddf9cf0c60a3c30b6b1f273135 10.95.200.12:@ myself,slave ed309033dbefe2b0b64ad7fb643c4d2531e53b95 connected

依据上面的操作,全部删除后,最后只剩下一个master了,就直接kill掉,停服务就好了。

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli -c -h 10.95.200.13 -p  cluster nodes
ed309033dbefe2b0b64ad7fb643c4d2531e53b95 10.95.200.13:@ myself,master - connected -

下面记录一下创建一组4个节点的集群的操作,并添加一主一从的过程。

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli --cluster create 10.95.200.12: 10.95.200.13: 10.95.200.12: 10.95.200.13: --cluster-replicas
*** ERROR: Invalid configuration for cluster creation.
*** Redis Cluster requires at least 3 master nodes.
*** This is not possible with 4 nodes and 1 replicas per node.
*** At least 6 nodes are required.

这个过程失败了,呵呵。那就6个节点吧,然后删除再添加

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli --cluster create 10.95.200.12: 10.95.200.13: 10.95.200.14: 10.95.200.12: 10.95.200.13: 10.95.200.14: --cluster-replicas
>>> Performing hash slots allocation on nodes...
Master[] -> Slots -
Master[] -> Slots -
Master[] -> Slots -
Adding replica 10.95.200.13: to 10.95.200.12:
Adding replica 10.95.200.12: to 10.95.200.13:
Adding replica 10.95.200.14: to 10.95.200.14:
>>> Trying to optimize slaves allocation for anti-affinity
[OK] Perfect anti-affinity obtained!
。。。。。
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All slots covered.

删除两个节点,10.95.200.13:7380 10.95.200.14:7381,删除的过程不多记录(当前是4个节点)。

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli -c -h 10.95.200.12 -p  cluster nodes
f855a20340af517e1502f610d82e8280cc6cd803 10.95.200.12:@ myself,slave 1591155d7df58218a26974b16996eeeba88c84f1 connected
1cf9c2ef22a7ce7831cfee357aca36bfb6f275b5 10.95.200.13:@ slave d46ae46cf66445ddeba923d6af84b78ca5f789cb connected
d46ae46cf66445ddeba923d6af84b78ca5f789cb 10.95.200.12:@ master - connected -
1591155d7df58218a26974b16996eeeba88c84f1 10.95.200.14:@ master - connected -

记得删除掉的节点,其实已经shutdown了,要将他们起起来后,再执行添加操作。

1)将新的节点10.95.200.13:7380添加到集群(选择一个已经在集群中的节点即可)

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli --cluster add-node 10.95.200.13: 10.95.200.14:
>>> Adding node 10.95.200.13: to cluster 10.95.200.14:
>>> Performing Cluster Check (using node 10.95.200.14:)
M: 1591155d7df58218a26974b16996eeeba88c84f1 10.95.200.14:
slots:[-] ( slots) master
additional replica(s)
S: 1cf9c2ef22a7ce7831cfee357aca36bfb6f275b5 10.95.200.13:
slots: ( slots) slave
replicates d46ae46cf66445ddeba923d6af84b78ca5f789cb
S: f855a20340af517e1502f610d82e8280cc6cd803 10.95.200.12:
slots: ( slots) slave
replicates 1591155d7df58218a26974b16996eeeba88c84f1
M: d46ae46cf66445ddeba923d6af84b78ca5f789cb 10.95.200.12:
slots:[-] ( slots) master
additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All slots covered.
>>> Send CLUSTER MEET to node 10.95.200.13: to make it join the cluster.
[OK] New node added correctly.

加完后,看看集群:

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli -c -h 10.95.200.12 -p  cluster nodes
f855a20340af517e1502f610d82e8280cc6cd803 10.95.200.12:@ myself,slave 1591155d7df58218a26974b16996eeeba88c84f1 connected
1cf9c2ef22a7ce7831cfee357aca36bfb6f275b5 10.95.200.13:@ slave d46ae46cf66445ddeba923d6af84b78ca5f789cb connected
4fd334f64bc5b121f5810da3b5800a29d4e8c3ee 10.95.200.13:@ master - connected
d46ae46cf66445ddeba923d6af84b78ca5f789cb 10.95.200.12:@ master - connected -
1591155d7df58218a26974b16996eeeba88c84f1 10.95.200.14:@ master - connected -

2)新加入的一个节点默认会变成master,下面给这个master分配slot,就是一个reshard的过程

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli --cluster reshard 10.95.200.13: --cluster-from d46ae46cf66445ddeba923d6af84b78ca5f789cb,1591155d7df58218a26974b16996eeeba88c84f1 --cluster-to 4fd334f64bc5b121f5810da3b5800a29d4e8c3ee --cluster-slots 

添加完后,看看集群:

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli -c -h 10.95.200.12 -p  cluster nodes
f855a20340af517e1502f610d82e8280cc6cd803 10.95.200.12:@ myself,slave 1591155d7df58218a26974b16996eeeba88c84f1 connected
1cf9c2ef22a7ce7831cfee357aca36bfb6f275b5 10.95.200.13:@ slave d46ae46cf66445ddeba923d6af84b78ca5f789cb connected
4fd334f64bc5b121f5810da3b5800a29d4e8c3ee 10.95.200.13:@ master - connected - -
d46ae46cf66445ddeba923d6af84b78ca5f789cb 10.95.200.12:@ master - connected -
1591155d7df58218a26974b16996eeeba88c84f1 10.95.200.14:@ master - connected -

3)给刚才添加的master节点添加slave节点

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli --cluster add-node 10.95.200.14: 10.95.200.13: --cluster-slave --cluster-master-id 4fd334f64bc5b121f5810da3b5800a29d4e8c3ee
>>> Adding node 10.95.200.14: to cluster 10.95.200.13:
>>> Performing Cluster Check (using node 10.95.200.13:)
M: 4fd334f64bc5b121f5810da3b5800a29d4e8c3ee 10.95.200.13:
slots:[-],[-] ( slots) master
additional replica(s)
S: 1cf9c2ef22a7ce7831cfee357aca36bfb6f275b5 10.95.200.13:
slots: ( slots) slave
replicates 4fd334f64bc5b121f5810da3b5800a29d4e8c3ee
M: d46ae46cf66445ddeba923d6af84b78ca5f789cb 10.95.200.12:
slots:[-] ( slots) master
M: 1591155d7df58218a26974b16996eeeba88c84f1 10.95.200.14:
slots:[-] ( slots) master
additional replica(s)
S: f855a20340af517e1502f610d82e8280cc6cd803 10.95.200.12:
slots: ( slots) slave
replicates 1591155d7df58218a26974b16996eeeba88c84f1
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All slots covered.
>>> Send CLUSTER MEET to node 10.95.200.14: to make it join the cluster.
Waiting for the cluster to join >>> Configure node as replica of 10.95.200.13:.
[OK] New node added correctly.

最后再看看集群:

[tkiot@tkwh-kfcs-app2 redis]$ redis-cli -c -h 10.95.200.12 -p  cluster nodes
f855a20340af517e1502f610d82e8280cc6cd803 10.95.200.12:@ myself,slave 1591155d7df58218a26974b16996eeeba88c84f1 connected
f6093d443470ae37b8330407d20291ae959fc22f :@ slave,fail,noaddr d46ae46cf66445ddeba923d6af84b78ca5f789cb disconnected
1cf9c2ef22a7ce7831cfee357aca36bfb6f275b5 10.95.200.13:@ slave d46ae46cf66445ddeba923d6af84b78ca5f789cb connected
4fd334f64bc5b121f5810da3b5800a29d4e8c3ee 10.95.200.13:@ master - connected - -
d46ae46cf66445ddeba923d6af84b78ca5f789cb 10.95.200.12:@ master - connected -
1591155d7df58218a26974b16996eeeba88c84f1 10.95.200.14:@ master - connected -
9f069b1f62cc93b95cb432f3726bc5bbfb0c8c76 10.95.200.14:@ slave 4fd334f64bc5b121f5810da3b5800a29d4e8c3ee connected

总结一下集群节点添加的过程
A) 增加节点(前提是对应节点服务器已经运行了),默认成为master节点,命令:redis-cli --cluster add-node <new_ip:new_port> <existing_ip:existing_port>
B) 给新增加的这个master节点分配slot,命令:redis-cli --cluster reshard <master_ip:master_port> --cluster-from <集群已存在master的nodeId,多个需要逗号分隔> --cluster-to <当前master的nodeId> --cluster-slots <分配slot的数量>
C) 给这个master添加slave,slot就不用了,因为是slave,命令:redis-cli --cluster add-node <slave_ip:slave_port> <master_ip:master_port> --cluster-slave --cluster-master-id <mastr node_id>

最后,有一个问题,没有搞清楚,就是将节点从集群删除后,再添加进去的时候,总会遇到提示说该节点不是空节点,导致添加失败,采取的策略就是将待添加的节点对应的数据文件全部删除后,重新启动,再执行添加操作指令,就成功了。

基于redis5的session共享:【redis 5.x集群应用研究】的更多相关文章

  1. Redis+Tomcat+Nginx集群实现Session共享,Tomcat Session共享

    Redis+Tomcat+Nginx集群实现Session共享,Tomcat Session共享 ============================= 蕃薯耀 2017年11月27日 http: ...

  2. Spring-Session实现Session共享Redis集群方式配置教程

    循序渐进,由易到难,这样才更有乐趣! 概述 本篇开始继续上一篇的内容基础上进行,本篇主要介绍Spring-Session实现配置使用Redis集群,会有两种配置方式,一种是Redis-Cluster, ...

  3. Redis存储Tomcat集群的Session

    Redis存储Tomcat集群的Session 如何 做到把新开发的代码推送到到生产系统中部署,生产系统要能够零宕机.对使用用户零影响. 设想 是使用集群来搞定,通过通知负载均衡Nginx,取下集群中 ...

  4. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:2.搭建环境-2.3配置共享磁盘

    2.3.配置共享磁盘 2.3.1.创建共享磁盘 在cmd中进入WMware Workstation 10.0 安装目录: 1.创建存储Oracle Clusterware文件  (Oracle Clu ...

  5. 基于docker实现redis高可用集群

    基于docker实现redis高可用集群 yls 2019-9-20 简介 基于docker和docker-compose 使用redis集群和sentinel集群,达到redis高可用,为缓存做铺垫 ...

  6. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:4.安装Oracle RAC FAQ-4.6.重新配置与缷载11R2 Grid Infrastructure

    1.[root@linuxrac1 ~]# /u01/app/oraInventory/orainstRoot.sh 2.[root@linuxrac2 ~]# /u01/app/oraInvento ...

  7. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:4.安装Oracle RAC FAQ-4.4.无法图形化安装Grid Infrastructure

    无法图形化安装: [grid@linuxrac1 grid]$ ./runInstaller Starting Oracle Universal Installer... Checking Temp ...

  8. Redis+Twemproxy+HAProxy集群(转) 干货

    原文地址:Redis+Twemproxy+HAProxy集群  干货 Redis主从模式 Redis数据库与传统数据库属于并行关系,也就是说传统的关系型数据库保存的是结构化数据,而Redis保存的是一 ...

  9. 通过 Docker 部署 Redis 6.x 集群

    要点步骤总结: # 这里演示使用同一台主机上 # 创建各节点存储路径 mkdir -p /opt/redis/{7000,7001,7002,7003,7004,7005} # 创建各节点配置文件 c ...

随机推荐

  1. JVM垃圾收集算法之清除算法

    最近看了一些大佬的博文,文中提到说:学习知识不能一味的死学滥学,在学之前要明白为什么要学这个知识,在实际的应用中怎么运用这个知识.我觉得说的很对,很多时候我学习确实是了解了这是什么原理,但是要说到实际 ...

  2. first集合follow集的求法

    FIRST集的定义 : 设G=(VT,VN,P,S)是上下文无关文法 FIRST(a)={a|a=>*ab,a∈VT, a,b∈V*} 若a=>*ε则规定ε∈FIRST (a) FIRST ...

  3. mysql显示一张表的索引

    show index from tm_show.fulfillment_order;show index from tm_show.express_verify;show index from tra ...

  4. eclipse使用mybatis实现Java与xml文件相互跳转

    原文:https://jingyan.baidu.com/article/8ebacdf0f06c8c09f65cd5a0.html 一直习惯使用eclipse,看见同事使用IDEA,直接从Java类 ...

  5. Linux 定时任务的控制台导出导入到文件

    这个不但适用于定时任务,也适用于一般的脚本. 以前喜欢用>>这样的快捷方式, 今天看到用tee命令的,也记下. 55 23 * * * /bin/sh /sql_bak/restore_s ...

  6. python中pop()与split()的用法

    imglist = ['11.jpg','12.jpg','13.jpg','14.jpg','2.jpg','1.jpg',] print(str(imglist)) a = str(imglist ...

  7. 自定义微信小程序swiper轮播图面板指示点的样式

    微信小程序的swiper组件是滑块视图容器,也就是说平常我们看到的轮播图就可以用它来做,不过这个组件有很多样式是固定的,但是,有时候我们的设计稿的面板指示点是需要个性化的,那么如何去修改swiper组 ...

  8. Java Mail 异常

    Java Mail 异常 java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream 解决方案: 把Jar包换一个比较高的版本就 ...

  9. 项目Beta冲刺(团队)——05.26(4/7)

    项目Beta冲刺(团队)--05.26(4/7) 格式描述 课程名称:软件工程1916|W(福州大学) 作业要求:项目Beta冲刺(团队) 团队名称:为了交项目干杯 作业目标:记录Beta敏捷冲刺第4 ...

  10. POJ3259-Wormholes-( spfa || Bellman_Ford )

    题意:有n块田,之间有m条无向边表示路径,权值表示走过需要花费的时间.有w对虫洞,虫洞是单向的,表示穿越一定时间到过去,并且回到虫洞指向的点,问一个人有没有可能通过虫洞回到某个起点,并且在从这个起点出 ...