Installing Redis 2.x Using the Pivotal Packaging

Installation procedures for Redis differ according to the operating system you are using.

RHEL: Install Redis from a RPM

RHEL: Install Redis Using the Binary RPM

Prerequisites

Configuring the repository

  1. From the RHEL computer on which you will install Redis, log in as the root user (or as an unprivileged user who has sudo privileges) and start a terminal.
  2. Execute the following wget command:

    • RHEL 5:

      prompt$ wget -q -O - http://packages.pivotal.io/pub/rpm/rhel5/app-suite/app-suite-installer | sh
      
    • RHEL 6:

      prompt$ wget -q -O - http://packages.pivotal.io/pub/rpm/rhel6/app-suite/app-suite-installer | sh
      

      Note: You may need to install the wget package first. The package is not installed by default in a minimal server configuration.

Install the RPM from the yum repository

  1. Execute the following command in the open terminal window:

    prompt$ yum install pivotal-redis
    

What to do next

RHEL: Install Redis Using the Source RPM

Prerequisites

Configuring the repository

  1. From the RHEL computer on which you will install Redis, log in as the root user (or as an unprivileged user who has sudo privileges) and start a terminal.

  2. Execute the following wget command:

    • RHEL 5:

      prompt$ wget -q -O - http://packages.pivotal.io/pub/rpm/rhel5/app-suite/app-suite-installer | sh
      
    • RHEL 6:

      prompt$ wget -q -O - http://packages.pivotal.io/pub/rpm/rhel6/app-suite/app-suite-installer | sh
      

      Note: You may need to install the wget package first. The package is not installed by default in a minimal server configuration.

Install the yum dependencies

  1. Execute the following command in the open terminal window:

    prompt$ yum install yum-utils rpm-build
    

    The yum-utils package provides the commands yumdownloader and yum-builddep.

Fetch the source RPM

  1. Execute the following command in the open terminal window:

    prompt$ yumdownloader --source pivotal-redis
    

    This command allows you to avoid having to use the long wget URL path and src rpm version string. The command copies the src rpm to the current directory.

Install the build dependencies

  1. Execute the following command in the open terminal window:

    prompt$ yum-builddep pivotal-redis-<version>.elX.src.rpm
    

    This command installs the build dependencies to build the RPM from source - gcc and make.

Build the RPM from the source

  1. Execute the following command in the open terminal window:

    prompt$ rpmbuild --rebuild pivotal-redis-<version>.elX.src.rpm
    

Install the local RPM

  1. Execute the following command in the open terminal window:

    prompt$ yum install /path_to_rpmbuild/rpmbuild/RPMS/x86_64/pivotal-redis-<version>.elX.rpm
    

    Note: The --nogpgcheck option may be required on RHEL5 because this RPM is unsigned.

What to do next

Starting or Stopping Redis

To start or stop Redis:

  1. Log in to the computer as the root user (or as an unprivileged user who has sudo privileges) and start a terminal.

  2. Start or stop Redis instance by executing the appropriate command:

    • Start:

      prompt$ service pivotal-redis-6379 start
      
    • Stop:

      prompt$ service pivotal-redis-6379 stop
      

The name of the Upstart job for this instance of the redis server is pivotal-redis-6379, where 6379 is the port number the Redis server listens on. Upstart is an event-based replacement for the /sbin/init daemon that handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.

Configure default Redis instance to start at boot

The Pivotal Redis RPM registers the init script with chkconfig so that you can issue the service commands, but it does not configure Redis to start on boot.

To configure boot startup, run the chkconfig command to enable Redis startup for your desired run levels:

  1. Log in to the computer as the root user (or as an unprivileged user who has sudo privileges) and start a terminal.

  2. Execute the following command:

    prompt$ chkconfig --level 35 pivotal-redis-6379 on
    

Ubuntu: Install Redis from the Pivotal Debian Package Repository

It is recommended that you install Redis on a computer running Ubuntu by first installing the Pivotal Debian package repository and then using apt-get to perform the Redis installation.

Ubuntu: Install Redis Using the Binary Package

Prerequisites

  • Verify that your system meets the supported configurations and installation requirements. See Supported Configurations and System Requirements.
  • Install the Pivotal Debian package repository that contains the Redis *.deb packages:

    1. On the Ubuntu computer, start a terminal either as the root user or as an unprivileged user who has sudo privileges.
    2. Install the Pivotal Debian package repository using the following wget command:

      Important: Run the entire wget command on a single line. Be sure you include the | sh at the end, or the installation fails.

      • Ubuntu 10.04 and 12.04

        • Short URL with OS detection:

          wget -q -O - http://packages.pivotal.io/ | sh
          
      • Ubuntu 10.04 (Lucid)

        • Long URL:

          wget -q -O - http://packages.pivotal.io/pub/apt/ubuntu/vfabric-suite-installer-lucid | sh
          
        • Silent installer (no prompt for EULA):

          wget -q -O - http://packages.pivotal.io/pub/apt/ubuntu/vfabric-silent-suite-installer-lucid | sh
          
      • Ubuntu 12.04 (Precise)

        • Long URL:

          wget -q -O - http://package.pivotal.io/pub/apt/ubuntu/vfabric-suite-installer-precise | sh
          
        • Silent installer (no prompt for EULA):

          wget -q -O - http://packages.pivotal.io/pub/apt/ubuntu/vfabric-silent-suite-installer-precise | sh
          

The wget command performs the following tasks:

  • Imports the Pivotal GNU Privacy Guard (GPG) key.
  • Installs the Pivotal Debian package repository.
  • Launches the Pivotal End User License Agreement (EULA) acceptance and repository configuration script (unless you run the silent installer URL).
  • Outputs the EULA for you to read; you must answer yes to accept the terms and continue (unless you run the silent installer URL).

Procedure

  1. From the Ubuntu computer on which you will install Redis, log in as the root user (or as an unprivileged user who has sudo privileges) and start a terminal.

  2. Execute the following apt-get command:

    prompt$ apt-get install pivotal-redis 
    

    The apt-get command begins the install process, resolves dependencies, and displays the packages it will install.

    If necessary, use sudo to run the preceding command if you are not logged in as the root user:

    prompt$ sudo apt-get install pivotal-redis
    

What the apt-get install command does

The apt-get install command:

  • Installs Redis into the /opt/pivotal/redis directory and sets the owner of the directory, along with all child directories and files, to root:pivotal.
  • If the user does not already exist, adds a redis non-interactive user (in the group pivotal). It is recommended that you create and run Redis instances as this user. You cannot log in directly as the redis user because interactive login is disabled. Rather, you must log in as the root user or as a privileged user using sudo , and then su - redis.
  • Creates an empty directory called /var/opt/pivotal/redis and sets the owner to redis:pivotal. It is recommended that you create new Redis instances in this directory rather than the installation directory. You do this by specifying the -i option of the redis-instance command.

What to do next

Read the Redis documentation for administration and programming information and tutorials: http://redis.io/documentation .

Ubuntu: Install Redis Using the Source Package

Prerequisites

  • Verify that your system meets the supported configurations and installation requirements. See Supported Configurations and System Requirements.

  • Install the Pivotal Debian package repository that contains the Redis *.deb packages:

    1. On the Ubuntu computer, start a terminal either as the root user or as an unprivileged user who has sudo privileges.
    2. Install the Pivotal Debian package repository using the following wget command:

      Important: Run the entire wget command on a single line. Be sure you include the | sh at the end, or the installation fails.

      • Ubuntu 10.04 and 12.04

        • Short URL with OS detection:

          wget -q -O - http://packages.pivotal.io/ | sh
          
      • Ubuntu 10.04 (Lucid)

        • Long URL:

          wget -q -O - http://packages.pivotal.io/pub/apt/ubuntu/vfabric-suite-installer-lucid | sh
          
        • Silent installer (no prompt for EULA):

          wget -q -O - http://packages.pivotal.io/pub/apt/ubuntu/vfabric-silent-suite-installer-lucid | sh
          
      • Ubuntu 12.04 (Precise)

        • Long URL:

              wget -q -O - http://package.pivotal.io/pub/apt/ubuntu/vfabric-suite-installer-precise | sh
          
        • Silent installer (no prompt for EULA):

          wget -q -O - http://packages.pivotal.io/pub/apt/ubuntu/vfabric-silent-suite-installer-precise | sh
          

The wget command performs the following tasks: * Imports the Pivotal GNU Privacy Guard (GPG) key. * Installs the Pivotal Debian package repository. * Launches the Pivotal End User License Agreement (EULA) acceptance and repository configuration script (unless you run the silent installer URL). * Outputs the EULA for you to read; you must answer yes to accept the terms and continue (unless you run the silent installer URL).

Install build dependencies

  1. Execute the following command in the open terminal window:

    prompt$ apt-get build-dep pivotal-redis
    

    If necessary, use sudo to run the preceding command if you are not logged in as the root user:

    prompt$ sudo apt-get build-dep pivotal-redis
    

Fetch and compile source package, create binary package

  1. Execute the following command in the open terminal window:

    prompt$ apt-get source pivotal-redis --compile
    

    If necessary, use sudo to run the preceding command if you are not logged in as the root user:

    prompt$ sudo apt-get source pivotal-redis --compile
    

Install local binary package

  1. Execute the following command in the open terminal window:

    prompt$ dpkg -i pivotal-redis_<version>-<build>_*.deb
    

What to do next

Read the Redis documentation for administration and programming information and tutorials: http://redis.io/documentation .

Starting or Stopping Redis

To start or stop Redis:

  1. Log in to the computer as the root user (or as an unprivileged user who has sudo privileges) and start a terminal.

  2. Start or stop Redis instance by executing the appropriate command:

    • Start:

      prompt$ service pivotal-redis-6379 start
      
    • Stop:

      prompt$ service pivotal-redis-6379 stop
      

The name of the Upstart job for this instance of the redis server is pivotal-redis-6379, where 6379 is the port number the Redis server listens on. Upstart is an event-based replacement for the /sbin/init daemon that handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.

Configure default Redis instance to start at boot

To configure the default Redis instance to start at boot:

  1. Log in to the computer as the root user (or as an unprivileged user who has sudo privileges) and start a terminal.

  2. Execute the following command:

    prompt$ redis-instance.sh -s -p 6379
    

    The command adds the start stanza to the default Redis Upstart job.

Checking the Status of a Redis Instance

To check the status of a Redis instance:

  1. Log in to the computer as the root user (or as an unprivileged user who has sudo privileges) and start a terminal.

  2. Execute the following command:

    prompt$ service pivotal-redis-6379 status
    

Configuration Scripts

edit_system_files.sh

The edit_system_files.sh script located in the /opt/pivotal/pivotal-redis/util directory provides a quick way to update the sysctl.conf and limits.conf files, adding values recommended by Redis. The values prevent the startup warnings in the log file.

edit_system_files.sh -h -e -R [-u USERNAME]

Simple script to edit sysctl.conf and limits.conf for redis
 -h           Display this text
 -u USERNAME  Use this username instead of the default of p-redis
 -e           Edit the sysctl.conf and limits.conf files
 -R           Remove existing edits made by this script from the
               sysctl.conf and limits.conf files

redis-instance.sh

The redis-instance.sh script located in the /opt/pivotal/pivotal-redis/util directory provides a quick way to add or remove Redis instances.

redis-instance.sh -h -d [-p PORT_NUM] -u [USER_NAME] -s -R 

Simple script to add a Redis instance.
 -h           Display this text
 -d            Dry run. Only report what action will be taken
 -p PORT_NUM   Mandatory, port number to use for the new instance
 -u USER_NAME  Optional, specify user name for instance to run as
               defaults to p-redis if option is not provided.
 -s            Optional, configure instance to start at boot.
 -R            Remove an instance named by port number with -p PORT_NUM.

To add an instance using port 7001 and username redis7001 and have
 the instance start at boot:
   redis-instance.sh -p 7001 -u redis7001 -s

To see what commands would be run to remove an existing instance
 using port 6980:
   redis-instance.sh -d -p 6980 -R