Redis-cli Mac Manual

Related

Apple Macintosh Instruction Manuals (User Guides) As per reader requests, direct links to official Apple Macintosh instruction manuals in PDF format - hosted by Apple's own support site- are provided below as well as on the specs page for each G3 and newer Mac. 3、关闭命令:redis-cli shutdown. 1.首先把redis-cli 移动到/usr/local/bin 目录,方便执行,和JAVAHOME 类似. 默认install 的时候已经有了.

How to Benchmark the Performance of a Redis Server on Ubuntu 18.04 Tutorial
How To Install and Secure Redis on Debian 10 Tutorial

Introduction

Redis is an in-memory key-value store known for its flexibility, performance, and wide language support. In this guide, we will demonstrate how to install and configure Redis on an Ubuntu 16.04 server.

Prerequisites

To complete this guide, you will need access to an Ubuntu 16.04 server. You will need a non-root user with sudo privileges to perform the administrative functions required for this process. You can learn how to set up an account with these privileges by following our Ubuntu 16.04 initial server setup guide.

When you are ready to begin, log in to your Ubuntu 16.04 server with your sudo user and continue below.

Install the Build and Test Dependencies

In order to get the latest version of Redis, we will be compiling and installing the software from source. Before we download the code, we need to satisfy the build dependencies so that we can compile the software.

To do this, we can install the build-essential meta-package from the Ubuntu repositories. We will also be downloading the tcl package, which we can use to test our binaries.

We can update our local apt package cache and install the dependencies by typing:

Download, Compile, and Install Redis

Next, we can begin to build Redis.

Download and Extract the Source Code

Since we won’t need to keep the source code that we’ll compile long term (we can always re-download it), we will build in the /tmp directory. Let’s move there now:

Now, download the latest stable version of Redis. This is always available at a stable download URL:

Unpack the tarball by typing:

Move into the Redis source directory structure that was just extracted:

Build and Install Redis

Now, we can compile the Redis binaries by typing:

After the binaries are compiled, run the test suite to make sure everything was built correctly. You can do this by typing:

This will typically take a few minutes to run. Once it is complete, you can install the binaries onto the system by typing:

Configure Redis

Now that Redis is installed, we can begin to configure it.

To start off, we need to create a configuration directory. We will use the conventional /etc/redis directory, which can be created by typing:

Now, copy over the sample Redis configuration file included in the Redis source archive:

Next, we can open the file to adjust a few items in the configuration:

Manual

In the file, find the supervised directive. Currently, this is set to no. Since we are running an operating system that uses the systemd init system, we can change this to systemd:

Next, find the dir directory. This option specifies the directory that Redis will use to dump persistent data. We need to pick a location that Redis will have write permission and that isn’t viewable by normal users.

We will use the /var/lib/redis directory for this, which we will create in a moment:

/etc/redis/redis.conf

Save and close the file when you are finished.

Create a Redis systemd Unit File

Next, we can create a systemd unit file so that the init system can manage the Redis process.

Redis-cli Mac Manual 2016

Create and open the /etc/systemd/system/redis.service file to get started:

Inside, we can begin the [Unit] section by adding a description and defining a requirement that networking be available before starting this service:

In the [Service] section, we need to specify the service’s behavior. For security purposes, we should not run our service as root. We should use a dedicated user and group, which we will call redis for simplicity. We will create these momentarily.

To start the service, we just need to call the redis-server binary, pointed at our configuration. To stop it, we can use the Redis shutdown command, which can be executed with the redis-cli binary. Also, since we want Redis to recover from failures when possible, we will set the Restart directive to “always”:

/etc/systemd/system/redis.service

Finally, in the [Install] section, we can define the systemd target that the service should attach to if enabled (configured to start at boot):

Save and close the file when you are finished.

Manual

Create the Redis User, Group and Directories

Now, we just have to create the user, group, and directory that we referenced in the previous two files.

Begin by creating the redis user and group. This can be done in a single command by typing:

Now, we can create the /var/lib/redis directory by typing:

We should give the redis user and group ownership over this directory:

Adjust the permissions so that regular users cannot access this location:

Start and Test Redis

Now, we are ready to start the Redis server.

Start the Redis Service

Start up the systemd service by typing:

Check that the service had no errors by running:

You should see something that looks like this:

Test the Redis Instance Functionality

To test that your service is functioning correctly, connect to the Redis server with the command-line client:

In the prompt that follows, test connectivity by typing:

You should see:

Check that you can set keys by typing:

Now, retrieve the value by typing:

You should be able to retrieve the value we stored:

Exit the Redis prompt to get back to the shell:

Redis-cli Mac Manual

As a final test, let’s restart the Redis instance:

Now, connect with the client again and confirm that your test value is still available:

The value of your key should still be accessible:

Back out into the shell again when you are finished:

Enable Redis to Start at Boot

If all of your tests worked, and you would like to start Redis automatically when your server boots, you can enable the systemd service.

To do so, type:

Conclusion

You should now have a Redis instance installed and configured on your Ubuntu 16.04 server. To learn more about how to secure your Redis installation, take a look at our How To Secure Your Redis Installation on Ubuntu 14.04 (from step 3 onward). Although it was written with Ubuntu 14.04 in mind, it should mostly work for 16.04 as well.

Active7 months ago

Redis can give sub millisecond response times. That's a great promise. I'm testing heroku redis and I get 1ms up to about 8ms, for a zincrby. I'm using microtime() in php to wrap the call. This heroku redis (I'm using the free plan) is a shared instance and there is resource contention so I expect response times for identical queries to vary, and they certainly do.

I'm curious as to the cause of the difference in performance vs. redis installed on my macbook pro via homebrew. There's obviously no network latency there. What I'm curious about is does this mean that any cloud redis (i.e. connecting over the network, say within aws), is always going to be quite a bit slower than if I were to have one cloud server and run a redis inside the same physical machine, thus eliminating network latency?

There is also resource contention in these cloud offerings, unless a private server is chosen which costs a lot more.

Some numbers: my local macbook pro consistently gives 0.2ms for the identical zincrby that takes between 1ms & 8ms on the heroku redis.

Is network latency the cause of this?

mwal

Redis-cli Mac Manual Download

mwalmwal

1 Answer

Redis-cli Mac Manual Download

No, probably not.

The typical latency of a 1 Gbit/s network is about 200us. That's 0.2ms.

What's more, in aws you're probably on 10gbps at least.

As this page in the redis manual explains, the main cause of the latency variation between these two environments will almost certainly be a result of the higher intrinsic latency (there's a redis command to test this on any particular system: redis-cli --intrinsic-latency 100, see the manual page above) arising from being run in a linux container.

i.e., network latency is not the dominant cause of the variation seen here.

Here is a checklist (from redis manual page linked above).

Redis-cli Mac Manual 2017

  • If you can afford it, prefer a physical machine over a VM to host the server.
  • Do not systematically connect/disconnect to the server (especially true for web based applications). Keep your connections as long lived as possible.
  • If your client is on the same host than the server, use Unix domain sockets.
  • Prefer to use aggregated commands (MSET/MGET), or commands with variadic parameters (if possible) over pipelining.
  • Prefer to use pipelining (if possible) over sequence of roundtrips.
  • Redis supports Lua server-side scripting to cover cases that are not suitable for raw pipelining (for instance when the result of a command is an input for the following commands).
mwalmwal

Redis-cli Mac Manual 2017

Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged amazon-web-servicesrediscloudheroku-redis or ask your own question.