Redis Deployment Guide on Linux

System

aarch64

1$ uname -a
2Linux yhy-87 5.10.0-153.12.0.92.oe2203sp2.aarch64 #1 SMP Wed Jun 28 23:18:48 CST 2023 aarch64 aarch64 aarch64 GNU/Linux
3$ cat /etc/os-release
4NAME="openEuler"
5VERSION="22.03 (LTS-SP2)"
6ID="openEuler"
7VERSION_ID="22.03"
8PRETTY_NAME="openEuler 22.03 (LTS-SP2)"
9ANSI_COLOR="0;31"

x86_64

1$ uname -a
2Linux yhy-106 5.10.0-182.0.0.95.oe2203sp3.x86_64 #1 SMP Sat Dec 30 13:10:36 CST 2023 x86_64 x86_64 x86_64 GNU/Linux
3$ cat /etc/os-release
4NAME="openEuler"
5VERSION="22.03 (LTS-SP3)"
6ID="openEuler"
7VERSION_ID="22.03"
8PRETTY_NAME="openEuler 22.03 (LTS-SP3)"
9ANSI_COLOR="0;31"

Download

aarch64

1#### Download URL
2https://repo.openeuler.org/openEuler-22.03-LTS-SP3/everything/x86_64/Packages/

x86_64

1#### Download URL
2https://dl-cdn.openeuler.openatom.cn/openEuler-22.03-LTS-SP3/everything/aarch64/Packages/

Installation Packages

1jemalloc-5.3.0-1.oe2203sp3.x86_64.rpm
2redis6-6.2.7-3.oe2203sp3.x86_64.rpm

Installation

1rpm -ivh *.rpm

Start

1systemctl enable redis
2systemctl start redis
3systemctl status redis

Service

1# /usr/lib/systemd/system/redis.service
2[Unit]
3Description=Redis persistent key-value database
4After=network.target
5After=network-online.target
6Wants=network-online.target
7[Service]
8ExecStart=/usr/bin/redis-server /etc/redis/redis.conf --daemonize no --supervised systemd
9ExecStop=/usr/libexec/redis-shutdown
10Type=notify
11User=redis
12Group=redis
13RuntimeDirectory=redis
14RuntimeDirectoryMode=0755
15[Install]
16WantedBy=multi-user.target

Configuration

1# /etc/redis/redis.conf
2# 1. Allow access from any network interface (default only listens to 127.0.0.1)
3bind 0.0.0.0
4# 2. Disable protected mode (otherwise, even with bind, remote access is not possible)
5protected-mode no
6# 3. Set a password (to prevent external attacks)
7requirepass StrongPassw0rd!
8# 4. Run in the background
9daemonize yes
10# 5. Change log path (recommended)
11logfile /usr/local/redis/logs/redis.log

Open Port

1systemctl start firewalld
2firewall-cmd --list-ports
3firewall-cmd --permanent --add-port=6379/tcp
4firewall-cmd --reload

Restart

1systemctl restart redis

Verification

1redis-cli -h 192.168.0.1
2192.168.0.1:6379> get name
3(error) NOAUTH Authentication required.
4192.168.0.1:6379> auth password
5OK
6192.168.0.1:6379> get name
7(nil)

Leave a Comment