만쥬의 개발일기
article thumbnail
[PostgreSQL / Trouble Shooting] - PostgreSQL 에러 로그 확인 및 해결법(psql: error: could not connect to server: No such file or directory )
🛠️TOOL/🐘PostgreSQL 2024. 2. 14. 16:07

개발환경 linux ubuntu 20.04 문제 상황 postgre 서버를 실행하고, psql로 접속을 시도하자 다음과 같은 에러가 발생했다. psql: error: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 그래서 먼저 포트가 열렸는지를 확인했는데, 포트도 열려있지 않았다. (포트 설정은 /var/lib/postgresql/{version}/main/postgresql.conf 에서 확인가능) sudo lsof -i :5432 혹시나 해서 Pos..

article thumbnail
[PostgreSQL / Trouble Shooting] PostgreSQL 에러 로그 확인 및 해결법(psql: error: could not connect to server: No such file or directory )
🛠️TOOL/🐘PostgreSQL 2024. 1. 22. 11:41

개발환경 linux ubuntu 20.04 문제 상황 postgre 서버를 실행하고, psql로 접속을 시도하자 다음과 같은 에러가 발생했다. psql: error: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 포트 개방 여부 확인 그래서 먼저 다음 명령어로 포트가 열렸는지를 확인했는데, 포트도 열려있지 않았다. (포트 설정은 /var/lib/postgresql/{version}/main/postgresql.conf 에서 확인가능) sudo lsof..

article thumbnail
[PostgreSQL] - 원격 서버에서 PostgreSQL 접속하는 법
🛠️TOOL/🐘PostgreSQL 2024. 1. 2. 10:08

PostgreSQL을 설치하면 기본적으로 외부 서버에서 접속할 수 없기 때문에, config 파일들을 수정해주어야 한다. 개발환경은 WSL2 + ubuntu18.04 이다. 우선 다음 명령어로 Ubuntu에서 열려있는 포트를 확인한다. netstat -nltp postgres의 기본 포트는 5432이다. 위 결과처럼 127.0.0.1:5432로 되어 있다면 5432포트는 내부에서만 접속할 수 있다는 뜻이다. postgresql.conf파일 수정 Postgres 설정을 변경하려면 postgresql.conf에서 변경해 줘야 한다. 먼저 다음 명령어로 postgresql.conf 파일을 vim 편집기로 변경해준다. sudo vim /etc/postgresql/10/main/postgresql.conf (po..

article thumbnail
[PostgreSQL] - PostgreSQL DB생성 및 접속 시 Peer authentication 에러 해결법
🛠️TOOL/🐘PostgreSQL 2024. 1. 1. 23:18

PostgreSQL을 사용하며 DB를 생성하거나, psql로 접속할때 종종 Peer authentication 에러가 발생하곤 한다. 이때에는 pg_hba.conf파일의 설정을 변경해주어야 한다. 먼저 pg_hba_conf 파일의 위치를 찾아야하는데, 리눅스 우분투의 경우 보통 다음 경로에 위치한다. /etc/postgresql/{postgresql 버전}/main/pg_hba.conf 해당 파일을 vi 편집기로 접속하고, 몇가지 설정을 변경해준다. 로컬 호스트 기준 여기서 local all postgres와 local all all의 peer을 모두 md5로 변경해준다. 위 사진과 같이 변경되었다면 저장을 해준다. 외부 host기준 host all all 127.0.0.1/32 md5 위 설정에서 12..

article thumbnail
[PostgreSQL] - PostgreSQL사용 시 데이터 공간 부족 문제 해결
🛠️TOOL/🐘PostgreSQL 2024. 1. 1. 23:09

postgresql 설정 파일이 위치한 폴더로 이동한다. 각 OS별로 대부분 다음 위치에 존재한다. Linux /etc/postgresql/13/main/postgresql.conf macos /usr/local/var/postgres/postgresql.conf window C:\\Program Files\\PostgreSQL\\13\\data\\postgresql.conf 해당위치의 postgresql.conf 파일에서 data_directory를 확인한다. 해당 경로가 postgresql 서버에서 사용하는 모든 데이터와 메타데이터가 저장되는 데이터베이스 클러스터이다. 그리고 해당 파일에서 log_temp_files 부분을 다음과 같이 수정해준다. log_temp_files = 10240 공간 확보 ..

article thumbnail
[PostgreSQL] - PostgreSQL 설치 및 사용 예시 in Linux ubuntu
🛠️TOOL/🐘PostgreSQL 2024. 1. 1. 22:08

Ubuntu에 설치할 수 있는 PostgreSQL 버전 확인하기 apt show postgresql 위 명령어를 통해 설치할 수 있는 postgreSQL 버전을 확인할 수 있다. 현재 테스트 환경은 ubuntu18.04이고, 설치 가능한 버전은 10버전이다. $ sudo apt install postgresql postgresql-contrib 위 명령어를 통해 바로 설치가 가능하다. 설치 후 버전 확인 설치 후 버전 확인 방법은 여러가지가 있다. psql --version 가장 간단하게 위 명령어로 확인이 가능하고, pg_config --version 위 명령어로도 확인이 가능하다. 다만 해당 명령어 사용시 다음과 같은 에러메세지가 날 때가 있다. "You need to install postgresq..