启动的时候,通过配置文件来进行启动!!!!
配置文件,必须了解,优化必备!!!!!!
单位配置文件的Unit单位 对大小写不敏感!!!
INCLUDES 包含类似于spring中的 import、include
NETWORK 网络bind 127.0.0.1 # 绑定用户访问的ip 默认本机 protected-mode yes # 保护模式 默认yes port 7369 # 设置访问的端口GENERAL 通用
################################# GENERAL ##################################### daemonize yes # 是否以守护进程的方式运行,默认是no,我们需要自己开启yes pidfile /var/run/redis_6379.pid # 如果以后台的方式运行,我们需要制定一个pid文件! # 日志 # 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) # notice (moderately verbose, what you want in production probably) # 生产环境 # warning (only very important / critical messages are logged) loglevel notice # 日志 级别的设置 logfile "" # 日志文件的位置,"" 为当前目录 databases 16 # 数据库的数量,默认是16个数据库 always-show-logo no # 启动时是否显示logoSNAPSHOTTING 快照
################################ SNAPSHOTTING ################################ # 如果 3600S内,如果有一个key进行了修改,我们及进行持久化操作 # save 3600 1 # 如果 300s 内,有100个key进行了修改,我们及进行持久化操作 # save 300 100 # 如果 60s 内,有10000个key进行了修改,我们及进行持久化操作 # save 60 10000 # 如果持久化出现问题,是否继续工作 stop-writes-on-bgsave-error yes # 是否压缩rdb 文件,需要消耗一些cpu资源 rdbcompression yes # 保存rdb文件的时候,进行错误的检验 rdbchecksum yes # rdb 保存的目录 dir ./REPLICATION 主从复制
主从复制,后面再补
SECURITY 安全可以在这里设置redis的密码
# 方式一:
通过配置文件进行设置
requirepass 123456
# 方式二:
通过命令的方式进行设置
127.0.0.1:7369> config set requirepass 123456
OK
127.0.0.1:7369> ping
(error) NOAUTH Authentication required.
127.0.0.1:7369> AUTH 123456
OK
127.0.0.1:7369> ping
PONG
CLIENTS 限制
################################### CLIENTS #################################### maxclients 10000 # 设置最大的访问客户端 maxmemoryAPPEND onLY MODE 限制# redis 最大的内存数量 maxmemory-policy noeviction # 内存到达上限之后的处理策略 1、volatile-lru;只对设置了过期时间的key进行LRU (默认值) 2、allkeys-lru:删除lru算法的key 3、volatile-random:随机删除即将过期的key 4、allkeys-random:随机删除 5、volatile-ttl:删除即将过期的 6、noeviction:永不过期,返回错误
############################## APPEND onLY MODE ############################### appendonly no # 默认是不开启aof模式的,默认是使用rdb方式持久化的,在大部门的情况下,rdb完全够用 appendfilename "appendonly.aof" # 持久化的文件名称 # appendfsync always # 每次修改都会sync,消耗性能 appendfsync everysec # 每一秒执行一次sync,可能会丢失这一秒的数据 # appendfsync no # 不执行 sync,这个时候操作系统自己同步数据,速度最快



