Redis is an open source (BSD licensed), in-memory data structure used as database and cache. Its a very powerful and advanced key-value store. It supports data structures such as strings, hashes, lists, sets, sorted sets and much more.
We will discuss more on it. Let us start with the Installation of Redis. As said in couple of previous article you have to login on the terminal with root privileges to install it. or use sudo. I am asuming you are on root privilege.
Before installing Redis you need some tools installed like gcc, gcc-c++, make and tcl. So install it first.
Tools are now installed. Now navigate to /usr/local/src and download redis
yum -y install gcc gcc-c++ make tcl
Download and Install Redis
After downloading untar the downloaded file with above command and navigate to redis directory
tar xzf redis-3.0.6.tar.gz
Now build It and Install
You can now test installation (Optional)If everything is ok it will display All tests passed without errors! in the end
Now copy the binary to bin directory
Now create a directory and copy Redis config file to it.
cp src/redis-server src/redis-cli /usr/local/bin
Now create a working directory for this Redis instance. -p option is for creating recursive directory structure under /var i.e. redis/6379
cp redis.conf /etc/redis
Edit Redis config file with your favourite text editor to make some necessery changes. Make sure you make change to following lines and set its value as given
mkdir -p /var/redis/6379
Now download Redis init script (redis-server) and move it to /etc/init.d and make it execeutable
loglevel notice (choose any one from verbose/debug/notice/warning)
Make sure Redis restarts on server reboot. So add it and start Redis
mv redis-server /etc/init.d
chmod 755 /etc/init.d/redis-server
Now open /etc/sysctl.conf in any editor and add following line in the bottom of file (Optional)
chkconfig --add redis-server
chkconfig redis-server on
service redis-server start
And thats it. We are done with Redis Installation. Open Redis CLI terminal with following command
#Add following line on bottom
You are now on Redis command line. Try executing Redis commands here. Type exit or press ctrl+c to close session.