Linux上编译Redis4.0.2

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的安装部署就结束了!!!

 

posted @ 2017-11-19 16:11  gouyadong  阅读(1849)  评论(0编辑  收藏  举报