ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • FATAL: could not open lock file "/tmp/.s.PGSQL.5432.lock": Permission denied
    typescript+nestjs 2025. 1. 17. 21:24
    728x90

     

    로컬 환경에 postgres깔려하는데 자꾸 안된다

     

    brew install postgresql

    수동 시작

    pg_ctl -D /usr/local/var/postgres start

    상태 확인

    pg_ctl -D /usr/local/var/postgres status

    수동 종료

    pg_ctl -D /usr/local/var/postgres stop

    이라고 분명 나와있느데!!!!! 안된다

     

    GPT행님은 cat ~/Library/Logs/Homebrew/postgresql@14.log

    자꾸 로그 확인해보라고 있는데 저 경로가 없지 뭐야

    그래서 따끔하게 혼내줌

    where postgres

    해봤더니 gpt햄 잘못알려줌 ㅡㅡ

    macOS의 M1/M2 기반 시스템용 디렉토리인 /opt/homebrew에 설치했기 때문입니다. 

    라고 답변함

    m1이라 미안해 모든 사람들이 m3부터 갖고 있다는 생각을 멈춰

     

    pg_ctl -D /opt/homebrew/var/postgresql start

    다시 수정했는데 !?

     

    waiting for server to start....2025-01-17 20:56:07.264 KST [20925] LOG:  starting PostgreSQL 14.15 (Homebrew) on aarch64-apple-darwin23.6.0, compiled by Apple clang version 16.0.0 (clang-1600.0.26.4), 64-bit
    2025-01-17 20:56:07.264 KST [20925] LOG:  could not bind IPv6 address "::1": Address already in use
    2025-01-17 20:56:07.264 KST [20925] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
    2025-01-17 20:56:07.264 KST [20925] LOG:  could not bind IPv4 address "127.0.0.1": Address already in use
    2025-01-17 20:56:07.264 KST [20925] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
    2025-01-17 20:56:07.264 KST [20925] WARNING:  could not create listen socket for "localhost"
    2025-01-17 20:56:07.264 KST [20925] FATAL:  could not create any TCP/IP sockets
    2025-01-17 20:56:07.265 KST [20925] LOG:  database system is shut down
     stopped waiting
    pg_ctl: could not start server
    Examine the log output.

     

     

    디비 설치 주제에 내 시간을 이렇게 가져갈 줄 몰랐다

    혹시 내가 nest가 작동중인 로컬호스트 때문가 싶어서 얘도 껐다

    5432도 lsof -i:5432해봤느데 없다

     

    없다는데 지피티햄은 자꾸 5432를 죽이란다

    이미 난도질해서 사라졌다고 애초에 존재하지도 않았다고 ㅜㅜ

     

    pkill -9 postgres

    걍 이렇게 살인해버림

     

    waiting for server to start....2025-01-17 21:06:15.127 KST [21345] LOG:  starting PostgreSQL 14.15 (Homebrew) on aarch64-apple-darwin23.6.0, compiled by Apple clang version 16.0.0 (clang-1600.0.26.4), 64-bit
    2025-01-17 21:06:15.127 KST [21345] LOG:  listening on IPv6 address "::1", port 5432
    2025-01-17 21:06:15.128 KST [21345] LOG:  listening on IPv4 address "127.0.0.1", port 5432
    2025-01-17 21:06:15.128 KST [21345] FATAL:  could not open lock file "/tmp/.s.PGSQL.5432.lock": Permission denied
    2025-01-17 21:06:15.128 KST [21345] LOG:  database system is shut down
     stopped waiting
    pg_ctl: could not start server
    Examine the log output.

    에러가 바껴서 행복함

     

    semihan@semiui-MacBookAir var % ls -ld /tmp
    lrwxr-xr-x@ 1 root  wheel  11  5  7  2024 /tmp -> private/tmp

    private/tmp 로 되어있길래 열어줄라했음..

    sudo chmod 1777 /tmp

    근데 암튼 이거 아님 (검색 키워드 잡을라고 이런 시도한 사람을 위해 넣어봄)

     

    결론으로 가겠음

     

    sudo rm -f /tmp/.s.PGSQL.5432.lock

    sudo rm -f /tmp/.s.PGSQL.5432.lock 명령어로 락 파일을 삭제하고 PostgreSQL이 정상적으로 시작된 이유는

    PostgreSQL 서버가 이미 실행 중이었거나 이전에 제대로 종료되지 않아서 락 파일이 남아있었기 때문

     

    Lock의 역할

    PostgreSQL 서버는 한 번에 하나만 실행될 수 있습니다. 서버가 시작될 때 /tmp/.s.PGSQL.5432.lock (또는 /private/tmp/.s.PGSQL.5432.lock) 파일을 생성합니다. 이 락 파일은 PostgreSQL이 현재 실행 중임을 나타내는 역할을 하며, 다른 인스턴스가 동일한 포트(5432)에서 실행되지 않도록 합니다.

    728x90
Designed by Tistory.