redis单机开启多实例

php教程评论560 views阅读模式

这篇文章主要介绍了关于redis单机开启多实例,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库、缓存和消息中间件。 它支持多种类型的数据结构,如 字符串(strings), 散列(hashes), 列表(lists), 集合(sets), 有序集合(sorted sets) 与范围查询, bitmaps, hyperloglogs 和地理空间(geospatial) 索引半径查询。 Redis 内置了 复制(replication),LUA脚本(Lua scripting), LRU驱动事件(LRU eviction),事务(transactions) 和不同级别的 磁盘持久化(persistence), 并通过 Redis哨兵(Sentinel)和自动 分区(Cluster)提供高可用性(high availability)。

单机多实例设置

Redis 支持在同一台主机上运行多个实例, 用来提供不同目的的服务.
通过开放的端口号来区分, 默认端口是 6379, 配置文件路径是:
/etc/redis/redis.conf
如果打算新开一个实例使用6581端口, 那么拷贝一份配置文件改名为 redis-6581.conf
修改里面与端口有关的配置:

port 6581pidfile /var/run/redis/redis-server-6581.pid
unixsocket /var/run/redis/redis-6581.sock
logfile /var/log/redis/redis-server-6581.logdbfilename dump-6581.rdb

需要注意的是, 正常应该使用 redis 用户启动 redis 服务, 意味着需要将以上配置文件涉及的目录权限赋予 redis 用户.

使用 redis 用户启动新服务的命令是:

# su -l redis --shell=/bin/bash -c '/usr/bin/redis-server /etc/redis/redis-6581.conf'

以下是一个示例配置文件:

# su -l redis --shell=/bin/bash -c '/usr/bin/redis-server /etc/redis/redis-6581.conf'daemonize yes

port 6581pidfile /var/run/redis/redis-server-6581.pid
unixsocket /var/run/redis/redis-6581.sock
logfile /var/log/redis/redis-server-6581.logdbfilename dump-6581.rdb

tcp-backlog 511bind 127.0.0.1unixsocketperm 777timeout 0tcp-keepalive 0loglevel notice
databases 16save ""stop-writes-on-bgsave-error yesrdbcompression yes
dir /var/lib/redis
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5repl-disable-tcp-nodelay no
slave-priority 100appendonly no
appendfilename "appendonly.aof"appendfsync everysec
no-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000slowlog-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 256
mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes

以上就是redis单机开启多实例的详细内容,更多请关注php教程网其它相关文章!

企鹅博客
  • 本文由 发表于 2019年10月1日 23:33:35
  • 转载请务必保留本文链接:https://www.qieseo.com/247988.html

发表评论