Redis实践之 配置文件解析

本文原创自 http://blog.csdn.net/voipmaker  转载注明出处。

要掌握redis的用法,配置文件的重要参数必须掌握,下面是笔者对各个参数的学习笔记,同时会针对特殊参数的使用场景做简短说明。

include /path/to/other.conf

 解释:include和c里面的include概念类似,可以把redis的的参数分散到其他文件,当运行多个redis实例时,通过include一个common的配置文件让所有redis-server共享,简化redis.conf的内容。

daemonize no

解释:

毋容置疑,这个参数指定redis是否以后台进程方式启动,默认不是,生产环境可以改成yes,另外,Redis是单线程的。

pidfile /var/run/redis.pid

解释:

当daemonize参数为yes时,后台进程方式启动后,redis会创建进程文件,这个参数是指定此文件的路径。

port 6379

解释:redistcp 监听端口,客户端通过此端口与redis服务器交互。非集群模式下,redis只有这个监听端口

tcp-backlog 511

解释:客户端连接队列值,这个值是socket里面listen函数的参数。如果服务器caps很高,需要把这个参数改大些。

bind 127.0.0.1

解释:监听地址,默认是监听所有网卡,也可以指定监听一个或多个。多个的格式:

bind 192.168.1.1 192.168.1.2

loglevel notice

解释:

指定log级别,默认是notice,包括debug,verbose ,notice, , warning.

生产环境建议用notice,测试阶段可以用debug或者verbose,debug的log最多。

Logfile

解释:

log 文件指定,默认是空,打印到控制台,可指定路径,如/var/log/redis.log

 

save 900 1

解释:

这个参数是redis持久化的支持,基于snapshot机制,定期执行持久化存储,生成rdb文件,save 命令打开此配置,第一个参数指定多久(单位是秒)执行一次,第二个是在第一个参数指定的时间内执行多少次写操作才执行持久化操作。

dbfilename dump.rdb

save生成的数据库文件名字

dir ./

数据库的目录路径,默认和server一个目录

slaveof <masterip> <masterport>

解释:

Redis 主从复制功能,通过这个参数可以让一个redis启动时作为某个master的slave,

 Slaveof 第一个参数是master的ip,第二个参数是master的port.

也可以通过redis-cli控制台执行slaveof命令动态把某个redis作为另一个master的slave。

requirepass     passwd

  解释:

此redis的密码,如果开启,客户端连接时需要设置密码,另外一个作用是redis作为slave时,如果master开启了此参数,slave需要设置masterauth参数的值为此参数(requirepass)的值,

masterauth <master-password>

解释:

这个参数只有在当前redis作为slave时管用,用于slave和master之间的鉴权,如果master开启了鉴权功能,则masterauth的意思是此slave和master通信时用这个密码。

另外,这个参数只有在master的redis.conf文件中开启了reqireuth参数时才被使用。

maxclients 10000

解释:最大并发客户端数。同时存在10000个tcp连接

maxmemory  

解释:redis申请的最大内存,字节为单位,默认不限制。

appendonly  yes

解释:

Redis持久化第二种方式,AOF,默认开启,默认每秒执行一次持久化保存,也可以设置成实时保持,这个比save更安全。

appendfilename "appendonly.aof"

解释:AOF方式下,保持的数据文件名字

appendfsync   no

解释:执行aof的时机,可以为每秒(everysec),实时(always),不手动,交给操作系统执行flush(no)

cluster-enabled yes

解释:开启当前redis的集群模式,3.0版本才出现,默认关闭。

cluster-config-file nodes-6379.conf

解释:

集群模式下,每个redis节点生成一个自己的集群配置文件,这个文件不需要人工修改,由redis自己维护。

cluster-node-timeout 15000

解释:

集群模式时,当前节点在与其他节点保活探测时,多久没有响应时认为其他节点处于fail状态,上面是15秒。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
My sincere hope is that this book becomes valued reading for IT professionals in all areas and at all levels of an IT organization well into the future. As you will shortly find, the ITaaS framework is just as much about the culture of the IT organization, reestablishing the purpose and obligation of IT to the parent enterprise, and establishing a structure for communicating the value of IT Services, as it is about designing Service Portfolios and catalogs. In this regard, I truly believe the contents of this book to be of value for every member of the IT organization. CIOs and senior IT leaders play a critical role in shaping framework and then utilizing a series of strategic levers to steer the IT organization in an agile and competitive way. IT Service Management and enterprise architecture teams will play a significant role in the Services Transformation Program, forming the bulk of any potential IT transformation team. From there, the success of the ITaaS framework will hinge on the successful introduction of Service Roles such as Service Owners, Service Executives, and more taken up by professionals across the IT organization. Finally, a true End-to-End Services Organization requires every member of the organization, even those not facilitating a Service delivery Role, to recognize how their daily activities ultimately contribute to the delivery and resulting value of IT Services. In short, while this book will initially be of greatest interest to CIOs, senior IT leaders, and Service management teams, the successful adoption of the ITaaS framework as a foundation for Fast IT requires support and familiarity with the new approach to IT Service delivery from every member of the organization.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值