1. 基礎說明
# Redis configuration file example. # # Note that in order to read the configuration file, Redis must be # started with the file path as first argument: # # ./redis-server /path/to/redis.conf # Note on units: when memory size is needed, it is possible to specify # it in the usual form of 1k 5GB 4M and so forth: # # 1k => 1000 bytes # 1kb => 1024 bytes # 1m => 1000000 bytes # 1mb => 1024*1024 bytes # 1g => 1000000000 bytes # 1gb => 1024*1024*1024 bytes # # units are case insensitive so 1GB 1Gb 1gB are all the same.
明確了 啟動方式,必須指定引數(檔案)
Note that in order to read the configuration file, Redis must be
started with the file path as first argument
例如 ./redis-server /path/to/redis.conf
另外,也說明了記憶體配置時,用到的大小單位,且單位是大小不敏感的。
2. INCLUDES
################################## INCLUDES ################################### # Include one or more other config files here. This is useful if you # have a standard template that goes to all Redis servers but also need # to customize a few per-server settings. Include files can include # other files, so use this wisely. ....
指定要在當前配置檔案中包含的配置檔案。這樣做的目的便於對配置資訊的管理:可以將不同場景的配置進行單獨的定義,然後在當前核心配置檔案中根據不同場景選擇包含進來不同的配置檔案。
3.MODULES
################################## MODULES ##################################### # Load modules at startup. If the server is not able to load modules # it will abort. It is possible to use multiple loadmodule directives. # # loadmodule /path/to/my_module.so # loadmodule /path/to/other_module.so # loadmodule /path/to/args_module.so [arg [arg ...]]
Redis 配置檔案中可以透過載入不同的第三方模組,來增強、擴充套件Redis的功能
4.網路NETWORK
################################## NETWORK ##################################### # By default, if no "bind" configuration directive is specified, Redis listens # for connections from all available network interfaces on the host machine. # It is possible to listen to just one or multiple selected interfaces using # the "bind" configuration directive, followed by one or more IP addresses. # Each address can be prefixed by "-", which means that redis will not fail to # start if the address is not available. Being not available only refers to # addresses that does not correspond to any network interface. Addresses that # are already in use will always fail, and unsupported protocols will always BE # silently skipped. # # Examples: # # bind 192.168.1.100 10.0.0.1 # listens on two specific IPv4 addresses # bind 127.0.0.1 ::1 # listens on loopback IPv4 and IPv6 # bind * -::* # like the default, all available interfaces # # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the # internet, binding to all the interfaces is dangerous and will expose the # instance to everybody on the internet. So by default we uncomment the # following bind directive, that will force Redis to listen only on the # IPv4 and IPv6 (if available) loopback interface addresses (this means Redis # will only be able to accept client connections from the same host that it is # running on). # # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES # COMMENT OUT THE FOLLOWING LINE. # # You will also need to set a password unless you explicitly disable protected # mode. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bind 127.0.0.1 -::1 # By default, outgoing connections (from replica to master, from Sentinel to # instances, cluster bus, etc.) are not bound to a specific local address. In # most cases, this means the operating system will handle that based on routing # and the interface through which the connection goes out. # # Using bind-source-addr it is possible to configure a specific address to bind # to, which may also affect how the connection gets routed. # # Example: # # bind-source-addr 10.0.0.1 # Protected mode is a layer of security protection, in order to avoid that # Redis instances left open on the internet are accessed and exploited. # # When protected mode is on and the default user has no password, the server # only accepts local connections from the IPv4 address (127.0.0.1), IPv6 address # (::1) or Unix domain sockets. # # By default protected mode is enabled. You should disable it only if # you are sure you want clients from other hosts to connect to Redis # even if no authentication is configured. protected-mode yes # Redis uses default hardened security configuration directives to reduce the # attack surface on innocent users. Therefore, several sensitive configuration # directives are immutable, and some potentially-dangerous commands are blocked. # # Configuration directives that control files that Redis writes to (e.g., 'dir' # and 'dbfilename') and that aren't usually modified during runtime # are protected by making them immutable. # # Commands that can increase the attack surface of Redis and that aren't usually # called by users are blocked by default. # # These can be exposed to either all connections or just local ones by setting # each of the configs listed below to either of these values: # # no - Block for any connection (remain immutable) # yes - Allow for any connection (no protection) # local - Allow only for local connections. Ones originating from the # IPv4 address (127.0.0.1), IPv6 address (::1) or Unix domain sockets. # # enable-protected-configs no # enable-debug-command no # enable-module-command no # Accept connections on the specified port, default is 6379 (IANA #815344). # If port 0 is specified Redis will not listen on a TCP socket. port 6379 # TCP listen() backlog. # # In high requests-per-second environments you need a high backlog in order # to avoid slow clients connection issues. Note that the Linux kernel # will silently truncate it to the value of /proc/sys/net/core/somaxconn so # make sure to raise both the value of somaxconn and tcp_max_syn_backlog # in order to get the desired effect. tcp-backlog 511 # Unix socket. # # Specify the path for the Unix socket that will be used to listen for # incoming connections. There is no default, so Redis will not listen # on a unix socket when not specified. # # unixsocket /run/redis.sock # unixsocketperm 700 # Close the connection after a client is idle for N seconds (0 to disable) timeout 0 # TCP keepalive. # # If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence # of communication. This is useful for two reasons: # # 1) Detect dead peers. # 2) Force network equipment in the middle to consider the connection to be # alive. # # On Linux, the specified value (in seconds) is the period used to send ACKs. # Note that to close the connection the double of the time is needed. # On other kernels the period depends on the kernel configuration. # # A reasonable value for this option is 300 seconds, which is the new # Redis default starting with Redis 3.2.1. tcp-keepalive 300 # Apply OS-specific mechanism to mark the listening socket with the specified # ID, to support advanced routing and filtering capabilities. # # On Linux, the ID represents a connection mark. # On FreeBSD, the ID represents a socket cookie ID. # On OpenBSD, the ID represents a route table ID. # # The default value is 0, which implies no marking is required. # socket-mark-id 0
說明:
(1) bind 127.0.0.1(IPv4 本地表示方法) -::1(
IPv6 本地表示方法
);
預設的只能直接本地訪問
(2)
protected-mode yes : 受保護模式, 開啟, 保證安全性;預設的只能直接本地訪問
(3)port: 指定埠號
(4)tcp-backlog:
在linux系統中控制tcp三次握手已完成連線佇列的長度。
在高併發系統中,通常需要設定一個較高的tcp-backlog來避免客戶端連線速度慢的問題(三次握手的速度)。
已完成連線佇列的長度也與作業系統中somaxconn引數有關,取二者最小min(tcp-backlog,somaxconn)。
linux檢視已完成連線佇列的長度:$ /proc/sys/net/core/somaxconn
【tcp-backlog是一個TCP連線的佇列,主要用於解決高併發場景下客戶端慢連線問題。這裡設定的值就是這個佇列的長度。該佇列與TCP連線的三次握手有關,不同的linux核心,backlog佇列中存放的元素(客戶端連線)型別是不同的。
***Linux核心2.2版本之前,該佇列中存放的是已經完成了第一次握手的所有客戶端連線,其中就包含已完成三次握手的客戶端連線。此時的backlog佇列中的連線具有兩種狀態:未完成三次握手的連線狀態SYN_RECEIVED,已完成三次握手連線狀態為ESTABLISHED,只有ESTABLISHED狀態的連線才會被Redis處理。
***Linux核心2.2版本之後,TCP系統維護了兩個佇列:SYN_RECEIVED佇列和ESTABLISHED佇列。SYN_RECEIVED佇列中存放的是未完成三次握手的連線;ESTABLISHED佇列中存放的是已完成三次握手的連線,此時的的backlog就是ESTABLISHED佇列。 】
補充下知識點 --檢視Linux核心版本
uname -a
或
cat /proc/version
補充下知識點 --修改somaxconn的方法步驟
step 1 vim /etc/sysctl.conf ##開啟配置檔案 step 2 net.core.somaxconn=2048 ##檔案最後 新增這樣一句話,此處2048代表你要修改後的值,請注意替換。 step 3 檔案儲存退出。 step 4 sysctl -p ##重啟生效
(5)timeout:不再使用的
連線 超時時間(關閉時間),單位秒;超過timeout,服務端會斷開連線。為0則服務端不會主動斷開連線(依賴於TCP 本身的預設屬性,為2H後斷開),不能小於0
(6)tcp-keepalive:表示針對
空閒連線,為了保持可用,server 端每隔tcp-keepalive這麼長的時間,就去探測一下。
5.TLS/SSL模組
################################# TLS/SSL ##################################### # By default, TLS/SSL is disabled. To enable it, the "tls-port" configuration # directive can be used to define TLS-listening ports. To enable TLS on the # default port, use:
6.GENERAL模組
################################# GENERAL #####################################
。。。。。。。。。
6.1 daemonize
預設值為no
預設情況下,Redis不作為守護程序執行(老版本預設)。如果需要可以修改daemonize為‘yes’。
注意,Redis在守護程序時會在var/run/redis.pid中寫入一個pid檔案。當Redis被upstart或systemd監管時,這個引數沒有影響。
6.2 pidfile
該配置用於指定redis允許時pid寫入的檔案,無論是否採用守護程序的方式啟動,pid都會寫入到該配置的檔案中。
說明:如果沒有在conf檔案中顯式配置pid檔案,不同的啟動方式,pid檔案產生的效果是不同的:(1)採用守護程序方式啟動(後臺方式啟動即daemonize 為yes):pid檔案為 /var/run/redis.pid。(2)採用前臺方式啟動(daemonize 為no
):不產生pid檔案。
6.3 loglevel notice 和
logfile ""
日誌級別 和 日誌檔案
關於logfile的說明:指定日誌檔案。如果設定為空字串,則強制將日誌記錄到標準輸出裝置(顯示器)。如果使用的是守護程序方式啟動,設定為空串,則意味著將日誌傳送到裝置/dev/null(空裝置--即不顯示)。--所以這個建議進行設定。
6.4 databases 16
設定資料庫的數量。預設資料庫是0號資料庫。可以使用select<dbid>,在每個連線上進行選擇。其中dbid介於0 和’databases‘-1 之間的數字。
7.安全策略
################################## SECURITY ################################### # Warning: since Redis is pretty fast, an outside user can try up to # 1 million passwords per second against a modern box. This means that you # should use very strong passwords, otherwise they will be very easy to break. # Note that because the password is really a shared secret between the client # and the server, and should not be memorized by any human, the password # can be easily a long string from /dev/urandom or whatever, so by using a # long and unguessable password no brute force attack will be possible. # Redis ACL users are defined in the following format: # # user <username> ... acl rules ... # # For example: # # user worker +@list +@connection ~jobs:* on >ffa9203c493aa99 # # The special username "default" is used for new connections. If this user # has the "nopass" rule, then new connections will be immediately authenticated # as the "default" user without the need of any password provided via the # AUTH command. Otherwise if the "default" user is not flagged with "nopass" # the connections will start in not authenticated state, and will require # AUTH (or the HELLO command AUTH option) in order to be authenticated and # start to work. # # The ACL rules that describe what a user can do are the following: # # on Enable the user: it is possible to authenticate as this user. # off Disable the user: it's no longer possible to authenticate # with this user, however the already authenticated connections # will still work. # skip-sanitize-payload RESTORE dump-payload sanitization is skipped. # sanitize-payload RESTORE dump-payload is sanitized (default). # +<command> Allow the execution of that command. # May be used with `|` for allowing subcommands (e.g "+config|get") # -<command> Disallow the execution of that command. # May be used with `|` for blocking subcommands (e.g "-config|set") # +@<category> Allow the execution of all the commands in such category # with valid categories are like @admin, @set, @sortedset, ... # and so forth, see the full list in the server.c file where # the Redis command table is described and defined. # The special category @all means all the commands, but currently # present in the server, and that will be loaded in the future # via modules. # +<command>|first-arg Allow a specific first argument of an otherwise # disabled command. It is only supported on commands with # no sub-commands, and is not allowed as negative form # like -SELECT|1, only additive starting with "+". This # feature is deprecated and may be removed in the future. # allcommands Alias for +@all. Note that it implies the ability to execute # all the future commands loaded via the modules system. # nocommands Alias for -@all. # ~<pattern> Add a pattern of keys that can be mentioned as part of # commands. For instance ~* allows all the keys. The pattern # is a glob-style pattern like the one of KEYS. # It is possible to specify multiple patterns. # %R~<pattern> Add key read pattern that specifies which keys can be read # from. # %W~<pattern> Add key write pattern that specifies which keys can be # written to. # allkeys Alias for ~* # resetkeys Flush the list of allowed keys patterns. # &<pattern> Add a glob-style pattern of Pub/Sub channels that can be # accessed by the user. It is possible to specify multiple channel # patterns. # allchannels Alias for &* # resetchannels Flush the list of allowed channel patterns. # ><password> Add this password to the list of valid password for the user. # For example >mypass will add "mypass" to the list. # This directive clears the "nopass" flag (see later). # <<password> Remove this password from the list of valid passwords. # nopass All the set passwords of the user are removed, and the user # is flagged as requiring no password: it means that every # password will work against this user. If this directive is # used for the default user, every new connection will be # immediately authenticated with the default user without # any explicit AUTH command required. Note that the "resetpass" # directive will clear this condition. # resetpass Flush the list of allowed passwords. Moreover removes the # "nopass" status. After "resetpass" the user has no associated # passwords and there is no way to authenticate without adding # some password (or setting it as "nopass" later). # reset Performs the following actions: resetpass, resetkeys, resetchannels, # allchannels (if acl-pubsub-default is set), off, clearselectors, -@all. # The user returns to the same state it has immediately after its creation. # (<options>) Create a new selector with the options specified within the # parentheses and attach it to the user. Each option should be # space separated. The first character must be ( and the last # character must be ). # clearselectors Remove all of the currently attached selectors. # Note this does not change the "root" user permissions, # which are the permissions directly applied onto the # user (outside the parentheses). # # ACL rules can be specified in any order: for instance you can start with # passwords, then flags, or key patterns. However note that the additive # and subtractive rules will CHANGE MEANING depending on the ordering. # For instance see the following example: # # user alice on +@all -DEBUG ~* >somepassword # # This will allow "alice" to use all the commands with the exception of the # DEBUG command, since +@all added all the commands to the set of the commands # alice can use, and later DEBUG was removed. However if we invert the order # of two ACL rules the result will be different: # # user alice on -DEBUG +@all ~* >somepassword # # Now DEBUG was removed when alice had yet no commands in the set of allowed # commands, later all the commands are added, so the user will be able to # execute everything. # # Basically ACL rules are processed left-to-right. # # The following is a list of command categories and their meanings: # * keyspace - Writing or reading from keys, databases, or their metadata # in a type agnostic way. Includes DEL, RESTORE, DUMP, RENAME, EXISTS, DBSIZE, # KEYS, EXPIRE, TTL, FLUSHALL, etc. Commands that may modify the keyspace, # key or metadata will also have `write` category. Commands that only read # the keyspace, key or metadata will have the `read` category. # * read - Reading from keys (values or metadata). Note that commands that don't # interact with keys, will not have either `read` or `write`. # * write - Writing to keys (values or metadata) # * admin - Administrative commands. Normal applications will never need to use # these. Includes REPLICAOF, CONFIG, DEBUG, SAVE, MONITOR, ACL, SHUTDOWN, etc. # * dangerous - Potentially dangerous (each should be considered with care for # various reasons). This includes FLUSHALL, MIGRATE, RESTORE, SORT, KEYS, # CLIENT, DEBUG, INFO, CONFIG, SAVE, REPLICAOF, etc. # * connection - Commands affecting the connection or other connections. # This includes AUTH, SELECT, COMMAND, CLIENT, ECHO, PING, etc. # * blocking - Potentially blocking the connection until released by another # command. # * fast - Fast O(1) commands. May loop on the number of arguments, but not the # number of elements in the key. # * slow - All commands that are not Fast. # * pubsub - PUBLISH / SUBSCRIBE related # * transaction - WATCH / MULTI / EXEC related commands. # * scripting - Scripting related. # * set - Data type: sets related. # * sortedset - Data type: zsets related. # * list - Data type: lists related. # * hash - Data type: hashes related. # * string - Data type: strings related. # * bitmap - Data type: bitmaps related. # * hyperloglog - Data type: hyperloglog related. # * geo - Data type: geo related. # * stream - Data type: streams related. # # For more information about ACL configuration please refer to # the Redis web site at https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/. # ACL LOG # # The ACL Log tracks failed commands and authentication events associated # with ACLs. The ACL Log is useful to troubleshoot failed commands blocked # by ACLs. The ACL Log is stored in memory. You can reclaim memory with # ACL LOG RESET. Define the maximum entry length of the ACL Log below. acllog-max-len 128 # Using an external ACL file # # Instead of configuring users here in this file, it is possible to use # a stand-alone file just listing users. The two methods cannot be mixed: # if you configure users here and at the same time you activate the external # ACL file, the server will refuse to start. # # The format of the external ACL user file is exactly the same as the # format that is used inside redis.conf to describe users. # # aclfile /etc/redis/users.acl # IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility # layer on top of the new ACL system. The option effect will be just setting # the password for the default user. Clients will still authenticate using # AUTH <password> as usually, or more explicitly with AUTH default <password> # if they follow the new protocol: both will work. # # The requirepass is not compatible with aclfile option and the ACL LOAD # command, these will cause requirepass to be ignored. # # requirepass foobared # New users are initialized with restrictive permissions by default, via the # equivalent of this ACL rule 'off resetkeys -@all'. Starting with Redis 6.2, it # is possible to manage access to Pub/Sub channels with ACL rules as well. The # default Pub/Sub channels permission if new users is controlled by the # acl-pubsub-default configuration directive, which accepts one of these values: # # allchannels: grants access to all Pub/Sub channels # resetchannels: revokes access to all Pub/Sub channels # # From Redis 7.0, acl-pubsub-default defaults to 'resetchannels' permission. # # acl-pubsub-default resetchannels # Command renaming (DEPRECATED). # # ------------------------------------------------------------------------ # WARNING: avoid using this option if possible. Instead use ACLs to remove # commands from the default user, and put them only in some admin user you # create for administrative purposes. # ------------------------------------------------------------------------ # # It is possible to change the name of dangerous commands in a shared # environment. For instance the CONFIG command may be renamed into something # hard to guess so that it will still be available for internal-use tools # but not available for general clients. # # Example: # # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 # # It is also possible to completely kill a command by renaming it into # an empty string: # # rename-command CONFIG "" # # Please note that changing the name of commands that are logged into the # AOF file or transmitted to replicas may cause problems.
(1)requirepass 安全設定
可以透過 # requirepass foobared,進行手動設定。而
命令列設定 : config set requirepass "????" 。若已設定密碼則需要登入 命令 : auth XXXX 。登入成功 獲取使用者密碼 : config get requirepass。
(2)rename-command 安全設定
改寫命令;例如,我們禁用 flushall、flushdb的命令
那麼可以在 # rename-command CONFIG "" 加上下面指令碼:
# rename-command CONFIG "" rename-command flushall "" ##禁用flushall;刪除所有DB
rename-connand flushdb "" ##禁用flushdb;只刪除當前DB
8. CLIENTS 部分
################################### CLIENTS #################################### # Set the max number of connected clients at the same time. By default # this limit is set to 10000 clients, however if the Redis server is not # able to configure the process file limit to allow for the specified limit # the max number of allowed clients is set to the current file limit # minus 32 (as Redis reserves a few file descriptors for internal uses). # # Once the limit is reached Redis will close all the new connections sending # an error 'max number of clients reached'. # # IMPORTANT: When Redis Cluster is used, the max number of connections is also # shared with the cluster bus: every node in the cluster will use two # connections, one incoming and another outgoing. It is important to size the # limit accordingly in case of very large clusters. # # maxclients 10000
該模組用於設定與客戶端相關的屬性,其中僅包含一個屬性maxclients。
maxclients用於設定redis可併發處理的客戶端連線數量,預設為10000。如果到達了該最大連線數,則會拒絕新的連線,並返回一個異常資訊--
max number of clients reached
。
注意: 還受限於 the process file limit to allow for the specified limit【可開啟的檔案描述符最大閾值】
其設定檢視的命令
ulimit -m
9.MEMORY MANAGEMENT
該配置可以控制最大可用記憶體即相關內容移除問題。
############################## MEMORY MANAGEMENT ################################ # Set a memory usage limit to the specified amount of bytes. # When the memory limit is reached Redis will try to remove keys # according to the eviction policy selected (see maxmemory-policy). # 。。。。。。。。。
9.1 maxmemory <bytes>
設定記憶體最大使用值,單位為位元組數。當記憶體達到記憶體限制時,redis將根據選擇的逐出策略 maxmemory-policy,嘗試刪除符合條件的key。
如果策略設定的是不移除,則會給寫操作命令返回Error。對於只讀的命令,沒影響。
9.2
maxmemory-policy
逐出策略。
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory # is reached. You can select one from the following behaviors: # # volatile-lru -> Evict using approximated LRU, only keys with an expire set. # allkeys-lru -> Evict any key using approximated LRU. # volatile-lfu -> Evict using approximated LFU, only keys with an expire set. # allkeys-lfu -> Evict any key using approximated LFU. # volatile-random -> Remove a random key having an expire set. # allkeys-random -> Remove a random key, any key. # volatile-ttl -> Remove the key with the nearest expire time (minor TTL) # noeviction -> Don't evict anything, just return an error on write operations. #
9.3 maxmemory-samples 5
# LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated # algorithms (in order to save memory), so you can tune it for speed or # accuracy. By default Redis will check five keys and pick the one that was # used least recently, you can change the sample size using the following # configuration directive. # # The default of 5 produces good enough results. 10 Approximates very closely # true LRU but costs more CPU. 3 is faster but not very accurate. The maximum # value that can be set is 64. #
該屬性用於指定挑選要刪除的key的樣本數量。樣本的選擇採用的是LRU演算法,其不能修改。單從樣本中再選擇移除的key,採用的是maxmemory-policy引數指定的演算法。
9.4 maxmemory-eviction-tenacity 10
設定移除容忍度。數值越小表示容忍度越低,需要移除的資料移除延遲越小;數值越大,表示容忍度越高,需要移除的資料移除延遲越大。
10.
THREADED I/O
該配置模組用於配置Redis對多執行緒IO模型的支援。
################################ THREADED I/O ################################# # Redis is mostly single threaded, however there are certain threaded # operations such as UNLINK, slow I/O accesses and other things that are # performed on side threads. # # Now it is also possible to handle Redis clients socket reads and writes # in different I/O threads. Since especially writing is so slow, normally # Redis users use pipelining in order to speed up the Redis performances per # core, and spawn multiple instances in order to scale more. Using I/O # threads it is possible to easily speedup two times Redis without resorting # to pipelining nor sharding of the instance. # # By default threading is disabled, we suggest enabling it only in machines # that have at least 4 or more cores, leaving at least one spare core. # Using more than 8 threads is unlikely to help much. We also recommend using # threaded I/O only if you actually have performance problems, with Redis # instances being able to use a quite big percentage of CPU time, otherwise # there is no point in using this feature. # # So for instance if you have a four cores boxes, try to use 2 or 3 I/O # threads, if you have a 8 cores, try to use 6 threads. In order to # enable I/O threads use the following configuration directive: # # io-threads 4 # # Setting io-threads to 1 will just use the main thread as usual. # When I/O threads are enabled, we only use threads for writes, that is # to thread the write(2) syscall and transfer the client buffers to the # socket. However it is also possible to enable threading of reads and # protocol parsing using the following configuration directive, by setting # it to yes: # # io-threads-do-reads no # # Usually threading reads doesn't help much. # # NOTE 1: This configuration directive cannot be changed at runtime via # CONFIG SET. Also, this feature currently does not work when SSL is # enabled. # # NOTE 2: If you want to test the Redis speedup using redis-benchmark, make # sure you also run the benchmark itself in threaded mode, using the # --threads option to match the number of Redis threads, otherwise you'll not # be able to notice the improvements.
(1)io-threads
該屬性用於指定要啟用多執行緒IO模型時,需使用的執行緒數量。
(2)io-threads-do-reads
將io執行緒設定為1將照常使用主執行緒。當啟用IO執行緒時,只使用執行緒進行寫入,也就是說,透過執行緒執行write(2)系統呼叫,並將客戶端緩衝區傳輸到套接字。
但是,也可以使用以下配置指令啟用讀取執行緒和協議解析,方法是將其設定為yes.
補充知識--檢視CPU的命令
lscpu
補充知識--redis 關閉方式
redis-cli shutdown