Thursday, May 7, 2015

Redis Quick installation on CentOS


Install below packages if missed
sudo yum install -y gcc
sudo yum install -y tcl

-------------------------------------------------------------------
Now Download and isntall
sudo mkdir cp /usr/share/blue/redis
cd /usr/share/blue/redis
sudo wget http://download.redis.io/redis-stable.tar.gz
sudo tar xvzf redis-stable.tar.gz
cd redis-stable
cd deps; sudo make hiredis lua jemalloc linenoise
cd ..
sudo make

-------------------------------------------------------------------
After successfull installation test it. This step takes around 2-3 minutes.
sudo make test
If every thing is perfect then you get below Message
\o/ All tests passed without errors!

-------------------------------------------------------------------
Now copy Redis server and command line interface in proper places
sudo make install
This above step does these given two operations
sudo cp src/redis-server /usr/local/bin/
sudo cp src/redis-cli /usr/local/bin/

-------------------------------------------------------------------
We are using the default configuration file, so for safe side, we can take a backup of original conf file
cp /usr/share/blue/redis/redis-stable/redis.conf /usr/share/blue/redis/redis-stable/redis.conf.bak

-------------------------------------------------------------------
***** PROPER installation for live system *****
sudo mkdir /etc/redis
sudo mkdir /var/redis
sudo cp /usr/share/blue/redis/redis-stable/utils/redis_init_script /etc/init.d/redis_6379
sudo cp /usr/share/blue/redis/redis-stable/redis.conf /etc/redis/6379.conf
sudo mkdir /var/redis/6379

-------------------------------------------------------------------
Update config file
sudo vim /etc/redis/6379.conf

Set daemonize to yes (by default it is set to no).
        To set server to start in the background, ope /etc/redis.conf and change "daemonize" key value "yes"

Set the pidfile to /var/run/redis_6379.pid (modify the port if needed).
Change the port accordingly. In our example it is not needed as the default port is already 6379.

Set the logfile to /var/log/redis_6379.log
Set the dir to /var/redis/6379 (very important step!)

-------------------------------------------------------------------
change the logfile permissions
sudo vim /var/log/redis_6379.log // create the file, if not existed
sudo chmod 777 /var/log/redis_6379.log
change permission so that server can "save" dump files as "dump.rdb"
sudo chmod 777 /var/redis/6379
adds the new Redis init script to all the default runlevels
         sudo update-rc.d redis_6379 defaults

-------------------------------------------------------------------
Now we can run our instance by below command
/etc/init.d/redis_6379 start
Redis listens on port number: 6379, check is started
ps aux | grep redis
now check the logs at
tail -f /var/log/redis_6379.log

-------------------------------------------------------------------
Now test the server by client
redis-cli ping
response will be: PONG
we can start client in interactive mode, by not passing any params
redis-cli

-------------------------------------------------------------------
Shutdown redis
      redis-cli shutdown
 OR you can do this by connecting client in interactive mode then give "shutdown" command

-------------------------------------------------------------------
Set the password
uncomment "requirepass" line and replace dummy password with real and long password
sudo vim /etc/redis/6379.conf

-------------------------------------------------------------------
Interactive Tutorial
    http://try.redis.io/
-------------------------------------------------------------------

more: http://redis.io/topics/quickstart
For securing your redis server, more info: http://redis.io/topics/security

No comments:

Post a Comment