The command
-
PING uses the client to send a PING to the Redis server. If the connection between the client and the server is normal and the server is operating properly, the command will return a PONG, usually used to test the network connection and server status, or to measure latency values
127.0.0.1:6379 > ping PONGCopy the code
-
INFO [section] View various information and statistics of Redis server. You can specify the content of the information to be returned by the command by giving an optional section argument
SECTION parameter values
value Information displayed all All server information Default (Default value) The most common and important server information that is selected by default server Information about the server itself, such as the version number, listening port number, and server ID clients Information about connected clients, such as the number of connected clients, the number of clients that are blocking, and so on memoery Memory information, such as the amount of memory used, memory allocator used, and so on persistence Information related to RDB persistence and AOF persistence, such as whether RDB persistence is in progress, whether AOF file rewriting is in progress, etc stats Server statistics, such as number of command requests processed, number of command requests processed per second, and so on replication Information related to the master/slave replication, such as the role of the server and whether the connection status of the master/slave server is normal cpu System CPU usage and user CPU usage of the server commandstats Command execution statistics, such as the number of commands executed, CPU time consumed by commands, and average CPU time consumed by each command cluster Provides information about the cluster function keyspace Information related to the database key space, such as the number of keys in the database, the number of expired keys that have been deleted from the database, and so on -
MONITOR prints commands received by the Redis server in real time in the format of “timestamp [database number IP address and port number] commands executed
127.0.0.1:6379> MONITOR OK 1567543223.752616 [0 127.0.0.1:34000] "auth" "123456" 1567543225.352941 [0 127.0.0.1:34000] [0 127.0.0.1:34000] "set" "MSG" "hi"Copy the code
Slow query function
The slow query function of Redis is used to record the commands that take longer than the specified time and show the recorded commands to users, so that users can find the commands that run slowly and optimize them accordingly
Slow query function Settings:
- Slowlog-log-than
Slowlog-log-than slower than microseconds commands are recorded. Setting this value to negative indicates that slowquery is disabled. The default is 10000 or 1/100 of a second. Because 1 second is 1 million microseconds
- Slowlog-max-len
Specifies the maximum number of slow query logs. When the number of recorded logs exceeds this value, new logs overwrite old logs (FIFO). The default value is 128
Viewing slow query logs:
-
SLOWLOG GET [number] Returns slow query logs currently recorded by the server. If the optional number argument is given, only a maximum number of logs are returned. Otherwise, all slow query logs are returned
-
SLOWLOG LEN Displays the number of slow query logs
-
SLOWLOG RESET Deletes all slow query logs
Server Password
- By configuring the option requirePass, users can set a password for the serverWhen a client connects to a server with a password, it must execute the AUTH command to unlock it, otherwise the client cannot execute commands other than AUTH
[root@localhost redis-5.0.4]# redis-cli 127.0.0.1:6379> get msg (error) NOAUTH Authentication required. 127.0.0.1:6379> auth 123456 OK 127.0.0.1:6379> get msg "hi" Copy the code
Shut down the server
SHUTDOWN [option]
- If no option parameter is given, the server performs persistence first: if AOF persistence is enabled, then fdatasync is called to ensure that the previously executed command is written to the hard disk. If RDB persistence is enabled and the database has changed, then the SAVE command is executed
When all of the above is done, the server is shut down
- With persistence enabled, no data is lost using the SHUTDOWN command to SHUTDOWN the server. Option The value of option can be save or nosave
SHUTDOWN save: Always run the save command before closing. This command is used to create an RDB file to save data without RDB persistence enabled. Do not run the SAVE command before closing to avoid saving the wrong data to the RDB file in case the database might have failed