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

redissonの接続サーバを環境変数で設定する

Posted at

前回の記事(Apache、mod_jk、Tomcat、redisson、Redisでセッション共有を試してみる)ではredissonの接続するRedisサーバを設定ファイルに直書きしていたので、今回はTomcatのポート番号と同じく環境変数で定義・変更できるようにしたいと思います。

%CATALINA_HOME%/conf/redisson.conf
singleServerConfig:
  address: "${redis.address}"

threads: 0
nettyThreads: 0
transportMode: NIO

Tomcatのポート番号を環境変数で定義・変更する方法に記載の通りシステムプロパティを定義します。

%CATALINA_HOME%/bin/setenv.bat
@echo off
set JAVA_OPTS=-Dserver.port=%SERVER_PORT% -Dajp.port=%AJP_PORT% -Dshutdown.port=%SHUTDOWN_PORT% -Dredis.address=%REDIS_ADDRESS%

REDIS_ADDRESS環境変数にRedisの接続サーバの設定情報を定義すれば完了です。

apserver2_startup.bat
@echo off
set JAVA_HOME=C:¥tools¥corretto¥jdk17.0.12_7
set CATALINA_HOME=C:¥tools¥apache-tomcat-10.1.26
set CATALINA_BASE=C:¥tools¥apserver_2

set SHUTDOWN_PORT=8006
set SERVER_PORT=8084
set AJP_PORT=8019

rem ⭐️ ポイント
set REDIS_ADDRESS=redis://127.0.0.1:7777

call %CATALINA_HOME%¥bin¥startup.bat

ちなみにRedisサーバ側でリッスンするポート番号を変更するには--portオプションを指定します。

ポート番号を7777に変更するコマンド
redis-server.exe --port 7777
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?