質問編集履歴

10

質問内容を更新

2019/08/23 08:36

投稿

hasshy
hasshy

スコア102

test CHANGED
@@ -1 +1 @@
1
- 【AWS ElasticCache】EC2からredisサーバに接続できな
1
+ 【AWS ElasticCache】EC2からElasticCacheのredisサーバに暗号化で接続
test CHANGED
@@ -1,14 +1,14 @@
1
- 曖昧な質問で申し訳ありません。
2
-
3
- もし、情報が不足していたらご指摘をお願いいたします。
4
-
5
-
6
-
7
1
  AWSのコンテナでlaravelのアプリケーションを動かしていて、キャッシュとセッションをRedisサーバにしようと思います。
8
2
 
9
3
  RedisサーバーはElasticCacheで作成しました。
10
4
 
5
+
6
+
11
7
  実際にサーバーへアップロードしたプログラムからRedisサーバに接続したとこタイムアウトを起こして接続できませんでした。
8
+
9
+ 暗号化やパスワードを指定しない設定であれば接続する事はできるのですが、
10
+
11
+ (セキュリティのために)暗号化とAuth認証(パスワード)を設定すると接続できません。
12
12
 
13
13
 
14
14
 
@@ -18,9 +18,7 @@
18
18
 
19
19
 
20
20
 
21
- 原因を調査したいのですが、ElasticCacheのログを見つけられませんでした。
22
21
 
23
- 曖昧な質問で恐縮ですが、ログや考えられる問題はないでしょうか?
24
22
 
25
23
 
26
24
 

9

状況追記

2019/08/23 08:36

投稿

hasshy
hasshy

スコア102

test CHANGED
File without changes
test CHANGED
@@ -130,6 +130,12 @@
130
130
 
131
131
 
132
132
 
133
+ この状態であればアプリケーションからの接続が可能ですが、
134
+
135
+ 最終的にはパスワードを設定したいので、本件の原因を解決したいです。
136
+
137
+
138
+
133
139
  ## 参考にしているページ
134
140
 
135
141
  [https://docs.aws.amazon.com/ja_jp/AmazonElastiCache/latest/red-ug/GettingStarted.html](https://docs.aws.amazon.com/ja_jp/AmazonElastiCache/latest/red-ug/GettingStarted.html)

8

状況追記

2019/08/23 08:34

投稿

hasshy
hasshy

スコア102

test CHANGED
File without changes
test CHANGED
@@ -102,6 +102,34 @@
102
102
 
103
103
 
104
104
 
105
+ ### 暗号化をしない状態で作った場合
106
+
107
+ redisを作るときに、送受信の暗号化を外した状態で作ってみました。
108
+
109
+ セキュリティグループも同じです。
110
+
111
+ この状態では接続できました。
112
+
113
+
114
+
115
+ そのため、下記の状態だと推測できます。 
116
+
117
+ - redisサーバーは接続できる場所、同じVPCに設定されており、接続許可の設定にも問題ない
118
+
119
+ - 暗号化に必要な設定が抜けているのかもしれない
120
+
121
+
122
+
123
+ ```sh
124
+
125
+ redis-cli -h (cache名).cache.amazonaws.com -p 6379
126
+
127
+ (cache名).apne1.cache.amazonaws.com:6379>
128
+
129
+ ```
130
+
131
+
132
+
105
133
  ## 参考にしているページ
106
134
 
107
135
  [https://docs.aws.amazon.com/ja_jp/AmazonElastiCache/latest/red-ug/GettingStarted.html](https://docs.aws.amazon.com/ja_jp/AmazonElastiCache/latest/red-ug/GettingStarted.html)

7

追記

2019/08/23 08:24

投稿

hasshy
hasshy

スコア102

test CHANGED
File without changes
test CHANGED
@@ -99,3 +99,9 @@
99
99
 
100
100
 
101
101
  ```
102
+
103
+
104
+
105
+ ## 参考にしているページ
106
+
107
+ [https://docs.aws.amazon.com/ja_jp/AmazonElastiCache/latest/red-ug/GettingStarted.html](https://docs.aws.amazon.com/ja_jp/AmazonElastiCache/latest/red-ug/GettingStarted.html)

6

追記調整

2019/08/22 15:23

投稿

hasshy
hasshy

スコア102

test CHANGED
File without changes
test CHANGED
@@ -86,7 +86,7 @@
86
86
 
87
87
  関係が無いと思いますが、masterを外した状態でも確認しました。
88
88
 
89
- やはり、サーバが見つかりませんでした。
89
+ 暗号化する設定なのでか、サーバが見つかりませんでした。
90
90
 
91
91
  ```sh
92
92
 

5

試した事修正

2019/08/22 15:21

投稿

hasshy
hasshy

スコア102

test CHANGED
File without changes
test CHANGED
@@ -74,7 +74,7 @@
74
74
 
75
75
  ```sh
76
76
 
77
- $ redis-cli -h (cache名).cache.amazonaws.com -p 6379
77
+ $ redis-cli -h master.(cache名).cache.amazonaws.com -p 6379
78
78
 
79
79
  Could not connect to Redis at (cache名).cache.amazonaws.com:6379: Connection timed out
80
80
 
@@ -82,15 +82,19 @@
82
82
 
83
83
  ```
84
84
 
85
- また、masterをつけた状態で確認してみましたが、やはり同じでした。
86
85
 
87
86
 
87
+ 関係が無いと思いますが、masterを外した状態でも確認しました。
88
+
89
+ やはり、サーバが見つかりませんでした。
88
90
 
89
91
  ```sh
90
92
 
91
- $ redis-cli -h master.(cache名).cache.amazonaws.com -p 6379
93
+ $ redis-cli -h (cache名).cache.amazonaws.com -p 6379
92
94
 
93
- Could not connect to Redis at (cache名).cache.amazonaws.com:6379: Connection timed out
95
+ Could not connect to Redis at (cache名).cache.amazonaws.com:6379: Name or service not known
96
+
97
+ Could not connect to Redis at (cache名).cache.amazonaws.com:6379: Name or service not known
94
98
 
95
99
 
96
100
 

4

試した事追記

2019/08/22 15:18

投稿

hasshy
hasshy

スコア102

test CHANGED
File without changes
test CHANGED
@@ -81,3 +81,17 @@
81
81
 
82
82
 
83
83
  ```
84
+
85
+ また、masterをつけた状態で確認してみましたが、やはり同じでした。
86
+
87
+
88
+
89
+ ```sh
90
+
91
+ $ redis-cli -h master.(cache名).cache.amazonaws.com -p 6379
92
+
93
+ Could not connect to Redis at (cache名).cache.amazonaws.com:6379: Connection timed out
94
+
95
+
96
+
97
+ ```

3

質問内容調整

2019/08/22 15:15

投稿

hasshy
hasshy

スコア102

test CHANGED
@@ -1 +1 @@
1
- 【AWS ElasticCache】redisに接続できないエラー原因の絞り方を教えてください。
1
+ 【AWS ElasticCache】EC2からredisサーバーに接続できない
test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
 
14
14
 
15
- ローカルでは、Dockerで環境構築しおり、REDIS_HOSTとDRIVERを設定するだけで接続できていましたので、
15
+ 開発環境では、Dockerのredisコンテナ使っいるのですが、REDIS_HOSTとDRIVERを設定するだけで接続できていましたので、
16
16
 
17
17
  プロジェクトのプログラムが起因している可能性は少ないと考えています。
18
18
 
@@ -24,49 +24,41 @@
24
24
 
25
25
 
26
26
 
27
- ## laravelの.envの設定
27
+ ## サーバー構成イメージ
28
28
 
29
- REDIS_HOSTエンドポイントを変更しした
29
+ 10.0.0.0/24の内にあるEC2から、10.0.1.0/24内のredisサーバーに接続したい考えてい
30
30
 
31
31
 
32
32
 
33
- ```
34
-
35
- CACHE_DRIVER=redis
36
-
37
- SESSION_DRIVER=redis
33
+ ![イメージ説明](19c123f28fc769de91e12d4bfb56801c.png)
38
34
 
39
35
 
40
36
 
41
- SESSION_LIFETIME=120
37
+ ご共有までに、RDSへの接続はできます。
42
38
 
43
39
 
44
40
 
45
- #Elasticcacheのエンドポイント
41
+ ## elasticcacheの設定
46
42
 
47
- REDIS_HOST=(cacheの名前).cache.amazonaws.com
43
+ ### redisサーバー設定
48
44
 
49
- REDIS_PASSWORD=
45
+ 1台構成(バックアップやクラスターの設定はしていません)のredisサーバーを用意しました。
50
46
 
51
- REDIS_PORT=6379
47
+ Redis認証(Redis Auth)は設定していないので、tlsやパスワードの指定は不要な状態です。
52
-
53
- ```
54
48
 
55
49
 
56
50
 
57
- ## Laravelのログ
58
-
59
- 原因を見る限り、タムアウトを起こしている事がわかります。
51
+ ![メージ説明](bb8b1b997f69bc90faf8c9bc88a13cd4.png)
60
-
61
- そもそも接続情報が悪いのか、それとも、AWSの構成(セキュリティグループや、VPCの設定)が悪いのか詳しく調べていきたいのですがLaravelのログではこれ以上原因を調べる事ができません。
62
52
 
63
53
 
64
54
 
65
- ```
55
+ ### redisのセキュリティグループ
66
56
 
67
- [2019-08-22 00:50:24] develop.ERROR: Connection timed out [tcp://(cache名前).cache.amazonaws.com:6379] {"exception":"[object] (Predis\Connection\ConnectionException(code: 110): Connection timed out [tcp://(cacheの名前).cache.amazonaws.com:6379] at /var/www/vendor/predis/predis/src/Connection/AbstractConnection.php:155)
57
+ とりあえず接続確認したいで、6379ポートであれば接続できるようにしています。
68
58
 
59
+
60
+
69
- ```
61
+ ![イメージ説明](0f5a5faa214258ff93c2a6216882fe12.png)
70
62
 
71
63
 
72
64
 

2

追記

2019/08/22 15:07

投稿

hasshy
hasshy

スコア102

test CHANGED
File without changes
test CHANGED
@@ -67,3 +67,25 @@
67
67
  [2019-08-22 00:50:24] develop.ERROR: Connection timed out [tcp://(cacheの名前).cache.amazonaws.com:6379] {"exception":"[object] (Predis\Connection\ConnectionException(code: 110): Connection timed out [tcp://(cacheの名前).cache.amazonaws.com:6379] at /var/www/vendor/predis/predis/src/Connection/AbstractConnection.php:155)
68
68
 
69
69
  ```
70
+
71
+
72
+
73
+ ## 試した事
74
+
75
+ ### EC2インスタンスから直接接続してみる
76
+
77
+ インスタンスから、接続できるかredis-cliで接続してみました。
78
+
79
+ やはりタイムアウトしてしまうため、もしかしたらネットワークの設定かもしれません。
80
+
81
+
82
+
83
+ ```sh
84
+
85
+ $ redis-cli -h (cache名).cache.amazonaws.com -p 6379
86
+
87
+ Could not connect to Redis at (cache名).cache.amazonaws.com:6379: Connection timed out
88
+
89
+
90
+
91
+ ```

1

追記

2019/08/22 11:41

投稿

hasshy
hasshy

スコア102

test CHANGED
@@ -1 +1 @@
1
- 【AWS ElasticCache】エラーログは何処で確認できますか?
1
+ 【AWS ElasticCache】redisに接続できないエラー原因の絞り方を教えてください。
test CHANGED
@@ -1,18 +1,26 @@
1
+ 曖昧な質問で申し訳ありません。
2
+
1
- AWSのコンテナでlaravelのアプリケーションを動かしていて、キャッシュとセッションRedisサーバにようと思います。
3
+ 、情報が不足していたらご指摘お願いいたします。
2
4
 
3
5
 
4
6
 
5
- ローカルは、Dockerで環境構築しており、REDIS_HOSTを設定るだけで接続できました
7
+ AWSのコンテナlaravelのアプリケーション動かしていてキャッシュとセッションをRedisサーバにしようと思います。
6
8
 
7
- 実際のサーバーにアップロードして、Awsで作成したredisに接続する設定をしたところ、
9
+ RedisサーバーはElasticCacheで作成しした
8
10
 
9
- タイムアウトを起こして接続できませんでした。
11
+ 実際にサーバーへアップロードしたプログラムからRedisサーバに接続したとこタイムアウトを起こして接続できませんでした。
10
12
 
11
13
 
12
14
 
13
- 原因を調査したいのすがElasticCacheのログの確認方法がわかりませんでした
15
+ ローカルDockerで環境を構築してお、REDIS_HOSTとDRIVERを設定するだけで接続できていましたので、
14
16
 
17
+ プロジェクトのプログラムが起因している可能性は少ないと考えています。
18
+
19
+
20
+
21
+ 原因を調査したいのですが、ElasticCacheのログを見つけられませんでした。
22
+
15
- 曖昧な質問で恐縮ですが、ログのようものはあるのでしょうか?
23
+ 曖昧な質問で恐縮ですが、ログや考えられる問題はでしょうか?
16
24
 
17
25
 
18
26