redis-trib.rb是官方提供的Redis Cluster的管理工具,无需额外下载,默认位于源码包的src目录下,但因该工具是用ruby开发的,所以需要准备相关的依赖环境。

准备redis-trib.rb的运行环境

wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.gz

yum -y install zlib-devel

tar xvf ruby-2.5.1.tar.gz

cd ruby-2.5.1/

./configure -prefix=/usr/local/ruby

make

make install

cd /usr/local/ruby/

cp bin/ruby /usr/local/bin

cp bin/gem /usr/local/bin

安装rubygem redis依赖

wget http://rubygems.org/downloads/redis-3.3.0.gem

gem install -l redis-3.3.0.gem

redis-trib.rb支持的操作

# redis-trib.rb help
Usage: redis-trib <command> <options> <arguments ...>create          host1:port1 ... hostN:portN--replicas <arg>check           host:portinfo            host:portfix             host:port--timeout <arg>reshard         host:port--from <arg>--to <arg>--slots <arg>--yes--timeout <arg>--pipeline <arg>rebalance       host:port--weight <arg>--auto-weights--use-empty-masters--timeout <arg>--simulate--pipeline <arg>--threshold <arg>add-node        new_host:new_port existing_host:existing_port--slave--master-id <arg>del-node        host:port node_idset-timeout     host:port millisecondscall            host:port command arg arg .. argimport          host:port--from <arg>--copy--replacehelp            (show this help)For check, fix, reshard, del-node, set-timeout you can specify the host and port of any working node in the cluster.

支持的操作如下:

1. create:创建集群

2. check:检查集群

3. info:查看集群信息

4. fix:修复集群

5. reshard:在线迁移slot

6. rebalance:平衡集群节点slot数量

7. add-node:添加新节点

8. del-node:删除节点

9. set-timeout:设置节点的超时时间

10. call:在集群所有节点上执行命令

11. import:将外部redis数据导入集群

创建集群

redis-trib.rb create --replicas 1 127.0.0.1:6379 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382 127.0.0.1:6383 127.0.0.1:6384

--replicas参数指定集群中每个主节点配备几个从节点,这里设置为1。

>>> Creating cluster
/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:6379
127.0.0.1:6380
127.0.0.1:6381
Adding replica 127.0.0.1:6383 to 127.0.0.1:6379
Adding replica 127.0.0.1:6384 to 127.0.0.1:6380
Adding replica 127.0.0.1:6382 to 127.0.0.1:6381
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: bc775f9c4dea40820b82c9451778b1fcd42f92bc 127.0.0.1:6379slots:0-5460 (5461 slots) master
M: 3b27d00d13706a032a92ff6b0a914af272dcaaf2 127.0.0.1:6380slots:5461-10922 (5462 slots) master
M: d874f003257f1fb036bbd856ca605172a1741232 127.0.0.1:6381slots:10923-16383 (5461 slots) master
S: 648eb314863b82aaa676380be7db2ec307f5547d 127.0.0.1:6382replicates bc775f9c4dea40820b82c9451778b1fcd42f92bc
S: 65a6efb441ac44c348f7da8c62e26b888cda7c48 127.0.0.1:6383replicates 3b27d00d13706a032a92ff6b0a914af272dcaaf2
S: 57bda956485109552547aef6c77fba43d2124abf 127.0.0.1:6384replicates d874f003257f1fb036bbd856ca605172a1741232
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:6379)
M: bc775f9c4dea40820b82c9451778b1fcd42f92bc 127.0.0.1:6379slots:0-5460 (5461 slots) master1 additional replica(s)
S: 648eb314863b82aaa676380be7db2ec307f5547d 127.0.0.1:6382slots: (0 slots) slavereplicates bc775f9c4dea40820b82c9451778b1fcd42f92bc
M: 3b27d00d13706a032a92ff6b0a914af272dcaaf2 127.0.0.1:6380slots:5461-10922 (5462 slots) master1 additional replica(s)
S: 57bda956485109552547aef6c77fba43d2124abf 127.0.0.1:6384slots: (0 slots) slavereplicates d874f003257f1fb036bbd856ca605172a1741232
S: 65a6efb441ac44c348f7da8c62e26b888cda7c48 127.0.0.1:6383slots: (0 slots) slavereplicates 3b27d00d13706a032a92ff6b0a914af272dcaaf2
M: d874f003257f1fb036bbd856ca605172a1741232 127.0.0.1:6381slots:10923-16383 (5461 slots) master1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

16384个槽全部被分配,集群创建成功。注意:给redis-trib.rb的节点地址必须是不包含任何槽/数据的节点,否则会拒绝创建集群。

>>> Creating cluster
/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
[ERR] Node 127.0.0.1:6379 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.

关于主从节点的选择及槽的分配,其算法如下:

1> 把节点按照host分类,这样保证master节点能分配到更多的主机中。

2> 遍历host列表,从每个host列表中弹出一个节点,放入interleaved数组。直到所有的节点都弹出为止。

3> 将interleaved数组中前master个数量的节点保存到masters数组中。

4> 计算每个master节点负责的slot数量,16384除以master数量取整,这里记为N。

5> 遍历masters数组,每个master分配N个slot,最后一个master,分配剩下的slot。

6> 接下来为master分配slave,分配算法会尽量保证master和slave节点不在同一台主机上。对于分配完指定slave数量的节点,还有多余的节点,也会为这些节点寻找master。分配算法会遍历两次masters数组。

7> 第一次遍历master数组,在余下的节点列表找到replicas数量个slave。每个slave为第一个和master节点host不一样的节点,如果没有不一样的节点,则直接取出余下列表的第一个节点。

8> 第二次遍历是分配节点数除以replicas不为整数而多出的一部分节点。

检查集群状态

redis-trib.rb check 127.0.0.1:6379

指定任意一个节点即可。

/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Performing Cluster Check (using node 127.0.0.1:6379)
M: bc775f9c4dea40820b82c9451778b1fcd42f92bc 127.0.0.1:6379slots:0-5460 (5461 slots) master1 additional replica(s)
S: 648eb314863b82aaa676380be7db2ec307f5547d 127.0.0.1:6382slots: (0 slots) slavereplicates bc775f9c4dea40820b82c9451778b1fcd42f92bc
M: 3b27d00d13706a032a92ff6b0a914af272dcaaf2 127.0.0.1:6380slots:5461-10922 (5462 slots) master1 additional replica(s)
S: 57bda956485109552547aef6c77fba43d2124abf 127.0.0.1:6384slots: (0 slots) slavereplicates d874f003257f1fb036bbd856ca605172a1741232
S: 65a6efb441ac44c348f7da8c62e26b888cda7c48 127.0.0.1:6383slots: (0 slots) slavereplicates 3b27d00d13706a032a92ff6b0a914af272dcaaf2
M: d874f003257f1fb036bbd856ca605172a1741232 127.0.0.1:6381slots:10923-16383 (5461 slots) master1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

查看集群信息

redis-trib.rb info 127.0.0.1:6383

/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
127.0.0.1:6380 (3b27d00d...) -> 0 keys | 5462 slots | 1 slaves.
127.0.0.1:6381 (d874f003...) -> 1 keys | 5461 slots | 1 slaves.
127.0.0.1:6379 (bc775f9c...) -> 0 keys | 5461 slots | 1 slaves.
[OK] 1 keys in 3 masters.
0.00 keys per slot on average.

修复集群

目前fix命令能修复两种异常,

1. 节点中存在处于迁移中(importing或migrating状态)的slot。

2. 节点中存在未分配的slot。

其它异常不能通过fix命令修复。

[root@slowtech conf]# redis-trib.rb fix 127.0.0.1:6379
/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Performing Cluster Check (using node 127.0.0.1:6379)
S: d826c5fd98efa8a17a880e9a90a25f06c88e6ae9 127.0.0.1:6379slots: (0 slots) slavereplicates a8b3d0f9b12d63dab3b7337d602245d96dd55844
S: 55c05d5b0dfea0d52f88548717ddf24975268de6 127.0.0.1:6383slots: (0 slots) slavereplicates a8b3d0f9b12d63dab3b7337d602245d96dd55844
M: f413fb7e6460308b17cdb71442798e1341b56cbc 127.0.0.1:6381slots:50-16383 (16334 slots) master2 additional replica(s)
S: beba753c5a63607fa66d9ec7427ed9a511ea136e 127.0.0.1:6382slots: (0 slots) slavereplicates f413fb7e6460308b17cdb71442798e1341b56cbc
S: 83797d518e56c235272402611477f576973e9d34 127.0.0.1:6384slots: (0 slots) slavereplicates f413fb7e6460308b17cdb71442798e1341b56cbc
M: a8b3d0f9b12d63dab3b7337d602245d96dd55844 127.0.0.1:6380slots:0-49 (50 slots) master2 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

在线迁移slot

交互环境中使用

如,

redis-trib.rb reshard 127.0.0.1:6379

指定任意一个节点即可。

/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Performing Cluster Check (using node 127.0.0.1:6379)
M: bc775f9c4dea40820b82c9451778b1fcd42f92bc 127.0.0.1:6379slots:3225-5460 (2236 slots) master1 additional replica(s)
S: 648eb314863b82aaa676380be7db2ec307f5547d 127.0.0.1:6382slots: (0 slots) slavereplicates bc775f9c4dea40820b82c9451778b1fcd42f92bc
M: 3b27d00d13706a032a92ff6b0a914af272dcaaf2 127.0.0.1:6380slots:0-3224,5461-13958 (11723 slots) master1 additional replica(s)
S: 57bda956485109552547aef6c77fba43d2124abf 127.0.0.1:6384slots: (0 slots) slavereplicates d874f003257f1fb036bbd856ca605172a1741232
S: 65a6efb441ac44c348f7da8c62e26b888cda7c48 127.0.0.1:6383slots: (0 slots) slavereplicates 3b27d00d13706a032a92ff6b0a914af272dcaaf2
M: d874f003257f1fb036bbd856ca605172a1741232 127.0.0.1:6381slots:13959-16383 (2425 slots) master1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)? 200
What is the receiving node ID? 3b27d00d13706a032a92ff6b0a914af272dcaaf2
Please enter all the source node IDs.Type 'all' to use all the nodes as source nodes for the hash slots.Type 'done' once you entered all the source nodes IDs.
Source node #1:

它首先会提示需要迁移多个槽,我这里写的是200。

接着它会提示需要将槽迁移到哪个节点,这里必须写节点ID。

紧跟着它会提示槽从哪些节点中迁出。

如果指定为all,则待迁移的槽在剩余节点中平均分配,在这里,127.0.0.1:6379和127.0.0.1:6381各迁移100个槽出来。

也可从指定节点中迁出,这个时候,必须指定源节点的节点ID,最后以done结束,如下所示,

Source node #1:bc775f9c4dea40820b82c9451778b1fcd42f92bc
Source node #2:doneReady to move 200 slots.Source nodes:M: bc775f9c4dea40820b82c9451778b1fcd42f92bc 127.0.0.1:6379slots:3225-5460 (2236 slots) master1 additional replica(s)Destination node:M: 3b27d00d13706a032a92ff6b0a914af272dcaaf2 127.0.0.1:6380slots:0-3224,5461-13958 (11723 slots) master1 additional replica(s)Resharding plan:Moving slot 3225 from bc775f9c4dea40820b82c9451778b1fcd42f92bcMoving slot 3226 from bc775f9c4dea40820b82c9451778b1fcd42f92bcMoving slot 3227 from bc775f9c4dea40820b82c9451778b1fcd42f92bc...
Do you want to proceed with the proposed reshard plan (yes/no)? yes
Moving slot 3225 from 127.0.0.1:6379 to 127.0.0.1:6380: .
Moving slot 3226 from 127.0.0.1:6379 to 127.0.0.1:6380:
Moving slot 3227 from 127.0.0.1:6379 to 127.0.0.1:6380: ..
Moving slot 3228 from 127.0.0.1:6379 to 127.0.0.1:6380:
...

最后,提示是否继续进行。

命令行中使用

redis-trib.rb reshard host:port --from <arg> --to <arg> --slots <arg> --yes --timeout <arg> --pipeline <arg>

其中,

host:port:必传参数,集群内任意节点地址,用来获取整个集群信息。

--from:源节点id,如果有多个源节点,使用逗号分隔,如果是all,则源节点为集群内出目标节点外的其它所有主节点。

--to:目标节点id,只能填写一个。

--slots:需要迁移槽的总数量。

--yes:迁移无需用户手动确认。

--timeout:控制每次migrate操作的超时时间,默认为60000毫秒。

--pipeline:控制每次批量迁移键的数量,默认为10。

如,

redis-trib.rb reshard --from a8b3d0f9b12d63dab3b7337d602245d96dd55844 --to f413fb7e6460308b17cdb71442798e1341b56cbc  --slots 10923 --yes --pipeline 20 127.0.0.1:6383

平衡集群节点slot数量

rebalance       host:port--weight <arg>--auto-weights--use-empty-masters--timeout <arg>--simulate--pipeline <arg>--threshold <arg>

其中,

--weight <arg>:节点的权重,格式为node_id=weight,如果需要为多个节点分配权重的话,需要添加多个--weight <arg>参数,即--weight b31e3a2e=5 --weight 60b8e3a1=5,node_id可为节点名称的前缀,只要保证前缀位数能唯一区分该节点即可。没有传递–weight的节点的权重默认为1。

--auto-weights:自动将每个节点的权重默认为1。如果--weight和--auto-weights同时指定,则--auto-weights会覆盖前者。

--threshold <arg>:只有节点需要迁移的slot阈值超过threshold,才会执行rebalance操作。

--use-empty-masters:默认没有分配slot节点的master是不参与rebalance的。如果要让其参与rebalance,需添加该参数。

--timeout <arg>:设置migrate命令的超时时间。

--simulate:设置该参数,只会提示用户会迁移哪些slots,而不会执行真正的迁移操作。

--pipeline <arg>:定义cluster getkeysinslot命令一次取出的key数量,不传的话使用默认值为10。

如,

# redis-trib.rb rebalance --weight a8b3d0f9b12d63dab3b7337d602245d96dd55844=3 --weight f413fb7e6460308b17cdb71442798e1341b56cbc=2  --use-empty-masters  127.0.0.1:6379
/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Performing Cluster Check (using node 127.0.0.1:6379)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Rebalancing across 2 nodes. Total weight = 5.0
Moving 3824 slots from 127.0.0.1:6380 to 127.0.0.1:6381
#########################################...

删除节点

redis-trib.rb del-node host:port node_id

在删除节点之前,其对应的槽必须为空,所以,在进行节点删除动作之前,必须使用redis-trib.rb reshard将其迁移出去。

需要注意的是,如果某个节点的槽被完全迁移出去,其对应的slave也会随着更新,指向迁移的目标节点。

# redis-trib.rb del-node 127.0.0.1:6379 8f7836a9a14fb6638530b42e04f5e58e28de0a6c
>>> Removing node 8f7836a9a14fb6638530b42e04f5e58e28de0a6c from cluster 127.0.0.1:6379
/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.

添加新节点

redis-trib add-node new_host:new_port existing_host:existing_port --slave --master-id <arg>

其中,

new_host:new_port:待添加的节点,必须确保其为空或不在其它集群中。否则,会提示以下错误。

[ERR] Node 127.0.0.1:6379 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.

所以,线上建议使用redis-trib.rb添加新节点,因为其会对新节点的状态进行检查。如果手动使用cluster meet命令加入已经存在于其它集群的节点,会造成被加入节点的集群合并到现有集群的情况,从而造成数据丢失和错乱,后果非常严重,线上谨慎操作。

existing_host:existing_port:集群中任意一个节点的地址。

如果添加的是主节点,只需指定源节点和目标节点的地址即可。

redis-trib.rb add-node 127.0.0.1:6379 127.0.0.1:6384

如果添加的是从节点,其语法如下,

redis-trib.rb add-node --slave --master-id f413fb7e6460308b17cdb71442798e1341b56cbc 127.0.0.1:6379 127.0.0.1:6384

注意:--slave和--master-id必须写在前面,同样的参数,如果是下面这样写法,会提示错误,

# redis-trib.rb add-node 127.0.0.1:6379 127.0.0.1:6384 --slave --master-id f413fb7e6460308b17cdb71442798e1341b56cbc
[ERR] Wrong number of arguments for specified sub command

添加从节点,可不设置--master-id,此时会随机选择主节点。

设置节点的超时时间

redis-trib.rb set-timeout host:port milliseconds

其实就是批量修改集群各节点的cluster-node-timeout参数。

# redis-trib.rb set-timeout 127.0.0.1:6379 20000
/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Reconfiguring node timeout in every cluster node...
*** New timeout set for 127.0.0.1:6379
*** New timeout set for 127.0.0.1:6383
*** New timeout set for 127.0.0.1:6381
*** New timeout set for 127.0.0.1:6382
*** New timeout set for 127.0.0.1:6384
*** New timeout set for 127.0.0.1:6380
>>> New node timeout set. 6 OK, 0 ERR.

在集群所有节点上执行命令

redis-trib.rb call host:port command arg arg .. arg
[root@slowtech conf]# redis-trib.rb call 127.0.0.1:6379 set hello world
/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Calling SET hello world
127.0.0.1:6379: MOVED 866 127.0.0.1:6381
127.0.0.1:6383: MOVED 866 127.0.0.1:6381
127.0.0.1:6381: OK
127.0.0.1:6382: MOVED 866 127.0.0.1:6381
127.0.0.1:6384: MOVED 866 127.0.0.1:6381
127.0.0.1:6380: MOVED 866 127.0.0.1:6381[root@slowtech conf]# redis-trib.rb call 127.0.0.1:6379 get hello
/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Calling GET hello
127.0.0.1:6379: MOVED 866 127.0.0.1:6381
127.0.0.1:6383: MOVED 866 127.0.0.1:6381
127.0.0.1:6381: world
127.0.0.1:6382: MOVED 866 127.0.0.1:6381
127.0.0.1:6384: MOVED 866 127.0.0.1:6381
127.0.0.1:6380: MOVED 866 127.0.0.1:6381

将外部redis数据导入集群

redis-trib.rb import --from 127.0.0.1:6378 127.0.0.1:6379

其内部处理流程如下:

1> 通过load_cluster_info_from_node方法加载集群信息,check_cluster方法检查集群是否健康。

2> 连接外部redis节点,如果外部节点开启了cluster_enabled,则提示错误([ERR] The source node should not be a cluster node.)

3> 通过scan命令遍历外部节点,一次获取1000条数据。

4> 遍历这些key,计算出key对应的slot。

5> 执行migrate命令,源节点是外部节点,目的节点是集群slot对应的节点,如果设置了--copy参数,则传递copy参数,其会保留源节点的key,如果设置了--replace,则传递replace参数。如果目标节点中存在同名key,其值会被覆盖。两个参数可同时指定。

6> 不停执行scan命令,直到遍历完所有key。

7> 迁移完成。

[root@slowtech conf]# redis-trib.rb import --from 127.0.0.1:6378 --replace  127.0.0.1:6379
>>> Importing data from 127.0.0.1:6378 to cluster
/usr/local/ruby/lib/ruby/gems/2.5.0/gems/redis-3.3.0/lib/redis/client.rb:459: warning: constant ::Fixnum is deprecated
>>> Performing Cluster Check (using node 127.0.0.1:6379)
S: d826c5fd98efa8a17a880e9a90a25f06c88e6ae9 127.0.0.1:6379slots: (0 slots) slavereplicates a8b3d0f9b12d63dab3b7337d602245d96dd55844
S: 55c05d5b0dfea0d52f88548717ddf24975268de6 127.0.0.1:6383slots: (0 slots) slavereplicates a8b3d0f9b12d63dab3b7337d602245d96dd55844
M: f413fb7e6460308b17cdb71442798e1341b56cbc 127.0.0.1:6381slots:50-16383 (16334 slots) master2 additional replica(s)
S: beba753c5a63607fa66d9ec7427ed9a511ea136e 127.0.0.1:6382slots: (0 slots) slavereplicates f413fb7e6460308b17cdb71442798e1341b56cbc
S: 83797d518e56c235272402611477f576973e9d34 127.0.0.1:6384slots: (0 slots) slavereplicates f413fb7e6460308b17cdb71442798e1341b56cbc
M: a8b3d0f9b12d63dab3b7337d602245d96dd55844 127.0.0.1:6380slots:0-49 (50 slots) master2 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Connecting to the source Redis instance
*** Importing 1 keys from DB 0
Migrating key5 to 127.0.0.1:6381: OK

redis-trib.rb操作命令相关推荐

  1. Redis Cluster日常操作命令梳理

    在之前的一篇文章已经介绍了Redis Cluster及其部署,下面说下Redis Cluster日常操作命令: 一.以下命令是Redis Cluster集群所独有的,执行下面命令需要先登录redis: ...

  2. Redis源码-Set:Redis Set存储原理、Redis Set集合操作命令、Redis Set两种存储底层编码intset+hashtable、Redis Set应用场景

    Redis源码-Set:Redis Set存储原理.Redis Set集合操作命令.Redis Set两种存储底层编码intset+hashtable.Redis Set应用场景 Redis数据类型 ...

  3. Redis 数据类型与操作命令整理

    Redis 优势 性能极高 – Redis能读的速度是110000次/s,写的速度是81000次/s . 丰富的数据类型 – Redis支持二进制案例的 Strings, Lists, Hashes, ...

  4. Redis数据类型与操作命令

    1. 键值对数据库 1.1 redis数据结构 redis的数据是 key-value 形式的键值对,其中 key 其实都是字符串的形式,而 value 的数据类型,也就是数据的保存形式,底层实现的方 ...

  5. redis的一些操作命令

    1.   ps -ef | grep redis (查看redis的启动实例) 2.   ./src/redis-cli -p 6380 shutdown(关闭6380实例) 3.   ./src/r ...

  6. redis的批量操作命令pipeline(PHP实现)

    redis执行一条命令有四个过程:发送命令.命令排队.命令执行.返回结果:整个过程是一个往返时间(RTT).如果有n条命令,就会消耗n次RTT.Redis的客户端和服务端可能部署在不同的机器上.在两地 ...

  7. Redis数据库常用操作命令(查询db、key、value)

    ①打开Redis可视化工具,点击console,进入查询操作界面 ②打开db库: select 5 ③获取指定 key 的值 get key """ key:Mary_c ...

  8. 【Flask项目】Redis各种数据类型操作命令

    连接redis数据库 [root@mylinux2 zhilong]# redis-cli -h 192.168.17.3 启动redis服务 [root@mylinux2 zhilong]# red ...

  9. Redis INCR数值操作命令

    Redis string 类型提供了一些专门操作数值的命令,比如 INCRBY(自增).DECRBR(自减).INCR(加1) 和 DECR(减1) 等命令.数值操作,同样有特定的应用场景,比如常见的 ...

  10. 七、Redis集群搭建

    1.搭建步骤 第一步:在第一台机器的/usr/local下创建文件夹redis‐cluster,然后在其下面分别创建2个文件夹如下 1. mkdir ‐p /opt/module/redis‐clus ...

最新文章

  1. ML 自学者周刊:第 4 期
  2. 剑指-利用树的前序遍历和中序遍历结果,输出树的原始结构
  3. 怎么用git将本地代码上传到远程服务器_git之如何把本地文件上传到远程仓库的指定位置...
  4. 围观神龙架构首次开箱,现场直播暴力拆机
  5. 两个栈实现队列+两个队列实现栈----java
  6. python kafka kerberos 验证 消费 生产
  7. 计算机专业解说,计算机专业解说.ppt
  8. Off World Live 插件:广播UE4内部的音频信号到NDI
  9. PayPal(大陆、美国、英国)如何提现到国内教程详解
  10. C语言中%d,%o,%f,%e,%x的意义
  11. 零零信安:攻击面管理(ASM)技术详解和实现
  12. 海豚php框架漏洞,代码审计 - dolphin.pro cms SQL注入漏洞,Bypass过滤规则
  13. ssh框架的学习之strut2小测试(2)
  14. mysql 5.6 64 位安装 缺少libai.so_CentOS6.7安装部署LNMP(nginx1.8.0+php5.6.10+mysql5.6.12) 法外狂徒...
  15. python中添加.pth_使用.pth文件扩展python环境路径
  16. Geany无法识别中文怎么办
  17. 工程测量乙级资质申请条件及具体流程
  18. mongodb数据备份与恢复
  19. (一)操作系统的基本概念
  20. 一个整数称为完全平方数,是指它的值是另一个整数的平方。如81是个完全平方数,因为它是9的平方。请按要求完成:①在三位的正整数中寻找所有完全平方数;例如:144(12*12),676(26*26)

热门文章

  1. [C语言]if语句的常见用法
  2. Week 2 Sequence Labelling
  3. 页眉---header
  4. 关于csv文件最大行数和最大列数
  5. 密歇根州立大学被黑 个人信息和社保号码被盗
  6. 如何修复dns服务器,如何修复DNS?DNS是什么?如何设置DNS?
  7. 数据科学----知识树(机器学习、数据挖掘学习思维导图)
  8. 【土豆】——做人,要像土豆一样
  9. 最近在上海浦东新区的租房经历
  10. matlab2014如何获得hostid,关于如何修改hostid的问题