目录
Centos 5.x redis-2.8.19 安装配置... 1
版本历史
时间 | 版本 | 说明 | 编写者 |
2015-01-11 | 1.0 | Centos 5.x redis-2.8.19 安装配置 | csc |
系统:centos 5.8 64 bit
软件:redis-2.8.19.tar.gz
1. 安装 redis-2.8.19.tar.gz
tar -zxvf redis-2.8.19.tar.gz
cd redis-2.8.19
make
make install
cp redis.conf /etc/redis.conf
2. redis配置:
mkdir /data/redis/ -p
redis配置:
红色部署需要修改:
[root@yunli13redis]# cat /etc/redis.conf |grep -v ^# |grep -v ^$
daemonize no
pidfile /var/run/redis.pid
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel notice
logfile"/data/redis/redis.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /data/redis/
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
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
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 64mb60
client-output-buffer-limit pubsub 32mb 8mb60
hz 10
aof-rewrite-incremental-fsync yes
3. redis启动方式:
echo "exportPATH=$PATH:/usr/local/bin/ " >> /etc/profile
source /etc/profile
/usr/local/bin/redis-server/etc/redis.conf &
查看端口是否启用:
[root@yunli13redis-2.4.16]# netstat -ntpl
Active Internetconnections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 00.0.0.0:6379 0.0.0.0:* LISTEN 10217/redis-server
日志路径: /data/redis/redis.log
· redis-server:Redis服务器的daemon启动程序
· redis-cli:Redis命令行操作工具。当然,你也可以用telnet根据其纯文本协议来操作
· redis-benchmark:Redis性能测试工具,测试Redis在你的系统及你的配置下的读写性能
· redis-stat:Redis状态检测工具,可以检测Redis当前状态参数及延迟状况
4.关闭服务:
$ redis-cli shutdown
#关闭指定端口的redis-server
$redis-cli -p 6380 shutdown
状态监控:
redis-cli --stat
[root@whyl-vm-70-13-zspj~]# redis-cli --stat
------- data------ --------------------- load -------------------- - child -
keys mem clients blocked requests connections
0 791.83K 1 0 0 (+0) 2
5.命令测试
# redis-cli
redis> set foo bar
OK
redis> get foo "bar"
redis 主从集群配置:
配置Master-Slave,只需要在Slave上配置Master节点IP、 Port:
修改:
#slaveof <masterIP> <masterPort> 为:
slaveof 192.168.70.13 6379
其他部分与主一样:
#cat /etc/redis.conf |grep -v ^# |grep -v^$
daemonize no
pidfile /var/run/redis.pid
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel notice
logfile"/data/redis/redis.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /data/redis/
slaveof 192.168.70.13 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
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
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 64mb60
client-output-buffer-limit pubsub 32mb 8mb60
hz 10
aof-rewrite-incremental-fsync yes