Linux - Install redis-cli only

283,750

Solution 1

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

Instead of redis-cli you can simply use nc!

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

Then submit the commands.

Solution 3

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

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 5

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
Share:
283,750

Related videos on Youtube

Oleg
Author by

Oleg

Updated on April 10, 2022

Comments

  • Oleg
    Oleg about 2 years

    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)
    
    • arkascha
      arkascha over 10 years
      Well, 1. it is not surprising that just copying the executable does not work: most likely you have different architecture and library versions, that cannot work. 2. you should consult the software management system your distribution provides and see what redit packages it provides. Then installing one of those shoudl only require a single click. You should never do a wild installation of stuff into a Linux system if you can use the software management instead.
    • Oleg
      Oleg over 10 years
      @arkascha Thank you for your tip. I'm quite new to Linux so this information is very useful for me
    • arkascha
      arkascha over 10 years
      You mean you are a developer working under a Linux environment, but you never used your systems software management system? What distribution do you use?
    • arkascha
      arkascha over 10 years
      You might also be interested in a package called 'hiredis' which offers a minimalistic c client for redis. No ready-to-use cli client though.
    • Oleg
      Oleg over 10 years
      Well, actually I'm just playing with Redis. I'm on Ubuntu. I've installed Redis and it works fine. Then I installed Debian on VirtualBox, and now I'm trying to connect to Redis on Ubuntu from Debian virtual machine
    • arkascha
      arkascha over 10 years
      So how did you install redis on that ubuntu system?
    • Oleg
      Oleg over 10 years
      I've compiled the sources. I can do the same on Debian machine, but I'm just curious can I install just redis-cli without installing all redis components
    • Oleg
      Oleg over 10 years
      it seems that Debian doesn't support neither redis, nor redis-cli packages
    • arkascha
      arkascha over 10 years
      Why invest so much effort? Just pick the redis package in your software management and install it. That takes two minutes most and you can start using it. What is the advantage in doing all that by hand and ignoring all the advantages of cleanly installed packages?
    • arkascha
      arkascha over 10 years
      Debian does not offer redis packages? LOL. One more reasons not to use Debian. (sorry, could not resist).
    • arkascha
      arkascha over 10 years
    • deltheil
      deltheil over 10 years
      What about git clone [email protected]:antirez/redis.git then cd src && make redis-cli?
    • Oleg
      Oleg over 10 years
      @deltheil It works nicely. Thank you!
    • febot
      febot about 6 years
      I recommend the Docker solution, see my answer. Can be disposed at any time and your system's packages are untouched in the process.
  • Oleg
    Oleg about 10 years
    Thank you for your answer. I will try it as soon as I can
  • Oleg
    Oleg about 10 years
    For me this command compiled the whole Redis, not only redis-cli
  • dhamu
    dhamu over 9 years
    git clone http://github.com/antirez/redis.git && cd redis && git checkout 2.8.6 && make redis-cli && cp src/redis-cli /usr/local/bin - this works for me.
  • Ariel Allon
    Ariel Allon almost 8 years
    anything similar for centos?
  • James111
    James111 over 7 years
    Try nc -v redis.mydomain.com 6379 (or your custom port)
  • pyrospade
    pyrospade about 7 years
    This is the best answer since it requires absolutely no dependencies or external tools.
  • Matt Bucci
    Matt Bucci about 7 years
    is it possible to use this with a redis password?
  • Bryan Cote-Chang
    Bryan Cote-Chang almost 7 years
    Potentially stupid comment, but don't forget to install gcc sudo yum install gcc before running make!
  • Prashanth Chandra
    Prashanth Chandra over 6 years
    You can also use rlwrap nc -v redis.mydomain.com 6379 if you have rlwrap which lets you use keyboard shortcuts just as you would in a shell (e.g. cycle/search previous command, next word)
  • Artistan
    Artistan over 6 years
    tried to edit this. but here is a gist on how to do it now... gist.github.com/Artistan/d9288f8e12c4027096e66bd331d4e4fd
  • Artistan
    Artistan over 6 years
  • barath
    barath almost 6 years
    Works on linux too.
  • hashlash
    hashlash over 5 years
    I can't find --ssl option for nc. Did you mean ncat?
  • Balázs Németh
    Balázs Németh over 5 years
    netcat - it depends on your OS what the binary exactly is. maybe it's called ncat. I don't know :(
  • yihuang
    yihuang almost 5 years
    @AlinPurcaru docker run --rm --network=host redis redis-cli info
  • Andrew Sneck
    Andrew Sneck over 4 years
    now it isn't working http://security.ubuntu.com/ubuntu bionic-updates/universe amd64 redis-tools amd64 5:4.0.9-1ubuntu0.1 returns 404 Not Found
  • Vipresh
    Vipresh about 4 years
    Getting this error on copy command, any idea how to fix it cp src/redis-cli /usr/local/bin/ cp: cannot stat 'src/redis-cli': No such file or directory
  • Govind Kailas
    Govind Kailas about 3 years
    Liked your solution, the last update is 3 years ago. Did you try building with the new go version, will it make any difference?
  • manu muraleedharan
    manu muraleedharan almost 3 years
    Worked for me on Amazon Linux
  • Marc Shepherd
    Marc Shepherd over 2 years
    @MattBucci You can do the following: (printf "AUTH <password> \r\n"; sleep 1) | nc -v redis.mydomain.com 6379
  • lboix
    lboix about 2 years
    Great snippet, I never thought of it ^^