Home > Backend Development > PHP Tutorial > Open multiple instances of redis on a single machine

Open multiple instances of redis on a single machine

不言
Release: 2023-03-24 22:30:01
Original
1717 people have browsed it

This article mainly introduces how to open multiple instances of redis on a single machine. It has certain reference value. Now I share it with you. Friends in need can refer to it.

Redis is an open source (BSD license). An in-memory data structure storage system that can be used as a database, cache, and messaging middleware. It supports many types of data structures such as strings, hashes, lists, sets, sorted sets and range queries, bitmaps, hyperloglogs and geospatial ( geospatial) index radius query. Redis has built-in replication, LUA scripting, LRU eviction, transactions and different levels of disk persistence, and through Redis Sentinel and automatic partitioning (Cluster) ) provides high availability.

Single-machine multi-instance setup

Redis supports running multiple instances on the same host to provide services for different purposes.
Distinguished by open port numbers, the default port is 6379, the configuration file path is:
/etc/redis/redis.conf
If you plan to open a new instance to use port 6581, then copy the configuration file and rename it redis-6581.conf
Modify the port-related configuration:

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
Copy after login

It should be noted that normally the redis user should be used to start the redis service, which means that the directory permissions involved in the above configuration file need to be given to the redis user.

The command to start a new service using the redis user is:

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

The following is a sample configuration file:

# 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

Copy after login

         

The above is the detailed content of Open multiple instances of redis on a single machine. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template