Linux - Install redis-cli only

LinuxRedis

Linux Problem Overview


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)

Linux Solutions


Solution 1 - Linux

Ubuntu (tested on 14.04) has package called redis-tools which contains redis-cli among other tools. To install it type:

sudo apt-get install redis-tools

Note that on Ubuntu 16.04+ the command is a little bit different:

sudo apt install redis-tools

Solution 2 - Linux

Instead of redis-cli you can simply use nc!

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

Then submit the commands.

Solution 3 - Linux

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

Solution 4 - Linux

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

Solution 5 - Linux

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/

Solution 6 - Linux

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

Solution 7 - Linux

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

docker run -it --rm redis:alpine 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.

You could also create an alias using the above command

alias redis-cli='docker run --rm --network=host redis:alpine redis-cli'

Which could be added to .bashrc if your using Bash

Solution 8 - Linux

You can also use telnet instead

telnet redis-host 6379

And then issue the command, for example for monitoring

monitor

Solution 9 - Linux

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

Solution 10 - Linux

For Amazon Linux

#sudo amazon-linux-extras install redis6
#redis-cli

Solution 11 - Linux

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

Solution 12 - Linux

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.

Solution 13 - Linux

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

Solution 14 - Linux

# 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/

Solution 15 - Linux

for CentOS to get redis-cli without compiling it you can fetch Redis rpm from Epel repo and extract just ths tool. Here's step by step instruction

yum install -y jemalloc
yum install -y yum-utils
# NOTE - EPEL REPO MUST BE INSTALLED AND ENABLED
RPM_URL=$(yumdownloader --urls redis | tail -n1)
RPM=$(basename $RPM_URL)
mkdir /tmp/redis
cd /tmp/redis
wget $RPM_URL
rpm2cpio $RPM | cpio -idmv "./usr/bin/redis-cli"
mv ./usr/bin/redis-cli /usr/bin/redis-cli
rm -rf /tmp/redis
/usr/bin/redis-cli --version

Solution 16 - Linux

2022 answer:

git clone https://github.com/redis/redis.git
cd redis/src/
make redis-cli
sudo cp redis-cli /usr/bin/redis-cli
redis-cli --version

worked for me.

Solution 17 - Linux

There's a script that automatically download, build and install the latest redis-cli on Ubuntu 20.04 LTS.

To run it, copy and paste this on your terminal.

curl -sL "https://raw.githubusercontent.com/SecretX33/redis-cli/main/install_redis_cli.sh" | bash

Or wget, in case you don't have curl installed.

wget -qO - "https://raw.githubusercontent.com/SecretX33/redis-cli/main/install_redis_cli.sh" | bash

Feel free to look the source code: https://github.com/SecretX33/redis-cli

PS.: I'm the author of this script.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionOlegView Question on Stackoverflow
Solution 1 - LinuxИван БишевацView Answer on Stackoverflow
Solution 2 - LinuxBalázs NémethView Answer on Stackoverflow
Solution 3 - LinuxKevin WatsonView Answer on Stackoverflow
Solution 4 - LinuxAgisView Answer on Stackoverflow
Solution 5 - LinuxdamoiserView Answer on Stackoverflow
Solution 6 - LinuxrobertView Answer on Stackoverflow
Solution 7 - LinuxOndra ŽižkaView Answer on Stackoverflow
Solution 8 - LinuxxelberView Answer on Stackoverflow
Solution 9 - LinuxbacongobblerView Answer on Stackoverflow
Solution 10 - Linuxankursingh1000View Answer on Stackoverflow
Solution 11 - LinuxZaurView Answer on Stackoverflow
Solution 12 - LinuxholysView Answer on Stackoverflow
Solution 13 - LinuxShalauddin Ahamad ShuzaView Answer on Stackoverflow
Solution 14 - LinuxWhite Mask GuyView Answer on Stackoverflow
Solution 15 - LinuxKrzysztof KsiężykView Answer on Stackoverflow
Solution 16 - LinuxIvan CarcamoView Answer on Stackoverflow
Solution 17 - LinuxSecretXView Answer on Stackoverflow