'데이터 엔지니어'로 성장하기

정리하는 걸 좋아하고, 남이 읽으면 더 좋아함

Storage/RDMS

PostgreSql) Centos7에 Psql 설치 후 설정

MightyTedKim 2021. 9. 1. 19:00
728x90
반응형

어제 회사에서 pgsql을 설치하고 세팅해서 설치 방법을 2가지를 설명하려고 합니다.

- yum을 이용

- install wizard를 이용

 

Postgre란?

오픈소스 데이터베이스로 안정적입니다. 상용으로 사용했을 때도 무료이기 때문에 인기가 많습니다.

- 1985년 post-ingres 데이터베이스로 등장

- 오픈소스 + 안정적

 

PostgreSQL - 위키백과, 우리 모두의 백과사전

PostgreSQL은 확장 가능성 및 표준 준수를 강조하는 객체-관계형 데이터베이스 관리 시스템(ORDBMS)의 하나이다. BSD 허가권으로 배포되며 오픈소스 개발자 및 관련 회사들이 개발에 참여하고 있다.

ko.wikipedia.org

 

설치

yum

  • 공식 문서 설치 방법

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql10-server
sudo /usr/pgsql-10/bin/postgresql-10-setup initdb
sudo systemctl enable postgresql-10
sudo systemctl start postgresql-10

  • /usr/pgsql-10/bin/
    • initdb

install wizard

  • 콘솔통해 설치하는 방법
    1. root 계정 접속
    2. chmod 755 ./postgresql-10.13-1-linux-x64.run
    3. ./postgresql-10.13-1-linux-x64.run
    4. 설정값
      1. Installation Directory : /postgres/app/pgsql10 (상관없)
        1. Installation 폴더는 삭제해도 재설정이 안되서, 신중하게 결정 필요
      2. PostgreSQL Server : y
      3. pgAdmin : n
      4. Stack Builder : n
      5. Command Line Tools : y
      6. Data Directory : /postgres/data (상관없)
      7. postgres Password : postgres (상관없)
      8. Port : 5433 (상관없)
      9.  언어셋 : 465(ko_KR_utf8)
    5.  권한 설정
      1. /postgres/app/pgsql10 및 /postgres/data 소유자 postgres 로 변경(chown -R)
        1. postgres 사용자가 없으면 자동으로 사용자를 만들어줌

 

https://simpledownload.net/details/Z7DyVju-ea/postgresql-10-13-1-linux-x64-run.html

 

Download postgresql-10.13-1-linux-x64.run | Simpledownload.net

 

simpledownload.net

 

설정

접속허용

  • /var/lib/pgsql/10/data
    • data 폴더
      • pg_hba.conf 수정
        • vi /postgres/data/pg_hba.conf
          local all all md5 -- 수정
          host all all 0.0.0.0/0 md5 -- 수정
          host all all ::1/128 md5 -- 수정
        • ident 로 되어 있으면 인증 문제 발생할 수 있음

로그 위치 변경

  • /postgres/data/postgresql.conf
    log_directory = '/logs/postgres'
    log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
    log_file_mode = 0600
    log_rotation_age = 1d

-----서비스 등록--------------------------------
1. root 계정으로 접속
2. postgres.service 생성

- vi /usr/lib/systemd/postgresql-10.service  --신규생성

3. systemctl daemon-reload
4. systemctl start postgresql-10.service -- 서비스 시작
5. systemctl stop postgresql-10.service -- 서비스 중지
6. systemctl status postgresql-10.service -- 서비스 확인
7. systemctl reload postgresql-10.service -- 서비스 중지 및 시작

 

728x90
반응형

'Storage > RDMS' 카테고리의 다른 글

Mariadb) import 후 mysql.user empty 현상  (0) 2022.09.22
Postgresql) connection 끊기  (0) 2021.10.08