Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDS 배포 #56

Open
shunnyjang opened this issue Sep 14, 2020 · 4 comments
Open

RDS 배포 #56

shunnyjang opened this issue Sep 14, 2020 · 4 comments

Comments

@shunnyjang
Copy link
Contributor

shunnyjang commented Sep 14, 2020

대주제 : 다행 서비스의 디비 배포하자
소주제 : RDS로 PostgreSQL을 배포하자 (프리티어로^^)

  1. AWS - RDS - 데이터베이스 생성
  2. DB 환경 설정
  • 엔진옵션 : PostgreSQL (버전 12.3)
  • 템플릿 : 프리티어
    image
  • 비밀번호 설정
  • 연결 - 추가 연결 설정 - 퍼블릭 액세스 [예] 선택
    image
  • [데이터 베이스 생성] 선택
  • 생성까지 시간 조금 소요됨!
@shunnyjang
Copy link
Contributor Author

shunnyjang commented Sep 15, 2020

postgresql 외부에서 접속하기
postgresql을 설치하세요 (버전 : 12)

  • ubuntu
sudo apt-get install postgresql postgresql-contrib
  • mac
brew install postgresql
  1. RDS - 보안그룹 규칙 - 인바운드 규칙 편집 - Postgresql에 대해서 추가하기
  2. 원격에서 접속하기
    bash에서 (Mac기준)
psql \
   --host=엔드포인트 \
   --port=5432 \
   --username=postgres \
   --password \

비밀번호 입력 후 shell에서 접속 가능

참고 : https://docs.aws.amazon.com/ko_kr/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html

@shunnyjang
Copy link
Contributor Author

shunnyjang commented Sep 15, 2020

django와 postgreSQL을 연결해주자

pip install psycopg2==2.8.6
pip install psycopg2-binary==2.8.5

config/settings/prod.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': '디비이름',
        'USER': '유저이름',
        'PASSWORD': '비밀번호',
        'HOST': '엔드포인트',
        'PORT': '5432',
    }
}

@shunnyjang
Copy link
Contributor Author

shunnyjang commented Sep 15, 2020

Mac에서 psycopg2를 설치하다 다음과 같은 에러가 나는 경우
image

clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for psycopg2
which pg_config # /usr/local/bin/pg_config
export PATH=$PATH:/usr/local/bin/  # /usr/local/bin/ 은 pg_config가 존재하는 path
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
pip install --upgrade wheel
pip install --upgrade setuptools
pip install psycopg2

참고 : https://stackoverflow.com/questions/34304833/failed-building-wheel-for-psycopg2-macosx-using-virtualenv-and-pip

@shunnyjang
Copy link
Contributor Author

ubuntu에서 psycopg2를 설치하다 다음과 같은 에러가 나는 경우

Collecting psycopg2==2.8.6
  Downloading psycopg2-2.8.6.tar.gz (383 kB)
     |████████████████████████████████| 383 kB 1.1 MB/s 
ERROR: Command errored out with exit status 1:
Error: b'You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.\n'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
sudo apt-get install libpq-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant