태그 보관물: macos

macos

Brew 서비스를 통해 실행되는 Postgres 서버에 연결할 수 없습니다.

나는 이것에 대한 해결책을 찾고 있었지만 작동하는 해결책을 찾을 수 없었습니다.

brew install postgresMacBook에 brew ( )를 사용하여 postgres를 설치 했으며 현재 brew 서비스를 사용하여 실행 중입니다 ( brew services list postgres를 실행중인 서비스로 표시). 그러나 실행하려고 psql하면 다음과 같은 오류가 발생합니다.

psql : 서버에 연결할 수 없음 : 해당 파일 또는 디렉토리가 없습니다. 서버가 로컬에서 실행 중이고 Unix 도메인 소켓 “/tmp/.s.PGSQL.5432″에서 연결을 수락합니까?

누구나 이미 비슷한 문제를 해결 했습니까?



답변

동일한 오류가 발생하여 프로세스 pid 파일을 제거하여 수정했습니다.

rm -f /usr/local/var/postgres/postmaster.pid


답변

오늘이 문제가 발생했습니다. postgres는 homebrew가 실행 중이라고 생각했지만 연결 수락을 중지했습니다.

그것을 고치기 위해 나는 달렸다.

brew services restart -vvv postgresql

이 명령의 출력,

==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Generated plist for postgresql:
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
   <plist version="1.0">
   <dict>
     <key>KeepAlive</key>
     <true/>
     <key>Label</key>
     <string>homebrew.mxcl.postgresql</string>
     <key>ProgramArguments</key>
     <array>
       <string>/usr/local/opt/postgresql/bin/postgres</string>
       <string>-D</string>
       <string>/usr/local/var/postgres</string>
     </array>
     <key>RunAtLoad</key>
     <true/>
     <key>WorkingDirectory</key>
     <string>/usr/local</string>
     <key>StandardErrorPath</key>
     <string>/usr/local/var/log/postgres.log</string>
   </dict>
   </plist>

그런 다음 저는 그 로그 파일에 뭔가가있을 수 있다고 생각했습니다.

tail -n 10 /usr/local/var/log/postgres.log

물론입니다.

[4826] FATAL:  lock file "postmaster.pid" already exists
[4826] HINT:  Is another postmaster (PID 1489) running in data directory "/usr/local/var/postgres"?

그래서 그 파일을 제거했습니다

rm /usr/local/var/postgres/postmaster.pid

그리고 모든 것이 다시 작동하기 시작했습니다.


답변

제 경우에는 postmaster.pid파일이 없었습니다. postgres를 업그레이드하여 작동했습니다.

brew update
brew upgrade

그런 다음 메이저 버전을 10에서 11로 업그레이드했기 때문에 다음을 실행해야했습니다.

brew postgresql-upgrade-database

(출처 https://github.com/facebook/react-native/issues/18760#issuecomment-410533581 )


답변

여기서 Wilson과 Grasshopper의 두 답변을 결합합니다.

postgres 서비스에 대한 plist 파일을 확인하여 파일 brew services list의 위치를 ​​찾고 즐겨 찾는 편집기에서 열 수 있습니다.

StandardErrorPath다음과 같이 나열된 값이 표시 되어야합니다 .

<key>StandardErrorPath</key>
<string>/usr/local/var/log/postgres.log</string>

그런 다음 다음을 사용하여 로그 파일의 끝을 마무리해야합니다. tail -n 100 /usr/local/var/log/postgres.log

제 경우 오류는 다음과 같습니다.

2017-12-06 11 : 51 : 16.078 GMT [85476] FATAL : 잠금 파일 “postmaster.pid”가 이미 존재합니다. 2017-12-06 11 : 51 : 16.078 GMT [85476] 힌트 : 다른 포스트 마스터 (PID 601)가 실행 중입니까? 데이터 디렉토리 “/ usr / local / var / postgres”?

Mac을 강제 종료해야했고 postgres가 PID 파일을 정리할 기회가 없었기 때문입니다. PID 파일을 제거하고 rm /usr/local/var/postgres/postmaster.pidpostgres를 시작하십시오.brew services start postgresql

경고 : postgres가 실행되고 있지 않다고 확신하지 않는 한이 PID 파일을 삭제하지 마십시오 . 실행 brew services stop postgresql한 다음 brew services listposgres가 중지 된 상태임을 표시 하는 결과를 기다리면됩니다.


답변

나를 위해 일한 것은 /usr/local/var/postgres/폴더를 제거한 다음 postgres를 다시 제거하고 설치 하는 것이 었 습니다.


답변

버전 탭에서 postgresql93을 설치하는 것과 동일한 오류가 발생했습니다. brew services list( ~/Library/LaunchAgents/homebrew.mxcl.postgresql93.plist) 의 출력에 표시된 .plist 파일을 검사하면 다음 메시지가 표시됩니다.

치명적 : 데이터 디렉토리 “/ usr / local / var / postgres”에 그룹 또는 월드 액세스
권한이 있습니다. DETAIL : 권한은 u = rwx (0700)이어야합니다.

이 대답을하게 된 이유 : 데이터 디렉토리 “/ usr / local / var / postgres”에 잘못된 소유권이 있습니다.

실행 후 sudo chmod -R 700 /usr/local/var/postgres다른 오류가 발생했습니다.

치명적 : “pg_tblspc”디렉토리를 열 수 없음 : 해당 파일 또는 디렉토리가 없습니다.

그런 다음 나를 이끌었습니다 : 최신 버전의 OS X (Yosemite 또는 El Capitan) 설치 후`pg_tblspc`가 누락되었습니다.

실행 mkdir /usr/local/var/postgres/pg_tblspc/후 클러스터가 성공적으로 시작되었습니다.


답변

여러 버전의 postgresql이 설치된 경우. 아래 언급 된 명령은 프로세스 id (pid)를 제거하고 다시 시작하는 작업을 수행합니다. 올바른 버전을 선택했는지 확인하십시오.

rm -f /usr/local/var/postgresql@9.6/postmaster.pid

brew services restart postgresql@9.6

Eric Corner의 답변을 참조하여 문제가 로그 파일의 “잠금 파일 postmaster.pid가 이미 존재 함”에 관한 것인지 확인하십시오.