这篇文章主要介绍了关于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'
以下是一个示例配置文件:
<p style="margin-bottom: 7px;"># su -l redis --shell=/bin/bash -c '/usr/bin/redis-server /etc/redis/redis-6581.conf'daemonize yes<br/><br/>port 6581pidfile /var/run/redis/redis-server-6581.pid<br/>unixsocket /var/run/redis/redis-6581.sock<br/>logfile /var/log/redis/redis-server-6581.logdbfilename dump-6581.rdb<br/><br/>tcp-backlog 511bind 127.0.0.1unixsocketperm 777timeout 0tcp-keepalive 0loglevel notice<br/>databases 16save ""stop-writes-on-bgsave-error yesrdbcompression yes<br/>dir /var/lib/redis<br/>slave-serve-stale-data yes<br/>slave-read-only yes<br/>repl-diskless-sync no<br/>repl-diskless-sync-delay 5repl-disable-tcp-nodelay no<br/>slave-priority 100appendonly no<br/>appendfilename "appendonly.aof"appendfsync everysec<br/>no-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mb<br/>aof-load-truncated yes<br/>lua-time-limit 5000slowlog-log-slower-than 10000<br/>slowlog-max-len 128<br/>latency-monitor-threshold 0<br/>notify-keyspace-events ""<br/>hash-max-ziplist-entries 512<br/>hash-max-ziplist-value 64<br/>list-max-ziplist-entries 512<br/>list-max-ziplist-value 64<br/>set-max-intset-entries 512<br/>zset-max-ziplist-entries 128<br/>zset-max-ziplist-value 64<br/>hll-sparse-max-bytes 3000<br/>activerehashing yes<br/>client-output-buffer-limit normal 0 0 0<br/>client-output-buffer-limit slave 256<br/>mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes<br/></p>
以上就是redis单机开启多实例的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号