3

AWS redis-cli on EC2

 1 year ago
source link: https://gist.github.com/todgru/14768fb2d8a82ab3f436
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
AWS redis-cli on EC2

Setup redis-cli on AWS EC2

SSH into your EC2 instance. Run the following:

$ sudo yum install gcc This may return an "already installed" message. That's OK.

$ wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make

See: http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/GettingStarted.ConnectToCacheNode.Redis.html

bin is src/redis-cli

thanks dude, this is helpful

jobwat commented on Jul 13, 2017

edited

+1 Thanks!

In 1 copypaste:

sudo yum install -y gcc
wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make
sudo cp src/redis-cli /usr/bin/

Had to make deps also (see https://unix.stackexchange.com/questions/94479/jemalloc-and-other-errors-making-redis-on-centos-6-4)

sudo yum install -y gcc
wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz
cd deps
make hiredis jemalloc linenoise lua geohash-int
cd ..
make install
sudo cp src/redis-cli /usr/bin/
sudo yum install -y gcc wget
wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make
sudo cp src/redis-cli /usr/bin/

1ambda commented on Jun 5, 2018

edited

terraform user_data

data "template_cloudinit_config" "bastion_user_data" {
  gzip = false
  base64_encode = true

  # install mysql, redis client
  part {
    content_type = "text/x-shellscript"
    content = <<EOF
#!/bin/bash
cd /root
yum install -y mysql
yum install -y gcc wget
wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make
cp /root/redis-stable/src/redis-cli /home/ec2-user/
chown ec2-user:ec2-user /home/ec2-user/redis-cli
EOF
  }
}

You might want to use terraform template to replace username. Checkout these examples.

After doing it, redis clis is not working
[ec2-user@ip-xxx-xxx-xxx-xxx redis-stable]$ redis-cli
-bash: redis-cli: command not found

It works from src folder if prefixed with './'
like so
[ec2-user@ip-xxx-xxx-xxx-xxx src]$ ./redis-cli

tdmalone commented on Jul 26, 2018

edited

@test82987 Symlink to it from somewhere in your PATH. eg. ln -s /path/to/redis-stable/redis-cli /usr/local/bin/. Then, assuming /usr/local/bin is in your PATH (run echo $PATH to find out), just running redis-cli should work.

For anyone wondering, the executables are placed inside the src folder.

Can be run by doing $ ./src/redis-cli.

+1 Thanks!

In 1 copypaste:

sudo yum install -y gcc
wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make
sudo cp src/redis-cli /usr/bin/

what about make install instead of cping the file?

Is it possible to connect to a Redis cluster from userdata itself and write in variables ?

thanks dude, this is simple and helpful.
+1

dwaynebailey commented on Jun 2, 2020

edited

This is all you need to properly install redis-cli and remove the remnants of any build related things:

yum install -y gcc
wget http://download.redis.io/redis-stable.tar.gz && tar xzf redis-stable.tar.gz && cd redis-stable && make && make install
yum erase -y gcc && yum autoremove -y && yum clean

It's a refinement of https://gist.github.com/todgru/14768fb2d8a82ab3f436#gistcomment-2610635 (installing correctly using make install and cleaning up)

Update: yes you need sudo if you're not root. I'm running this in cloud-init scripts so I am root.

This is all you need to properly install redis-cli and remove the remnants of any build related things:

yum install -y gcc
wget http://download.redis.io/redis-stable.tar.gz && tar xzf redis-stable.tar.gz && cd redis-stable && make && make install
yum erase -y gcc && yum autoremove -y && yum clean

It's a refinement of https://gist.github.com/todgru/14768fb2d8a82ab3f436#gistcomment-2610635 (installing correctly using make install and cleaning up)

I think you need to use sudo for the make install to work. At least I run your script today and I got that error
But, thanks for the script.

If you have errors running make with the redis-stable version, you can download version 5.0.8
wget http://download.redis.io/releases/redis-5.0.8.tar.gz && tar xvzf redis-5.0.8.tar.gz && cd redis-5.0.8 && make sudo cp src/redis-cli /usr/bin/

I am using AWS Linux

Amazon Linux AMI release 2017.09

I need to install gcc64 before running build. If you don't do that, you will face that problem

make[2]: Leaving directory `/root/redis-stable/redis-stable/deps'
    CC adlist.o
    CC quicklist.o
    CC ae.o
    CC anet.o
    CC dict.o
    CC server.o
In file included from server.c:30:0:
server.h:1051:5: error: expected specifier-qualifier-list before ‘_Atomic’
     _Atomic unsigned int lruclock; /* Clock for LRU eviction */
     ^
server.c: In function ‘serverLogRaw’:
server.c:1032:31: error: ‘struct redisServer’ has no member named ‘logfile’
     int log_to_stdout = server.logfile[0] == '\0';
                               ^
server.c:1035:23: error: ‘struct redisServer’ has no member named ‘verbosity’
     if (level < server.verbosity) return;
                       ^
server.c:1037:47: error: ‘struct redisServer’ has no member named ‘logfile’
     fp = log_to_stdout ? stdout : fopen(server.logfile,"a");
                                               ^
yum install gcc64

all you need on Amazon Linux 2 is;

yum install gcc
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make MALLOC=libc
chmod a+x src/redis-cli
cp src/redis-cli /usr/bin/

Minor change to @chrisdlangton



wget http://download.redis.io/redis-stable.tar.gz

tar xvzf redis-stable.tar.gz

cd redis-stable

make MALLOC=libc

chmod a+x src/redis-cli

sudo cp src/redis-cli /usr/bin/

Run the following commands line by line to install Redis and dependencies.

  1. sudo yum -y install gcc make # install GCC compiler
  2. cd /usr/local/src
  3. sudo wget http://download.redis.io/redis-stable.tar.gz
  4. sudo tar xvzf redis-stable.tar.gz
  5. sudo rm -f redis-stable.tar.gz
  6. cd redis-stable
  7. sudo yum groupinstall "Development Tools"
  8. sudo make distclean
  9. sudo make
  10. sudo yum install -y tcl
  11. sudo make test
  12. sudo cp src/redis-server /usr/local/bin/
  13. sudo cp src/redis-cli /usr/local/bin/
  14. redis-server
  15. redis-cli

Simple way to install

Thanks!

How to install redis-cli with --tls flag enabled ? By default --tls is not enabled.

sudo amazon-linux-extras install redis6

thanks, @thapabishwa, worked for me. thanks

sudo amazon-linux-extras enable redis6
sudo yum clean metadata
sudo yum update
sudo yum install redis

kevin1193 commented on Apr 21

Thanks

faced this issue recently
Combining all solutions is what I shared with DevOps on the Ubuntu system.

sudo wget http://download.redis.io/redis-stable.tar.gz
sudo tar xvzf redis-stable.tar.gz
cd redis-stable
sudo apt-get install libssl-dev
sudo make BUILD_TLS=yes

./src/redis-cli -h <REDIS_HOST> --tls -p 6379

On Amazon Linux 2 this worked for me:

yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum update -y
yum install -y redis

On Amazon Linux you can use this:

$ sudo yum install gcc openssl-devel
$ wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make BUILD_TLS=yes

and then connect using this:

$ src/redis-cli -h conn-string-elasticache.amazonaws.com -p 6379 --tls

// If you have auth
$ src/redis-cli -h conn-string-elasticache.amazonaws.com -p 6379 --tls -a password

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK