Redis: Difference between revisions

From Halfface
Jump to navigation Jump to search
Line 16: Line 16:
  redis-cli keys '*'
  redis-cli keys '*'
=list key type=
=list key type=
  type "zc:k:x2060_MDRJEUPVQD0DC48B"
  type foo
=get hash=
HGETALL foo


=get key value=
=get key value=

Revision as of 14:10, 23 September 2020

Redis

Continues stats.

redis-cli -p $(awk '/^port/ {print $2}' /etc/redis.conf) --stat

Info about redis node.

redis-cli -p 6379 info

Which role does redis have

redis-cli -p 6401 info | grep role
redis-cli -p 6401 role

how many databases exist

redis-cli CONFIG GET databases

list keyspaces with content

redis-cli INFO keyspace

list keys

redis-cli keys '*'

list key type

type foo

get hash

HGETALL foo

get key value

redis-cli get key_name

increment a value. raw output.

redis-cli --raw incr mycounter

Set a key with a value

redis-cli set foo value

Set redis key foo too output from date.

date | redis-cli -x set foo

set a key to a temporary value.

redis-cli set key_name value EX 60

expire key after 10s

EXPIRE foo 10

how long does temporary value still exist.

redis-cli ttl foo

Read content of key foo

redis-cli getrange foo 0 5000

continuasly run command.

redis-cli -r -1 -i 1 INFO | grep total_commands_processed
total_commands_processed:69
total_commands_processed:70

delete a key.

redis-cli del key_name

create list.

redis-cli lpush mylist a b c d e=

read list

redis-cli --csv lrange mylist 0 -1

change database

select 1

how big is database

dbsize

List clients

CLIENT LIST

Listen for all requests received by the server in real time

MONITOR

scanning for big keys

redis-cli --bigkeys

getting list of keys.

redis-cli --scan 

redis-sentinel

Sentinel config files.

/etc/redis-*sentinel.conf

talk to redis sentinel and ask configuration api who is my master.

redis-cli -p 5011 SENTINEL get-master-addr-by-name mymaster

which masters exist.

redis-cli -p 5010 SENTINEL masters

asking sentinel for status of a master.

redis-cli -p 5010 SENTINEL master mymaster

asking sentinel for info about sentinel

redis-cli -p 5010 SENTINEL sentinels mymaster 

ask about replicas.

redis-cli -p 5010 SENTINEL SENTINEL replicas 

Show a list of sentinel instances for this master, and their state.

redis-cli -p 5001 SENTINEL sentinels mymaster

Sentinel logfile.

/var/log/redis/sentinel.log

Look for listening ports.

grep ^port /etc/redis*.conf

read slowlog

SLOWLOG GET