[linux] Linux - Install redis-cli only

I have a Linux server with Redis installed and I want to connect to it via command line from my local Linux machine.

Is it possible to install redis-cli only (without redis-server and other tools)?

If I just copy redis-cli file to my local machine and run it, I have the following error:

./redis-cli: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by ./redis-cli)

This question is related to linux redis

The answer is


You can also use telnet instead

telnet redis-host 6379

And then issue the command, for example for monitoring

monitor

From http://redis.io/topics/quickstart

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make redis-cli
sudo cp src/redis-cli /usr/local/bin/

With Docker I normally use https://registry.hub.docker.com/_/redis/. If I need to add redis-cli to an image I use the following snippet.

RUN cd /tmp &&\
    curl http://download.redis.io/redis-stable.tar.gz | tar xz &&\
    make -C redis-stable &&\
    cp redis-stable/src/redis-cli /usr/local/bin &&\
    rm -rf /tmp/redis-stable

# get system libraries
sudo yum install -y gcc wget

# get stable version and untar it
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make redis-cli

If the build fails / make command fails, then :

Removing all line with _Atomic from src/server.h and src/networking.c should makes the compile complete.

# make it globally accesible
sudo cp src/redis-cli /usr/local/bin/

I made a simple pure-go solution, which is under development.

redis-cli: https://github.com/holys/redis-cli

Build once, and run everywhere. Fully portable.

Please feel free to have a try.


Instead of redis-cli you can simply use nc!

nc -v --ssl redis.mydomain.com 6380

Then submit the commands.


you may scp it from your redis machine if you have one, its just single binary. Or copy with nc if private network (this method is insecure):

redisclient: nc -l 8888 > /usr/local/bin/redis-cli
redisserver: cat /usr/local/bin/redis-cli | nc redisclient 8888

For centOS, maybe can try following steps

cd /tmp
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
cp src/redis-cli /usr/local/bin/
chmod 755 /usr/local/bin/redis-cli

To expand on @Agis's answer, you can also install the Redis CLI by running

$ git clone -b v2.8.7 [email protected]:antirez/redis.git
$ make -C redis install redis-cli /usr/bin

This will build the Redis CLI and toss the binary into /usr/bin. To anyone who uses Docker, I've also built a Dockerfile that does this for you: https://github.com/bacongobbler/dockerfiles/blob/master/redis-cli/Dockerfile


Using Docker, you may run this command to get Redis CLI:

docker run -it --rm redis redis-cli -h redis.mycompany.org -p 6379

where redis is the redis docker image from Docker Hub,
redis-cli is pre-installed in that image, and all after that are parameters to redis-cli:
-h is hostname to connect to,
-p is apparently the port to connect to.


To install 3.0 which is the latest stable version:

$ git clone http://github.com/antirez/redis.git 
$ cd redis && git checkout 3.0 
$ make redis-cli 

Optionally, you can put the compiled executable in your load path for convenience:

$ ln -s src/redis-cli /usr/local/bin/redis-cli

There are many way to install radis-cli. It comes with redis-tools and redis-server. Installing any of them will install redis-cli too. But it will also install other tools too. As you have redis-server installed somewhere and only interested to install redis-cli. To install install only redis-cli without other unnecessary tools follow below command

cd /tmp
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
cp src/redis-cli /usr/local/bin/
chmod 755 /usr/local/bin/redis-cli

In my case, I have to run some more steps to build it on RedHat or Centos.

# get system libraries
sudo yum install -y gcc wget

# get stable version and untar it
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable

# build dependencies too!
cd deps
make hiredis jemalloc linenoise lua geohash-int
cd ..

# compile it
make

# make it globally accesible
sudo cp src/redis-cli /usr/bin/