CentOS 8
Sponsored Link

Redis 5 : Basic Operation for Server2019/11/29

This is the Basic Usage of Redis with [redis-cli] client program.
Following examples are basic one, you can see more commands on Official Site below.
⇒ https://redis.io/commands
[1] Connect to Redis Server like follows.
# connect to local Redis server

[root@www ~]#

# authenticate ⇒ specify [password] you set in [redis.conf]> auth password 

# exit from connection> quit 

# connect with password and database ID
# -a [password] -n [database ID]
# -a [password] on terminal is not safe, so warnings is shown
# if database ID is not specified, connect to database ID [0]
[root@www ~]# redis-cli -a password -n 1 
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.

# change to Database-ID [2][1]> select 2 

# to connect to Redis on another Host, specify [-h (hostname)]
[root@www ~]# redis-cli -h node01.srv.world -a password 

# possible to get results with non-interactively with redis-cli
# for example, set and get Value of a Key
[root@www ~]# redis-cli -a password set key01 value01 
[root@www ~]# redis-cli -a password get key01 
[2] This is the basic Usage of control Redis Server itself.
[root@www ~]#
redis-cli> auth password 

# refer to statics> info 
# Server
os:Linux 4.18.0-80.7.1.el8_0.x86_64 x86_64

# show connected clients now> client list 
id=6 addr= fd=7 name= age=115 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=26 qbuf-free=32742 obl=0 oll=0 omem=0 events=r cmd=client
id=7 addr= fd=8 name= age=9 idle=5 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=info

# kill connection of a client> client kill 

# dump all requests after the command below> monitor 
1469078099.850114 [0] "get" "key01"
1469078112.319154 [0] "set" "key02" "value02"

# save data on disk on foreground> save 

# save data on disk on background> bgsave 
Background saving started

# get UNIX time stamp of the last save to disk> lastsave 
(integer) 1574926575

# save data on disk and shutdown Redis> shutdown 
not connected> quit 

[root@www ~]# ps aux | grep [r]edis 

Matched Content