ERR SELECT is not allowed in cluster mode: SELECT is not allowed in cluster mode
Redis의미
Redis Cluster 모드에서 SELECT로 다른 논리 데이터베이스(DB 인덱스)로 전환하려 했다. 클러스터 모드는 데이터베이스 0만 지원하며 여러 DB를 사용할 수 없다.
원인
standalone Redis에서 SELECT로 DB 0-15를 전환하던 애플리케이션이 Redis Cluster로 이전한 후에도 같은 명령을 계속 보내는 경우다. 클러스터 아키텍처는 slot 기준으로 데이터를 분산하므로 다중 DB 개념을 지원하지 않는다.
해결 방법
클러스터 모드에서는 SELECT 호출을 제거한다. DB 0만 사용된다. 논리적 분리가 필요하면 키 접두사(namespace)를 사용한다(예: app1:key). 특정 키를 함께 처리해야 한다면 hash tag({user123})를 사용해 같은 slot에 배치한다. 애플리케이션 구성을 cluster-aware하게 만든다.
같은 데이터베이스의 다른 항목
- NOTBUSY No scripts in execution right nowNo scripts in execution right now
- DENIED Redis is running in protected modeRedis is running in protected mode
- ERR Can't execute '<cmd>': only (P|S)SUBSCRIBE / (P|S)UNSUBSCRIBE / PING / QUIT / RESET are allowed in this contextCommand not allowed in subscribe context (subscribe 컨텍스트에서 허용되지 않는 명령)
- ERR wrong number of arguments for commandWrong number of arguments for command
- ERR Background save already in progressBackground save already in progress
- ERR bit offset is not an integer or out of rangeBit offset is not an integer or out of range (비트 오프셋이 정수가 아니거나 범위를 벗어남)
- ERR Protocol error: invalid multibulk lengthProtocol error: invalid multibulk length (프로토콜 오류: 유효하지 않은 multibulk 길이)