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

CentOS에 PostgreSQL 14.5 설치

# 저장소 추가
sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# 패키지 설치
sudo yum install postgresql14-server postgresql14-contrib

# 데이터베이스 초기화
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb

# 서비스 시작 및 활성화
sudo systemctl start postgresql-14
sudo systemctl enable postgresql-14

# postgres 사용자로 전환 및 셸 접속
sudo -i -u postgres
psql

참조
https://www.postgresql.org/download/linux/redhat/

 

PostgreSQL: Linux downloads (Red Hat family)

Linux downloads (Red Hat family) The Red Hat family of distributions includes: Red Hat Enterprise Linux Rocky Linux CentOS (7 and 6 only) Fedora Oracle Linux and others. PostgreSQL is available on these platforms by default. However, each version of the pl

www.postgresql.org

 

https://computingforgeeks.com/how-to-install-postgresql-14-centos-rhel-7/

 

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-centos-7

 

How To Install and Use PostgreSQL on CentOS 7 | DigitalOcean

 

www.digitalocean.com

 

https://docs.3rdeyesys.com/database/ncloud-database-postgresql-install-connect-guide-centos.html

 

설치형 PostgreSQL DB 설치, 접속 가이드 CentOS

Ncloud VPC환경에서 CentOS 서버에 설치형 PostgreSQL DB를 설치하고, 접속하는 방법입니다.

docs.3rdeyesys.com

 

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

CentOS PostgreSQL data directory 변경  (0) 2023.07.05
[PostgreSQL] 배열 FOR LOOP  (0) 2023.01.04
PostgreSQL increment 초기화  (0) 2022.08.12

DO $$
DECLARE
    v_arr_charge_hour int[]:= array[1,2,3,4,5,6,7,8,9];
    v_arr_val int[];
    v_i int:=1;
    v_max int:=array_length(v_arr_charge_hour, 1);
BEGIN
    FOR v_i IN 1..v_max--SELECT v_arr_charge_hour
    LOOP
        RAISE NOTICE '%', (v_arr_charge_hour[v_i]);
    END LOOP;
END$$;

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

CentOS PostgreSQL data directory 변경  (0) 2023.07.05
CentOS에 PostgreSQL 14.5 설치  (0) 2023.07.05
PostgreSQL increment 초기화  (0) 2022.08.12

Reset auto increment counter in postgres

 

최초값으로 초기화

TRUNCATE TABLE <테이블명> RESTART IDENTITY;

- 실행하니까 테이블 데이터도 모두 삭제 됨

 

시작값 지정

ALTER TABLE <테이블명>
    ALTER COLUMN <자동증가 컬럼명> RESTART SET START <시작 번호>;



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

CentOS PostgreSQL data directory 변경  (0) 2023.07.05
CentOS에 PostgreSQL 14.5 설치  (0) 2023.07.05
[PostgreSQL] 배열 FOR LOOP  (0) 2023.01.04

+ Recent posts