ACL Users & Cluster Operations
Manage ACL users, redis-check tools, and cluster resharding.
Code
# --- ACL (Redis 6+) ---
127.0.0.1:6379> ACL WHOAMI # current user
127.0.0.1:6379> ACL LIST # all users (with rules)
127.0.0.1:6379> ACL GETUSER default
127.0.0.1:6379> ACL SETUSER alice on >alicepass ~user:* +get +set +del
127.0.0.1:6379> ACL SETUSER alice +@read -@dangerous # category-based
127.0.0.1:6379> ACL DELUSER alice
127.0.0.1:6379> ACL LOG # security events (denied commands)
127.0.0.1:6379> ACL SAVE # persist to users.acl (with CONFIG REWRITE)
# --- Cluster (Redis Cluster) ---
127.0.0.1:6379> CLUSTER INFO # cluster state, slots, size
127.0.0.1:6379> CLUSTER NODES # all nodes (id, addr, flags, slots)
127.0.0.1:6379> CLUSTER MYID
127.0.0.1:6379> CLUSTER COUNTKEYSINSLOT 1234
127.0.0.1:6379> CLUSTER KEYSLOT mykey # which slot a key hashes to
# Cluster mode CLI auto-routes by keyslot (-c)
$ redis-cli -c -h cluster.example.com -p 7000 SET foo bar
# (redirected to the slot owner automatically)
# Add a node, reshard (manual or with the helper)
$ redis-cli --cluster create node1:7000 node2:7000 node3:7000 --cluster-replicas 1
$ redis-cli --cluster reshard node1:7000 \
--cluster-from <src-node-id> --cluster-to <dst-node-id> \
--cluster-slots 1000 --cluster-yes
# Offline repair / inspection
$ redis-check-rdb /var/lib/redis/dump.rdb
$ redis-check-aof --fix /var/lib/redis/appendonly.aofExplanation
ACL (Redis 6+) replaces the single-password model with named users, each with rules: on/off, >password (set password), ~pattern (key globs allowed), +command/-command, +@category/-@category (e.g. +@read, -@dangerous). ACL LOG shows denied commands — great for tightening least privilege safely. CLUSTER INFO/NODES inspect cluster state and slot ownership; CLUSTER KEYSLOT shows the CRC16 hash slot for a key. Use redis-cli -c to auto-follow MOVED/ASK redirects across nodes. --cluster create/reshard/fixup handle topology changes. redis-check-rdb and redis-check-aof validate (and can repair) corrupted persistence files offline.
More Redis CLI Snippets
Connecting: URLs, TLS, AUTH & Select
Connect to standalone, TLS, authenticated, or non-default DB indexes.
Interactive Mode, HELP & Inspecting
Navigate the REPL, discover commands, and introspect the server.
MULTI / EXEC / WATCH (Transactions)
Queue commands atomically and use optimistic locking with WATCH.
Pub/Sub: SUBSCRIBE, PUBLISH & PSUBSCRIBE
Fan-out messaging with channels and pattern subscriptions.
MONITOR, SLOWLOG & Latency Debugging
Watch every command in real time and find slow queries.
EVAL, Lua & Function Stats (Server-side Scripting)
Run atomic server-side Lua scripts; load and call functions.