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

What are the common configurations in Redis

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

In this issue, the editor will bring you about the commonly used configurations in Redis. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

Daemonize yes

# specify Redis listening port. The default listening port is 6379. If changed, add-p port to the command line tool login, such as:. / redis-cli-p 6378.

Port 6378

# bound CVM address. 127.0.0.1 means you can only log in locally. You can configure multiple logins to be separated by spaces. If changed, add-h ip address to the command line tool login, such as. / redis-cli-h 49.234.56.234.

Bind 127.0.0.1 49.234.56.234

# set the client link timeout (in seconds). To put it bluntly, the client closes the link without issuing any instructions during this period

Timeout 10

# specify the logging level. Redis supports a total of four levels: debug, verbose, notice, and warning. The default is verbose. Note that the log here is not the same as the aof data log.

Loglevel debug

# the file name of log records, which is generated under the current directory by default

Logfile "redis.log"

# set the number of databases. Default is 16 databases and default is 0. You can use the SELECT command to specify the database id on the connection

Databases 16

# specify the local database storage directory. The default is the current directory. This must be a directory that cannot be a file name.

Dir. /

# # limit related configurations # #

# set redis server access password

Requirepass 123456

# set the maximum number of client connections at the same time. By default, there is no limit. The number of client connections that Redis can open at the same time is the maximum number of file descriptors that can be opened by Redis processes.

# linux command to query the maximum number of file descriptors that a redis process can open: cat / proc/ {redis PID} / limits | grep "Max open files"

Maxclients 100

# specify the maximum memory limit for Redis. 0 means there is no limit. When the maximum memory setting is reached, the write operation can no longer be performed, but the read operation can still be performed.

# query the memory already occupied by the current redis: open the redis client and enter the info instruction to find the used\ _ memory\\ _ human information in it. The following value is the amount of memory occupied by the current data.

Maxmemory 1000K

# # RDB persistence configuration # #

# RDB persistence configuration rules. The first parameter represents the number of seconds, and the second parameter indicates the number of changes. Here, save 601 means that data synchronization will be carried out if there is a data change within 60 seconds.

Save 60 1

Save 50 10

Save 40 10000

# specify whether to enable compression when synchronizing memory data to rdb files. By default, the compression algorithm is LZF. If not, the rdb file data is relatively large, and if compressed, cpu is consumed.

Rdbcompression yes

# specify the local database file name

Dbfilename redis.rdb

# # AOF persistence configuration # #

# whether to enable AOF persistence no: disable yes: enable

Appendonly yes

# AOF the file name of persisted data

Appendfilename "appendonly.aof"

# AOF persistence rule configuration always means that every update is written to the hard disk (slow, but data secure) no and other operating systems synchronize the data cache to disk (for example, synchronization when redis service is turned off) everysec synchronizes once a second

Appendfsync everysec

# # Master / Slave Cluster configuration # #

# check whether the current redis service is a slave library or a master library, open the redis command line tool, and enter the role command to view

# set when the machine is a slave service, set the IP address and port of the master service. When Redis starts, it will automatically synchronize data from the master. For example, here 345.23.251.98 master server and master server redis port 6379 are configured as follows

# earlier version of redis slaveof

Slaveof 345.23.251.98 6379

# higher version of redis replicaof

Replicaof 345.23.251.98 6379

# when the master service is password protected, the password of the slave service connects to the master. For example, the password of the master server is 123456.

Masterauth 123456

# set whether to respond to client requests in master-slave replication. Yes: can respond to client requests no: no response, and return SYNC with master in progress

Slave-serve-stale-data yes

# set whether the slave server is read-only. Yes means the slave server can only do query operations. No means it can be written. If the setting is writable, the slave database has the same key as the master database. When copying actively, the key set from the slave database will be overwritten.

Slave-read-only yes

These are the common configurations in the Redis shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, 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

Internet Technology

Wechat

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

12
Report