문제 상황
Docker Compose 파일에서 Timescaledb에 대한 볼륨(volume)을 설정했지만 데이터가 원하는 경로에 없는 상황입니다.
docker-compose.yml
services:
timescaledb:
image: timescale/timescaledb-ha:pg14-latest
container_name: timescale
ports:
- "5432:5432"
volumes:
- ./timescaledb/data:/var/lib/postgres/data
TimescaleDB는 정상적으로 작동하고 있지만 데이터를 가져오지 못하고 있는 상태입니다.
공식 문서
TimescaleDB의 공식 문서에 의하면 postgresql에서 사용하는 경로인 /var/lib/postgres/data가 아닌 /home/postgres/pgdata/data 해당 경로를 사용하는 것을 알려주고 있습니다.
docker-compose.yml
services:
timescaledb:
image: timescale/timescaledb-ha:pg14-latest
container_name: timescale
ports:
- "5432:5432"
volumes:
- ./timescaledb/data:/home/postgres/pgdata/data
volume 경로를 수정하고 실행할 경우 아래와 같은 오류가 발생합니다.
결과
fixing permissions on existing directory /home/postgres/pgdata/data ... initdb: error: could not change permissions of directory "/home/postgres/pgdata/data": Operation not permitted
권한이 없어 /home/postgres/pgdata/data 해당 경로에 대한 작업을 진행하지 못하는 것을 확인할 수 있습니다.
해결 방안
https://github.com/timescale/timescaledb-docker-ha/issues/359
TimescaleDB에 대한 Github Issues 에서 해당 문제의 해결 방법을 찾을 수 있었습니다.
docker-compose.yml
services:
timescaledb:
image: timescale/timescaledb-ha:pg14-latest
container_name: timescale
user: "root"
container_name: timescale
environment:
PGDATA: "/var/lib/postgres/data"
ports:
- "5432:5432"
volumes:
- ./data/wems/timescaledb/data:/var/lib/postgres/data
- 사용자를 root로 지정하고 postgresql 데이터 디렉토리를 PGDATA로 변경합니다.
- **PGDATA**는 PostgreSQL 데이터 디렉토리를 지정하는 환경 변수입니다
- 기본 사용자 postgres에는 Window 디렉토리에 쓸 수 있는 권한이 없습니다.
결과
'DB' 카테고리의 다른 글
TimescaleDB - Continuous Aggregates (1) | 2023.11.28 |
---|---|
TimescaleDB - TimeBucket (0) | 2023.11.20 |
[DB] TimescaleDB에 대해 알아보고 간단하게 사용해보자 (0) | 2023.09.26 |