This article mainly introduces the Redis single-use open multi-instance, has a certain reference value, now share to everyone, the need for friends can refer to
Redis is an open-source (BSD-licensed), in-memory data structure storage system that can be used as a database, cache, and message middleware. It supports multiple types of data structures such as string (strings), hash (hashes), list (lists), set (sets), ordered set (sorted sets) with Range query, bitmaps, hyperloglogs and geo-spatial (geospatial) Index RADIUS query. Redis has built-in replication (replication), LUA scripting (LUA scripting), LRU driver events (LRU eviction), transactions (transactions), and different levels of disk persistence (persistence), and Redis Sentinel (Sentinel) and automatic partitioning (Cluster) provide high availability (HI availability).
Single-Machine multi-instance Setup
Redis supports running multiple instances on the same host to serve different purposes.
Distinguished by an open port number, the default port is 6379, and the configuration file path is:
/etc/redis/redis.conf
If you plan to open a new instance using port 6581, copy a configuration file and rename it to redis-6581.conf
Modify the port-related configuration inside:
Port 6581pidfile/var/run/redis/redis-server-6581.pidunixsocket/var/run/redis/redis-6581.socklogfile/var/log/ Redis/redis-server-6581.logdbfilename Dump-6581.rdb
It should be noted that Redis users should normally be used to start the Redis service, which means that the directory permissions involved in the above configuration file need to be assigned to Redis users.
The command to start a new service using a Redis user is:
# su-l Redis--shell=/bin/bash-c '/usr/bin/redis-server/etc/redis/redis-6581.conf '
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