2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Redisをソースからインストールする(RHEL 9)

Posted at

はじめに

インメモリデータベースのRedisに触れる機会がありました。

RHEL9.1でしたので、dnfでパッケージのインストールは可能でしたが、バージョンが6.2.7と古かったので、ソースからインストールしました。

ソースからのインストール方法についてのドキュメント。

インストール先の環境・インストールするRedisのバージョン

  • OSはRHEL 9.1
  • インストールするRedisは、インストール時点の最新安定版
    • 今回は7.2.4

インストール

Redisのインストールに必要なパッケージをインストールする

もしmakeとgccがインストールされていない場合は、先にインストールしてください。

$ sudo dnf install make gcc

Redisのソースをダウンロードする

最新の安定版をダウンロードする

$ wget https://download.redis.io/redis-stable.tar.gz
--2024-03-15 19:50:19--  https://download.redis.io/redis-stable.tar.gz
download.redis.io (download.redis.io) をDNSに問いあわせています... 45.60.125.1
download.redis.io (download.redis.io)|45.60.125.1|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 3479614 (3.3M) [application/octet-stream]
`redis-stable.tar.gz.1' に保存中

redis-stable.tar.gz.1                                100%[===================================================================================================================>]   3.32M  10.0MB/s 時間 0.3s

2024-03-15 19:50:20 (10.0 MB/s) - `redis-stable.tar.gz.1' へ保存完了 [3479614/3479614]

ダウンロードしたソースを展開する

$ tar xzvf redis-stable.tar.gz
redis-stable/
redis-stable/src/
redis-stable/src/geohash.h

(中略)

redis-stable/.codespell/wordlist.txt
redis-stable/.codespell/requirements.txt
redis-stable/sentinel.conf
redis-stable/runtest-moduleapi

展開したソースのディレクトリに移動する

$ cd redis-stable

redis-stableでダウンロードした場合のバージョン確認

ソースのバージョンを確認したい場合は、以下を参照すると確認できます。

  • 展開したディレクトリの直下にある00-RELEASENOTES
    • リリースされたバージョンの情報がバージョンの降順で記載されている
  • srcディレクトリのversion.hファイル

makeの実行

$ make
cd src && make all
make[1]: ディレクトリ '/home/---/redis-stable/src' に入ります
    CC Makefile.dep

(中略)

    INSTALL redis-check-rdb
    INSTALL redis-check-aof

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

make[1]: ディレクトリ '/home/---/redis-stable/src' から出ます

インストールの実行

$ sudo make install
[sudo] --- のパスワード:
cd src && make install
make[1]: ディレクトリ '/home/---/redis-stable/src' に入ります
    CC Makefile.dep

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

    INSTALL redis-server
    INSTALL redis-benchmark
    INSTALL redis-cli
make[1]: ディレクトリ '/home/---/redis-stable/src' から出ます

インストールされたコマンド

/usr/local/binに"redis"で始まる以下のコマンドがあればOKです。

$ find /usr/local/bin/ -name "redis*"
/usr/local/bin/redis-server
/usr/local/bin/redis-benchmark
/usr/local/bin/redis-cli
/usr/local/bin/redis-check-rdb
/usr/local/bin/redis-check-aof
/usr/local/bin/redis-sentinel

動作確認

redis-serverを起動してみます。以下のような表示がされれば成功です。

$ redis-server
32927:C 15 Mar 2024 20:35:10.622 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
32927:C 15 Mar 2024 20:35:10.623 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
32927:C 15 Mar 2024 20:35:10.623 * Redis version=7.2.4, bits=64, commit=00000000, modified=0, pid=32927, just started
32927:C 15 Mar 2024 20:35:10.623 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
32927:M 15 Mar 2024 20:35:10.623 * Increased maximum number of open files to 10032 (it was originally set to 1024).
32927:M 15 Mar 2024 20:35:10.623 * monotonic clock: POSIX clock_gettime
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 7.2.4 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 32927
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           https://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

32927:M 15 Mar 2024 20:35:10.625 * Server initialized
32927:M 15 Mar 2024 20:35:10.625 * Ready to accept connections tcp

停止するにはCtrl + cを押下します。

^C32927:signal-handler (1710502517) Received SIGINT scheduling shutdown...
32927:M 15 Mar 2024 20:35:17.471 * User requested shutdown...
32927:M 15 Mar 2024 20:35:17.472 * Saving the final RDB snapshot before exiting.
32927:M 15 Mar 2024 20:35:17.486 * DB saved on disk
32927:M 15 Mar 2024 20:35:17.486 # Redis is now ready to exit, bye bye...

まとめ

ソースからのインストールということで、面倒なことになるのではと思いましたが、gccとmakeがあれば簡単にインストールできました。

2
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?