Redis learning Manual (Server Management)

Source: Internet
Author: User
Tags redis server

I. Overview:

Redis was defined as a service process that runs continuously for a long time at the beginning of the design. Therefore, most system configuration parameters can take effect immediately without restarting the process. Even switching the current persistence mode from AOF to RDB does not require a restart.
Redis provides a SET of server management-related commands, including the config set/GET command related to parameter settings.

Ii. Related command list:

Command prototype Time Complexity Command description Return Value
CONFIG GETParameter   It is mainly used to read the runtime parameters of the server, but not all configuration parameters can be read through this command. The parameters of this command are subject to glob-style pattern matching rules. Therefore, if the parameter contains the pattern metacharacters, all matched parameters are listed as key/value. If the parameter is *, all parameters supported by this command will be listed. It should be pointed out that, unlike redis. conf, the abbreviated number format, such as GB and KB, cannot be used in the command. Only the integer representing the number of bytes can be used.  
CONFIG SETParameter value   This command is used to re-configure the runtime parameters of the Redis server. After the setting is successful, it takes effect without restarting. However, not all parameters can be dynamically set using this command. If you need to know the parameters supported by this command, you can view the execution result of the config get * command. If you want to set multiple parameters of the same type in a command, such as the save parameter in the redis. conf configuration file:Save 900 1/save 300 10. In this command, we can enclose multiple keys/Values in double quotation marks and separate them with space characters, such:Config set save "900 1 300 10". OK indicates that the setting is successful. Otherwise, related error messages are returned.
CONFIG RESETSTAT O (1) The statistics given by the Reset INFO command. Always Return OK.
DBSIZE   Returns the number of Keys in the currently opened database. The number of keys.
FLUSHALL   Clear all the Keys in the database managed by the current server, not limited to the currently opened database.  
FLUSHDB   Clears all Keys in the current database.  
INFO   Obtains the column statistics related to the server running status.  
SAVE   Set the Save policy for the RDB persistence mode.  
SHUTDOWN   Stop all clients and execute memory data persistence in blocking mode. If AOF mode is enabled, the cached data is flushed to the AOF file. Log out of the server.  
SLAVEOFHost port   This command is used to modify the replication settings of the SLAVE server. If a Redis server is already in the SLAVE status,SLAVEOF NO ONECommand will shut down the current server to be copied, and at the same time switch the server to the MASTER state. The parameter of this command specifies the listening IP address and port of the MASTER server. Another case is that the current server is already another MASTER's SLAVE. After executing this command, the current server will terminate the replication relationship with the previous MASTER, the server Load balancer will become the new MASTER, and the data in the MASTER will be cleared and changed to the data in the new MASTER. However, ifSLAVEOF NO ONECommand, then the server only interrupts the replication relationship with the current MASTER, and upgrades to an independent MASTER, the data will not be cleared.  
SLOWLOGSubcommand [argument]   This command is mainly used to read commands that have been executed for a long time. The execution time is only the execution time of the command, not the network interaction time. There are two main configuration parameters related to this command. The first one is the threshold value between execution (in microseconds). That is, all commands whose execution time exceeds this value are saved to the slowlog queue, for this command to read. The second is the length of the slowlog queue. If the command in the queue is equal to this parameter before the current command is saved, the oldest command in the queue needs to be removed from the queue before the command enters the queue. This ensures that the total memory occupied by the queue is kept in a relatively constant size. Because the slowlog queue will not be persistent to the disk, Redis will not have a great impact on the performance when collecting commands. Usually we can set the parameter"Slowlog-log-slower-"Set to 0 to collect the execution time of all commands. The command also contains the following sub-commands:
1 ).SLOWLOG GET N: Reads command information from the slowlog queue. N indicates the information of the last N commands.
2 ).SLOWLOG LEN: Gets the length of the slowlog queue.
3 ).SLOWLOG RESET: Clears the content in the slowlog.
Finally, the slowlog get command returns information.
Redis 127.0.0.1: 6379> slowlog get 10
1) 1) (integer) 5# Unique identifier. This value must be unique before Redis is restarted.
2) (integer) 1330369320.# Unix Timestamp format indicates the command execution time.
3) (integer) 13# The number of microseconds used for command execution.
4) 1) "slowlog"# Output the collected commands and their parameters in string array format.
2) "reset"
 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.