Skip to content

Instantly share code, notes, and snippets.

@kometchtech
Last active December 15, 2017 06:10
Show Gist options
  • Save kometchtech/c23e4205607ec3100b195f381c36b095 to your computer and use it in GitHub Desktop.
Save kometchtech/c23e4205607ec3100b195f381c36b095 to your computer and use it in GitHub Desktop.
Redis server systemctl file
#Type Path Mode UID GID Age Argument
d /var/run/redis 0755 redis redis - -
--- redis.conf 2017-12-14 20:50:34.970383998 +0900
+++ redis_6379.conf 2017-12-14 22:59:59.558271829 +0900
@@ -1,3 +1,4 @@
+## Generated by install_server.sh ##
# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
@@ -66,7 +67,7 @@
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-bind 127.0.0.1
+#bind 127.0.0.1 ::1
# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
@@ -89,7 +90,7 @@
# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
-port 6379
+#port 6379
# TCP listen() backlog.
#
@@ -108,6 +109,8 @@
#
# unixsocket /tmp/redis.sock
# unixsocketperm 700
+unixsocket /var/run/redis/redis.sock
+unixsocketperm 766
# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
@@ -133,7 +136,7 @@
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
-daemonize no
+daemonize yes
# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
@@ -155,7 +158,7 @@
#
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
-pidfile /var/run/redis_6379.pid
+pidfile /var/run/redis/redis_6379.pid
# Specify the server verbosity level.
# This can be one of:
@@ -168,7 +171,7 @@
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
-logfile ""
+logfile /var/log/redis/redis_6379.log
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
@@ -215,9 +218,11 @@
#
# save ""
-save 900 1
-save 300 10
-save 60 10000
+#save 900 1
+#save 300 10
+#save 60 10000
+
+save ""
# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
@@ -260,7 +265,7 @@
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
-dir ./
+dir /var/lib/redis/6379
################################# REPLICATION #################################
@@ -699,8 +704,8 @@
# If unsure, use "everysec".
# appendfsync always
-appendfsync everysec
-# appendfsync no
+#appendfsync everysec
+ appendfsync no
# When the AOF fsync policy is set to always or everysec, and a background
# saving process (a background save or AOF log background rewriting) is
[Unit]
Description=Redis persistent key-value database
After=network.target
Before=kresd.service
[Service]
Type=forking
# Since it is set in config file, description is unnecessary
# PIDFile=/var/run/redis/redis_6379.pid
User=redis
Group=redis
# Is not set up in tmpfiles.d unnecessary?
Environment=statedir=/var/run/redis
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p ${statedir}
ExecStartPre=/bin/chown -R redis:redis ${statedir}
ExecStart=/usr/local/bin/redis-server /etc/redis/redis_6379.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment