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

[Postgresql] 설치

by 초이MS 2021. 8. 24.

목적

  • postgresql및 해당하는 cli를 이용하기위해 postgre를 설치한다.

과정

  • 필자는 aws ec2 환경에서 진행하였다. linux 기반의 yum을 이용할 수 있는 환경에서는 모두 이용가능할 것으로 보인다.
  • postgresql의 설치과정은 아래와 같이 진행하였다. 
# postgresql 및 그에 필요한 환경들 설치
sudo yum install -y postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs

# postgresql이 동작하도록 설정
sudo service postgresql initdb
sudo systemctl start postgresql
sudo systemctl enable postgresql
  • postgresql의 로컬용 디비 등의 설정은 아래와 같이 진행하였다.
# postgres로 계정 전환
sudo su - postgres

# postgresql cli 접속
psql

# hadoop 계정을 위한 설정 추가(필자가 이용한 계정이 hadoop 계정이다)
CREATE ROLE hadoop superuser;
ALTER ROLE hadoop WITH LOGIN;
CREATE DATABASE hadoop;
  • remote postgresql 서버에 접속할 때는 다음과 같이 진행하였다.
psql -h {end_point} -d {dbname} -U {username} -W
  • 각 옵션은 h(서버 주소), d(데이터베이스 명) U(유저 이름) W(비밀번호)을 의미한다.
  • 추가적인 옵션은 --help 옵션을 참고하자.

 

 

 

반응형

댓글