Xinxing analyzes Server Management in Redis and Xinxing redis

Source: Internet
Author: User
Tags redis server

Xinxing analyzes Server Management in Redis and Xinxing redis

Redis was defined as a service process that can run continuously for a long time at the beginning of the design. Therefore, most system configuration parameters can take effect immediately without restarting. Even if the current persistence mode is switched from AOF to RDB, no restart is required. In Redis, we also have some commands related to server management. We will introduce them as follows:

(1) config get parameter is mainly used to read 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. Unlike redis. conf, the abbreviated number format, such as GB and KB, cannot be used in commands. Only integers representing the number of bytes can be used.

(2) config set parameter value this command is used to reconfigure 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. We can use config get * to check which parameters are supported by this command. If you want to set multiple parameter types in a command, such as in redis. in the configuration file of conf, the save parameter save 900 1/save 300 10. In this command, we can enclose multiple keys/Values in double quotation marks and separate them with spaces, for example, config set save "900 1 300 10 ".

(3) config resetstat: it provides the statistics given by the reset info command. It always returns OK.

(4) dbsize: return the number of keys in the currently opened database.

(5) flushdb clears all keys in the current database.

(6) info gets statistics related to the server running status.

(7) save sets the RDB persistence mode storage policy.

(8) shutdown stops all clients and sets memory data persistence in blocking mode. If AOF mode is enabled, the cached data is flushed to the AOF file and the server is released.

(9) slaveof host port this command is used to modify the replication settings of the slave server. If a Redis server is already in the slave status, the slaveof no one command will disable the replication status of the current server and 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 the slave of another master. 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, if the slaveof no one command is executed on the current slave server, the server only interrupts the replication relationship with the current master and is upgraded to an independent master, the data is not cleared.

(10) slowlog subcommand [argument] This command is mainly used to read commands that have been executed for a long time. The execution time is judged only by the execution time of the command itself, and does not include the time when the network gets angry. There are two main configuration parameters related to this command. The first one is the threshold value between execution, in milliseconds. That is, all commands whose execution time exceeds this value will be saved to the slowlog queue, for command reading. 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. 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. Generally, we can set the parameter "slowlog-log-slower-than" to 0 to collect the execution time of all commands. The command can also contain the following sub-commands:

Slowlog get n: reads command information from the slowlog queue. n indicates the information of the last n commands.

Slowlog len: gets the length of the slowlog queue.

Slowlog reset: clears the content of the slowlog queue.



















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.