Redis服务的配置管理:/usr/local/etc/redis.conf
daemonize yes 默认是以守护进程的方式运行的 --> pidfile /var/run/redis_6379.pid
port 6379
loglevel notice
#debug (a lot of information, useful for development/testing) # 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)
databases 16 设置数据库的数量,默认为16,可以使用SELECT命令在连接上指定数据库id
# Set the number of databases. The default database is DB 0, you can select # a different one on a per-connection basis using SELECT <dbid> where # dbid is a number between 0 and '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. # # In the example below the behaviour will be to save: # after 900 sec (15 min) if at least 1 key changed # after 300 sec (5 min) if at least 10 keys changed # after 60 sec if at least 10000 keys changed # # Note: you can disable saving completely by commenting out all "save" lines. # # It is also possible to remove all the previously configured save # points by adding a save directive with a single empty string argument # like in the following example: # # save "" save 900 1 save 300 10 save 60 10000
服务器端设定
设置服务器以守护进程的方式运行 daemonize yes|no
绑定主机地址 bind 127.0.0.1
设置服务器端口号 port 6379
设置数据库数量 databases 16
日志配置
设置服务器以指定日志记录级别 loglevel debug|verbose|notice|warning
日志记录文件名 logfile 端口号.log
日志级别开发期设置为verbose即可,生产环境中配置为notice,简化日志输出量,降低写日志IO的频度
客户端配置
设置同一时间最大客户端连接数,默认无限制。当客户端连接到达上限,Redis会关闭新的连接
maxclients 0
客户端闲置等待最大时长,达到最大值后关闭连接。如需关闭该功能,设置为0
timeout 300
多服务器快捷配置
导入并加载指定配置文件信息,用于快速创建redis公共配置较多的redis实例配置文件,便于维护
include /path/server-端口号.conf