linux安装redis及配置

官网:https://redis.io/
中文官方网站:http://www.redis.cn/
下载:wget http://download.redis.io/releases/redis-5.0.7.tar.gz
解压:自带Makefile
安装:make install PREFIX=/usr/local/redis
目录bin:redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
copy配置:redis.conf sentinel.conf

启动:/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf
登录:/usr/local/redis/redis-cli

info Status:
latest_fork_usec:0 # 上次Fork child子进程 持久化耗时

shutdown [save:持久化|nosave:不持久化]

在redis进程运行时,rdb处于打开状态,复制文件,占用同样的句柄;需关闭服务,copy dump文件

面向请求:单进程;

redis.conf:
############ NETWORK #######################
bind 127.0.0.1 # 绑定IP,0.0.0.0 监听所有IP
port 6379 # 端口
tcp-backlog 511 # TCP listen() backlog
tcp-keepalive 300 # TCP keepalive
############### GENERAL ####################
daemonize yes # 守护进程运行,pid file in /var/run/redis.pid when daemonized
logfile "" # 日志文件
databases 16 # 数据库:默认16个;
################# SECURITY #################
# requirepass foobared # 密码
############## SNAPSHOTTING  ##########rdb##
#   save "" # 关闭rdb持久化
save 900 1
save 300 10
save 60 10000
stop-write-on-bgsave-error yes # 后台存储错误停止写;
rdbcommpression yes # 使用压缩rdb文件;
rdbchecksum yes # 存储和加载rdb文件时校验;
dbfilename dump.rdb # 设置rdb文件名;
dir: ./ # 设置工作目录,rdb文件会写入该目录;
./bin/redis-benchmark -n 10000 # 性能测试
BGSAVE # rdb持久化
####### APPEND ONLY MODE #############aof####
aof: 重启服务以aof为主,即使rdb有数据也不使用;
# When loading Redis recognizes that the AOF file starts with the "REDIS" string and loads the prefixed RDB file, and continues loading the AOF tail.
aof-use-rdb-preamble yes

appendonly yes # 开启日志;
appendfilename "appendonly.aof"
appendfsync no # 系统缓冲,统一写,速度快;
appendfsync always # 系统不缓冲,每次都写;
appendfsync everysec # 每秒写一次;
no-appendfsync-on-write no # 重写aof时同步最新数据
auto-AOF-rewrite-percentage 100 # 当前aof文件是上次重写时的N%时重写;
auto-AOF-rewrite-min-size 64mb # 文件aof重写至少达到大小(64M)
BGREWRITEAOF # aof持久化
######## SLOW LOG ####
slowlog-log-slower-than 10000 # 耗时大于10000 微秒(meantime)
slowlog-max-len 128 # 保存128条记录
########### REPLICATION ######Master-->Replica###
replicaof <masterip> <masterport> # 主从
masterauth <master-password>	# 主密码
replica-serve-stale-data yes 
replica-read-only yes	# 只读
replica-priority 100	# 被sentinel提升为master优先级
# min-replicas-to-write 3
# min-replicas-max-lag 10
################# REDIS CLUSTER  ###############
cluster-enabled yes # 开启集群
cluster-config-file nodes-6379.conf #  This file is not intended to be edited by hand,无需手工设置
cluster-node-timeout 15000(milliseconds) # node timeout
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值