Friday, December 23, 2016

Redis Standalone Installation on AWS

1. Login to AWS using PuTTy

    $ ec2-user
    $ sudo su -
    $ cd /mnt1/analytics/arvind

2. Download, extract and make Redis

    $ wget http://download.redis.io/redis-stable.tar.gz
    $ tar xvzf redis-stable.tar.gz
    $ cd redis-stable
    $ make
    $ sudo make install  // Copies redis-server & redis-cli to /usr/local/bin/

3. Test the Connections:

+-------------------------------------------------------------------+
| $ redis-server                    |    $ redis-cli ping            |
| [...] ... The server is now         |      PONG                        |
|        ... ready to accept         |    $ redis-cli                 |
|        ... connections on            |    redis 127.0.0.1:6379> ping    |
|        ... port 6379                |    PONG                        |
|                                    |    redis 127.0.0.1:6379> exit    |
|                                    |    $ redis-cli shutdown        |
+-------------------------------------------------------------------+

4. Create directories to store Redis config files and data

    $ sudo mkdir /etc/redis
    $ sudo mkdir /var/redis
   

5. Copy the init script from utils directory into /etc/init.d

    $ sudo cp utils/redis_init_script /etc/init.d/redis_6379
   

6. Copy the template configuration file from root directory into /etc/redis/

    $ sudo cp redis.conf /etc/redis/6379.conf

7. Edit the configuration file:

    A. Set daemonize to yes
    B. Set the pidfile to /var/run/redis_6379.pid
    C. Change the port accordingly. Default port is 6379.
    D. Set your preferred loglevel.
    E. Set the logfile to /var/log/redis_6379.log
    F. Set the dir to /var/redis/6379 (very important step!)
    G. Comment the bind directive
    H. Set the protected mode option to 'no'

7. Create a directory inside /var/redis for data and work

    $ sudo mkdir /var/redis/6379
   

8. Add the new Redis init script to all the default runlevels

    $ sudo update-rc.d redis_6379 defaults
   

9. Run the instance

    $ sudo /etc/init.d/redis_6379 start
   

10. Do a test save

    $ redis-cli save  // dump file will be stored into /var/redis/6379/dump.rdb
   

11. Check the log file

    $ tail -f /var/log/redis_6379.log
   

12. Connect with Server / Instance IP

    $ redis-cli -h 10.3.50.12 -p 6379
    redis 10.3.50.12:6379> ping
    PONG
   
Reference: https://redis.io/topics/quickstart

---

No comments:

Post a Comment