728x90
laravel에서 ElastiCache로 만들어진 redis 연동하는 방법은 아래와 같다.
env에는 구성 엔드포인트를 넣으면된다
여기서 중요한건 만들때 클러스터 활성화 모드로 만들어야된다는것!
database.php
'redis'=>[
'cluster' => env('REDIS_CLUSTER', true),
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
'clusters' => [
'default' => [
[
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DATABASE', 0),
'read_write_timeout' => 60,
],
],
'options' => [ // Clustering specific options
'cluster' => 'redis', // This tells Redis Client lib to follow redirects (from cluster)
]
],
'options' => [
'parameters' => [ // Parameters provide defaults for the Connection Factory
'password' => env('REDIS_PASSWORD', null), // Redirects need PW for the other nodes
'scheme' => env('REDIS_SCHEME', 'tcp'), // Redirects also must match scheme
],
'ssl' => ['verify_peer' => false], // Since we dont have TLS cert to verify
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
.env
CACHE_DRIVER=redis
REDIS_HOST= 구성엔드포인트
REDIS_PORT=6379
REDIS_SCHEME =tcp
그리고 elasticache 특성상 local에서는 접근을 할 수없다!
AWS ElastiCache(Redis)의 외부 접근 비허용 이슈
AWS의 ElastiCache(Redis)를 로컬에서 접속을 하려고 하니, 정상적인 연결이 되지 않아 찾아보니 ElastiCache는 같은 VPC 내부에서만 접속이 가능하다는 것을 알게되었다. 아마도 RDS나 MongoDB와는 달리 상대
nashorn.tistory.com
728x90
'SERVER > LARAVEL & PHP' 카테고리의 다른 글
The \"\" file does not exist or is not readable 오류 해결 (0) | 2021.08.04 |
---|---|
PHP CURL GET방식 POST방식 정리 (0) | 2021.03.09 |
Laravel + vuejs Access to XMLHttpRequest at been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. 오류 해결 (0) | 2021.01.21 |
Laravel+vue+vuetify 설정하기 (0) | 2021.01.07 |
php 메모리 부족 오류(수정) (0) | 2020.06.04 |