Redis 实战 —— Redis 安装

1. 环境准备

  1. 下载安装包

    $ wget https://download.redis.io/releases/redis-4.0.11.tar.gz
    
  2. 安装编译环境

    如果有 gcc 编译环境跳过

    $ sudo yum install gcc
    $ sudo yum install gcc-c++ 
    

2. Redis 安装

  1. 解压

    $ tar -zvxf redis-4.0.11.tar.gz
    
  2. make 编译

    $ make MALLOC=libc
    
  3. 安装到指定目录

    $ make PREFIX=/opt/module/redis install
    
  4. 在 redis 目录下创建以下几个目录

    $ mkdir data logs pid conf
    

3. Redis 配置

在 conf 目录编写 redis.conf配置

bind 0.0.0.0
port 6379
tcp-backlog 1024
timeout 60
tcp-keepalive 60
daemonize yes
pidfile "/opt/module/redis/pid/6379.pid"
#debug、verbose、notice、warning
#loglevel warning
logfile "/opt/module/redis/logs/redis.log"
databases 16
maxclients 800
requirepass "123456"

#maxmemory
maxmemory 104857600
maxmemory-samples 5
maxmemory-policy volatile-lru

#rdb
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir "/opt/module/redis/data/"

#aof
appendonly yes
appendfilename "appendonly.aof"
#always  everysec  no
appendfsync no
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-rewrite-incremental-fsync yes

# slaveof 192.168.1.1 7001
# masterauth qianKUN1jian
slave-serve-stale-data yes
slave-read-only yes
repl-ping-slave-period 10
repl-timeout 60
repl-disable-tcp-nodelay no
repl-backlog-size 1mb
#slave yes: hui dai lai yan ci  ; no: jiang di yan ci, xiao hao kuang dai
repl-disable-tcp-nodelay no
repl-backlog-size 20mb
repl-backlog-ttl 3600

slave-priority 100

#default 0 10
min-slaves-to-write 0
min-slaves-max-lag 10

repl-diskless-sync no
repl-diskless-sync-delay 5

slowlog-log-slower-than 10000
slowlog-max-len 128

notify-keyspace-events ""
#hash
hash-max-ziplist-entries 512
hash-max-ziplist-value 64

#list
list-max-ziplist-size -2
list-compress-depth 0

#set
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
#HyperLogLog
hll-sparse-max-bytes 3000
activerehashing yes


hz 10

client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
# lazy delete
lazyfree-lazy-eviction no
lazyfree-lazy-expire yes
lazyfree-lazy-server-del yes
slave-lazy-flush yes

rename-command keys ""
rename-command flushall ""

4. 启动 Redis

$ bin/redis-server conf/redis.conf
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值