Redis Announces CEO Transition

A.2 Installing on OS X

  • Redis in Action – Home
  • Foreword
  • Preface
  • Part 1: Getting Started
  • Part 2: Core concepts
  • 1.3.1 Voting on articles
  • 1.3.2 Posting and fetching articles
  • 1.3.3 Grouping articles
  • 4.2.1 Configuring Redis for replication
  • 4.2.2 Redis replication startup process
  • 4.2.3 Master/slave chains
  • 4.2.4 Verifying disk writes
  • 5.1 Logging to Redis
  • 5.2 Counters and statistics
  • 5.3 IP-to-city and -country lookup
  • 5.4 Service discovery and configuration
  • 5.1.1 Recent logs
  • 5.1.2 Common logs
  • 5.2.2 Storing statistics in Redis
  • 5.3.1 Loading the location tables
  • 5.3.2 Looking up cities
  • 5.4.1 Using Redis to store configuration information
  • 5.4.2 One Redis server per application component
  • 5.4.3 Automatic Redis connection management
  • 8.1.1 User information
  • 8.1.2 Status messages
  • 9.1.1 The ziplist representation
  • 9.1.2 The intset encoding for SETs
  • Chapter 10: Scaling Redis
  • Chapter 11: Scripting Redis with Lua
  • 10.1 Scaling reads
  • 10.2 Scaling writes and memory capacity
  • 10.3 Scaling complex queries
  • 10.2.2 Creating a server-sharded connection decorator
  • 10.3.1 Scaling search query volume
  • 10.3.2 Scaling search index size
  • 10.3.3 Scaling a social network
  • 11.1.1 Loading Lua scripts into Redis
  • 11.1.2 Creating a new status message
  • 11.2 Rewriting locks and semaphores with Lua
  • 11.3 Doing away with WATCH/MULTI/EXEC
  • 11.4 Sharding LISTs with Lua
  • 11.5 Summary
  • 11.2.1 Why locks in Lua?
  • 11.2.2 Rewriting our lock
  • 11.2.3 Counting semaphores in Lua
  • 11.4.1 Structuring a sharded LIST
  • 11.4.2 Pushing items onto the sharded LIST
  • 11.4.4 Performing blocking pops from the sharded LIST
  • A.1 Installation on Debian or Ubuntu Linux
  • A.2 Installing on OS X
  • B.1 Forums for help
  • B.4 Data visualization and recording
  • Buy the paperback
  • Redis in Action – Home
  • Foreword
  • Preface
  • Part 1: Getting Started
  • Part 2: Core concepts
  • 1.3.1 Voting on articles
  • 1.3.2 Posting and fetching articles
  • 1.3.3 Grouping articles
  • 4.2.1 Configuring Redis for replication
  • 4.2.2 Redis replication startup process
  • 4.2.3 Master/slave chains
  • 4.2.4 Verifying disk writes
  • 5.1 Logging to Redis
  • 5.2 Counters and statistics
  • 5.3 IP-to-city and -country lookup
  • 5.4 Service discovery and configuration
  • 5.1.1 Recent logs
  • 5.1.2 Common logs
  • 5.2.2 Storing statistics in Redis
  • 5.3.1 Loading the location tables
  • 5.3.2 Looking up cities
  • 5.4.1 Using Redis to store configuration information
  • 5.4.2 One Redis server per application component
  • 5.4.3 Automatic Redis connection management
  • 8.1.1 User information
  • 8.1.2 Status messages
  • 9.1.1 The ziplist representation
  • 9.1.2 The intset encoding for SETs
  • Chapter 10: Scaling Redis
  • Chapter 11: Scripting Redis with Lua
  • 10.1 Scaling reads
  • 10.2 Scaling writes and memory capacity
  • 10.3 Scaling complex queries
  • 10.2.2 Creating a server-sharded connection decorator
  • 10.3.1 Scaling search query volume
  • 10.3.2 Scaling search index size
  • 10.3.3 Scaling a social network
  • 11.1.1 Loading Lua scripts into Redis
  • 11.1.2 Creating a new status message
  • 11.2 Rewriting locks and semaphores with Lua
  • 11.3 Doing away with WATCH/MULTI/EXEC
  • 11.4 Sharding LISTs with Lua
  • 11.5 Summary
  • 11.2.1 Why locks in Lua?
  • 11.2.2 Rewriting our lock
  • 11.2.3 Counting semaphores in Lua
  • 11.4.1 Structuring a sharded LIST
  • 11.4.2 Pushing items onto the sharded LIST
  • 11.4.4 Performing blocking pops from the sharded LIST
  • A.1 Installation on Debian or Ubuntu Linux
  • A.2 Installing on OS X
  • B.1 Forums for help
  • B.4 Data visualization and recording
  • Buy the paperback

    A.2 Installing on OS X

    As is the case with other platforms, there are a few ways to download and install Redis
    and the Python Redis client library. In this section, we’ll discuss the following:

    1. Downloading, installing, and running Redis on OS X.
    2. Installing the Redis client library for Python.

    If you read the Linux section, you’ll know that we made sure that the necessary tools
    for building Redis from scratch were available, because it was easy to do so. Though
    the installation of Xcode for OS X is a bit more difficult, the fact that the build tools
    download is 10 times larger makes following along without a long break much more
    difficult. As such, you’ll use a method to install Redis that doesn’t require a compiler.

    To install Redis in OS X without using a compiler, you’ll use a Python utility called
    Rudix, which installs precompiled binaries for a variety of software. Conveniently, as of
    this writing it includes an installer for the most recent version of Redis.

    To download and install Rudix and Redis, you should open a Terminal. The Terminal
    application can be found in the Utilities group inside of Applications. After
    you’ve started the terminal, please follow along with the next listing to install Redis
    using Rudix.

    Listing A.4Installing Redis on OS X
    ~:$ curl -O http://rudix.googlecode.com/hg/Ports/rudix/rudix.py
    

    Download the bootstrap script that installs Rudix.

    [trimmed]
    
    ~:$ sudo python rudix.py install rudix
    

    Tell Rudix to install itself.

    Downloading rudix.googlecode.com/files/rudix-12.10-0.pkg
    [trimmed]
    installer: The install was successful.
    All done
    

    Rudix is downloading and installing itself.

    ~:$ sudo rudix install redis
    

    Tell Rudix to install Redis.

    Downloading rudix.googlecode.com/files/redis-2.6.9-0.pkg
    [trimmed]
    installer: The install was successful.
    All done
    

    Rudix is downloading and installing Redis.

    ~:$ redis-server
    

    Start the Redis server.

    [699] 6 Feb 21:18:09 # Warning: no config file specified, using the
    default config. In order to specify a config file use 'redis-server
    /path/to/redis.conf'
    [699] 6 Feb 21:18:09 * Server started, Redis version 2.6.9
    [699] 6 Feb 21:18:09 * The server is now ready to accept connections
    on port 6379
    [699] 6 Feb 21:18:09 - 0 clients connected (0 slaves), 922304 bytes
    in use
    

    Redis started and is running with the default configuration.

    Now that you’ve installed Redis, it’s time to install the Redis client library for Python.
    You don’t need to install Python, because OS X versions 10.6 and 10.7 come with
    either Python 2.6 or 2.7 preinstalled and available via python by default. While Redis
    is running in one terminal, open up a new tab (command + T), and follow along with
    the next listing to install the Python Redis library.

    Listing A.5Installing the Redis client library for Python on OS X
    ~:$ sudo rudix install pip
    

    Because you have Rudix installed, you can install a Python package manager called pip.

    Downloading rudix.googlecode.com/files/pip-1.1-1.pkg
    [trimmed]
    installer: The install was successful.
    All done
    

    Rudix is installing pip.

    ~:$ sudo pip install redis
    

    You can now use pip to install the Python Redis client library.

    Downloading/unpacking redis
    [trimmed]
    Cleaning up...
    

    Pip is installing the Redis client library for Python.

    ~:$
    

    If you read either of the Linux or Windows install instructions, you may have noticed
    that we used setuptools’s easy_install method to install the Redis client library, but
    here you use pip. This is because Rudix offers a pip package, but doesn’t have a setuptools
    package, so it was easier to install pip, and then use pip to install the Redis client
    library for Python instead of manually downloading and installing setuptools.

    Also, if you read the installation instructions for Linux, you may have noticed that
    we installed the hiredis helper library there, but you don’t install it on OS X. This is
    because, like before, you can’t guarantee that users will have Xcode installed, so you’ll
    use what you have available.

    Now that you have the Redis Python library installed, you should skip ahead to section
    A.4 and follow along to use Redis from Python for the first time.