Redis - The common commands

Chaotic form, mainly in order to record some of the usual operation, the learning process;
1, check the number of
127.0.0.1:6379> The dbsize
(Integer). 6
2, aof manually override file
127.0.0.1:6379> bgrewriteaof
Background File rewriting the append only Started
3, save log aof, this command will block other operations, recommended bgsave
127.0.0.1:6379> the save
the OK
4, view the last saved time
127.0.0.1:6379> LASTSAVE
(Integer) 1,561,370,112
5, backstage way to save
127.0.0.1:6379> bgsave
Background Saving Started
127.0.0.1:6379> LASTSAVE
(Integer) 1561370140
. 6, the current connection flushdb cleaning DB
flushall clear all DB
. 7, the command info display detailed information, such as information Memory
used_memory: 1928448 spatial data structure
used_memory_rss: 8679424 real space-
mem_fragmentation_ratio: 2 ratio of 4.50 were before, 1.n best, if this value is particularly large, indicating redis severe memory fragmentation, you can export and then import again.

role:master
connected_slaves:2
slave0:ip=127.0.0.1,port=6380,state=online,offset=567100,lag=0
slave1:ip=127.0.0.1,port=6381,state=online,offset=567100,lag=0

Stats-fork information
latest_fork_usec: 2506 Last rdb export snapshots, persistent spending microseconds, note that if there is an instance 10G content, export 2 minutes, every minute written 10,000 times, resulting in constant rdb export, has been in disk IO higher status.

8, slow log slowlog
1, how long is the slow?
slowlog-log-slower-than 10000 to specify, in microseconds

设置方式:
127.0.0.1:6379> config get slowlog-log-slower-than
1) "slowlog-log-slower-than"
2) "10000"
127.0.0.1:6379> config set slowlog-log-slower-than 100
OK
127.0.0.1:6379> config get slowlog-log-slower-than
1) "slowlog-log-slower-than"
2) "100"

2, the log server stores how many slow
slowlog-max-len 128 is restricted.

3,查看慢日志
127.0.0.1:6379> slowlog get
1) 1) (integer) 2
2) (integer) 1561442704
3) (integer) 131
4) 1) "keys"
2) "*"
2) 1) (integer) 1
2) (integer) 1561442666
3) (integer) 105
4) 1) "config"
2) "get"
3) "slowlog-log-slower-than"
3) 1) (integer) 0
2) (integer) 1561370112
3) (integer) 20647
4) 1) "save"

Guess you like

Origin blog.51cto.com/yangjunfeng/2413183