1. 程式人生 > >Linux上編譯Redis4.0.2

Linux上編譯Redis4.0.2

app only level tag alloc evict alt free b-

Linux上安裝部署Redis4.0.2

  • 安裝Redis4.0.2,需要先安裝依賴:
yum -y install gcc gcc-c++ libstdc++-devel tcl -y
  • 下載Redis4.0.2的安裝包:
wget http://219.238.7.71/files/403400000ABE0C0C/download.redis.io/releases/redis-4.0.2.tar.gz
  • 解壓縮:
tar -zxvf redis-4.0.2.tar.gz -C /usr/local/src/
  • 進入Redis解壓目錄,重命名:
cd /usr/local/src/
ll
mv redis-4.0.2/ redis
  • 編譯Redis:
cd /usr/local/src/redis
make MALLOC=libc  #添加內存回收機制  否則可能會安裝報錯 error: jemalloc/jemalloc.h: No such file or directory
make PREFIX=/usr/local/src/redis/ install  
  • 準備配置文件:
cd /usr/local/src/redis
mkdir conf    #存放配置文件的目錄
mkdir -p data/6379    #存放redis數據的目錄,日誌等
cd conf
vi redis_6379.conf
  • redis_6379.conf配置文件內容如下:
bind 192.168.161.150
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /usr/local/src/redis/data/6379/redis_6379.pid
loglevel notice
logfile "/usr/local/src/redis/data/6379/log.log"
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /usr/local/src/redis/data/6379/
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly yes
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 no
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
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
  • 進入Redis的bin目錄,啟動Redis服務:
cd /usr/local/src/redis/bin
./redis-server ../conf/redis_6379.conf 
  • 查看Redis服務是否啟動成功:
ps -ef|grep redis

技術分享圖片

技術分享圖片

  • 啟動成功,連接客戶端,測試:
./redis-cli -h 192.168.161.150 -p 6379

技術分享圖片

技術分享圖片技術分享圖片

  • 註意:啟動客戶端時不能直接運行./redis-cli命令,否則會報錯:

技術分享圖片

到此,Redis4.0.2的安裝部署就結束了!!!

Linux上編譯Redis4.0.2