Redis: Difference between revisions

From Halfface
Jump to navigation Jump to search
(Created page with "=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= red...")
 
 
(10 intermediate revisions by the same user not shown)
Line 8: Line 8:
  redis-cli -p 6401 info | grep role
  redis-cli -p 6401 info | grep role
  redis-cli -p 6401 role
  redis-cli -p 6401 role
=how many databases exist=
redis-cli CONFIG GET databases
=list keyspaces with content,list databases with content=
redis-cli INFO keyspace
=list keys=
=list keys=
  echo 'keys *' | redis-cli
  redis-cli keys '*'
=list key type=
type foo
=get hash=
HGETALL foo
 
=get key value=
=get key value=
  redis-cli get key_name
  redis-cli get key_name
Line 20: Line 30:
=set a key to a temporary value.=
=set a key to a temporary value.=
  redis-cli set key_name value EX 60
  redis-cli set key_name value EX 60
=expire key after 10s=
EXPIRE foo 10
=how long does temporary value still exist.=
=how long does temporary value still exist.=
  redis-cli ttl foo
  redis-cli ttl foo
=Read content of key foo=
=Read content of key foo=
  redis-cli getrange foo 0 5000
  redis-cli getrange foo 0 5000
Line 30: Line 43:
=delete a key.=
=delete a key.=
  redis-cli del key_name
  redis-cli del key_name
=flushdb=
Delete all the keys of the currently selected DB.
redis-cli ; select
=create list.=
=create list.=
  redis-cli lpush mylist a b c d e=
  redis-cli lpush mylist a b c d e=
Line 46: Line 63:
=getting list of keys.=
=getting list of keys.=
  redis-cli --scan  
  redis-cli --scan  
==redis-sentinel-=
==redis-sentinel==
 
=Sentinel config files.=
=Sentinel config files.=
  /etc/redis-*sentinel.conf
  /etc/redis-*sentinel.conf
Line 65: Line 83:
=Look for listening ports.=
=Look for listening ports.=
  grep ^port /etc/redis*.conf
  grep ^port /etc/redis*.conf
=read slowlog=
SLOWLOG GET
=redis-cli with password=
redis-cli -h 127.0.0.1 -p 6379 -a 'thisizmy!PASS'

Latest revision as of 12:57, 29 March 2022

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,list databases 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

flushdb

Delete all the keys of the currently selected DB.

redis-cli ; select

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

redis-cli with password

redis-cli -h 127.0.0.1 -p 6379 -a 'thisizmy!PASS'