In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
How is redis configured? This problem may be our daily study or work often see. I hope you learned something from this question. The following is the reference content brought to you by Xiaobian. Let's take a look together!
The Redis configuration file is located in the Redis installation directory and is called reddis.conf(Windows name is reddis.windows.conf).
You can view or set configuration items with the CONFIG command.
The Redis CONFIG command format is as follows:
redis 127.0.0.1:6379> CONFIG GET CONFIG_SETTING_NAME
Examples:
redis 127.0.0.1:6379> CONFIG GET loglevel "loglevel" "notice"
Use * to get all configuration items:
Examples:
redis 127.0.0.1:6379> CONFIG GET * "dbfilename" "dump.rdb" "requirepass" "" "masterauth" "" "unixsocket" "" "logfile" "" "pidfile" "/var/run/redis.pid" "maxmemory" "0" "maxmemory-samples" "3" "timeout" "0" "tcp-keepalive" "0" "auto-aof-rewrite-percentage" "100" "auto-aof-rewrite-min-size" "67108864" "hash-max-ziplist-entries" "512" "hash-max-ziplist-value" "64" "list-max-ziplist-entries" "512" "list-max-ziplist-value" "64" "set-max-intset-entries" "512" "zset-max-ziplist-entries" "128" "zset-max-ziplist-value" "64" "hll-sparse-max-bytes" "3000" "lua-time-limit" "5000" "slowlog-log-slower-than" "10000" "latency-monitor-threshold" "0" "slowlog-max-len" "128" "port" "6379" "tcp-backlog" "511" "databases" "16" "repl-ping-slave-period" "10" "repl-timeout" "60" "repl-backlog-size" "1048576" "repl-backlog-ttl" "3600" "maxclients" "4064" "watchdog-period" "0" "slave-priority" "100" "min-slaves-to-write" "0" "min-slaves-max-lag" "10" "hz" "10" "no-appendfsync-on-rewrite" "no" "slave-serve-stale-data" "yes" "slave-read-only" "yes" "stop-writes-on-bgsave-error" "yes" "daemonize" "no" "rdbcompression" "yes" "rdbchecksum" "yes" "activerehashing" "yes" "repl-disable-tcp-nodelay" "no" "aof-rewrite-incremental-fsync" "yes" "appendonly" "no" "dir" "/home/deepak/Downloads/redis-2.8.13/src" "maxmemory-policy" "volatile-lru" "appendfsync" "everysec" "save" "3600 1 300 100 60 10000" "loglevel" "notice" "client-output-buffer-limit" "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60" "unixsocketperm" "0" "slaveof" "" "notify-keyspace-events" "" "bind" ""
edit the configuration
You can modify the configuration by modifying the redis.conf file or by using the CONFIG set command.
syntax
CONFIG SET command basic syntax:
redis 127.0.0.1:6379> CONFIG SET CONFIG_SETTING_NAME NEW_CONFIG_VALUE
Examples:
redis 127.0.0.1:6379> CONFIG SET loglevel "notice"OKredis 127.0.0.1:6379> CONFIG GET loglevel "loglevel" "notice"
The redis.conf configuration entry is described as follows:
1、daemonize no
Redis does not run as a daemon by default. It can be modified through this configuration item. Use yes to enable daemons (Windows does not support daemon threads. Configuration is no).
2、pidfile /var/run/redis.pid
When Redis runs as a daemon, Redis writes pid to the file/var/run/redis.pid by default, which can be specified via pidfile.
3、port 6379
Specify Redis listening port, default port is 6379, the author explained in his own blog post why 6379 as the default port, because 6379 on the phone button corresponding to the number MERZ, and MERZ from the Italian singer Alessia Merz name
4、bind 127.0.0.1
bound host address
5、timeout 300
How long does the client idle before closing the connection? If specified as 0, it means closing the function.
6、loglevel notice
Specify the logging level. Redis supports four levels: debug, verbose, notice, warning, default is notice
7、logfile stdout
Logging mode, default is standard output, if Redis is configured to run as a daemon, and here is configured to log as standard output, then the log will be sent to/dev/null
8、databases 16
Set the number of databases, default database is 0, you can use SELECT command to specify database id on the connection
9、save
The Redis default configuration file provides three conditions:
save 900 1
save 300 10
save 60 10000
1 change in 900 seconds (15 minutes), 10 changes in 300 seconds (5 minutes), and 10000 changes in 60 seconds.
Specifies how many updates occur over a period of time to synchronize data to a data file, which can be matched by multiple conditions
10、rdbcompression yes
Specify whether to compress data when storing to local database, default is yes, Redis uses LZF compression, if to save CPU time, you can turn off this option, but it will cause database files to become huge
11、dbfilename dump.rdb
Specifies the local database file name, the default is dump.rdb
12、dir ./
Specify the directory where the local database resides
13、slaveof
Set the IP address and port of the master service when this machine is slav service. When Redis starts, it will automatically synchronize data from the master.
14、masterauth
When the master service is password protected, the slav service connects to the master password
15、requirepass foobared
Set the Redis connection password. If the connection password is configured, the client needs to provide the password through the AUTH command when connecting to Redis. It is closed by default.
16、maxclients 128
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 Redis can open. If maxclients 0 is set, it means there is no limit. When the client connection limit is reached, Redis closes the new connection and returns the max number of clients reached error message to the client.
17、maxmemory
Specify the maximum memory limit of Redis. Redis loads data into memory at startup. After reaching the maximum memory, Redis will first try to clear expired or expiring keys. When this method is processed, it still reaches the maximum memory setting. Write operations cannot be performed, but read operations can still be performed. Redis 'new vm mechanism will store Key in memory and Value in swap area
18、appendonly no
Specifies whether to log after each update operation. Redis writes data to disk asynchronously by default, and if not turned on, may cause data loss for a period of time during a power outage. Because redis itself synchronizes data files according to the above save condition, some data will only exist in memory for a period of time. default is no
19、appendfilename appendonly.aof
Specifies the update log file name, default is appendonly.aof
20、appendfsync everysec
Specifies the update log criteria, with 3 optional values:
no: indicates that the operating system synchronizes the data cache to disk (fast) always: indicates that fsync() is manually called after each update operation to write data to disk (slow, safe) everysec: indicates synchronization once per second (compromise, default)
21、vm-enabled no
Specify whether to enable the virtual memory mechanism, the default value is no, a brief introduction, VM mechanism will page data storage, by Redis will access less pages, that is, cold data swap to disk, access more pages from disk automatically swapped out to memory (in the following articles I will carefully analyze Redis VM mechanism)
22、vm-swap-file /tmp/redis.swap
Virtual memory file path, default value is/tmp/redis.swap, multiple Redis instances cannot be shared
23、vm-max-memory 0
Store all data greater than vm-max-memory in virtual memory, no matter how small vm-max-memory is set, all index data is stored in memory (Redis index data is keys), that is, when vm-max-memory is set to 0, all values actually exist on disk. The default value is 0
24、vm-page-size 32
Redis swap file is divided into many pages, an object can be saved on multiple pages, but a page cannot be shared by multiple objects, vm-page-size is to be set according to the size of the stored data, the author suggests that if you store a lot of small objects, the page size is best set to 32 or 64bytes; if you store a lot of large objects, you can use a larger page, if you are not sure, use the default value
25、vm-pages 134217728
Set the number of pages in a swap file. Since page tables (a bitmap indicating free or used pages) are stored in memory, every eight pages on disk consumes 1 byte of memory.
26、vm-max-threads 4
Set the number of threads accessing the swap file, preferably not more than the number of cores on the machine. If set to 0, all operations on the swap file are serial, which may cause a long delay. default value is 4
27、glueoutputbuf yes
Set whether to merge smaller packets into one packet when replying to the client. Default is ON
28、hash-max-zipmap-entries 64hash-max-zipmap-value 512
Specifies that a special hash algorithm is used when more than a certain number or the largest element exceeds a certain threshold
29、activerehashing yes
Specifies whether to activate reset hash, default is on (described later in detail when introducing Redis hash algorithm)
30、include /path/to/local.conf
Specify to include other profiles. You can use the same profile across multiple Redis instances on the same host, while each instance has its own specific profile.
Thank you for reading! After reading the above, do you know how to configure redis? I hope the content of this article is helpful to everyone. If you want to know more about related articles, please pay attention to 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.