小丸子學Redis系列之——安裝Redis

wxjzqym發表於2015-12-14
目前Redis最新的穩定版本為3.0.5,那麼就以次版本為例,以下是安裝步驟:
一.安裝Redis
1.下載Redis3.0軟體包並解壓
[root@vm1 ~]# cd /appbase/apps
[root@vm1 ~]# rz 
[root@vm1 ~]# tar xzvf redis-3.0.5.tar.gz 


2.建立個人使用者
[root@vm1 ~]# useradd -u 611 -g dbg -d /appbase/users/rdsusr01 rdsusr01
[root@vm1 ~]# echo oracle|passwd --stdin rdsusr01


3.編譯安裝Redis
[root@vm1 apps]# cd /appbase/apps/redis-3.0.5
[root@vm1 redis-3.0.5]# make
[root@vm1 redis-3.0.5]# make test
[root@vm1 redis-3.0.5]#make PREFIX=/appbase/users/rdsusr01/redis
[root@vm1 redis-3.0.5]# make PREFIX=/appbase/users/rdsusr01/redis install


--安裝完成後會生產以下檔案
[root@vm1 redis-3.0.5]# ls /appbase/users/rdsusr01/redis/bin
redis-benchmark  redis-check-aof  redis-check-dump  redis-cli  redis-sentinel  redis-server
--簡單說明下每個檔案的作用
redis-server:Redis伺服器
redis-sentinel:Redis哨兵服務,主要用於監控和故障切換
redis-cli:與Redis服務互動的命令列介面
redis-benchmark:用於檢測Redis效能
redis-check-aof:AOF檔案檢查工具
redis-check-dump:RDB檔案檢查工具


4.配置Redis
[root@vm1 redis-3.0.5]# chown -R rdsusr01:dbg /appbase/users/rdsusr01
[root@vm1 redis-3.0.5]# su - rdsusr01
[rdsusr01@vm1 ~]$ vi .bash_profile
export REDIS_HOME=/appbase/users/rdsusr01/redis
export PATH=$REDIS_HOME/bin:$PATH
[rdsusr01@vm1 ~]$ source .bash_profile

[rdsusr01@vm1 ~]$ mkdir redis/{logs,conf,data}
[rdsusr01@vm1 ~]$ cp /appbase/apps/redis-3.0.5/redis.conf redis/conf/
[rdsusr01@vm1 ~]$ vi redis/conf/redis.conf
daemonize yes
pidfile /appbase/users/rdsusr01/redis/data/redis-single.pid
port 16379
tcp-backlog 511
bind 192.168.157.128
timeout 180
tcp-keepalive 60
loglevel notice
logfile /appbase/users/rdsusr01/redis/logs/redis-single.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename redis-signle
dir /appbase/users/rdsusr01/redis/data/
appendonly 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-entries 512
list-max-ziplist-value 64
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
注:標紅的引數為修改的內容,其餘的引數都是繼承的預設值。


4.啟動Redis
[rdsusr01@vm1 ~]$ redis-server /appbase/users/rdsusr01/redis/conf/redis.conf


5.驗證Redis服務是否正常
[rdsusr01@vm1 ~]$ redis-cli -h 192.168.157.128 -p 16379
192.168.157.128:16379> ping
PONG
192.168.157.128:16379> set person leige
OK
192.168.157.128:16379> get person
"leige"
至此,Redis安裝成功

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20801486/viewspace-1871982/,如需轉載,請註明出處,否則將追究法律責任。

相關文章