Redis: Difference between revisions

From Halfface
Jump to navigation Jump to search
Line 46: Line 46:
=getting list of keys.=
=getting list of keys.=
  redis-cli --scan  
  redis-cli --scan  
==redis-sentinel=
==redis-sentinel==


=Sentinel config files.=
=Sentinel config files.=

Revision as of 11:32, 8 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

list keys

echo 'keys *' | redis-cli

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

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