redis从开始到精通-配置详解

redis

Posted by XJ on January 14, 2023

redis配置文件精讲

部分配置文件

Utils一些数据单位的换算 没啥好讲的 注意内存使用就行

# 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.

include path 对于一些公共配置的引用卸载这里

# include /path/to/local.conf
# include /path/to/other.conf

Network 网络相关

# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
bind 127.0.0.1  bind 127.0.0.1  只能本地访问 如果要外部访问  如果要配置多个ip 需要用空格分开  例如  

bing 127.0.0.1 10.0.4.5

保护模式 protected-mode

从注释信息就可以看到,如果protected-mode是yes的话,如果没有指定bind或者没有指定密码,那么只能本地访问
protected-mode yes

端口号 port

默认6379

# 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

daemonize yes

是否以守护进程的方式启动 (是否后台启动

pidfile

redis启动后会把pid写入到pidfile指定的文件中。

 pidfile /var/run/redis_6379.pid

loglevel 日志打印

默认 notice

# Specify the server verbosity level.
# This can be one of:
# debug (a lot of information, useful for development/testing) --会打印所有日志
# verbose (many rarely useful info, but not a mess like the debug level) -- 打印除debug外所有日志
# notice (moderately verbose, what you want in production probably) --打印除debug和verbose外所有日志
# warning (only very important / critical messages are logged) --只打印重要日志
loglevel notice

logfile 日志文件

日志文件输出地址

logfile /var/log/redis_6379.log