Created
April 29, 2015 23:57
-
-
Save nexdrew/14392032ed6f105474a3 to your computer and use it in GitHub Desktop.
Example files for running Redis on CentOS 7 (after manual install)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/var/lib/redis/logs/redis.log { | |
daily | |
rotate 14 | |
copytruncate | |
delaycompress | |
compress | |
notifempty | |
missingok | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Redis Server | |
After=network.target | |
[Service] | |
Type=simple | |
PIDFile=/var/run/redis.pid | |
User=redis | |
ExecStartPre=/bin/mkdir -p /var/lib/redis/logs | |
ExecStart=/usr/local/bin/redis-server /etc/redis.conf | |
ExecStop=/bin/kill -15 $MAINPID | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<service> | |
<short>Redis Server</short> | |
<description>Redis Datastore Server</description> | |
<port protocol="tcp" port="6379"/> | |
</service> |
ExecStop=/bin/kill -15 $MAINPID
Where is MAINPID
defined??
@govindkailas It's provided/defined by Systemd. Source: http://www.dsm.fordham.edu/cgi-bin/man-cgi.pl?topic=systemd.service
Is there any advice regarding the Redis daemonize option within a systemd service? The Redis Administration page simply says "Use daemonize no when run under daemontools", which is default. Does this refer to any kind of startup system or just this specific tool set?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/etc/systemd/system/redis-server.service
This is a systemd unit (service) config file. After you add this file, make sure to set proper file permissions via
chmod 664 /etc/systemd/system/redis-server.service
. Then you can use systemd to run Redis as a managed service, e.g.$ systemctl daemon-reload $ systemctl start redis-server $ systemctl enable redis-server
This config has the following assumptions:
make
), and installed (viamake install
) Redis, and theredis-server
program was installed under/usr/local/bin
/etc/redis.conf
redis
user, which has write access to/var/lib/redis
/var/lib/redis/logs
(defined in/etc/redis.conf
)/etc/firewalld/services/redis-server.xml
This is a firewalld service config file. It lets you open the firewall for Redis as a service instead of by port and protocol directly. It assumes the following:
After you add this file, you can open remote access to Redis in firewalld via something like the following:
/etc/logrotate.d/redis-server
This is a logrotate config file that assumes the following:
/var/lib/redis/logs/redis.log
redis.log
each day and keep the last 14 days worth of logs