Redis Server Configuration

Source: Internet
Author: User
Tags unsupported redis server

Configuration Options
The redis server provides some configuration options. By modifying the values of these options, you can change the functions of the options.
For example, by default, the redis server creates sixteen databases ranging from 0 to 15 for your use.
However, the number of databases on the redis server is not static. redis provides the databases option, which defaults to 16. By modifying the value of this option, we can ask the server to create a specified number of databases, such as 5, 10, 32, and 100.
For another example, when we introduced the Lua script, we once said that if the running time of a script is too long, you can use the script kill command to force the script to stop, the value of the LUA-time-limit option determines the maximum number of milliseconds that the script can run without interruption. If the value of this option is 5000, then, the server will begin to accept the script kill command only after the script running time exceeds 5000 milliseconds, allowing the user to end the running script. If necessary, you can reduce or increase the value of this option.

Modify the value of the option (1): by specifying the Parameter
Redis provides three methods to modify the value of configuration options.
The first method is to set a value for the configuration options by specifying parameters when starting the server. The format is:
$ Redis-server -- <option1> <value1> -- <option2> <value2> -- <option3> <value3>...
For example, if the following parameters are specified to start the redis server, the server will create 32 databases:
$ Redis-server -- databases 32
Given the following parameters, the server can create 100 databases and set the server port to 10086:
$ Redis-server -- databases 100 -- Port 10086

Modify the option value (2): by specifying the configuration file
The second method for modifying the configuration option value is to record the configuration options and option values to be modified in a configuration file, and let the server load the configuration file when starting the server. Format:
$ Redis-server <path-to-config-File>
For example, we can create a configuration file redis. conf that contains the following content:
Databases 128
Port 10086
When the server is started, let the server load the file:
$ Redis-server redis. conf
Then, the started server will create 128 databases and use port 10086 to listen to client connection requests.

Modify the value of the option (3): Use the config commands
Both methods can only modify the value of configuration options when the server is started. By using the config commands, You can dynamically modify the value of the options when the server is running, you can also use the command to obtain the current value of the option.
You can use the config GET command to obtain the current value of the option. The format of this command is:
Config get <option>
For example, run the following command to return the maximum normal execution time of the Lua script currently set on the server:
Redis> config get LUA-time-limit
1) "LUA-time-limit"
2) "5000"

Modify the value of the option (3): Use the config commands
You can use the config set command to modify the value of the configuration option. The format of this command is:
Config set <option> <value>
For example, run the following command to change the maximum normal execution time of the Lua script from 5000 to 3000:
Redis> config set LUA-time-limit 3000
OK
Run the config GET command to check whether the setting is successful:
Redis> config get LUA-time-limit
1) "LUA-time

Config set considerations (1/2)
When using config set, note that not all configuration options can be set dynamically during server running. Some configuration options must be set at server startup.
For example, because database creation is performed at server startup, the number of databases must be specified at server startup. During server running, it is not feasible to try to use config set to modify the number of databases:
Redis> config set databases 100
(Error) Err unsupported config parameter: Databases
Another example is the listening port number used by the server. This option cannot be set even if the server is already running:
Redis> config set port 10086
(Error) Err unsupported config parameter: Port

Config set considerations (2/2)
In config set, the option value set by config set takes effect only when the server is running. Once the server is shut down, the option value set by config set is lost.
For example, the default value of the LUA-time-limit option is 5000. Although you can change the value of the option to 3000 through config set LUA-time-limit 3000, however, this modification will only be valid in the current running of the server. Once the server is shut down and restarted, the value of the luatime-limit option will be changed back to the default value of 5000.
Redis> config set LUA-time-limit 3000
OK
Redis> config get LUA-time-limit
1) "LUA-time-limit"
2) "3000"
Redis> config get LUA-time-limit # Run the command after restarting the server
1) "LUA-time-limit"
2) "5000"

Config rewrite command
If the server loads the configuration file at startup and uses config set to modify the value of configuration options during server running, you can run the config rewrite command to write the modified configuration options and their values to the configuration file.
For example, if the server is started with a configuration file containing the following content:
Databases 32
Lua-time-limit 5000
If the user executes the config set LUA-time-limit 3000 command while the server is running and intends to record the modification to the configuration file, then, you can run the config rewrite command to modify the content of the configuration file:
Databases 32
Lua-time-limit 3000
In this way, the server will continue to set the maximum normal running time of the Lua script to 3000 milliseconds when the configuration file is started and loaded next time.

 

Configuration Options
Three methods for setting configuration options:
1. When the server is started, it is set by parameters in the format of $ redis-server -- <option> <value>.
2. When the server is started, you can specify the configuration file in the format of $ redis-server <path-to-config-File>.
3. When the server is running, use the config set <option> <value> command.
Note that not all configuration options can be modified using config set. Some options can only be set when the server is started, and config rewrite is not used, the option value set in config set is lost after the server is disabled.
Use the config get <option> command to obtain the current value of the configuration option. If the server loads the configuration file at startup and you use config set to modify the values of some options during server running, you only need to use the config rewrite command, you can record the configuration set changes to the configuration file so that the server can be used at the next startup.

Redis Server Configuration

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.