Skip to content

Instantly share code, notes, and snippets.

@ryanguill
Last active December 31, 2015 03:39
Show Gist options
  • Save ryanguill/7928914 to your computer and use it in GitHub Desktop.
Save ryanguill/7928914 to your computer and use it in GitHub Desktop.

Preface

This guide is one section of a larger guide to installing a cent 6.x server in virtual box for development purposes with different applications. The top level guide with links to all of the sections is here: https://gist.github.com/ryanguill/5149058 Some instructions in this guide may assume a configuration from other parts of the guide.

#Install Redis

Instructions taken loosely from here: http://www.ebrueggeman.com/blog/install-redis-centos-56

See also these instructions: http://library.linode.com/databases/redis/centos-5 ... might be good to create a special user for redis to run as like these instructions talk about.

# su -
# yum install make gcc wget telnet
# wget http://download.redis.io/releases/redis-2.8.9.tar.gz
# tar -xvf redis-2.8.9.tar.gz
# cd redis-2.8.9
# make && make install

We're going to change the default redis.conf file to daemonize it, change the location of the database, change the log notices to a production acceptable level, and change the logfile location.

# mkdir /etc/redis /var/lib/redis
# sed -e "s/^daemonize no$/daemonize yes/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel debug$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" redis.conf > /etc/redis/redis.conf

To make management easy, we're going to use an init script that I found here on github. The install location on this script doesn't match where the /usr/local/bin/redis-server location we're using, so I'm using sed to update it.

# wget https://gist.githubusercontent.com/paulrosania/257849/raw/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
# sed -i "s/usr\/local\/sbin\/redis/usr\/local\/bin\/redis/" redis-server
# chmod u+x redis-server
# mv redis-server /etc/init.d
# /sbin/chkconfig --add redis-server
# /sbin/chkconfig --level 345 redis-server on
# /sbin/service redis-server start

By now it should be running. Test it out

# redis-cli
# set foo bar
# get foo

We need to edit the redis.conf to tell it to write the data to the /data partition

Create the directory for redis data

# mkdir /data/redis
# sudo chmod 777 /data/redis
# sudo chown user:user /data/redis

If you want to make sure that Redis writes synchronously to disk (because you care about every write that happens) - change the config to be appendonly yes

# sudo vi /etc/redis/redis.conf

Look for the line that says

dir /var/lib/redis/

Change it to say:

dir /data/redis/

Then, if you want to make sure that Redis writes synchronously to disk (because you care about every write that happens) - change the config to be appendonly yes

Find this line and change no to yes

appendonly no

Restart the service

# sudo service redis-server restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment