redis5.0.7安裝


時間:201912201015
version:5.0.7

一、安裝依賴包

yum install -y gcc gcc-c++

二、下載最新版redis並解壓安裝

cd /usr/local/src
wget http://download.redis.io/releases/redis-5.0.7.tar.gz
tar -zxvf redis-5.0.7.tar.gz && cd redis-5.0.7 && make
ln -s /home/db/redis /usr/local

三、創建運行用戶和組

groupadd redis
useradd -g redis redis

四、創建對應目錄及配置文件

創建目錄

 mkdir -p /usr/local/redis/{bin,etc,var,log} 
 chown -R redis.redis /usr/local/redis

創建配置文件

# 指定redis綁定的主機地址
bind 0.0.0.0
protected-mode yes
# 指定訪問redis服務端的端口
port 6680
tcp-backlog 511
# 指定客戶端連接redis服務器時,當閑置的時間為多少(如300)時,關閉連接
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /home/db/redis/logs/redis_6680.pid
loglevel notice
logfile /home/db/redis/logs/redis6680.log
databases 16
always-show-logo yes
#指定redis數據庫多長時間內(s)有多少次(c)更新操作時就把緩存中的數據同步到本地庫,比如:save 600 2,指的是10分鍾內有2次更新操作,就同步到本地庫
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump6696.rdb
# 指定redis本地數據文件存放的目錄
dir /home/db/redis/var
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100
# 指定redis的訪問密碼
requirepass 123456
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
# 指定redis是否開啟日志記錄功能,由於redis是利用什么save命令異步的方式更新數據到本地庫,所以不開啟日志記錄功能,可能會導致在出現生產事故時,導致部分數據未更新到本地庫
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
# 指定內存
maxmemory 4294967296

四、啟動redis

redis-server /home/db/redis/etc/redis6680.conf

部分參數引用自https://baijiahao.baidu.com/s?id=1636391018961856175&wfr=spider&for=pc


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM