跳至主要內容

[redis] 基本用法

https://blog.csdn.net/u014034329/article/details/83833665
https://blog.csdn.net/xiaoliuliu2050/article/details/72898828https://dotblogs.com.tw/supershowwei/2015/12/29/101928
https://dotblogs.com.tw/supershowwei/2015/12/29/164853https://blog.csdn.net/vtopqx/article/details/50235891
https://blog.csdn.net/ya_1249463314/article/details/77488826https://www.jianshu.com/p/7c25d903290a
https://www.shellhacks.com/redis-delete-all-keys-redis-cli/
cd C:\Redis-x64-3.2.100\Redis-cluster
redis-server.exe C:\Redis-x64-3.2.100/Redis-cluster/redis-9001.conf
redis-server.exe C:\Redis-x64-3.2.100/Redis-cluster/redis-9002.conf
redis-server.exe C:\Redis-x64-3.2.100/Redis-cluster/redis-9003.conf
redis-server.exe C:\Redis-x64-3.2.100/Redis-cluster/redis-9004.conf
redis-server.exe C:\Redis-x64-3.2.100/Redis-cluster/redis-9005.conf
redis-server.exe C:\Redis-x64-3.2.100/Redis-cluster/redis-9006.conf
redis-trib.rb create –replicas 1 127.0.0.1:9001 127.0.0.1:9002 127.0.0.1:9003 127.0.0.1:9004 127.0.0.1:9005 127.0.0.1:9006
redis-trib.rb create –replicas 0 127.0.0.1:9001 127.0.0.1:9002 127.0.0.1:9003
redis-cli -h 127.0.0.1 -p 9001
flushall
cluster reset
quit
redis-cli -h 127.0.0.1 -p 9002
flushall
cluster reset
quit
redis-cli -h 127.0.0.1 -p 9003
flushall
cluster reset
quit
redis-cli -h 127.0.0.1 -p 9004
flushall
cluster reset
quit
redis-cli -h 127.0.0.1 -p 9005
flushall
cluster reset
quit
redis-cli -h 127.0.0.1 -p 9006
flushall
cluster reset
quit
redis-cli -c -p 9001
cluster meet 127.0.0.1 9002
cluster meet 127.0.0.1 9003
cluster meet 127.0.0.1 9004
cluster meet 127.0.0.1 9005
cluster meet 127.0.0.1 9006
quit
redis-cli -c -p 9002
cluster meet 127.0.0.1 9001
cluster meet 127.0.0.1 9003
cluster meet 127.0.0.1 9004
cluster meet 127.0.0.1 9005
cluster meet 127.0.0.1 9006
quit
redis-cli -c -p 9003
cluster meet 127.0.0.1 9001
cluster meet 127.0.0.1 9002
cluster meet 127.0.0.1 9004
cluster meet 127.0.0.1 9005
cluster meet 127.0.0.1 9006
quit
redis-cli -c -p 9004
cluster meet 127.0.0.1 9001
cluster meet 127.0.0.1 9002
cluster meet 127.0.0.1 9003
cluster meet 127.0.0.1 9005
cluster meet 127.0.0.1 9006
quit
redis-cli -c -p 9005
cluster meet 127.0.0.1 9001
cluster meet 127.0.0.1 9002
cluster meet 127.0.0.1 9003
cluster meet 127.0.0.1 9004
cluster meet 127.0.0.1 9006
quit
redis-cli -c -p 9006
cluster meet 127.0.0.1 9001
cluster meet 127.0.0.1 9002
cluster meet 127.0.0.1 9003
cluster meet 127.0.0.1 9004
cluster meet 127.0.0.1 9005
quit
指令 redis-trib.rb add-node 127.0.0.1:6383 127.0.0.1:6380
指令 redis-trib.rb reshard 127.0.0.1:6380
redis-trib.rb info 127.0.0.1:9001 ———-> 看目前的狀況 key/slots/slaves
redis-trib.rb check 172.168.63.202:7000 —–> 看目前的狀況
redis-trib.rb reshard –from dd5333e3927eb199564b54308dbaf71cd5ae0b5d –to c1663ed15f472e26c5b1ebf9534a2a0cdeebaef3 –slots 454 –yes 127.0.0.1:6380
redis-trib.rb reshard
–from dd5333e3927eb199564b54308dbaf71cd5ae0b5d
–to c1663ed15f472e26c5b1ebf9534a2a0cdeebaef3
–slots 454
–yes 127.0.0.1:6380
701f764146ab8c2a7fb43f5c0aaefdadcc32b73c
redis-trib.rb add-node –slave –master-id a87f3bd894a5d58fda2c7ba0fb0926e05c8ebf96 192.168.1.179:30004 192.168.1.179:30001
redis-trib.rb add-node
–slave –master-id a87f3bd894a5d58fda2c7ba0fb0926e05c8ebf96 192.168.1.179:30004 192.168.1.179:30001
[ERR] Node 127.0.0.1:9004 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.
redis-cli 127.0.0.1:9004
redis-cli -c -p 9006
$ flushdb
[ERR] Not all 16384 slots are covered by nodes.
redis-trib.rb fix 172.168.63.201:7001
redis-trib.rb reshard 172.168.63.201:7001
*** Please fix your cluster problems before resharding
redis-trib.rb fix 12.0.0.1:9001
keys pattern
flushdb
flushall
./redis-trib.rb rebalance –use-empty-masters 127.0.0.1:7001
Removing a master
./redis-trib.rb info 127.0.0.1:7001
./redis-trib.rb rebalance –weight 0fdc74e9=0 127.0.0.1:7001
./redis-trib.rb del-node 127.0.0.1:7001 0fdc74e9d090047e8217e891fea4d858e9dd1def
redis-cli -c -p 127.0.0.1:9002
$ cluster forget 127.0.0.1:9001
redis-trib.rb check 127.0.0.1:9002 ——> 才會將 9001 不見
CLUSTERDOWN Hash slot not served解决
用命令检测一下试试:redis-trib.rb check 127.0.0.1:6379
检测结果: [ERR] Not all 16384 slots are covered by nodes。
执行修复命令:redis-trib.rb fix 127.0.0.1:6379。

分類:redis
由 Compete Themes 設計的 Author 佈景主題