Difference between revisions of "Redis"

From ArchWiki
Jump to navigation Jump to search
(→‎Listen on socket: change tmp file)
m (→‎Listen on socket: /var/run is a symlink to /run)
Line 24: Line 24:
  
 
* Enable and update the Redis socket path:
 
* Enable and update the Redis socket path:
  unixsocket /var/run/redis/redis.sock
+
  unixsocket /run/redis/redis.sock
  
 
* Set permission to the socket to all members of the redis [[group]]:
 
* Set permission to the socket to all members of the redis [[group]]:
Line 30: Line 30:
  
 
* Create the directory which contains the socket:
 
* Create the directory which contains the socket:
  # mkdir /var/run/redis
+
  # mkdir /run/redis
  # chown redis:redis /var/run/redis
+
  # chown redis:redis /run/redis
  # chmod 755 /var/run/redis
+
  # chmod 755 /run/redis
  
 
* Persist the directory which contains the socket:
 
* Persist the directory which contains the socket:
  
 
{{hc|/etc/tmpfiles.d/redis.conf|2=
 
{{hc|/etc/tmpfiles.d/redis.conf|2=
d /var/run/redis 0755 redis redis -
+
d /run/redis 0755 redis redis -
 
}}
 
}}
  

Revision as of 19:10, 8 June 2017

From Wikipedia:Redis:

Redis is a software project that implements data structure servers. It is open-source, networked, in-memory, and stores keys with optional durability.

Installation

Install the redis package.

Start/enable redis.service.

Configuration

The Redis configuration file is well-documented and located at /etc/redis.conf.

  • By default, if no "bind" configuration directive is specified, Redis listens for connections from all the network interfaces. it may be preferred to allow only access on the host instead:
bind 127.0.0.1
  • Accept connections on the specified port (default is 6379), specify port 0 to disable listing on TCP:
port 6379 

Listen on socket

Using Redis over a Unix socket may give a performance increase, compared to TCP/IP [1].

The following changes should be made in /etc/redis.conf to enable use of the unix socket:

  • Enable and update the Redis socket path:
unixsocket /run/redis/redis.sock
  • Set permission to the socket to all members of the redis group:
unixsocketperm 770
  • Create the directory which contains the socket:
# mkdir /run/redis
# chown redis:redis /run/redis
# chmod 755 /run/redis
  • Persist the directory which contains the socket:
/etc/tmpfiles.d/redis.conf
d /run/redis 0755 redis redis -
  • Add users (e.g. git, http) to the redis group so they can access and use the socket.

Finally restart the redis.service.