Redis has several commands that allow you to change the configuration settings of your Redis server on the fly. This tutorial will introduce some of these commands and explain how to make these configuration changes permanent.
How to use this guide
This guide is written as a cheat sheet with complete examples. We encourage you to skip to any section that is relevant to the task you want to complete.
The commands shown in this guide were tested on an Ubuntu 18.04 server running Redis version 4.0.9. To set up a similar environment, you can follow step 1 of our guide How to install and secure Redis on Ubuntu 18.04. We will demonstrate the behavior of these commands by running them using the Redis command line interface. Note that if you use another Redis interface (such as Redli), the exact output of some commands may vary.
Please note that hosted Redis databases generally do not allow users to change configuration files. If you are using DigitalOcean's managed database, the commands outlined in this guide will cause errors.
Change the configuration of Redis
The commands outlined in this section will only change the behavior of the Redis server during the current session or until you run config rewrite which will make them permanent. You can change it directly by opening and editing the Redis configuration file with your preferred text editor. For example, you can nano do this:
sudo nano /etc/redis/redis.conf
WARNING: This config set command is considered dangerous. By changing the Redis configuration files, it is possible to cause the Redis server to behave in an unexpected or undesirable manner. We recommend running the config set command only when testing the command's behavior or when you are absolutely sure you want to make changes to your Redis configuration.
You may want to rename this command to one that is less likely to be run accidentally.
The config set allows you to reconfigure Redis at runtime 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 a command like this:
config set "dbfilename" "new_file.rdb"
If the configuration changes are valid, The command will return OK. Otherwise an error will be 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.
Making configuration changes permanently
The config set does not permanently change the configuration file of the Redis instance; it only changes the behavior of Redis at runtime. To edit redis.conf after running the config-set command and make the current session's configuration permanent, run config rewrite:
config rewrite
This command will do its best to preserve the comments and entirety of the original redis.conf file structure with minimal changes required to match the settings currently used by the server.
Just like config set, config rewrite will return OK if the rewrite is successful.
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 an exact match of either of the parameters used in redis.conf or glob 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 return all supported config set by running Configuration parameters config get *.
Related references:Redis Tutorial
The above is the detailed content of How to modify the redis configuration through the command line. For more information, please follow other related articles on the PHP Chinese website!

Redis是现在最热门的key-value数据库,Redis的最大特点是key-value存储所带来的简单和高性能;相较于MongoDB和Redis,晚一年发布的ES可能知名度要低一些,ES的特点是搜索,ES是围绕搜索设计的。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了关于redis的一些优势和特点,Redis 是一个开源的使用ANSI C语言编写、遵守 BSD 协议、支持网络、可基于内存、分布式存储数据库,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis Cluster集群收缩主从节点的相关问题,包括了Cluster集群收缩概念、将6390主节点从集群中收缩、验证数据迁移过程是否导致数据异常等,希望对大家有帮助。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis实现排行榜及相同积分按时间排序,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,希望对大家有帮助。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了关于原子操作中命令原子性的相关问题,包括了处理并发的方案、编程模型、多IO线程以及单命令的相关内容,下面一起看一下,希望对大家有帮助。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了bitmap问题,Redis 为我们提供了位图这一数据结构,位图数据结构其实并不是一个全新的玩意,我们可以简单的认为就是个数组,只是里面的内容只能为0或1而已,希望对大家有帮助。

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis实现排行榜及相同积分按时间排序,本文通过实例代码给大家介绍的非常详细,下面一起来看一下,希望对大家有帮助。

redis error就是redis数据库和其组合使用的部件出现错误,这个出现的错误有很多种,例如Redis被配置为保存数据库快照,但它不能持久化到硬盘,用来修改集合数据的命令不能用。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.