This post we look into how to install latest Redis cache onto (say) Fedora 21. It is quite simple, and lets start:
Goto http://redis.io/download, and download latest version using wget.
wget http://download.redis.io/releases/redis-2.8.19.tar.gzuntar/unzip the package
tar -xzvf redis-2.8.19.tar.gzcompile the bundle
cd redis-2.8.19 makeIt is good to do a "make test" to test the functionality on your system. For this test you need tcl.
If you don't have tcl, install it by:
yum install tclRun make test:
make testIf functionality test passed it will show:
\o/ All tests passed without errors!Lets install the excutables into /usr/local/bin/.
make installFor Fedora systemctl system, lets create a redis service script.
vi /usr/lib/systemd/system/redis.service
[Unit] Description=Redis persistent key-value database After=network.target [Service] ExecStart=/usr/local/bin/redis-server /etc/redis.conf --daemonize no ExecStop=/usr/local/bin/redis-shutdown User=redis Group=redis [Install] WantedBy=multi-user.targetMove sample redis.conf to /etc.
cp /root/download/redis-2.8.19/redis.conf /etc/redis.confCreate redis-shutdown script.
vi /usr/local/bin/redis-shutdown
#!/bin/bash # # Wrapper to close properly redis and sentinel test x"$REDIS_DEBUG" != x && set -x REDIS_CLI=/usr/local/bin/redis-cli # Retrieve service name SERVICE_NAME="$1" if [ -z "$SERVICE_NAME" ]; then SERVICE_NAME=redis fi # Get the proper config file based on service name CONFIG_FILE="/etc/$SERVICE_NAME.conf" # Use awk to retrieve port from config file PORT=`awk '/^[[:blank:]]*port/ { print $2 }' $CONFIG_FILE` # Just in case, use default port if [ "$SERVICE_NAME" = redis ]; then PORT=${PORT:-6379} else PORT=${PORT:-26739} fi # shutdown the service properly $REDIS_CLI -p $PORT SHUTDOWN NOSAVEEnable and start redis service.
systemctl enable redis.service systemctl start redis.serviceLets try the redis-cli. Set a key and get a key:
[root@fc21 temp]# redis-cli 127.0.0.1:6379> get key1 (nil) 127.0.0.1:6379> set key1 value1 OK 127.0.0.1:6379> get key1 "value1"