12

Amazon Linux 2023 is loosely based on Fedora 34, 35 and 36 as per aws: https://docs.aws.amazon.com/linux/al2023/ug/relationship-to-fedora.html

However redis package is not available in AL2023, instead redis6 is available: https://docs.aws.amazon.com/linux/al2023/release-notes/all-packages-al2023-20230322.html

I tried installing it using sudo dnf -y install redis6 and it installed successfully. But I'm not able to find any redis configuration file. A redis6 folder got created and is accessible using sudo cd /etc/redis6 however the folder is empty and doesn't have any configuration file. ls inside /etc/redis6 is not returning anything.

What is the right way to install redis server in AL2023?

[UPDATE] ls command didn't return any files inside /etc/redis6 folder but a configuration file is actually available. Using sudo nano /etc/redis6/redis6.conf I was able to update the existing redis config file to use systemd and set a password.

So the redis server is working fine now, just need to use redis6 instead of redis everywhere in AL2023, for ex redis6-cli.

VIVEK
  • 123

4 Answers4

27

Try this:

sudo dnf install -y redis6
sudo systemctl start redis6
sudo systemctl enable redis6
sudo systemctl is-enabled redis6
redis6-server --version
redis6-cli ping
dualklip
  • 386
  • 2
  • 2
3

You can try building it from source. This way you can get latest version as well. These instruction can be found at:

  1. Installation from source.
  2. Additional Steps after installation.

Here are the steps for the installation on Amazon Linux 2023.

  1. Install the latest version of redis from source.
  sudo yum update
  sudo yum install -y make gcc
  mkdir redis && cd redis && wget https://download.redis.io/redis-stable.tar.gz 
  tar -xzvf redis-stable.tar.gz && cd redis-stable/
  make distclean  # for clean build
  make
  sudo make install
  1. Run server using redis-server. At this point redis should be installed on your instance and will only accept connections from same instance. This can be checked by running redis-cli ping in a separate terminal.

  2. Next step is to enable redis to accept connections from other clients and run after restart. These instructions are referenced from docs. Run following to make sure redis-server is started after restart.

  cd ~/redis/redis-stable
  sudo mkdir /etc/redis
  sudo mkdir /var/redis
  sudo cp utils/redis_init_script /etc/init.d/redis_6379
  sudo chmod 755 /etc/init.d/redis_6379 # Optional
  sudo cp redis.conf /etc/redis/6379.conf
  sudo chkconfig --add redis_6379
  sudo chkconfig redis_6379 on
  1. Make config changes to accept connection from other instances. NOTE: These config changes will open redis for external connections. Make sure to have proper security config for the instance. Open config file:
  sudo nano /etc/redis/6379.conf 
  Change the following values from default to as indicated
  bind 127.0.0.1 -::1 ->> bind 0.0.0.0 -::1 
  protected-mode yes ->> protected-mode no 
  daemonize no ->> daemonize yes 
  logfile "" ->> logfile "/var/log/redis_6379.log" 
  dir ./ ->> dir /var/redis/6379 
  1. Restart the instance and redis should start automatically in daemon mode and accept external connections.

After above steps you will have redis installed with following configuration.

  • config file at: /etc/redis/6379.conf
  • log file at: /var/log/redis_6379.log
  • auto restart enabled (via runlevels)
  • To stop run, redis-cli shutdown
  • To start server (if #4 skipped), sudo redis-server /etc/redis/6379.conf --daemonize yes

Hope this helps !

ap14
  • 131
2

To install Redis 7 on Amazon Linux 2023 with TLS support:

sudo yum -y install openssl-devel gcc
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make distclean
make redis-cli BUILD_TLS=yes
sudo install -m 755 src/redis-cli /usr/local/bin/
lmaooooo
  • 121
0

Try this

sudo amazon-linux-extras install epel sudo amazon-linux-extras install redis6

sudo systemctl start redis

sudo systemctl enable redis