CentOS PostgreSQL data directory 변경

 

1. 설치된 PostgreSQL 서비스 중지
2. 데이터 디렉토리를 새 위치로 이동하거나 복사
3. postgresql.conf 파일에서 data_directory 설정을 새 경로로 변경
4. 서비스 시작 스크립트 또는 명령을 수정하여 새 postgresql.conf 파일의 위치 반영
5. PostgreSQL 서비스 재시작

# 서비스 중지
sudo systemctl stop postgresql-14

# 데이터 디렉토리 이동
sudo mv /var/lib/pgsql/14/data 이동할 경로

# postgresql.conf 수정
sudo nano 이동한 경로/postgresql.conf

#data_directory = '이동한 경로' 로 변경

참고) 설치시 기본 경로 : ConfigDir

# 서비스 시작 스크립트 수정
sudo nano /usr/lib/systemd/system/postgresql-14.service

Environment=PGDATA=/home/mlu/postgres-data 로 변경

참고) 설치시 기본 경로 : /var/lib/pgsql/14/data/

# 서비스 재시작
sudo systemctl start postgresql-14

참조
https://dba.stackexchange.com/questions/197809/changing-data-directory-for-postgres-on-centos

 

Changing data directory for postgres on CentOS

I've got a postgres 9.2.18 installation on CentOS which used the standard installation path. Now I realised that on this particular partition, there isn't sufficient hard-disk space for some bigger

dba.stackexchange.com

 

https://stackoverflow.com/questions/22596301/how-to-change-postgresql-data-directory\

 

how to change PostgreSQL data directory?

I am having a problem changing the data directory on postgresql 9.2 on windows7: i`m trying to change my data directory: how can i change data directory on postgreSQL with pgAdmin?

stackoverflow.com

 

https://stackoverflow.com/questions/64124528/still-located-to-default-data-directory-postgresql-even-ive-changed

 

still located to default data directory postgreSQL even i've changed

I've fresh install postgreSQL on my centOs7 server and want to changed my default postgresql data directory to /opt/postgres on my server. and this what i have done : # chown postgres:postgres /opt/

stackoverflow.com

 

'개발 > PostgreSQL' 카테고리의 다른 글

CentOS에 PostgreSQL 14.5 설치  (0) 2023.07.05
[PostgreSQL] 배열 FOR LOOP  (0) 2023.01.04
PostgreSQL increment 초기화  (0) 2022.08.12

+ Recent posts