系统:Centos6.6x64
安装目录:/usr/local/
主:192.168.100.103
从:192.168.100.104
,下载安装:
安装依赖:
# yum install gcc tcl ruby -y
# wget http://download.redis.io/releases/redis-3.2.4.tar.gz
# tar xf redis-3.2..tar.gz
# mv redis-3.2. /opt/redis
# cd /opt/redis
# make
# make test ,内核修改配置
echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
/sbin/sysctl -p ,iptables端口开发 selinux关闭设置:
# cat /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT ,创建 数据 日志目录
mkdir -p redis/{log,data}
5,redis 主从配置
主服务:192.168.100.103
# cat redis.conf bind 192.168.100.103
protected-mode yes
port
tcp-backlog
timeout
tcp-keepalive
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /opt/redis/log/redis.log
databases
save
save
save
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /opt/redis/data
requirepass passwd
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay
repl-disable-tcp-nodelay no
slave-priority
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit
slowlog-log-slower-than
slowlog-max-len
latency-monitor-threshold
notify-keyspace-events ""
hash-max-ziplist-entries
hash-max-ziplist-value
list-max-ziplist-size -
list-compress-depth
set-max-intset-entries
zset-max-ziplist-entries
zset-max-ziplist-value
hll-sparse-max-bytes
activerehashing yes
client-output-buffer-limit normal
client-output-buffer-limit slave 256mb 64mb
client-output-buffer-limit pubsub 32mb 8mb
hz
aof-rewrite-incremental-fsync yes
从服务:192.168.100.104
# cat redis.conf bind 192.168.100.104
protected-mode yes
port
tcp-backlog
timeout
tcp-keepalive
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /opt/redis/log/redis.log
databases
save
save
save
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /opt/redis/data
slaveof 192.168.100.103
masterauth passwd
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay
repl-disable-tcp-nodelay no
slave-priority
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit
slowlog-log-slower-than
slowlog-max-len
latency-monitor-threshold
notify-keyspace-events ""
hash-max-ziplist-entries
hash-max-ziplist-value
list-max-ziplist-size -
list-compress-depth
set-max-intset-entries
zset-max-ziplist-entries
zset-max-ziplist-value
hll-sparse-max-bytes
activerehashing yes
client-output-buffer-limit normal
client-output-buffer-limit slave 256mb 64mb
client-output-buffer-limit pubsub 32mb 8mb
hz
aof-rewrite-incremental-fsync yes
6,启动测试:
# /opt/redis# nohup src/redis-server redis.conf &
# ps-ef|grep redis # /usr/local/redis/bin/redis-cli ping
7,测试:
主服务103上执行创建:
# /usr/local/redis/bin/redis-cli -h 192.168.100.103 -a passwd set test 从服务104上执行查看:
# /usr/local/redis/bin/redis-cli -h 192.168.100.104 get test
性能测试
# /usr/local/redis/bin/redis-benchmark 关闭服务
# /usr/local/redis/bin/redis-cli -p 6379 shutdown 强制刷新数据到磁盘【Redis默认是异步写入磁盘的】
# /usr/local/redis/bin/redis-cli -p 6379 save