본문 바로가기
데이터베이스/Postgresql

[Postgresql] Postgresql13 rpm으로 설치

by 초이MS 2021. 8. 27.

목적

  • 필자의 경우 yum으로 설치한 postgre는 remote와 버전이 맞지 않아 pg_dump등의 작업이 가능하지 않았다.
  • 로컬 테스트 환경도 만들겸 겸사겸사 postgresql 13.3 버전을 설치하고자 한다.

과정

  1. 필자의 경우 13.3버전을 설치하여야 했다. Postgresql의 다운로드 사이트에 들어가 원하는 os를 선택한다. 필자의 경우는 linux기반의 설치를 해야했기에 linux >> Red Hat / Rocky/CentOS를 선택했다.
  2. 필자는 yum으로 설치가 안되어 최하단의 Direct RPM download를 이용하였다. 붉은 "direct download"를 선택하자.
  3. 다음 화면에서 POSTGRESQL13 >> RHEL/CentOS/Oracle Linux 7 - x86_64를 선택했다.
  4. 아래 이미지의 빨간 링크를 클릭한다.
  5. 아래 사진의 파란 링크에 들어가 13.3버전의 rpm파일의 주소 4개를 복사한다. 혹시 주소 복사하기 귀찮다면 아래 코드를 참고하자. 필자는 13.3버전으로 설치했다.
wget https://yum.postgresql.org/13/redhat/rhel-7-x86_64/postgresql13-13.3-1PGDG.rhel7.x86_64.rpm
wget https://yum.postgresql.org/13/redhat/rhel-7-x86_64/postgresql13-contrib-13.3-1PGDG.rhel7.x86_64.rpm
wget https://yum.postgresql.org/13/redhat/rhel-7-x86_64/postgresql13-libs-13.3-1PGDG.rhel7.x86_64.rpm
wget https://yum.postgresql.org/13/redhat/rhel-7-x86_64/postgresql13-server-13.3-1PGDG.rhel7.x86_64.rpm
  1. 다운로드된 rpm을 이용해서 설치해주자. 순서는 확실하지 않으므로 설치 간 에러메시지를 확인하여 dependency에 맞게 설치하자.
sudo rpm -i postgresql13-libs-13.3-1PGDG.rhel7.x86_64.rpm
sudo rpm -i postgresql13-13.3-1PGDG.rhel7.x86_64.rpm
sudo rpm -i postgresql13-server-13.3-1PGDG.rhel7.x86_64.rpm
sudo rpm -i postgresql13-contrib-13.3-1PGDG.rhel7.x86_64.rpm​
  1. rpm까지 다 돌렸으면 아래의 코드를 입력하자! 그러면 거의 다 왔다!
sudo postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13​
  • 필자는 작성 중 hadoop 계정으로 로그인 중이며 hadoop으로 접속할 수 있도록 설정을 할 것이다. 독자의 필요에 따라 hadoop을 원하는 이름으로 변경하면 된다.
# postgres계정으로 접속
sudo su - postgres

# postgresql 접속!
psql

# hadoop 계정용 롤과 권한 설정
CREATE ROLE hadoop superuser;
ALTER ROLE hadoop WITH LOGIN;
CREATE DATABASE hadoop;​
  • 이제 postgres 계정으로의 접속을 마친 후 나와서 psql을 입력하면 postgresql 13에 접속이 된다!

 

반응형

'데이터베이스 > Postgresql' 카테고리의 다른 글

[Postgresql] 테이블 DDL 확인하기  (0) 2021.09.14
[Postgresql] 설치  (0) 2021.08.24

댓글