Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Introduction to redis configuration

Shulou Source: shulou.com Published: 2022-06-01 06:48:49 10月03日 Update

Main configuration file: / etc/redis.conf

Daemonize no: do not start with a daemon, but change to yes if you want to start with a daemon

Port:6379/tcp

Bind: the address to be listened to. You must not listen to the public network IP in the production environment, that is, 127.0.0.1.

Timeout: client idle connection timeout. 0 or disable means no timeout. Set it as needed.

Loglevel: define log level

Logfile: log file location

Databases 16: indicates how many databases can be used to store data, if not specifically specified, all in database 0

Tcp-backlog: the length of the waiting queue when the maximum number of connections is reached in a high concurrency environment

Sentinel configuration file: / etc/sentinel.conf

How to use snapshotting:

Save

Within 900s of save 900 1, a key changes and takes a snapshot, which is applied to scenarios where data changes are very small.

Within 300s of save 300 10, 10 key will be snapped if they change.

Save 60 10000: within 60s, if there is a change in 10000 key, the process snapshot should be used in the scenario where the data changes very quickly.

Save "": indicates the persistence mode in which snapshotting (rdb format) is disabled

Dbfilename dump-6379.rdb: sets the name of the file to save when snapshotting is enabled

Dir. /: the location where persistent files (including both rdb and aof) are saved, and. / indicates that they are saved in the current directory

How to configure replication (master-slave):

Slaveof: set the ip and port of master to show who you are from

Slave-read-only: restrict read-only from the server

Slave-priority: if there is more than one slave, specify priority

Limits restrictions:

Maxclients: maximum number of concurrency

Maxmemory: maximum amount of memory allowed on the current host

How to use APPEND ONLY MODE (persistence):

Appendonly no: indicates how to disable the persistence of aof

Appendfilename "appendonly-6379.aof": sets the name of the file to save when appendonly is enabled

Appendfsync always | everysec | no

Always: write to the aof file on disk every time you receive a write command

Everysec: write once per second, no matter how many write requests are received (usually in this way)

No: do not write to disk actively, but let the system decide what to write

Actively trigger aof file to rewrite relevant parameters:

No-appendfsync-on-rewrite no: during rewrite, new write requests are not synchronized to disk, but are only placed in the buffer queue in memory. Yes is recommended to prevent data loss caused by redis crash during rewrite.

Auto-aof-rewrite-percentage 100A bgrewriteaof rewrite occurs when the current aof file size is twice the size of the aof file when it was last rewritten

Auto-aof-rewrite-min-size 64mb: the minimum value to start bgrewriteaof rewriting, that is, when this aof reaches this minimum value, it will be rewritten.

Slow log related:

Slowlog-log-slower-than 10000; the day during which slow logs are recorded in microseconds, that is, 1000000 equals 1 second; a negative number disables slow logs

Slowlog-max-len; records the maximum number of entries that can be stored in a slow query. When the maximum value is reached, it will be deleted on a first-in-first-out basis.

Cluster-related configuration:

Cluster-enabled yes// starts the cluster

Cluster-config-file nodes.conf// saves the file of cluster information

Cluster-node-timeout 5000max / cluster node connection timeout (in milliseconds)

Security-related configuration:

Requirepass: setting authentication password

After entering redis through redis-cli, you must enter the authentication password before you can perform subsequent operations.

Example: requirepass liuzhengwei-- > set the authentication password to liuzhengwei

[root@xuegod63 redis] # redis-cli-h 192.168.2.99

192.168.2.99pur6379 > auth liuzhengwei

OK

Note: redis in production environment cannot be bound to public network IP

Tags: File data method configuration log change cluster maximum password snapshot environment disk process monitor authentication minimum active location memory unit Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Information OPPO Reno Shulou Technology Apple