Amazon Linux 2023やRed Hat Enterprise Linuxに redis-cli のみをインストールする

不要なものはインストールしたくない
2023.11.09

RedisのCLIクライアントだけ欲しい

こんにちは、のんピ(@non____97)です。

皆さんはRedisのCLIクライアントだけ欲しいと思ったことはありますか? 私はあります。

sudo dnf install redisとすると、redis-cliだけでなくRedisのサーバーもインストールされてしまいます。余計なものはインストールしたくないですよね。

Amazon Linux 2023やRed Hat Enterprise Linux(以降RHEL)の8や9の標準リポジトリにはredis-cliのみを提供しているパッケージはありません。

そのため、Redis公式のダウンロードサイトからソースコードをダウンロードしてmakeすることになります。

redis-cliのインストール方法は以下AWS公式ドキュメントに記載されています。

ただし、こちらの手順ではredis-cli以外もmakeされる かつ TLSでRedisサーバーに接続することができません。

TLSによる接続ができるredis-cliをインストール方法を整理します。

いきなりまとめ

  • gccopenssl-develを事前にインストールしよう
  • make redis-cli BUILD_TLS=yesでTLSでも接続できるようにしよう

やってみた

実際にやってみます。使用しているEC2インスタンスは以下の通りです。

  • AMI ID : ami-05c13eab67c5d8861
  • AMI名 : al2023-ami-2023.2.20231030.1-kernel-6.1-x86_64

EC2インスタンス作成後、SSMセッションマネージャーで接続します。

makeする際にはgccが必要となります。インストールされているか確認します。

$ rpm -qa | grep gcc
libgcc-11.4.1-2.amzn2023.0.2.x86_64

インストールされていないので、インストールしてあげます。

$ sudo dnf install gcc
Last metadata expiration check: 0:02:01 ago on Thu Nov  9 04:31:55 2023.
Dependencies resolved.
=================================================================================================================
 Package                       Architecture      Version                            Repository              Size
=================================================================================================================
Installing:
 gcc                           x86_64            11.4.1-2.amzn2023.0.2              amazonlinux             32 M
Installing dependencies:
 annobin-docs                  noarch            10.93-1.amzn2023.0.1               amazonlinux             92 k
 annobin-plugin-gcc            x86_64            10.93-1.amzn2023.0.1               amazonlinux            887 k
 cpp                           x86_64            11.4.1-2.amzn2023.0.2              amazonlinux             10 M
 gc                            x86_64            8.0.4-5.amzn2023.0.2               amazonlinux            105 k
 glibc-devel                   x86_64            2.34-52.amzn2023.0.7               amazonlinux             45 k
 glibc-headers-x86             noarch            2.34-52.amzn2023.0.7               amazonlinux            446 k
 guile22                       x86_64            2.2.7-2.amzn2023.0.3               amazonlinux            6.4 M
 kernel-headers                x86_64            6.1.59-84.139.amzn2023             amazonlinux            1.4 M
 libmpc                        x86_64            1.2.1-2.amzn2023.0.2               amazonlinux             62 k
 libtool-ltdl                  x86_64            2.4.7-1.amzn2023.0.3               amazonlinux             38 k
 libxcrypt-devel               x86_64            4.4.33-7.amzn2023                  amazonlinux             32 k
 make                          x86_64            1:4.3-5.amzn2023.0.2               amazonlinux            534 k

Transaction Summary
=================================================================================================================
Install  13 Packages

Total download size: 52 M
Installed size: 168 M
Is this ok [y/N]: y
Downloading Packages:
(1/13): libmpc-1.2.1-2.amzn2023.0.2.x86_64.rpm                                   780 kB/s |  62 kB     00:00
(2/13): gc-8.0.4-5.amzn2023.0.2.x86_64.rpm                                       1.2 MB/s | 105 kB     00:00
.
.
(中略)
.
.

Installed:
  annobin-docs-10.93-1.amzn2023.0.1.noarch               annobin-plugin-gcc-10.93-1.amzn2023.0.1.x86_64
  cpp-11.4.1-2.amzn2023.0.2.x86_64                       gc-8.0.4-5.amzn2023.0.2.x86_64
  gcc-11.4.1-2.amzn2023.0.2.x86_64                       glibc-devel-2.34-52.amzn2023.0.7.x86_64
  glibc-headers-x86-2.34-52.amzn2023.0.7.noarch          guile22-2.2.7-2.amzn2023.0.3.x86_64
  kernel-headers-6.1.59-84.139.amzn2023.x86_64           libmpc-1.2.1-2.amzn2023.0.2.x86_64
  libtool-ltdl-2.4.7-1.amzn2023.0.3.x86_64               libxcrypt-devel-4.4.33-7.amzn2023.x86_64
  make-1:4.3-5.amzn2023.0.2.x86_64

Complete!

インストール後、ソースコードをダウンロードします。

# ソースコードのダウンロード
$ curl -s http://download.redis.io/redis-stable.tar.gz -o redis-stable.tar.gz

# ダウンロードしたソースコードの解凍
$ tar zxf redis-stable.tar.gz

# 解凍先のディレクトリの確認
$ cd redis-stable/
$ ls -l
total 276
-rw-rw-r--.  1 ec2-user ec2-user  20137 Nov  1 12:38 00-RELEASENOTES
-rw-rw-r--.  1 ec2-user ec2-user     51 Nov  1 12:38 BUGS
-rw-rw-r--.  1 ec2-user ec2-user   5027 Nov  1 12:38 CODE_OF_CONDUCT.md
-rw-rw-r--.  1 ec2-user ec2-user   2634 Nov  1 12:38 CONTRIBUTING.md
-rw-rw-r--.  1 ec2-user ec2-user   1487 Nov  1 12:38 COPYING
-rw-rw-r--.  1 ec2-user ec2-user     11 Nov  1 12:38 INSTALL
-rw-rw-r--.  1 ec2-user ec2-user   6888 Nov  1 12:38 MANIFESTO
-rw-rw-r--.  1 ec2-user ec2-user    151 Nov  1 12:38 Makefile
-rw-rw-r--.  1 ec2-user ec2-user  22607 Nov  1 12:38 README.md
-rw-rw-r--.  1 ec2-user ec2-user   1695 Nov  1 12:38 SECURITY.md
-rw-rw-r--.  1 ec2-user ec2-user   3628 Nov  1 12:38 TLS.md
drwxrwxr-x.  8 ec2-user ec2-user    133 Nov  1 12:38 deps
-rw-rw-r--.  1 ec2-user ec2-user 107512 Nov  1 12:38 redis.conf
-rwxrwxr-x.  1 ec2-user ec2-user    279 Nov  1 12:38 runtest
-rwxrwxr-x.  1 ec2-user ec2-user    283 Nov  1 12:38 runtest-cluster
-rwxrwxr-x.  1 ec2-user ec2-user   1772 Nov  1 12:38 runtest-moduleapi
-rwxrwxr-x.  1 ec2-user ec2-user    285 Nov  1 12:38 runtest-sentinel
-rw-rw-r--.  1 ec2-user ec2-user  14700 Nov  1 12:38 sentinel.conf
drwxrwxr-x.  4 ec2-user ec2-user  16384 Nov  1 12:38 src
drwxrwxr-x. 11 ec2-user ec2-user  16384 Nov  1 12:38 tests
drwxrwxr-x.  9 ec2-user ec2-user  16384 Nov  1 12:38 utils

Makefileを確認してみましょう。

$ cat Makefile
# Top level makefile, the real shit is at src/Makefile

default: all

.DEFAULT:
        cd src && $(MAKE) $@

install:
        cd src && $(MAKE) $@

.PHONY: install

$ cat src/Makefile
# Redis Makefile
# Copyright (C) 2009 Salvatore Sanfilippo <antirez at gmail dot com>
# This file is released under the BSD license, see the COPYING file
#
# The Makefile composes the final FINAL_CFLAGS and FINAL_LDFLAGS using
# what is needed for Redis plus the standard CFLAGS and LDFLAGS passed.
# However when building the dependencies (Jemalloc, Lua, Hiredis, ...)
# CFLAGS and LDFLAGS are propagated to the dependencies, so to pass
# flags only to be used when compiling / linking Redis itself REDIS_CFLAGS
# and REDIS_LDFLAGS are used instead (this is the case of 'make gcov').
#
# Dependencies are stored in the Makefile.dep file. To rebuild this file
# Just use 'make dep', but this is only needed by developers.

release_hdr := $(shell sh -c './mkreleasehdr.sh')
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
CLANG := $(findstring clang,$(shell sh -c '$(CC) --version | head -1'))
OPTIMIZATION?=-O3
ifeq ($(OPTIMIZATION),-O3)
        ifeq (clang,$(CLANG))
                REDIS_CFLAGS+=-flto
        else
                REDIS_CFLAGS+=-flto=auto
        endif
        REDIS_LDFLAGS+=-O3 -flto
endif
DEPENDENCY_TARGETS=hiredis linenoise lua hdr_histogram fpconv
NODEPS:=clean distclean

# Default settings
STD=-pedantic -DREDIS_STATIC=''

# Use -Wno-c11-extensions on clang, either where explicitly used or on
# platforms we can assume it's being used.
ifeq (clang,$(CLANG))
  STD+=-Wno-c11-extensions
else
ifneq (,$(findstring FreeBSD,$(uname_S)))
  STD+=-Wno-c11-extensions
endif
endif
WARN=-Wall -W -Wno-missing-field-initializers -Werror=deprecated-declarations -Wstrict-prototypes
OPT=$(OPTIMIZATION)

# Detect if the compiler supports C11 _Atomic.
# NUMBER_SIGN_CHAR is a workaround to support both GNU Make 4.3 and older versions.
NUMBER_SIGN_CHAR := \#
C11_ATOMIC := $(shell sh -c 'echo "$(NUMBER_SIGN_CHAR)include <stdatomic.h>" > foo.c; \
        $(CC) -std=gnu11 -c foo.c -o foo.o > /dev/null 2>&1; \
        if [ -f foo.o ]; then echo "yes"; rm foo.o; fi; rm foo.c')
ifeq ($(C11_ATOMIC),yes)
        STD+=-std=gnu11
else
        STD+=-std=c99
endif

PREFIX?=/usr/local
INSTALL_BIN=$(PREFIX)/bin
INSTALL=install
PKG_CONFIG?=pkg-config

ifndef PYTHON
PYTHON := $(shell which python3 || which python)
endif

# Default allocator defaults to Jemalloc on Linux and libc otherwise
MALLOC=libc
ifeq ($(uname_S),Linux)
        MALLOC=jemalloc
endif

# To get ARM stack traces if Redis crashes we need a special C flag.
ifneq (,$(filter aarch64 armv%,$(uname_M)))
        CFLAGS+=-funwind-tables
endif

# Backwards compatibility for selecting an allocator
ifeq ($(USE_TCMALLOC),yes)
        MALLOC=tcmalloc
endif

ifeq ($(USE_TCMALLOC_MINIMAL),yes)
        MALLOC=tcmalloc_minimal
endif

ifeq ($(USE_JEMALLOC),yes)
        MALLOC=jemalloc
endif

ifeq ($(USE_JEMALLOC),no)
        MALLOC=libc
endif

ifdef SANITIZER
ifeq ($(SANITIZER),address)
        MALLOC=libc
        CFLAGS+=-fsanitize=address -fno-sanitize-recover=all -fno-omit-frame-pointer
        LDFLAGS+=-fsanitize=address
else
ifeq ($(SANITIZER),undefined)
        MALLOC=libc
        CFLAGS+=-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer
        LDFLAGS+=-fsanitize=undefined
else
ifeq ($(SANITIZER),thread)
        CFLAGS+=-fsanitize=thread -fno-sanitize-recover=all -fno-omit-frame-pointer
        LDFLAGS+=-fsanitize=thread
else
    $(error "unknown sanitizer=${SANITIZER}")
endif
endif
endif
endif

# Override default settings if possible
-include .make-settings

FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS)
FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG)
FINAL_LIBS=-lm
DEBUG=-g -ggdb

# Linux ARM32 needs -latomic at linking time
ifneq (,$(findstring armv,$(uname_M)))
        FINAL_LIBS+=-latomic
endif

ifeq ($(uname_S),SunOS)
        # SunOS
        ifeq ($(findstring -m32,$(FINAL_CFLAGS)),)
                CFLAGS+=-m64
        endif
        ifeq ($(findstring -m32,$(FINAL_LDFLAGS)),)
                LDFLAGS+=-m64
        endif
        DEBUG=-g
        DEBUG_FLAGS=-g
        export CFLAGS LDFLAGS DEBUG DEBUG_FLAGS
        INSTALL=cp -pf
        FINAL_CFLAGS+= -D__EXTENSIONS__ -D_XPG6
        FINAL_LIBS+= -ldl -lnsl -lsocket -lresolv -lpthread -lrt
        ifeq ($(USE_BACKTRACE),yes)
            FINAL_CFLAGS+= -DUSE_BACKTRACE
        endif
else
ifeq ($(uname_S),Darwin)
        # Darwin
        FINAL_LIBS+= -ldl
        # Homebrew's OpenSSL is not linked to /usr/local to avoid
        # conflicts with the system's LibreSSL installation so it
        # must be referenced explicitly during build.
ifeq ($(uname_M),arm64)
        # Homebrew arm64 uses /opt/homebrew as HOMEBREW_PREFIX
        OPENSSL_PREFIX?=/opt/homebrew/opt/openssl
else
        # Homebrew x86/ppc uses /usr/local as HOMEBREW_PREFIX
        OPENSSL_PREFIX?=/usr/local/opt/openssl
endif
else
ifeq ($(uname_S),AIX)
        # AIX
        FINAL_LDFLAGS+= -Wl,-bexpall
        FINAL_LIBS+=-ldl -pthread -lcrypt -lbsd
else
ifeq ($(uname_S),OpenBSD)
        # OpenBSD
        FINAL_LIBS+= -lpthread
        ifeq ($(USE_BACKTRACE),yes)
            FINAL_CFLAGS+= -DUSE_BACKTRACE -I/usr/local/include
            FINAL_LDFLAGS+= -L/usr/local/lib
            FINAL_LIBS+= -lexecinfo
        endif

else
ifeq ($(uname_S),NetBSD)
        # NetBSD
        FINAL_LIBS+= -lpthread
        ifeq ($(USE_BACKTRACE),yes)
            FINAL_CFLAGS+= -DUSE_BACKTRACE -I/usr/pkg/include
            FINAL_LDFLAGS+= -L/usr/pkg/lib
            FINAL_LIBS+= -lexecinfo
        endif
else
ifeq ($(uname_S),FreeBSD)
        # FreeBSD
        FINAL_LIBS+= -lpthread -lexecinfo
else
ifeq ($(uname_S),DragonFly)
        # DragonFly
        FINAL_LIBS+= -lpthread -lexecinfo
else
ifeq ($(uname_S),OpenBSD)
        # OpenBSD
        FINAL_LIBS+= -lpthread -lexecinfo
else
ifeq ($(uname_S),NetBSD)
        # NetBSD
        FINAL_LIBS+= -lpthread -lexecinfo
else
ifeq ($(uname_S),Haiku)
        # Haiku
        FINAL_CFLAGS+= -DBSD_SOURCE
        FINAL_LDFLAGS+= -lbsd -lnetwork
        FINAL_LIBS+= -lpthread
else
        # All the other OSes (notably Linux)
        FINAL_LDFLAGS+= -rdynamic
        FINAL_LIBS+=-ldl -pthread -lrt
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif

ifdef OPENSSL_PREFIX
        OPENSSL_CFLAGS=-I$(OPENSSL_PREFIX)/include
        OPENSSL_LDFLAGS=-L$(OPENSSL_PREFIX)/lib
        # Also export OPENSSL_PREFIX so it ends up in deps sub-Makefiles
        export OPENSSL_PREFIX
endif

# Include paths to dependencies
FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/fpconv

# Determine systemd support and/or build preference (defaulting to auto-detection)
BUILD_WITH_SYSTEMD=no
LIBSYSTEMD_LIBS=-lsystemd

# If 'USE_SYSTEMD' in the environment is neither "no" nor "yes", try to
# auto-detect libsystemd's presence and link accordingly.
ifneq ($(USE_SYSTEMD),no)
        LIBSYSTEMD_PKGCONFIG := $(shell $(PKG_CONFIG) --exists libsystemd && echo $$?)
# If libsystemd cannot be detected, continue building without support for it
# (unless a later check tells us otherwise)
ifeq ($(LIBSYSTEMD_PKGCONFIG),0)
        BUILD_WITH_SYSTEMD=yes
        LIBSYSTEMD_LIBS=$(shell $(PKG_CONFIG) --libs libsystemd)
endif
endif

# If 'USE_SYSTEMD' is set to "yes" use pkg-config if available or fall back to
# default -lsystemd.
ifeq ($(USE_SYSTEMD),yes)
        BUILD_WITH_SYSTEMD=yes
endif

ifeq ($(BUILD_WITH_SYSTEMD),yes)
        FINAL_LIBS+=$(LIBSYSTEMD_LIBS)
        FINAL_CFLAGS+= -DHAVE_LIBSYSTEMD
endif

ifeq ($(MALLOC),tcmalloc)
        FINAL_CFLAGS+= -DUSE_TCMALLOC
        FINAL_LIBS+= -ltcmalloc
endif

ifeq ($(MALLOC),tcmalloc_minimal)
        FINAL_CFLAGS+= -DUSE_TCMALLOC
        FINAL_LIBS+= -ltcmalloc_minimal
endif

ifeq ($(MALLOC),jemalloc)
        DEPENDENCY_TARGETS+= jemalloc
        FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include
        FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS)
endif

# LIBSSL & LIBCRYPTO
LIBSSL_LIBS=
LIBSSL_PKGCONFIG := $(shell $(PKG_CONFIG) --exists libssl && echo $$?)
ifeq ($(LIBSSL_PKGCONFIG),0)
        LIBSSL_LIBS=$(shell $(PKG_CONFIG) --libs libssl)
else
        LIBSSL_LIBS=-lssl
endif
LIBCRYPTO_LIBS=
LIBCRYPTO_PKGCONFIG := $(shell $(PKG_CONFIG) --exists libcrypto && echo $$?)
ifeq ($(LIBCRYPTO_PKGCONFIG),0)
        LIBCRYPTO_LIBS=$(shell $(PKG_CONFIG) --libs libcrypto)
else
        LIBCRYPTO_LIBS=-lcrypto
endif

BUILD_NO:=0
BUILD_YES:=1
BUILD_MODULE:=2
ifeq ($(BUILD_TLS),yes)
        FINAL_CFLAGS+=-DUSE_OPENSSL=$(BUILD_YES) $(OPENSSL_CFLAGS) -DBUILD_TLS_MODULE=$(BUILD_NO)
        FINAL_LDFLAGS+=$(OPENSSL_LDFLAGS)
        FINAL_LIBS += ../deps/hiredis/libhiredis_ssl.a $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS)
endif

TLS_MODULE=
TLS_MODULE_NAME:=redis-tls$(PROG_SUFFIX).so
TLS_MODULE_CFLAGS:=$(FINAL_CFLAGS)
ifeq ($(BUILD_TLS),module)
        FINAL_CFLAGS+=-DUSE_OPENSSL=$(BUILD_MODULE) $(OPENSSL_CFLAGS)
        TLS_CLIENT_LIBS = ../deps/hiredis/libhiredis_ssl.a $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS)
        TLS_MODULE=$(TLS_MODULE_NAME)
        TLS_MODULE_CFLAGS+=-DUSE_OPENSSL=$(BUILD_MODULE) $(OPENSSL_CFLAGS) -DBUILD_TLS_MODULE=$(BUILD_MODULE)
endif

ifndef V
    define MAKE_INSTALL
        @printf '    %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$(1)$(ENDCOLOR) 1>&2
        @$(INSTALL) $(1) $(2)
    endef
else
    define MAKE_INSTALL
        $(INSTALL) $(1) $(2)
    endef
endif

REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS)
REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS)
REDIS_INSTALL=$(QUIET_INSTALL)$(INSTALL)

CCCOLOR="\033[34m"
LINKCOLOR="\033[34;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
MAKECOLOR="\033[32;1m"
ENDCOLOR="\033[0m"

ifndef V
QUIET_CC = @printf '    %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR) 1>&2;
QUIET_GEN = @printf '    %b %b\n' $(CCCOLOR)GEN$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR) 1>&2;
QUIET_LINK = @printf '    %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
QUIET_INSTALL = @printf '    %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
endif

ifneq (, $(findstring LOG_REQ_RES, $(REDIS_CFLAGS)))
        COMMANDS_DEF_FILENAME=commands_with_reply_schema
        GEN_COMMANDS_FLAGS=--with-reply-schema
else
        COMMANDS_DEF_FILENAME=commands
        GEN_COMMANDS_FLAGS=
endif

REDIS_SERVER_NAME=redis-server$(PROG_SUFFIX)
REDIS_SENTINEL_NAME=redis-sentinel$(PROG_SUFFIX)
REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o eval.o bio.o rio.o rand.o memtest.o syscheck.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.ot_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o tracking.o socket.o tls.o sha256.o timeout.o setcpuaffinity.o monotonic.o mt19937-64.o resp_parser.o call_reply.o script_lua.o script.o functions.o function_lua.o commands.o strl.o connection.o unix.o logreqres.o
REDIS_CLI_NAME=redis-cli$(PROG_SUFFIX)
REDIS_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o ae.o redisassert.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o cli_commands.o
REDIS_BENCHMARK_NAME=redis-benchmark$(PROG_SUFFIX)
REDIS_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o redisassert.o release.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.omt19937-64.o strl.o
REDIS_CHECK_RDB_NAME=redis-check-rdb$(PROG_SUFFIX)
REDIS_CHECK_AOF_NAME=redis-check-aof$(PROG_SUFFIX)
ALL_SOURCES=$(sort $(patsubst %.o,%.c,$(REDIS_SERVER_OBJ) $(REDIS_CLI_OBJ) $(REDIS_BENCHMARK_OBJ)))

all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME) $(TLS_MODULE)
        @echo ""
        @echo "Hint: It's a good idea to run 'make test' ;)"
        @echo ""

Makefile.dep:
        -$(REDIS_CC) -MM $(ALL_SOURCES) > Makefile.dep 2> /dev/null || true

ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
-include Makefile.dep
endif

.PHONY: all

persist-settings: distclean
        echo STD=$(STD) >> .make-settings
        echo WARN=$(WARN) >> .make-settings
        echo OPT=$(OPT) >> .make-settings
        echo MALLOC=$(MALLOC) >> .make-settings
        echo BUILD_TLS=$(BUILD_TLS) >> .make-settings
        echo USE_SYSTEMD=$(USE_SYSTEMD) >> .make-settings
        echo CFLAGS=$(CFLAGS) >> .make-settings
        echo LDFLAGS=$(LDFLAGS) >> .make-settings
        echo REDIS_CFLAGS=$(REDIS_CFLAGS) >> .make-settings
        echo REDIS_LDFLAGS=$(REDIS_LDFLAGS) >> .make-settings
        echo PREV_FINAL_CFLAGS=$(FINAL_CFLAGS) >> .make-settings
        echo PREV_FINAL_LDFLAGS=$(FINAL_LDFLAGS) >> .make-settings
        -(cd ../deps && $(MAKE) $(DEPENDENCY_TARGETS))

.PHONY: persist-settings

# Prerequisites target
.make-prerequisites:
        @touch $@

# Clean everything, persist settings and build dependencies if anything changed
ifneq ($(strip $(PREV_FINAL_CFLAGS)), $(strip $(FINAL_CFLAGS)))
.make-prerequisites: persist-settings
endif

ifneq ($(strip $(PREV_FINAL_LDFLAGS)), $(strip $(FINAL_LDFLAGS)))
.make-prerequisites: persist-settings
endif

# redis-server
$(REDIS_SERVER_NAME): $(REDIS_SERVER_OBJ)
        $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a $(FINAL_LIBS)

# redis-sentinel
$(REDIS_SENTINEL_NAME): $(REDIS_SERVER_NAME)
        $(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME)

# redis-check-rdb
$(REDIS_CHECK_RDB_NAME): $(REDIS_SERVER_NAME)
        $(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_CHECK_RDB_NAME)

# redis-check-aof
$(REDIS_CHECK_AOF_NAME): $(REDIS_SERVER_NAME)
        $(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME)

# redis-tls.so
$(TLS_MODULE_NAME): $(REDIS_SERVER_NAME)
        $(QUIET_CC)$(CC) -o $@ tls.c -shared -fPIC $(TLS_MODULE_CFLAGS) $(TLS_CLIENT_LIBS)

# redis-cli
$(REDIS_CLI_NAME): $(REDIS_CLI_OBJ)
        $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(FINAL_LIBS) $(TLS_CLIENT_LIBS)

# redis-benchmark
$(REDIS_BENCHMARK_NAME): $(REDIS_BENCHMARK_OBJ)
        $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/hdr_histogram/libhdrhistogram.a $(FINAL_LIBS) $(TLS_CLIENT_LIBS)

DEP = $(REDIS_SERVER_OBJ:%.o=%.d) $(REDIS_CLI_OBJ:%.o=%.d) $(REDIS_BENCHMARK_OBJ:%.o=%.d)
-include $(DEP)

# Because the jemalloc.h header is generated as a part of the jemalloc build,
# building it should complete before building any other object. Instead of
# depending on a single artifact, build all dependencies first.
%.o: %.c .make-prerequisites
        $(REDIS_CC) -MMD -o $@ -c $<

# The file commands.def is checked in and doesn't normally need to be rebuilt. It
# is built only if python is available and its prereqs are modified.
ifneq (,$(PYTHON))
$(COMMANDS_DEF_FILENAME).def: commands/*.json ../utils/generate-command-code.py
        $(QUIET_GEN)$(PYTHON) ../utils/generate-command-code.py $(GEN_COMMANDS_FLAGS)
endif

commands.c: $(COMMANDS_DEF_FILENAME).def

clean:
        rm -rf $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME) *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep *.so
        rm -f $(DEP)

.PHONY: clean

distclean: clean
        -(cd ../deps && $(MAKE) distclean)
        -(cd modules && $(MAKE) clean)
        -(cd ../tests/modules && $(MAKE) clean)
        -(rm -f .make-*)

.PHONY: distclean

test: $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME)
        @(cd ..; ./runtest)

test-modules: $(REDIS_SERVER_NAME)
        @(cd ..; ./runtest-moduleapi)

test-sentinel: $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME)
        @(cd ..; ./runtest-sentinel)

test-cluster: $(REDIS_SERVER_NAME) $(REDIS_CLI_NAME)
        @(cd ..; ./runtest-cluster)

check: test

lcov:
        $(MAKE) gcov
        @(set -e; cd ..; ./runtest --clients 1)
        @geninfo -o redis.info .
        @genhtml --legend -o lcov-html redis.info

.PHONY: lcov

bench: $(REDIS_BENCHMARK_NAME)
        ./$(REDIS_BENCHMARK_NAME)

32bit:
        @echo ""
        @echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
        @echo ""
        $(MAKE) CFLAGS="-m32" LDFLAGS="-m32"

gcov:
        $(MAKE) REDIS_CFLAGS="-fprofile-arcs -ftest-coverage -DCOVERAGE_TEST" REDIS_LDFLAGS="-fprofile-arcs -ftest-coverage"

noopt:
        $(MAKE) OPTIMIZATION="-O0"

valgrind:
        $(MAKE) OPTIMIZATION="-O0" MALLOC="libc"

helgrind:
        $(MAKE) OPTIMIZATION="-O0" MALLOC="libc" CFLAGS="-D__ATOMIC_VAR_FORCE_SYNC_MACROS" REDIS_CFLAGS="-I/usr/local/include" REDIS_LDFLAGS="-L/usr/local/lib"

install: all
        @mkdir -p $(INSTALL_BIN)
        $(call MAKE_INSTALL,$(REDIS_SERVER_NAME),$(INSTALL_BIN))
        $(call MAKE_INSTALL,$(REDIS_BENCHMARK_NAME),$(INSTALL_BIN))
        $(call MAKE_INSTALL,$(REDIS_CLI_NAME),$(INSTALL_BIN))
        @ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_CHECK_RDB_NAME)
        @ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_CHECK_AOF_NAME)
        @ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_SENTINEL_NAME)

uninstall:
        rm -f $(INSTALL_BIN)/{$(REDIS_SERVER_NAME),$(REDIS_BENCHMARK_NAME),$(REDIS_CLI_NAME),$(REDIS_CHECK_RDB_NAME),$(REDIS_CHECK_AOF_NAME),$(REDIS_SENTINEL_NAME)}

何も指定せずにmakeしてしまうとredis-cliだけでなくredis-serverredis-sentinelredis-benchmarkredis-check-rdbredis-check-aofもビルドされてしまいそうです。

また、TLS.mdも確認しておきます。

$ cat TLS.md
TLS Support
===========

Getting Started
---------------

### Building

To build with TLS support you'll need OpenSSL development libraries (e.g.
libssl-dev on Debian/Ubuntu).

To build TLS support as Redis built-in:
Run `make BUILD_TLS=yes`.

Or to build TLS as Redis module:
Run `make BUILD_TLS=module`.

Note that sentinel mode does not support TLS module.

### Tests

To run Redis test suite with TLS, you'll need TLS support for TCL (i.e.
`tcl-tls` package on Debian/Ubuntu).

1. Run `./utils/gen-test-certs.sh` to generate a root CA and a server
   certificate.

2. Run `./runtest --tls` or `./runtest-cluster --tls` to run Redis and Redis
   Cluster tests in TLS mode.

3. Run `./runtest --tls-module` or `./runtest-cluster --tls-module` to
   run Redis and Redis cluster tests in TLS mode with Redis module.

### Running manually

To manually run a Redis server with TLS mode (assuming `gen-test-certs.sh` was
invoked so sample certificates/keys are available):

For TLS built-in mode:
    ./src/redis-server --tls-port 6379 --port 0 \
        --tls-cert-file ./tests/tls/redis.crt \
        --tls-key-file ./tests/tls/redis.key \
        --tls-ca-cert-file ./tests/tls/ca.crt

For TLS module mode:
    ./src/redis-server --tls-port 6379 --port 0 \
        --tls-cert-file ./tests/tls/redis.crt \
        --tls-key-file ./tests/tls/redis.key \
        --tls-ca-cert-file ./tests/tls/ca.crt \
        --loadmodule src/redis-tls.so

To connect to this Redis server with `redis-cli`:

    ./src/redis-cli --tls \
        --cert ./tests/tls/redis.crt \
        --key ./tests/tls/redis.key \
        --cacert ./tests/tls/ca.crt

This will disable TCP and enable TLS on port 6379. It's also possible to have
both TCP and TLS available, but you'll need to assign different ports.

To make a Replica connect to the master using TLS, use `--tls-replication yes`,
and to make Redis Cluster use TLS across nodes use `--tls-cluster yes`.

Connections
-----------

All socket operations now go through a connection abstraction layer that hides
I/O and read/write event handling from the caller.

**Multi-threading I/O is not currently supported for TLS**, as a TLS connection
needs to do its own manipulation of AE events which is not thread safe. The
solution is probably to manage independent AE loops for I/O threads and longer
term association of connections with threads. This may potentially improve
overall performance as well.

Sync IO for TLS is currently implemented in a hackish way, i.e. making the
socket blocking and configuring socket-level timeout.  This means the timeout
value may not be so accurate, and there would be a lot of syscall overhead.
However I believe that getting rid of syncio completely in favor of pure async
work is probably a better move than trying to fix that. For replication it would
probably not be so hard. For cluster keys migration it might be more difficult,
but there are probably other good reasons to improve that part anyway.

To-Do List
----------

- [ ] redis-benchmark support. The current implementation is a mix of using
  hiredis for parsing and basic networking (establishing connections), but
  directly manipulating sockets for most actions. This will need to be cleaned
  up for proper TLS support. The best approach is probably to migrate to hiredis
  async mode.
- [ ] redis-cli `--slave` and `--rdb` support.

Multi-port
----------

Consider the implications of allowing TLS to be configured on a separate port,
making Redis listening on multiple ports:

1. Startup banner port notification
2. Proctitle
3. How slaves announce themselves
4. Cluster bus port calculation

「TLSのサポートをするならmake BUILD_TLS=yesしろ」と記載ありますね。

実際にやってみます。

$ make redis-cli BUILD_TLS=yes
cd src && make redis-cli
make[1]: Entering directory '/home/ec2-user/redis-stable/src'
    CC Makefile.dep
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep *.so
rm -f adlist.d quicklist.d ae.d anet.d dict.d server.d sds.d zmalloc.d lzf_c.d lzf_d.d pqsort.d zipmap.d sha1.d ziplist.d release.d networking.d util.d object.d db.d replication.d rdb.d t_string.d t_list.d t_set.d t_zset.d t_hash.d config.d aof.d pubsub.d multi.d debug.d sort.d intset.d syncio.d cluster.d crc16.d endianconv.d slowlog.d eval.d bio.d rio.d rand.d memtest.d syscheck.d crcspeed.d crc64.d bitops.d sentinel.d notify.d setproctitle.d blocked.d hyperloglog.d latency.d sparkline.d redis-check-rdb.d redis-check-aof.d geo.d lazyfree.d module.d evict.d expire.d geohash.d geohash_helper.d childinfo.d defrag.d siphash.d rax.d t_stream.d listpack.d localtime.d lolwut.d lolwut5.d lolwut6.d acl.d tracking.d socket.d tls.d sha256.d timeout.d setcpuaffinity.d monotonic.d mt19937-64.d resp_parser.d call_reply.d script_lua.d script.d functions.d function_lua.d commands.d strl.d connection.d unix.d logreqres.d anet.d adlist.d dict.d redis-cli.d zmalloc.d release.d ae.d redisassert.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d strl.d cli_commands.d ae.d anet.d redis-benchmark.d adlist.d dict.d zmalloc.d redisassert.d release.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d strl.d
(cd ../deps && make distclean)
make[2]: Entering directory '/home/ec2-user/redis-stable/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(cd hdr_histogram && make clean) > /dev/null || true
(cd fpconv && make clean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory '/home/ec2-user/redis-stable/deps'
(cd modules && make clean)
make[2]: Entering directory '/home/ec2-user/redis-stable/src/modules'
rm -rf *.xo *.so
make[2]: Leaving directory '/home/ec2-user/redis-stable/src/modules'
(cd ../tests/modules && make clean)
make[2]: Entering directory '/home/ec2-user/redis-stable/tests/modules'
rm -f commandfilter.so basics.so testrdb.so fork.so infotest.so propagate.so misc.so hooks.so blockonkeys.so blockonbackground.so scan.so datatype.so datatype2.so auth.so keyspace_events.so blockedclient.so getkeys.so getchannels.so test_lazyfree.so timer.so defragtest.so keyspecs.so hash.so zset.so stream.so mallocsize.so aclcheck.so list.so subcommands.so reply.so cmdintrospection.so eventloop.so moduleconfigs.so moduleconfigstwo.so publish.so usercall.so postnotifications.so moduleauthtwo.so rdbloadsave.so commandfilter.xo basics.xo testrdb.xo fork.xo infotest.xo propagate.xo misc.xo hooks.xo blockonkeys.xo blockonbackground.xo scan.xo datatype.xo datatype2.xo auth.xo keyspace_events.xo blockedclient.xo getkeys.xo getchannels.xo test_lazyfree.xo timer.xo defragtest.xo keyspecs.xo hash.xo zset.xo stream.xo mallocsize.xo aclcheck.xo list.xo subcommands.xo reply.xo cmdintrospection.xo eventloop.xo moduleconfigs.xo moduleconfigstwo.xo publish.xo usercall.xo postnotifications.xo moduleauthtwo.xo rdbloadsave.xo
make[2]: Leaving directory '/home/ec2-user/redis-stable/tests/modules'
(rm -f .make-*)
echo STD=-pedantic -DREDIS_STATIC='' -std=gnu11 >> .make-settings
echo WARN=-Wall -W -Wno-missing-field-initializers -Werror=deprecated-declarations -Wstrict-prototypes >> .make-settings
echo OPT=-O3 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo BUILD_TLS=yes >> .make-settings
echo USE_SYSTEMD= >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS=-flto=auto >> .make-settings
echo REDIS_LDFLAGS=-O3 -flto >> .make-settings
echo PREV_FINAL_CFLAGS=-pedantic -DREDIS_STATIC='' -std=gnu11 -Wall -W -Wno-missing-field-initializers -Werror=deprecated-declarations -Wstrict-prototypes -O3 -g -ggdb  -flto=auto -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/fpconv -DUSE_JEMALLOC -I../deps/jemalloc/include -DUSE_OPENSSL=1  -DBUILD_TLS_MODULE=0 >> .make-settings
echo PREV_FINAL_LDFLAGS= -O3 -flto -g -ggdb -rdynamic  >> .make-settings
(cd ../deps && make hiredis linenoise lua hdr_histogram fpconv jemalloc)
make[2]: Entering directory '/home/ec2-user/redis-stable/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(cd hdr_histogram && make clean) > /dev/null || true
(cd fpconv && make clean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static USE_SSL=1
make[3]: Entering directory '/home/ec2-user/redis-stable/deps/hiredis'
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic alloc.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic net.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic hiredis.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic sds.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic async.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic read.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic sockcompat.c
ar rcs libhiredis.a alloc.o net.o hiredis.o sds.o async.o read.o sockcompat.o
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic ssl.c
ssl.c:55:10: fatal error: openssl/ssl.h: No such file or directory
   55 | #include <openssl/ssl.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [Makefile:270: ssl.o] Error 1
make[3]: Leaving directory '/home/ec2-user/redis-stable/deps/hiredis'
make[2]: *** [Makefile:55: hiredis] Error 2
make[2]: Leaving directory '/home/ec2-user/redis-stable/deps'
make[1]: [Makefile:384: persist-settings] Error 2 (ignored)
    CC anet.o
    CC adlist.o
In file included from adlist.c:34:
zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or directory
   50 | #include <jemalloc/jemalloc.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:436: adlist.o] Error 1
make[1]: Leaving directory '/home/ec2-user/redis-stable/src'
make: *** [Makefile:6: redis-cli] Error 2

openssl/ssl.hが存在しない」と怒られてしまいました。

openssl-develをインストールしてあげましょう。

$ sudo dnf install openssl-devel
Last metadata expiration check: 0:06:37 ago on Thu Nov  9 04:31:55 2023.
Dependencies resolved.
=================================================================================================================
 Package                   Architecture       Version                              Repository               Size
=================================================================================================================
Installing:
 openssl-devel             x86_64             1:3.0.8-1.amzn2023.0.9               amazonlinux             3.0 M

Transaction Summary
=================================================================================================================
Install  1 Package

Total download size: 3.0 M
Installed size: 4.7 M
Is this ok [y/N]: y
Downloading Packages:
openssl-devel-3.0.8-1.amzn2023.0.9.x86_64.rpm                                     17 MB/s | 3.0 MB     00:00
-----------------------------------------------------------------------------------------------------------------
Total                                                                             12 MB/s | 3.0 MB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                         1/1
  Installing       : openssl-devel-1:3.0.8-1.amzn2023.0.9.x86_64                                             1/1
  Running scriptlet: openssl-devel-1:3.0.8-1.amzn2023.0.9.x86_64                                             1/1
  Verifying        : openssl-devel-1:3.0.8-1.amzn2023.0.9.x86_64                                             1/1

Installed:
  openssl-devel-1:3.0.8-1.amzn2023.0.9.x86_64

Complete!

make distcleanで綺麗さっぱりさせた後、再度makeします。

$ make distclean
cd src && make distclean
make[1]: Entering directory '/home/ec2-user/redis-stable/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep *.so
rm -f adlist.d quicklist.d ae.d anet.d dict.d server.d sds.d zmalloc.d lzf_c.d lzf_d.d pqsort.d zipmap.d sha1.d ziplist.d release.d networking.d util.d object.d db.d replication.d rdb.d t_string.d t_list.d t_set.d t_zset.d t_hash.d config.d aof.d pubsub.d multi.d debug.d sort.d intset.d syncio.d cluster.d crc16.d endianconv.d slowlog.d eval.d bio.d rio.d rand.d memtest.d syscheck.d crcspeed.d crc64.d bitops.d sentinel.d notify.d setproctitle.d blocked.d hyperloglog.d latency.d sparkline.d redis-check-rdb.d redis-check-aof.d geo.d lazyfree.d module.d evict.d expire.d geohash.d geohash_helper.d childinfo.d defrag.d siphash.d rax.d t_stream.d listpack.d localtime.d lolwut.d lolwut5.d lolwut6.d acl.d tracking.d socket.d tls.d sha256.d timeout.d setcpuaffinity.d monotonic.d mt19937-64.d resp_parser.d call_reply.d script_lua.d script.d functions.d function_lua.d commands.d strl.d connection.d unix.d logreqres.d anet.d adlist.d dict.d redis-cli.d zmalloc.d release.d ae.d redisassert.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d strl.d cli_commands.d ae.d anet.d redis-benchmark.d adlist.d dict.d zmalloc.d redisassert.d release.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d strl.d
(cd ../deps && make distclean)
make[2]: Entering directory '/home/ec2-user/redis-stable/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(cd hdr_histogram && make clean) > /dev/null || true
(cd fpconv && make clean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory '/home/ec2-user/redis-stable/deps'
(cd modules && make clean)
make[2]: Entering directory '/home/ec2-user/redis-stable/src/modules'
rm -rf *.xo *.so
make[2]: Leaving directory '/home/ec2-user/redis-stable/src/modules'
(cd ../tests/modules && make clean)
make[2]: Entering directory '/home/ec2-user/redis-stable/tests/modules'
rm -f commandfilter.so basics.so testrdb.so fork.so infotest.so propagate.so misc.so hooks.so blockonkeys.so blockonbackground.so scan.so datatype.so datatype2.so auth.so keyspace_events.so blockedclient.so getkeys.so getchannels.so test_lazyfree.so timer.so defragtest.so keyspecs.so hash.so zset.so stream.so mallocsize.so aclcheck.so list.so subcommands.so reply.so cmdintrospection.so eventloop.so moduleconfigs.so moduleconfigstwo.so publish.so usercall.so postnotifications.so moduleauthtwo.so rdbloadsave.so commandfilter.xo basics.xo testrdb.xo fork.xo infotest.xo propagate.xo misc.xo hooks.xo blockonkeys.xo blockonbackground.xo scan.xo datatype.xo datatype2.xo auth.xo keyspace_events.xo blockedclient.xo getkeys.xo getchannels.xo test_lazyfree.xo timer.xo defragtest.xo keyspecs.xo hash.xo zset.xo stream.xo mallocsize.xo aclcheck.xo list.xo subcommands.xo reply.xo cmdintrospection.xo eventloop.xo moduleconfigs.xo moduleconfigstwo.xo publish.xo usercall.xo postnotifications.xo moduleauthtwo.xo rdbloadsave.xo
make[2]: Leaving directory '/home/ec2-user/redis-stable/tests/modules'
(rm -f .make-*)
make[1]: Leaving directory '/home/ec2-user/redis-stable/src'

# 再度make
$ make redis-cli BUILD_TLS=yes
cd src && make redis-cli
make[1]: Entering directory '/home/ec2-user/redis-stable/src'
    CC Makefile.dep
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep *.so
rm -f adlist.d quicklist.d ae.d anet.d dict.d server.d sds.d zmalloc.d lzf_c.d lzf_d.d pqsort.d zipmap.d sha1.d ziplist.d release.d networking.d util.d object.d db.d replication.d rdb.d t_string.d t_list.d t_set.d t_zset.d t_hash.d config.d aof.d pubsub.d multi.d debug.d sort.d intset.d syncio.d cluster.d crc16.d endianconv.d slowlog.d eval.d bio.d rio.d rand.d memtest.d syscheck.d crcspeed.d crc64.d bitops.d sentinel.d notify.d setproctitle.d blocked.d hyperloglog.d latency.d sparkline.d redis-check-rdb.d redis-check-aof.d geo.d lazyfree.d module.d evict.d expire.d geohash.d geohash_helper.d childinfo.d defrag.d siphash.d rax.d t_stream.d listpack.d localtime.d lolwut.d lolwut5.d lolwut6.d acl.d tracking.d socket.d tls.d sha256.d timeout.d setcpuaffinity.d monotonic.d mt19937-64.d resp_parser.d call_reply.d script_lua.d script.d functions.d function_lua.d commands.d strl.d connection.d unix.d logreqres.d anet.d adlist.d dict.d redis-cli.d zmalloc.d release.d ae.d redisassert.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d strl.d cli_commands.d ae.d anet.d redis-benchmark.d adlist.d dict.d zmalloc.d redisassert.d release.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d strl.d
(cd ../deps && make distclean)
make[2]: Entering directory '/home/ec2-user/redis-stable/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(cd hdr_histogram && make clean) > /dev/null || true
(cd fpconv && make clean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory '/home/ec2-user/redis-stable/deps'
(cd modules && make clean)
make[2]: Entering directory '/home/ec2-user/redis-stable/src/modules'
rm -rf *.xo *.so
make[2]: Leaving directory '/home/ec2-user/redis-stable/src/modules'
(cd ../tests/modules && make clean)
make[2]: Entering directory '/home/ec2-user/redis-stable/tests/modules'
rm -f commandfilter.so basics.so testrdb.so fork.so infotest.so propagate.so misc.so hooks.so blockonkeys.so blockonbackground.so scan.so datatype.so datatype2.so auth.so keyspace_events.so blockedclient.so getkeys.so getchannels.so test_lazyfree.so timer.so defragtest.so keyspecs.so hash.so zset.so stream.so mallocsize.so aclcheck.so list.so subcommands.so reply.so cmdintrospection.so eventloop.so moduleconfigs.so moduleconfigstwo.so publish.so usercall.so postnotifications.so moduleauthtwo.so rdbloadsave.so commandfilter.xo basics.xo testrdb.xo fork.xo infotest.xo propagate.xo misc.xo hooks.xo blockonkeys.xo blockonbackground.xo scan.xo datatype.xo datatype2.xo auth.xo keyspace_events.xo blockedclient.xo getkeys.xo getchannels.xo test_lazyfree.xo timer.xo defragtest.xo keyspecs.xo hash.xo zset.xo stream.xo mallocsize.xo aclcheck.xo list.xo subcommands.xo reply.xo cmdintrospection.xo eventloop.xo moduleconfigs.xo moduleconfigstwo.xo publish.xo usercall.xo postnotifications.xo moduleauthtwo.xo rdbloadsave.xo
make[2]: Leaving directory '/home/ec2-user/redis-stable/tests/modules'
(rm -f .make-*)
echo STD=-pedantic -DREDIS_STATIC='' -std=gnu11 >> .make-settings
echo WARN=-Wall -W -Wno-missing-field-initializers -Werror=deprecated-declarations -Wstrict-prototypes >> .make-settings
echo OPT=-O3 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo BUILD_TLS=yes >> .make-settings
echo USE_SYSTEMD= >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS=-flto=auto >> .make-settings
echo REDIS_LDFLAGS=-O3 -flto >> .make-settings
echo PREV_FINAL_CFLAGS=-pedantic -DREDIS_STATIC='' -std=gnu11 -Wall -W -Wno-missing-field-initializers -Werror=deprecated-declarations -Wstrict-prototypes -O3 -g -ggdb  -flto=auto -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/fpconv -DUSE_JEMALLOC -I../deps/jemalloc/include -DUSE_OPENSSL=1  -DBUILD_TLS_MODULE=0 >> .make-settings
echo PREV_FINAL_LDFLAGS= -O3 -flto -g -ggdb -rdynamic  >> .make-settings
(cd ../deps && make hiredis linenoise lua hdr_histogram fpconv jemalloc)
make[2]: Entering directory '/home/ec2-user/redis-stable/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(cd hdr_histogram && make clean) > /dev/null || true
(cd fpconv && make clean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static USE_SSL=1
make[3]: Entering directory '/home/ec2-user/redis-stable/deps/hiredis'
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic alloc.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic net.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic hiredis.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic sds.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic async.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic read.c
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic sockcompat.c
ar rcs libhiredis.a alloc.o net.o hiredis.o sds.o async.o read.o sockcompat.o
cc -std=c99 -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb  -pedantic ssl.c
ar rcs libhiredis_ssl.a ssl.o
make[3]: Leaving directory '/home/ec2-user/redis-stable/deps/hiredis'
MAKE linenoise
cd linenoise && make
make[3]: Entering directory '/home/ec2-user/redis-stable/deps/linenoise'
cc  -Wall -Os -g  -c linenoise.c
make[3]: Leaving directory '/home/ec2-user/redis-stable/deps/linenoise'
MAKE lua
cd lua/src && make all CFLAGS="-Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP  -O2 "MYLDFLAGS="" AR="ar rc"
make[3]: Entering directory '/home/ec2-user/redis-stable/deps/lua/src'
cc -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP  -O2    -c -o lapi.o lapi.c
cc -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP  -O2    -c -o lcode.o lcode.c
cc -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP  -O2    -c -o ldebug.o ldebug.c
.
.
(中略)
.
.
cc -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP  -O2    -c -o lua_struct.o lua_struct.c
cc -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP  -O2    -c -o lua_cmsgpack.o lua_cmsgpack.c
cc -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP  -O2    -c -o lua_bit.o lua_bit.c
ar rc liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o strbuf.o fpconv.o lauxlib.o lbaselib.o ldblib.o liolib.olmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o lua_cjson.o lua_struct.o lua_cmsgpack.o lua_bit.o     # DLL needs all object files
ranlib liblua.a
cc -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP  -O2    -c -o lua.o lua.c
cc -o lua  lua.o liblua.a -lm
cc -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP  -O2    -c -o luac.o luac.c
cc -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP  -O2    -c -o print.o print.c
cc -o luac  luac.o print.o liblua.a -lm
make[3]: Leaving directory '/home/ec2-user/redis-stable/deps/lua/src'
MAKE hdr_histogram
cd hdr_histogram && make
make[3]: Entering directory '/home/ec2-user/redis-stable/deps/hdr_histogram'
cc -std=c99 -Wall -Os -g  -DHDR_MALLOC_INCLUDE=\"hdr_redis_malloc.h\" -c  hdr_histogram.c
ar rcs libhdrhistogram.a hdr_histogram.o
make[3]: Leaving directory '/home/ec2-user/redis-stable/deps/hdr_histogram'
MAKE fpconv
cd fpconv && make
make[3]: Entering directory '/home/ec2-user/redis-stable/deps/fpconv'
cc  -Wall -Os -g  -c  fpconv_dtoa.c
ar rcs libfpconv.a fpconv_dtoa.o
make[3]: Leaving directory '/home/ec2-user/redis-stable/deps/fpconv'
MAKE jemalloc
cd jemalloc && ./configure --disable-cxx --with-version=5.3.0-0-g0 --with-lg-quantum=3 --disable-cache-oblivious--with-jemalloc-prefix=je_ CFLAGS="" LDFLAGS=""
checking for xsltproc... false
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
.
.
(中略)
.
.
config.status: executing include/jemalloc/jemalloc_mangle.h commands
config.status: executing include/jemalloc/jemalloc_mangle_jet.h commands
config.status: executing include/jemalloc/jemalloc.h commands
===============================================================================
jemalloc version   : 5.3.0-0-g0
library revision   : 2

CONFIG             : --disable-cxx --with-version=5.3.0-0-g0 --with-lg-quantum=3 --disable-cache-oblivious --with-jemalloc-prefix=je_ CFLAGS= LDFLAGS=
CC                 : gcc
CONFIGURE_CFLAGS   : -std=gnu11 -Wall -Wextra -Wsign-compare -Wundef -Wno-format-zero-length -Wpointer-arith -Wno-missing-braces -Wno-missing-field-initializers -Wno-missing-attributes -pipe -g3 -fvisibility=hidden -Wimplicit-fallthrough -O3 -funroll-loops
SPECIFIED_CFLAGS   :
EXTRA_CFLAGS       :
CPPFLAGS           : -D_GNU_SOURCE -D_REENTRANT
CXX                :
CONFIGURE_CXXFLAGS :
SPECIFIED_CXXFLAGS :
EXTRA_CXXFLAGS     :
LDFLAGS            :
EXTRA_LDFLAGS      :
DSO_LDFLAGS        : -shared -Wl,-soname,$(@F)
LIBS               : -lm  -pthread
RPATH_EXTRA        :

XSLTPROC           : false
XSLROOT            :

PREFIX             : /usr/local
BINDIR             : /usr/local/bin
DATADIR            : /usr/local/share
INCLUDEDIR         : /usr/local/include
LIBDIR             : /usr/local/lib
MANDIR             : /usr/local/share/man

srcroot            :
abs_srcroot        : /home/ec2-user/redis-stable/deps/jemalloc/
objroot            :
abs_objroot        : /home/ec2-user/redis-stable/deps/jemalloc/

JEMALLOC_PREFIX    : je_
JEMALLOC_PRIVATE_NAMESPACE
                   : je_
install_suffix     :
malloc_conf        :
documentation      : 1
shared libs        : 1
static libs        : 1
autogen            : 0
debug              : 0
stats              : 1
experimental_smallocx : 0
prof               : 0
prof-libunwind     : 0
prof-libgcc        : 0
prof-gcc           : 0
fill               : 1
utrace             : 0
xmalloc            : 0
log                : 0
lazy_lock          : 0
cache-oblivious    : 0
cxx                : 0
===============================================================================
cd jemalloc && make lib/libjemalloc.a
make[3]: Entering directory '/home/ec2-user/redis-stable/deps/jemalloc'
gcc -std=gnu11 -Wall -Wextra -Wsign-compare -Wundef -Wno-format-zero-length -Wpointer-arith -Wno-missing-braces -Wno-missing-field-initializers -Wno-missing-attributes -pipe -g3 -fvisibility=hidden -Wimplicit-fallthrough -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/jemalloc.sym.o src/jemalloc.c
nm -a src/jemalloc.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/jemalloc.sym
gcc -std=gnu11 -Wall -Wextra -Wsign-compare -Wundef -Wno-format-zero-length -Wpointer-arith -Wno-missing-braces -Wno-missing-field-initializers -Wno-missing-attributes -pipe -g3 -fvisibility=hidden -Wimplicit-fallthrough -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/arena.sym.o src/arena.c
nm -a src/arena.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/arena.sym
.
.
(中略)
.
.
gcc -std=gnu11 -Wall -Wextra -Wsign-compare -Wundef -Wno-format-zero-length -Wpointer-arith -Wno-missing-braces -Wno-missing-field-initializers -Wno-missing-attributes -pipe -g3 -fvisibility=hidden -Wimplicit-fallthrough -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/witness.o src/witness.c
ar crs lib/libjemalloc.a src/jemalloc.o src/arena.o src/background_thread.o src/base.o src/bin.o src/bin_info.o src/bitmap.o src/buf_writer.o src/cache_bin.o src/ckh.o src/counter.o src/ctl.o src/decay.o src/div.o src/ecache.o src/edata.o src/edata_cache.o src/ehooks.o src/emap.o src/eset.o src/exp_grow.o src/extent.o src/extent_dss.o src/extent_mmap.o src/fxp.o src/san.o src/san_bump.o src/hook.o src/hpa.o src/hpa_hooks.o src/hpdata.o src/inspect.o src/large.o src/log.o src/malloc_io.o src/mutex.o src/nstime.o src/pa.o src/pa_extra.o src/pai.o src/pac.o src/pages.o src/peak_event.o src/prof.o src/prof_data.o src/prof_log.o src/prof_recent.o src/prof_stats.o src/prof_sys.o src/psset.o src/rtree.o src/safety_check.o src/sc.o src/sec.o src/stats.o src/sz.o src/tcache.o src/test_hooks.o src/thread_event.o src/ticker.o src/tsd.o src/witness.o
make[3]: Leaving directory '/home/ec2-user/redis-stable/deps/jemalloc'
make[2]: Leaving directory '/home/ec2-user/redis-stable/deps'
    CC anet.o
    CC adlist.o
    CC dict.o
    CC redis-cli.o
    CC zmalloc.o
    CC release.o
    CC ae.o
    CC redisassert.o
    CC crcspeed.o
    CC crc64.o
    CC siphash.o
    CC crc16.o
    CC monotonic.o
    CC cli_common.o
    CC mt19937-64.o
    CC strl.o
    CC cli_commands.o
    LINK redis-cli
lto-wrapper: warning: using serial compilation of 4 LTRANS jobs
make[1]: Leaving directory '/home/ec2-user/redis-stable/src'

# redis-cli が作成されたことを確認
$ ls -l src/redis-cli
-rwxrwxr-x. 1 ec2-user ec2-user 7045904 Nov  9 04:42 src/redis-cli

redis-cliがmakeできたようです。

ちなみに、make distcleanではなくmake cleanをした後に再度makeをしても以下のようにエラーになります。

$ make clean
cd src && make clean
make[1]: Entering directory '/home/ec2-user/redis-stable/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep *.so
rm -f adlist.d quicklist.d ae.d anet.d dict.d server.d sds.d zmalloc.d lzf_c.d lzf_d.d pqsort.d zipmap.d sha1.d ziplist.d release.d networking.d util.d object.d db.d replication.d rdb.d t_string.d t_list.d t_set.d t_zset.d t_hash.d config.d aof.d pubsub.d multi.d debug.d sort.d intset.d syncio.d cluster.d crc16.d endianconv.d slowlog.d eval.d bio.d rio.d rand.d memtest.d syscheck.d crcspeed.d crc64.d bitops.d sentinel.d notify.d setproctitle.d blocked.d hyperloglog.d latency.d sparkline.d redis-check-rdb.d redis-check-aof.d geo.d lazyfree.d module.d evict.d expire.d geohash.d geohash_helper.d childinfo.d defrag.d siphash.d rax.d t_stream.d listpack.d localtime.d lolwut.d lolwut5.d lolwut6.d acl.d tracking.d socket.d tls.d sha256.d timeout.d setcpuaffinity.d monotonic.d mt19937-64.d resp_parser.d call_reply.d script_lua.d script.d functions.d function_lua.d commands.d strl.d connection.d unix.d logreqres.d anet.d adlist.d dict.d redis-cli.d zmalloc.d release.d ae.d redisassert.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d strl.d cli_commands.d ae.d anet.d redis-benchmark.d adlist.d dict.d zmalloc.d redisassert.d release.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d strl.d
make[1]: Leaving directory '/home/ec2-user/redis-stable/src'

$ make redis-cli BUILD_TLS=yes
cd src && make redis-cli
make[1]: Entering directory '/home/ec2-user/redis-stable/src'
    CC Makefile.dep
    CC anet.o
    CC adlist.o
In file included from adlist.c:34:
zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or directory
   50 | #include <jemalloc/jemalloc.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:436: adlist.o] Error 1
make[1]: Leaving directory '/home/ec2-user/redis-stable/src'
make: *** [Makefile:6: redis-cli] Error 2

makeが完了したので、パスを通してあげましょう。インストールパスはお好みですが、パッケージマネージャー以外でインストールするものは/usr/local/bin/に配置したいところです。

$ sudo install -m 0755 src/redis-cli /usr/local/bin/

$ which redis-cli
/usr/local/bin/redis-cli

$ redis-cli -v
redis-cli 7.2.3

パスが通りましたね。

最後に、ElastiCache for Redisに接続します。接続先のRedisクラスターはRedis AUTHによる認証を必須としています。

# Redisクラスターへの接続
$ redis-cli -h redis-test-001.redis-test.pvjbiy.use1.cache.amazonaws.com-c --tls -p 6379

# 認証前はコマンドを受け付けないことを確認
redis-test-001.redis-test.pvjbiy.use1.cache.amazonaws.com:6379> keys *
(error) NOAUTH Authentication required.

# 認証
redis-test-001.redis-test.pvjbiy.use1.cache.amazonaws.com:6379> auth <Redis AUTHのトークン>
OK

# 認証後はコマンドを受け付けることを確認
redis-test-001.redis-test.pvjbiy.use1.cache.amazonaws.com:6379> keys *
(empty array)

問題なく接続 & 操作できました。

問題なく動作することを確認したら、ダウンロードしたソースコードは削除しておきましょう。

不要なものはインストールしたくない

Amazon Linux 2023やRed Hat Enterprise Linuxに redis-cli のみをインストールする方法を紹介しました。

実際にRHEL 9でも同様の手順でredis-cliのインストールができることを確認しました。

不要なツールはなるべくインストールせずに使いたいところです。

この記事が誰かの助けになれば幸いです。

以上、AWS事業本部 コンサルティング部の のんピ(@non____97)でした!