Redis: Commands

 

 

 

 

   

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#---------------------------------------------------------------------
# ACL Configuration
#---------------------------------------------------------------------
# redis.conf ~* key正则    &- pub/sub channel   +@ 权限
# +<command> -<command> +@<category> -@<category>
# +@all -@all
user default on >conceive ~* &* +@all
user tenacity on nopass ~* &* +@all

redis-cli -h host -p 6379 [ --user tenaticy --pass random ] | [ -a conceive ]

ACL CAT
ACL LIST
ACL SETUSER ramp on >ramp ~k* +get  # 只能get k开头的keys
ACL GETUSRE ramp
ACL USERS  # 列出users
ACL WHOAMI


#---------------------------------------------------------------------
# commands
#---------------------------------------------------------------------
AUTH username password
CLIENT INFO | LIST
CONFIG SET protected-mode no
CONFIG REWRITE  # make this change permanent
COMMAND DOCS
BGSAVE
BGREWRITEAOF
CONNECT host port  # 连接到不同实例
DBSIZE  # key的总数
LASTSAVE  # Get the UNIX time stamp of the last successful save to disk

INFO [replication]

redis-cli -h 192.168.8.105 -p 6381 --stat
redis-cli -h 192.168.8.105 -p 6381 --hotkeys
redis-cli -h 192.168.8.105 -p 6381 --bigkeys
redis-cli -h 192.168.8.105 -p 6381 --latency


#---------------------------------------------------------------------
# Replication
#---------------------------------------------------------------------
# Master
bind *
port 6380
protected-mode no
user default on >conceive ~* &* +@all
user replica on >replica ~* &* +@all

# Slave
bind *
port 6381
protected-mode no
user default on >conceive ~* &* +@all
user replica on >replica ~* &* +@all
replicaof 192.168.8.105 6380
masteruser "replica"
masterauth "replica"
replica-serve-stale-data no
replica-read-only yes
repl-diskless-sync yes
repl-diskless-sync-delay 0

# Sentinel
bind 0.0.0.0
port 26379
protected-mode no
user default on >conceive ~* &* +@all
user replica on >replica ~* &* +@all
sentinel monitor introspect 192.168.8.105 6381 1
sentinel auth-user introspect replica
sentinel auth-pass introspect replica

# Cluster
port 6361
bind *
protected-mode no
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

# 会在当前执行命令目录生成nodes.conf, 其余节点会启动失败
for b in {1..6};do cd $b; redis-server redis.conf --daemonize yes;cd ..;done

redis-cli --cluster create 192.168.8.105:6361 192.168.8.105:6362 192.168.8.105:6363 \
                           192.168.8.105:6364 192.168.8.105:6365 192.168.8.105:6366 \
                           --cluster-replicas 1

redis-cli --cluster info
redis-cli -c -h host -p port
redis-cli --cluster add-node 192.168.8.105:6367 192.168.8.105:6261

192.168.8.105:6361,192.168.8.105:6362,192.168.8.105:6363,192.168.8.105:6364,192.168.8.105:6365,192.168.8.105:6366

CLUSTER NODES

 

posted @ 2022-05-05 23:51  ascertain  阅读(150)  评论(0编辑  收藏  举报