LoginSignup
0
0

More than 3 years have passed since last update.

RHELに最新バージョンのRedisをソースからコンパイルしてインストールした

Posted at

0. 前提

2020/4/22時点
- RHEL7.6のAMI(ちょっと古い。8.1が最新のようです。)
- Redis5.0.8(この記事を書いている時点での最新)

1. EC2インスタンス起動

1.1. AMI

東京リージョンで「RHEL 7.6」でAMIを検索すると、

RHEL-7.6_HVM_GA-20190128-x86_64-0-Hourly2-GP2
ami-00b95502a4d51a07e
Provided by Red Hat, Inc.

が見つかりますので、これを選択します。

1.2. インスタンスタイプ

t3.small (適宜サイジングしてください)

1.3. セキュリティグループ

tcp/6379をオープン

2. Redisインストール

2.1. ssh接続

RHEL7.6のAMIのユーザはec2-userです。
ssh -i private.pem ec2-user@[public ip]

2.2. gccインストール

sudo yum -y install gcc
コンパイルに必要です。
最後に

Complete!

が出てれば成功。

2.3. Redisダウンロード

curl http://download.redis.io/releases/redis-5.0.8.tar.gz -o redis-5.0.8.tar.gz

redis-5.0.8.tar.gzファイルが存在していれば成功。

2.4. アーカイブの展開

tar zxvf redis-5.0.8.tar.gz

redis-5.0.8ディレクトリが存在していれば成功。

2.5. コンパイル

cd redis-5.0.8
make

zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory

みたいなエラーが出たときは、下記記事を参考にして、
make distclean
してから
make
をやり直す。

(参考)
Redis使おうとしていろいろやったメモ
https://qiita.com/A-gen/items/345c07d830205a7ea6cb

makeの終わりの方に、

Hint: It's a good idea to run 'make test' ;)
って出力されたら成功。でも、
make test
してみたけどエラーになった。。

src下にバイナリが配置される

3. 動作確認

3.1. Redis Serverの起動

src/redis-server &
Redis Serverが起動する

3.2. Redis CLIからの接続

src/redis-cli

[ec2-user@ip-172-30-1-243 redis-5.0.8]$ src/redis-cli
127.0.0.1:6379> set key1 value1
OK
127.0.0.1:6379> get key1
"value1"
127.0.0.1:6379> shutdown
16077:M 22 Apr 2020 06:52:31.131 # User requested shutdown...
16077:M 22 Apr 2020 06:52:31.131 * Saving the final RDB snapshot before exiting.
16077:M 22 Apr 2020 06:52:31.133 * DB saved on disk
16077:M 22 Apr 2020 06:52:31.133 # Redis is now ready to exit, bye bye...
not connected> exit

4. 余談

make installしてみたら

デフォルトでは/usr/local/binにインストールされるようです。

[ec2-user@ip-172-30-1-243 redis-5.0.8]$ sudo make install
cd src && make install
make[1]: Entering directory `/home/ec2-user/redis-5.0.8/src'

Hint: It's a good idea to run 'make test' ;)

INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install

make[1]: Leaving directory `/home/ec2-user/redis-5.0.8/src'
[ec2-user@ip-172-30-1-243 redis-5.0.8]$ which redis-server
/usr/local/bin/redis-server
[ec2-user@ip-172-30-1-243 redis-5.0.8]$ which redis-sentinel
/usr/local/bin/redis-sentinel

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0