Friday, January 8, 2016

Redis server installation on webfaction/ on shared server

I come across redis while using sentry. With the latest version 7.7.4, you need redis to run sentry.

Here are the steps to install Redis server on shared server of webfaction -

First fetch redis installation on home directory (of your account)
$ wget "http://download.redis.io/releases/redis-3.0.6.tar.gz"

Extract it and remove the version name from the directory.
$ tar -xzf redis-3.0.6.tar.gz
$ mv redis-3.0.6 redis
(to keep it clean remove the redis-3.0.6.tar.gz)

Run installation
$ make
Run test to verify that installation was correct
$ make test
Now go to webfaction and create custom app, so that we can get port number and we can use it at various places on the configuration.

It will get you the new port information and creates the directory based on the name you have given inside the webapps directory in your account.

As per above, your app name is redis_server and custom port for it - 19957

Now copy redis.conf from extraction to the webapps.

$ cd ~/webapps/redis_server/
$ cp ~/redis/src/redis-server .
$ cp ~/redis/src/redis-cli .
$ cp ~/redis/redis.conf .
Update three items in the redis.conf file.

daemonize no > daemonize yes
pidfile /var/run/redis.pid > pidfile /home//webapps/redis_server/redis.pid
port 6379 -> port 19957
Now try to run it manually to verify once. (ideally we want to run it in background)
./redis-server redis.conf

Once it’s running, you can test if its running fine or now by going to cli
./redis-cli -p 19957

It should prompt -
127.0.0.1:19957>

Otherwise it will say-
not connected >

you can get out of the cli mode by Ctl + d

You can automate this commands by creating Makefile

vi Makefile
client cli:
       ./redis-cli -p 19957
start restart:
       ./redis-server redis.conf
stop:
       cat redis.pid | xargs kill

In order to start now, you can use
make start

to stop
make stop

you can manually search and find the redis process
ps -u $USER -o pid,command | grep redis

and kill it manually

Would still prefer the clean way of

No comments:

Post a Comment