-
Notifications
You must be signed in to change notification settings - Fork 1
Example Redis Setup (Ubuntu)
Angel Sanadinov edited this page May 9, 2017
·
4 revisions
Setup: Elasticsearch | Redis | Solr
These are example steps for setting up a Redis instance on Ubuntu. They will create a user redis, download version 3.2.8, install it under /opt/redis and add config under /opt/redis/<org>.
<org>should be replaced with some identifier (your organization, user, etc).
useradd -d /home/redis -m redis
mkdir -p /opt/redis/<org>/data
cd /opt/redis
wget http://download.redis.io/releases/redis-3.2.8.tar.gz
tar -xzf redis-3.2.8.tar.gz
cd redis-3.2.8
make
make test
make PREFIX=/opt/redis install
# ... add service script ...
touch /opt/redis/<org>/com-<org>-redis.sh
# ... add Redis config ...
touch /opt/redis/<org>/core.conf
touch /var/log/redis.log
chown redis.redis /var/log/redis.log
chown -R redis.redis /opt/redis
sudo chmod 700 /opt/redis/<org>/com-<org>-redis.sh
sudo ln -s /opt/redis/<org>/com-<org>-redis.sh /etc/init.d/com-<org>-redis
sudo update-rc.d com-<org>-redis defaults 97 03
- Ubuntu
16.04,17.04 - Redis
3.2.5,3.2.8
Replace <org> with your organization name (or something else)
#! /bin/sh
### BEGIN INIT INFO
# Provides: com-<org>-redis
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: redis
# Description: This file starts and stops a single Redis instance
### END INIT INFO
case "$1" in
start)
su redis -c "/opt/redis/bin/redis-server /opt/redis/<org>/core.conf"
;;
stop)
su redis -c "kill $(head -1 /opt/redis/redis.pid)"
;;
restart)
su redis -c "kill $(head -1 /opt/redis/redis.pid)"
sleep 5
su redis -c "/opt/redis/bin/redis-server /opt/redis/<org>/core.conf"
;;
status)
1
;;
*)
echo "Usage: com-<org>-redis.sh {start|stop|restart}" >&2
exit 3
;;
esac################################ GENERAL #####################################
# Run as daemon
daemonize yes
pidfile /opt/redis/redis.pid
port 6379
tcp-backlog 511
bind 127.0.0.1
timeout 0
tcp-keepalive 60
loglevel notice
logfile "/var/log/redis.log"
databases 1
notify-keyspace-events ""
################################ PERSISTENCE ################################
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /opt/redis/<org>/data
appendonly no
################################## SECURITY ###################################
# Require clients to issue AUTH <PASSWORD> before processing any commands
requirepass <some password>
################################### LIMITS ####################################
maxclients 16
maxmemory 1GB
maxmemory-policy allkeys-lru
maxmemory-samples 10
################################ LUA SCRIPTING ###############################
lua-time-limit 5000
################################## SLOW LOG ###################################
slowlog-log-slower-than 10000
slowlog-max-len 128
############################### ADVANCED CONFIG ###############################
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 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
Home | Getting Started | Structure | Containers | Workflows | Controllers