码迷,mamicode.com
首页 > 其他好文 > 详细

redis安装

时间:2016-05-06 12:00:44      阅读:317      评论:0      收藏:0      [点我收藏+]

标签:

# mkdir /opt/redis
# cd /opt/redis
# wget http://download.redis.io/redis-stable.tar.gz
# tar zxf redis-stable.tar.gz 
# cd redis-stable
# make
# make test
提示You need tcl 8.5 or newer in order to run the Redis test
# wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz  
# tar xzf tcl8.6.1-src.tar.gz -C /usr/local/  
# cd /usr/local/tcl8.6.1/unix/
# ./configure
# make
# make install
# cd -
# make test
这里没有make install,而是直接使用make好的命令
# echo "export PATH="/opt/redis/redis-stable/src/:$PATH"" >> /etc/profile
# source /etc/profile

redis命令工具:

redis-benchmark   性能测试工具
redis-check-aof  AOF文件修复工具
redis-check-dump  RDB文件检查工具
redis-cli      redis客户端
redis-sentinel   redis集群工具
redis-server    redis服务器

# mkdir -p /data/redis/redis6379
# cp /opt/redis/redis-stable/redis.conf /data/redis/redis6379/6379.conf
# vim /data/redis/redis6379/6379.conf
daemonize yes
pidfile /data/redis/redis6379/redis_6379.pid
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel notice
logfile "/data/redis/redis6379/6379.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename 6379.rdb
dir /data/redis/redis6379
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
maxclients 10000
maxmemory 100M
maxmemory-policy volatile-lru
appendonly yes
appendfilename "6379.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 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

  启动redis

# redis-server /data/redis/redis6379/6379.conf
# ss -tunlp|grep 6379
# cp /opt/redis/redis-stable/utils/redis_init_script /etc/init.d/redis
# vim /etc/init.d/redis 
......
REDISPORT=6379
EXEC=/opt/redis/redis-stable/src/redis-server 
CLIEXEC=/opt/redis/redis-stable/src/redis-cli

PIDFILE=/data/redis/redis6379/redis_${REDISPORT}.pid
CONF="/data/redis/redis6379/${REDISPORT}.conf"
......
# /etc/init.d/redis stop
# /etc/init.d/redis start

  测试

# redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> echo ‘hi‘
"hi"
127.0.0.1:6379> set site www.google.com.cn
OK
127.0.0.1:6379> get site
"www.google.com.cn"

  搭建从库

# mkdir /data/redis/redis6380/
# cp /data/redis/redis6379/6379.conf /data/redis/redis6380/6380.conf
# sed -i ‘s/6379/6380/g‘ /data/redis/redis6380/6380.conf
# echo "slaveof 192.168.56.71 6379" >> /data/redis/redis6380/6380.conf
# redis-server /data/redis/redis6380/6380.conf

  测试

# redis-cli -p6379
Unrecognized option or bad number of args for: ‘-p6379‘
# redis-cli -p 6379
127.0.0.1:6379> set test 111
OK

  

# redis-cli -p 6380
127.0.0.1:6380> get test
"111"
127.0.0.1:6380> info replication
# Replication
role:slave
master_host:192.168.56.71
master_port:6379
master_link_status:up
master_last_io_seconds_ago:8
master_sync_in_progress:0
slave_repl_offset:868
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

  

 

redis安装

标签:

原文地址:http://www.cnblogs.com/adba/p/5464951.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!