Setting up a Redis server is very simple to do. Simply install the software, make a few configuration changes, and startup the service. In the example below, we will show how to install Redis on a single server.
Install Redis
# mkdir /redis
# cd /redis
# wget http://download.redis.io/releases/redis-3.0.2.tar.gz
# tar xzf redis-3.0.2.tar.gz
# cd redis-3.0.2
# apt-get update
# apt-get install make
# apt-get install build-essential
# cd deps; make hiredis lua jemalloc linenoise
# cd /redis/redis-3.0.2
# make
#cd /
#chown -R redis redis
Run Redis
src/redis-server &
Test Redis
src/redis-cli
redis> set foo bar
OK
redis> get foo
“bar”
Configure Redis
# vi /redis/redis-3.0.2/redis.conf
To configure replication is trivial: just add the following line to the slave configuration file:
# slaveof <masterip> <masterport>
slaveof 192.168.1.1 6379
Note:
Redis does not requires root privileges to run. It is recommended to run it as an unprivileged redis user that is only used for this purpose.