redis 单实例

单机多实例

安装

wget http://download.redis.io/releases/redis-3.2.9.tar.gz
make PREFIX=/usr/local/redis install

配置 redis6379.conf

bind ip1 ip2
unixsocket /usr/local/redis/redis.sock
unixsocketperm 700
tcp-keepalive 300
pidfile /usr/local/redis/redis_6379.pid
loglevel notice
logfile “/usr/local/redis/logs/6379.log”
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump6379.rdb
dir /usr/local/redis/data/
# slaveof
# masterauth
slave-serve-stale-data yes
slave-read-only yes

repl-diskless-sync no
repl-diskless-sync-delay 5

# repl-ping-slave-period 10
# repl-timeout 60
repl-disable-tcp-nodelay no
# repl-backlog-size 1mb
# repl-backlog-ttl 3600
slave-priority 100

# min-slaves-to-write 3
# min-slaves-max-lag 10
requirepass 111111

# maxclients 10000
# maxmemory

# maxmemory-policy noeviction

appendonly no
appendfilename “appendonly.aof”

# appendfsync always
appendfsync everysec
# appendfsync no

no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

aof-load-truncated yes
lua-time-limit 5000
# cluster-enabled yes
# cluster-config-file nodes-6379.conf
# cluster-node-timeout 15000
# cluster-slave-validity-factor 10
# cluster-migration-barrier 1
# cluster-require-full-coverage yes
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events “”
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

创建目录

/usr/local/redis/data
/usr/local/redis/logs
/usr/local/redis/conf

启动

/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf &

停止

/usr/local/redis/bin/redis-cli -h 172.26.13.250 -p 6379 -a 111111 shutdown

信息
/# /usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 6379 info
测试:
向redis服务器发送10个请求,每个请求附带50个并发客户端,-n 接请求数,-c 接并发数
/# /usr/local/redis/bin/redis-benchmark -h 127.0.0.1 -p 6379 -n 10 -c 50

过期策略
LRU是Least Recently Used 近期最少使用算法。

volatile-lru -> 根据LRU算法生成的过期时间来删除。
allkeys-lru -> 根据LRU算法删除任何key。
volatile-random -> 根据过期设置来随机删除key。
allkeys->random -> 无差别随机删。
volatile-ttl -> 根据最近过期时间来删除(辅以TTL)
noeviction -> 谁也不删,直接在写操作时返回错误。

最大内存
maxmemory 268435456 // byte
可为物理内存的3/4

ps:
28934:M 28 Jun 14:33:02.815 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
28934:M 28 Jun 14:33:02.815 # Server started, Redis version 3.2.9
28934:M 28 Jun 14:33:02.815 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ‘vm.overcommit_memory = 1’ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1’ for this to take effect.
28934:M 28 Jun 14:33:02.815 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command ‘echo never > /sys/kernel/mm/transparent_hugepage/enabled’ as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
28934:M 28 Jun 14:33:02.815 * The server is now ready to accept connections on port 6379
28934:M 28 Jun 14:33:02.815 * The server is now ready to accept connections at /usr/local/redis/redis.sock

echo 10000 >/proc/sys/net/core/somaxconn
echo never > /sys/kernel/mm/transparent_hugepage/enabled
sysctl vm.overcommit_memory=1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值