Redis is defined as a service process that can run for a long time at the beginning of the design, so most system configuration parameters can take effect immediately without restarting. Even if the current persistence mode switches from aof to RDB, there is no need to restart. In Redis, we also have some commands related to server management, which we introduce as follows:
(1) The config get parameter is primarily used to read the runtime parameters of the server, but not all configuration parameters can be read by the command. The parameters of the command accept Glob-style pattern matching rules, so if the parameters contain pattern metacharacters, then all matching parameters will be listed in Key/value mode. If the argument is *, all parameters supported by the command will be listed. Unlike redis.conf, the number of abbreviated formats, such as GB, KB, and so on, cannot be used in a command, only integers that represent the number of bytes are used.
(2) config set parameter value the command is used to reconfigure the run-time parameters of the Redis server and can take effect without restarting after the setup is successful. However, not all parameters can be dynamically set by this command, and we can see which parameters the command supports by using config get *. If you want to set multiple parameter types in a command, such as the save parameter in a configuration file in redis.conf save 1/save 300 10, in which we can enclose multiple key/value in double quotes and then separate them with spaces, such as Confi G Set Save "900 1 300 10".
(3) Config Resetstat it gives the statistics given by the Reset Info command, which always returns OK.
(4) Dbsize returns the number of keys in the currently open database.
(5) Flushdb clears all keys in the current database.
(6) Info gets some statistics related to the health of the server.
(7) Save policy to set the RDB persistence mode.
(8) Shutdown stops all clients and sets memory data persistence in a blocking manner. If the AOF mode is enabled, the data in the cache is flush to the AOF file and the server is rolled out.
(9) Slaveof host Port This command modifies the replication settings for the slave server. If a Redis server is already in the slave state, the slaveof no one command will shut down the current server's replicated state while switching the server to the master state. The parameters of this command will establish the listening IP and port of the master server. In another case, the current server is already another master's slave, after executing the command, the current server will terminate the replication relationship with the previous master, and will become the new master slave, before the data in master will be emptied, Change to the data in the new master. However, if the slaveof no one command is executed on the current slave server, the server simply interrupts the replication relationship with the current master and is upgraded to a standalone master, where the data is not emptied.
(ten) Slowlog subcommand [argument] The command is primarily used to read commands that take longer to execute. The evaluation of the execution time is only the execution time of the command itself, and does not include the better rage time of the network. The configuration parameters associated with the command are mainly two, the first is the threshold between execution, in milliseconds, that is, the execution time exceeds the value of the command will be stored in the Slowlog queue for the command to read. The second is the length of the Slowlog queue, and the oldest command in the queue needs to be moved out of the queue before the command enters, if the command in the queue already equals this parameter before the current command is deposited. This ensures that the total amount of memory occupied by the queue remains at a relatively constant size. Because slowlog queues are not persisted to disk, Redis does not have a significant impact on performance when collecting commands. Usually we can set the parameter "Slowlog-log-slower-than" to 0 to collect the execution time of all the commands. The command can also contain several subcommands:
Slowlog get N: reads command information from the Slowlog queue, where n represents the information for the most recent n command.
Slowlog Len: Gets the length of the Slowlog queue.
Slowlog Reset: Empties the contents of the Slowlog queue.
Sinsing Analysis of server Management in Redis