Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change the configuration of Redis

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article shares with you how to change the configuration of Redis. The editor thought it was very practical, so I shared it with you to learn. The following information is about the use of commands to change the configuration of Redis.

The command will change the behavior of the Redis server only during the current session or until you run it, which config rewrite will make them permanent. You can change the Redis configuration file directly by opening and editing it using your preferred text editor. For example, you can nano to do this:

Sudo nano / etc/redis/redis.conf

Warning: this config set command is considered dangerous. By changing the Redis configuration file, it is possible to cause the Redis server to run unexpectedly or poorly. We recommend that you run the config set test command only if it behaves or if you are absolutely sure that you want to make changes to the Redis configuration.

You may want to rename this command to one that is less likely to run unexpectedly.

Config set allows you to reconfigure Redis at run time without restarting the service. It uses the following syntax:

Config set parameter value

For example, if you want to change the name of the database dump file that Redis will produce after running the save command, you can run the following command:

Config set "dbfilename"new_file.rdb"

If the configuration change is valid, the command returns OK. Otherwise, an error is returned.

Note: not every parameter in the redis.conf file can be changed through the config set operation. For example, you cannot change the authentication password defined by the requirepass parameter.

Make permanent configuration changes

Config set does not permanently change the configuration file of the Redis instance; it only changes the behavior of Redis at run time. To redis.conf edit after running the config-set command and make the configuration of the current session permanent, run config rewrite:

Config rewrite

This command will do its best to preserve the comments and overall structure of the original redis.conf file with minimal changes to match the settings currently used by the server.

Just like config set, config rewrite returns OK if it is rewritten successfully.

Check the configuration of Redis

To read the current configuration parameters of the Redis server, run the config get command. Config get has only one parameter, which can be any one of the parameters used that exactly matches the redis.conf or water droplet pattern. For example:

Config get repl*

Depending on your Redis configuration, this command may return:

Output 1) "repl-ping-slave-period" 2) "10" 3) "repl-timeout" 4) "60" 5) "repl-backlog-size" 6) "1048576" 7) "repl-backlog-ttl" 8) "3600" 9) "repl-diskless-sync-delay" 10) "5" 11) "repl-disable-tcp-nodelay" 12) "no" 13) "repl-diskless-sync" 14) "no"

You can also run config set to return all supported configuration parameters config get *.

The above is the method to change the configuration of Redis introduction, detailed use of their own use to know the specific essentials. If you want to read more related articles, you are welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report