欢迎投稿

今日深度:

Nginx配置文件nginx.conf, 以及Redis配置文件redis.conf的说明,

Nginx配置文件nginx.conf, 以及Redis配置文件redis.conf的说明,


1. /etc/nginx/nginx.conf的常用配置及说明

# 指定Nginx Worker进程运行用户, 语法: user user [group]
user nginx;

# worker进程数, 通常设置成和CPU的数量相等, 默认为1. 
worker_processes 1;

# 指定进程id存储文件
pid /run/nginx.pid;

# 事件模块
events {
    # 每个worker进程的连接数, 通过worker_connections和worker_proceses可以计算出maxclients: 
    # max_clients = worker_processes * worker_connections, 作为反向代理时, max_clients为: 
    # max_clients = worker_processes * worker_connections/4
    worker_connections 768;

    # 若开启此配置, 则Nginx会在接到一个新的连接通知之后, 尽可能多地去接受, 默认为: off
    multi_accept off;
}

# http核心模块
http {
    ##
    # 基本设置
    ##

    # 是否启动高效传输文件模式, sendfile可以让Nginx在传输文件时直接在磁盘和tcp socket之间传输数据. 
    # 如果这个参数不开启, 会先在用户空间(Nginx进程空间)申请一个buffer, 用read函数把数据从磁盘读到cache,
    # 再从cache读取到用户空间的buffer, 再用write函数把数据从用户空间的buffer写入到内核的buffer, 
    # 最后到tcp socket. 开启这个参数后可以让数据不用经过用户buffer, 默认off. 
    sendfile on;

    # 必须在sendfile开启模式才有效, 告诉Nginx在一个数据包里发送所有头文件, 而不一个接一个的发送, 默认off. 
    tcp_nopush on;

    # 告诉Nginx不要缓存数据, 而是一段一段的发送, 当需要及时发送数据时, 就应该开启这个功能, 
    # 这样发送一小块数据信息时就能够立即得到返回值, 默认on. 
    tcp_nodelay on;

    # 给客户端分配keep-alive链接超时时间, 服务器将在这个超时时间过后关闭链接. 
    # 我们将它设置低些可以让Ngnix持续工作的时间更长. 
    keepalive_timeout 65;

    # 影响散列表的冲突率, types_hash_max_size越大, 就会消耗更多的内存, 但散列key的冲突率会降低, 
    # 检索速度就更快. types_hash_max_size越小, 消耗的内存就越小, 但散列key的冲突率可能上升. 
    types_hash_max_size 2048;
    
    # 是否显示版本号, 若不显示, 浏览器访问时抓包, 查看HTTP响应的Server头没有版本号, 默认on 
    server_tokens on;

    # 保存服务器名字的hash表是由指令server_names_hash_max_size和server_names_hash_bucket_size所控制, 
    # 若Nginx给出需要增大hash max size或hash bucket size的提示, 那么首要的是增大前一个参数的大小. 
    # server_names_hash_max_size 512;
    # server_names_hash_bucket_size 64;

    # 若为off, 则始终按照默认的80端口, 若为on, 则返回当前正在监听的端口, 默认on. 
    port_in_redirect on;
    
    # 若为off, 则会以当前服务器的IP地址进行拼接URL. 若为on, 则会首先查找server_name, 
    # 若没有找到, 则会查找请求头的HOST字段, 若还是没有, 则以当前服务器的IP进行拼接, 默认on. 
    server_name_in_redirect on;

    # 设定MIME类型, 类型由mime.type文件定义. 
    include /etc/nginx/mime.types;
    
    # 设定默认的MIME类型, 默认: text/plain. 
    default_type application/octet-stream;

    # 设置上传文件大小最大为1000m, 超过会报413错误
    client_max_body_size 1000m;

    ##
    # SSL协议设置
    ##

    # 用于指定支持的加密协议. 
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    
    # 设置协商加密算法时, 优先使用服务端的加密套件, 而不是客户端浏览器的加密套件, 默认off. 
    ssl_prefer_server_ciphers off;

    ##
    # 日志设置
    ##

    # 每一个访问请求的记录位置
    access_log /var/log/nginx/access.log;
    
    # Nginx错误信息的记录位置
    error_log /var/log/nginx/error.log;

    ##
    # Gzip压缩设置
    ##

    # 是否启动Gzip
    gzip on;
    
    # IE6的某些版本对gzip的压缩支持很不好, 会造成页面的假死, 
    # 对img进行Gzip后造成IE6的假死, 把对img的Gzip压缩去掉后就正常了.
    gzip_disable "msie6";
    
    # 和HTTP头有关系, 加个vary头, 给代理服务器用的, 有的浏览器支持压缩, 有的不支持, 
    # 为了避免浪费不支持的也压缩, 根据客户端的HTTP头来判断, 是否需要压缩. 
    gzip_vary on;
    
    # Nginx作为反向代理的时候该参数起作用, 根据某些请求和应答来决定是否在对代理请求的应答启用Gzip压缩, 
    # 是否压缩取决于请求头中的"Via"字段, 指令中可以同时指定多个不同的参数, 可选值值为:
    # off - 关闭所有的代理结果数据的压缩  
    # expired - 启用压缩,如果header头中包含 "Expires" 头信息  
    # no-cache - 启用压缩,如果header头中包含 "Cache-Control:no-cache" 头信息  
    # no-store - 启用压缩,如果header头中包含 "Cache-Control:no-store" 头信息  
    # private - 启用压缩,如果header头中包含 "Cache-Control:private" 头信息  
    # no_last_modified - 启用压缩,如果header头中不包含 "Last-Modified" 头信息  
    # no_etag - 启用压缩 ,如果header头中不包含 "ETag" 头信息  
    # auth - 启用压缩 , 如果header头中包含 "Authorization" 头信息  
    # any - 无条件启用压 
    # 默认为off.
    gzip_proxied off;
    
    # Gzip压缩比, 值为1~9, 1的压缩比最小处理速度最快, 9的压缩比最大但处理最慢(传输快但比较消耗CPU)
    gzip_comp_level 6;
    
    # 设置允许压缩的页面最小字节数, 默认值是0, 不管页面多大都压缩, 建议设置大于1k(即1024), 小于1k可能会越压越大.
    gzip_min_length 1024;
    
    # 设置系统获取几个单位的缓存用于存储Gzip的压缩结果数据流, 4 8k代表: 按照原始数据大小以8k为单位的4倍申请内存.
    gzip_buffers 4 8k;
    
    # 匹配MIME类型进行压缩
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    
    # 识别HTTP的协议版本, 99.99%的浏览器都支持1.1, 所以可以不用设这个值, 保持系统默认即可, 默认1.1. 
    gzip_http_version 1.1;

    ##
    # 虚拟主机设置
    ##

    # Nginx的配置很灵活, 支持include配置文件, 如果我们的域名都配置到nginx.conf, 那么这个文件就会比较乱,
    # 也影响管理和阅读, 所以直接拆分出来, 分成不同的配置文件. 
    include /etc/nginx/conf.d/*.conf;
    
    # 加载一个外部的配置文件, sites-enabled文件夹下只有一个default文件, 
    # 这个外部的配置文件就是负责我们Nginx的默认代理, 也就是server块的配置. 
    include /etc/nginx/sites-enabled/*;

    ##
    # 缓存设置
    ##

    # 缓存文件路径
    # levels=1:2 设置目录深度, 第一层目录是1个字符, 第2层是2个字符. 
    # keys_zone 设置web缓存名称和内存缓存空间大小. 
    # inactive 自动清除缓存文件时间. 
    # max_size 硬盘空间最大可使用值, 如果缓存空间满, 默认覆盖掉缓存时间最长的资源.  
    proxy_cache_path /data/proxy/cache levels=1:2 keys_zone=cache_one:500m inactive=7d max_size=10g;
    
    # 指定临时缓存文件的存储路径(路径需和上面路径在同一分区)
    proxy_temp_path /data/proxy/temp;
}

# 配置邮件服务器
#mail {
#    # See sample authentication script at:
#    # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#    # 指定Nginx提供邮件服务时, 用于HTTP认证的服务地址
#    # auth_http localhost/auth.php;
#    # 指定现有客户端上的POP3协议的扩展
#    # pop3_capabilities "TOP" "USER";
#    # 指定现有客户端上的IMAP协议的扩展
#    # imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#    server {
#        # 指定邮件服务器监听的IP地址和端口. 
#        listen     localhost:110;
#       # 指定虚拟机支持的加密协议. 
#        protocol   pop3;
#        # 是否开启邮件代理
#        proxy      on;
#    }
# 
#    server {
#        # 指定邮件服务器监听的IP地址和端口. 
#        listen     localhost:143;
#        # 指定虚拟机支持的加密协议. 
#        protocol   imap;
#        # 是否开启邮件代理
#        proxy      on;
#    }
#}

2. /etc/nginx/sites-enabled/default的常用配置及说明

server {
    # Nginx监听的IP及端口号, 可以监听多个
    listen 127.0.0.1:80;
    # Nginx监听的IPv6的IP及端口号
    listen [::]:80;

    # SSL协议配置
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    # 加载配置片段
    # include snippets/snakeoil.conf;

    # 指定哪个目录作为根目录, 用于文件的检索
    root /var/www/html;

    # 在上面指定的根目录下, 找到如下页面, 作为Nginx的默认主页
    index index.html index.htm index.nginx-debian.html;

    # 配置server的多域名, 域名可以通过以下方式: 
    # 1. 完整的域名, 如: www.example.com
    # 2. 带*号开头的域名, 如: *.example.com
    # 3. 带*号末尾的域名, 如: mail.*
    # 4. 可匹配的正则表达式
    server_name www.paulandcode.com;

    location / {
        # 原请求不存在时, 重定向到指定的URI, 并返回结果(此处设定为404)
        try_files $uri $uri/ =404;
    }

    # 静态文件的处理
    location ~ ^/(images|javascript|js|css|flash|media|static)/ {
        # 设置被代理服务器的地址, 包含传输协议, 主机名称或IP地址加端口号, URI等要素. 
        proxy_pass http://www.paulandcode.com:8080;
        
        # 自定义http header头, 用于发送给后端真实服务器. 
         proxy_set_header Host $host:$server_port;
         
         # 指定哪个目录作为根目录, 用于文件的检索
         root /home/django/projects/blogs;
        
        # 启用Gzip压缩
        gzip on;
         # 对js、css、jpg、png、gif格式的文件启用gzip压缩功能
         gzip_types application/javascript text/css image/jpeg image/png image/gif;
         # 所压缩文件的最小值,小于这个的不会压缩
         gzip_min_length 1024;

         # 使用名为cache_one的对应缓存配置. 
         proxy_cache cache_one;
         # 对httpcode为200, 206, 301, 302, 304的缓存10天. 
         proxy_cache_valid 200 206 301 302 304 10d;
         # 定义缓存唯一key, 通过唯一key来进行hash存取. 
         proxy_cache_key $uri
        # 过期30天, 静态文件不怎么更新, 过期可以设大一点, 如果频繁更新, 则可以设置得小一点. 
         expires 30d;
    }
}

3. Redis配置文件redis.conf

# Redis配置文件样例

# Note on units: when memory size is needed, it is possible to specifiy
# 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.

# Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程
# 启用守护进程后,Redis会把pid写到一个pidfile中,在/var/run/redis.pid
daemonize no

# 当Redis以守护进程方式运行时,Redis默认会把pid写入/var/run/redis.pid文件,可以通过pidfile指定
pidfile /var/run/redis.pid

# 指定Redis监听端口,默认端口为6379
# 如果指定0端口,表示Redis不监听TCP连接
port 6379

# 绑定的主机地址
# 你可以绑定单一接口,如果没有绑定,所有接口都会监听到来的连接
# bind 127.0.0.1

# 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 /tmp/redis.sock
# unixsocketperm 755

# 当客户端闲置多长时间后关闭连接,如果指定为0,表示关闭该功能
timeout 0

# 指定日志记录级别,Redis总共支持四个级别:debug、verbose、notice、warning,默认为verbose
# debug (很多信息, 对开发/测试比较有用)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel verbose

# 日志记录方式,默认为标准输出,如果配置为redis为守护进程方式运行,而这里又配置为标准输出,则日志将会发送给/dev/null
logfile stdout

# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# syslog-enabled no

# Specify the syslog identity.
# syslog-ident redis

# Specify the syslog facility.  Must be USER or between LOCAL0-LOCAL7.
# syslog-facility local0

# 设置数据库的数量,默认数据库为0,可以使用select <dbid>命令在连接上指定数据库id
# dbid是从0到‘databases’-1的数目
databases 16

################################ SNAPSHOTTING  #################################
# 指定在多长时间内,有多少次更新操作,就将数据同步到数据文件,可以多个条件配合
# Save the DB on disk:
#
#   save <seconds> <changes>
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#
#   满足以下条件将会同步数据:
#   900秒(15分钟)内有1个更改
#   300秒(5分钟)内有10个更改
#   60秒内有10000个更改
#   Note: 可以把所有“save”行注释掉,这样就取消同步操作了

save 900 1
save 300 10
save 60 10000

# 指定存储至本地数据库时是否压缩数据,默认为yes,Redis采用LZF压缩,如果为了节省CPU时间,可以关闭该选项,但会导致数据库文件变的巨大
rdbcompression yes

# 指定本地数据库文件名,默认值为dump.rdb
dbfilename dump.rdb

# 工作目录.
# 指定本地数据库存放目录,文件名由上一个dbfilename配置项指定
# 
# Also the Append Only File will be created inside this directory.
# 
# 注意,这里只能指定一个目录,不能指定文件名
dir ./

################################# REPLICATION #################################

# 主从复制。使用slaveof从 Redis服务器复制一个Redis实例。注意,该配置仅限于当前slave有效
# so for example it is possible to configure the slave to save the DB with a
# different interval, or to listen to another port, and so on.
# 设置当本机为slav服务时,设置master服务的ip地址及端口,在Redis启动时,它会自动从master进行数据同步
# slaveof <masterip> <masterport>


# 当master服务设置了密码保护时,slav服务连接master的密码
# 下文的“requirepass”配置项可以指定密码
# masterauth <master-password>

# When a slave lost the connection with the master, or when the replication
# is still in progress, the slave can act in two different ways:
#
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
#    still reply to client requests, possibly with out of data data, or the
#    data set may just be empty if this is the first synchronization.
#
# 2) if slave-serve-stale data is set to 'no' the slave will reply with
#    an error "SYNC with master in progress" to all the kind of commands
#    but to INFO and SLAVEOF.
#
slave-serve-stale-data yes

# Slaves send PINGs to server in a predefined interval. It's possible to change
# this interval with the repl_ping_slave_period option. The default value is 10
# seconds.
#
# repl-ping-slave-period 10

# The following option sets a timeout for both Bulk transfer I/O timeout and
# master data or ping response timeout. The default value is 60 seconds.
#
# It is important to make sure that this value is greater than the value
# specified for repl-ping-slave-period otherwise a timeout will be detected
# every time there is low traffic between the master and the slave.
#
# repl-timeout 60

################################## SECURITY ###################################

# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
# 设置Redis连接密码,如果配置了连接密码,客户端在连接Redis时需要通过auth <password>命令提供密码,默认关闭
requirepass root

# Command renaming.
#
# It is possilbe to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# of hard to guess so that it will be still available for internal-use
# tools but not available for general clients.
#
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# It is also possilbe to completely kill a command renaming it into
# an empty string:
#
# rename-command CONFIG ""

################################### LIMITS ####################################

# 设置同一时间最大客户端连接数,默认无限制,Redis可以同时打开的客户端连接数为Redis进程可以打开的最大文件描述符数,
# 如果设置maxclients 0,表示不作限制。当客户端连接数到达限制时,Redis会关闭新的连接并向客户端返回max Number of clients reached错误信息
# maxclients 128

# Don't use more memory than the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys with an
# EXPIRE set. It will try to start freeing keys that are going to expire
# in little time and preserve keys with a longer time to live.
# Redis will also try to remove objects from free lists if possible.
#
# If all this fails, Redis will start to reply with errors to commands
# that will use more memory, like SET, LPUSH, and so on, and will continue
# to reply to most read-only commands like GET.
#
# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
# 'state' server or cache, not as a real DB. When Redis is used as a real
# database the memory usage will grow over the weeks, it will be obvious if
# it is going to use too much memory in the long run, and you'll have the time
# to upgrade. With maxmemory after the limit is reached you'll start to get
# errors for write operations, and this may even lead to DB inconsistency.
# 指定Redis最大内存限制,Redis在启动时会把数据加载到内存中,达到最大内存后,Redis会先尝试清除已到期或即将到期的Key,
# 当此方法处理后,仍然到达最大内存设置,将无法再进行写入操作,但仍然可以进行读取操作。
# Redis新的vm机制,会把Key存放内存,Value会存放在swap区
# maxmemory <bytes>

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached? You can select among five behavior:
# 
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with 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 expire at all, just return an error on write operations
# 
# Note: with all the kind of policies, Redis will return an error on write
#       operations, when there are not suitable keys for eviction.
#
#       At the date of writing this commands are: set setnx setex append
#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
#       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
#       getset mset msetnx exec sort
#
# The default is:
#
# maxmemory-policy volatile-lru

# LRU and minimal TTL algorithms are not precise algorithms but approximated
# algorithms (in order to save memory), so you can select as well the sample
# size to check. For instance for default Redis will check three keys and
# pick the one that was used less recently, you can change the sample size
# using the following configuration directive.
#
# maxmemory-samples 3

############################## APPEND ONLY MODE ###############################

# 
# Note that you can have both the async dumps and the append only file if you
# like (you have to comment the "save" statements above to disable the dumps).
# Still if append only mode is enabled Redis will load the data from the
# log file at startup ignoring the dump.rdb file.
# 指定是否在每次更新操作后进行日志记录,Redis在默认情况下是异步的把数据写入磁盘,如果不开启,可能会在断电时导致一段时间内的数据丢失。
# 因为redis本身同步数据文件是按上面save条件来同步的,所以有的数据会在一段时间内只存在于内存中。默认为no
# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append
# log file in background when it gets too big.

appendonly no

# 指定更新日志文件名,默认为appendonly.aof
# appendfilename appendonly.aof

# The fsync() call tells the Operating System to actually write data on disk
# instead to wait for more data in the output buffer. Some OS will really flush 
# data on disk, some other OS will just try to do it ASAP.

# 指定更新日志条件,共有3个可选值:
# no:表示等操作系统进行数据缓存同步到磁盘(快)
# always:表示每次更新操作后手动调用fsync()将数据写到磁盘(慢,安全)
# everysec:表示每秒同步一次(折衷,默认值)

appendfsync everysec
# appendfsync no

# When the AOF fsync policy is set to always or everysec, and a background
# saving process (a background save or AOF log background rewriting) is
# performing a lot of I/O against the disk, in some Linux configurations
# Redis may block too long on the fsync() call. Note that there is no fix for
# this currently, as even performing fsync in a different thread will block
# our synchronous write(2) call.
#
# In order to mitigate this problem it's possible to use the following option
# that will prevent fsync() from being called in the main process while a
# BGSAVE or BGREWRITEAOF is in progress.
#
# This means that while another child is saving the durability of Redis is
# the same as "appendfsync none", that in pratical terms means that it is
# possible to lost up to 30 seconds of log in the worst scenario (with the
# default Linux settings).
# 
# If you have latency problems turn this to "yes". Otherwise leave it as
# "no" that is the safest pick from the point of view of durability.
no-appendfsync-on-rewrite no

# Automatic rewrite of the append only file.
# Redis is able to automatically rewrite the log file implicitly calling
# BGREWRITEAOF when the AOF log size will growth by the specified percentage.
# 
# This is how it works: Redis remembers the size of the AOF file after the
# latest rewrite (or if no rewrite happened since the restart, the size of
# the AOF at startup is used).
#
# This base size is compared to the current size. If the current size is
# bigger than the specified percentage, the rewrite is triggered. Also
# you need to specify a minimal size for the AOF file to be rewritten, this
# is useful to avoid rewriting the AOF file even if the percentage increase
# is reached but it is still pretty small.
#
# Specify a precentage of zero in order to disable the automatic AOF
# rewrite feature.

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

################################## SLOW LOG ###################################

# The Redis Slow Log is a system to log queries that exceeded a specified
# execution time. The execution time does not include the I/O operations
# like talking with the client, sending the reply and so forth,
# but just the time needed to actually execute the command (this is the only
# stage of command execution where the thread is blocked and can not serve
# other requests in the meantime).
# 
# You can configure the slow log with two parameters: one tells Redis
# what is the execution time, in microseconds, to exceed in order for the
# command to get logged, and the other parameter is the length of the
# slow log. When a new command is logged the oldest one is removed from the
# queue of logged commands.

# The following time is expressed in microseconds, so 1000000 is equivalent
# to one second. Note that a negative number disables the slow log, while
# a value of zero forces the logging of every command.
slowlog-log-slower-than 10000

# There is no limit to this length. Just be aware that it will consume memory.
# You can reclaim memory used by the slow log with SLOWLOG RESET.
slowlog-max-len 1024

############################### ADVANCED CONFIG ###############################

# Hashes are encoded in a special way (much more memory efficient) when they
# have at max a given numer of elements, and the biggest element does not
# exceed a given threshold. You can configure this limits with the following
# configuration directives.
# 指定在超过一定的数量或者最大的元素超过某一临界值时,采用一种特殊的哈希算法
# hash-max-zipmap-entries 512
# hash-max-zipmap-value 64

# Similarly to hashes, small lists are also encoded in a special way in order
# to save a lot of space. The special representation is only used when
# you are under the following limits:
list-max-ziplist-entries 512
list-max-ziplist-value 64

# Sets have a special encoding in just one case: when a set is composed
# of just strings that happens to be integers in radix 10 in the range
# of 64 bit signed integers.
# The following configuration setting sets the limit in the size of the
# set in order to use this special memory saving encoding.
set-max-intset-entries 512

# Similarly to hashes and lists, sorted sets are also specially encoded in
# order to save a lot of space. This encoding is only used when the length and
# elements of a sorted set are below the following limits:
zset-max-ziplist-entries 128
zset-max-ziplist-value 64

# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
# order to help rehashing the main Redis hash table (the one mapping top-level
# keys to values). The hash table implementation redis uses (see dict.c)
# performs a lazy rehashing: the more operation you run into an hash table
# that is rhashing, the more rehashing "steps" are performed, so if the
# server is idle the rehashing is never complete and some more memory is used
# by the hash table.
# 
# The default is to use this millisecond 10 times every second in order to
# active rehashing the main dictionaries, freeing memory when possible.
#
# If unsure:
# use "activerehashing no" if you have hard latency requirements and it is
# not a good thing in your environment that Redis can reply form time to time
# to queries with 2 milliseconds delay.
# 指定是否激活重置哈希,默认为开启
activerehashing yes

################################## INCLUDES ###################################

# 指定包含其他的配置文件,可以在同一主机上多个Redis实例之间使用同一份配置文件,而同时各实例又拥有自己的特定配置文件
# include /path/to/local.conf
# include /path/to/other.conf

www.htsjk.Com true http://www.htsjk.com/redis/26049.html NewsArticle Nginx配置文件nginx.conf, 以及Redis配置文件redis.conf的说明, 1. /etc/nginx/nginx.conf的常用配置及说明 # 指定Nginx Worker进程运行用户, 语法: user user [group]user nginx;# worker进程数, 通常设置成和CPU的...
评论暂时关闭