M1 MacOS ํ๊ฒฝ
homebrew๋ก ์ค์น
๋งฅ์ postgresql ์ค์นํ๊ณ psql -d postgres
๋ก ์ ์ํ๋๋ฐ ์ค๋ฅ๊ฐ ๋ฌ๋ค.
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
brew services list
๋ก ํ์ธํด๋ณด๋ postgresql@14 error 256 ์๋ฌ๊ฐ ๋ฌ ๊ฒ์ ํ์ธํ๋ค. ์๋ฌ์ฝ๋๋ง์ผ๋ก ๊ฒ์ํด๋ณด๋ /opt/homebrew/var/postgresql@14/postmaster.pid
๋ฅผ ์ญ์ ํ๊ณ ์ฌ์คํํ๋ฉด ์ ์์ผ๋ก ๋์๊ฐ๋ค๋ ์ ๋ณด๊ฐ ๋ง์๋๋ฐ ์ ์ด์ ํด๋น ํ์ผ์ด ์์๊ณ , ๋ฐ๋ผ์ ์ด ๋ฐฉ๋ฒ์ผ๋ก๋ ํด๊ฒฐํ ์ ์์๋ค.
Service Configuration File ํ์ธ
brew services list
๋ก ๋จ๋ .plist
ํ์ผ์ ์๋น์ค์ ์ค์ ์ ๋ณด์ด๋ค. cat {filepath}
๋ก ์ด์ด ํ์ธํ๋ฉด ํด๋น ์๋น์ค์ ์๋ฌ ๋ก๊ทธ ๊ฒฝ๋ก์ ๊ฐ์ ์ ๋ณด๋ฅผ ์กฐํํ ์ ์๋ค.
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
....
<key>StandardErrorPath</key>
<string>/opt/homebrew/var/log/postgresql@14.log</string>
<key>StandardOutPath</key>
<string>/opt/homebrew/var/log/postgresql@14.log</string>
<key>WorkingDirectory</key>
<string>/opt/homebrew</string>
</dict>
</plist>
์๋ฌ ๋ก๊ทธํ์ผ ๊ฒฝ๋ก๋ฅผ ํ์ธํ๊ณ cat
์ผ๋ก ์ด์ด ํ์ธํ๋ค.
[49631] LOG: starting PostgreSQL ...
[49631] LOG: listening on IPv6 address "::", port 5432
[49631] LOG: listening on IPv4 address "0.0.0.0", port 5432
[49631] FATAL: could not open lock file "/tmp/.s.PGSQL.5432.lock": Permission denied
[49631] LOG: database system is shut down
์์ ๊ฐ์ ๋ก๊ทธ๋ฅผ ํ์ธํ๋ค.
/tmp/.s.PGSQL.5432.lock
- /tmp/.s.PGSQL.5432
- /tmp/.s.PGSQL.5432.lock
PostgreSQL ๋ฐ์ดํฐ๋ฒ ์ด์ค ์๋ฒ๊ฐ ์ฌ์ฉํ๋ ์ผ์์ ์ธ ์์ผ ํ์ผ ๋๋ ๋ฝ ํ์ผ์ด๋ค. ๋ ์ด์์ ํ๋ก์ธ์ค๊ฐ ํฌํธ๋ฅผ ๊ณต์ ํ ์ ์์ผ๋ฏ๋ก ํ๋๊ฐ ์ฌ์ฉํ๊ณ ์์ผ๋ฉด ๊ทธ๊ฑธ ํ์ํ๋ ๋ฝ์ด ํ์ํ๋ฐ, ์ด ํ์ผ์ด ๊ทธ ์ญํ ์ ํ๋ค. ์ฆ, ์ด ์์ผ ํ์ผ์ด ์์ผ๋ฉด ์๋ฒ๊ฐ ๊ธฐ๋ณธ 5432 ํฌํธ์์ ์คํ ์ค์ด๋ผ๊ณ ๊ฐ์ฃผํ๋ ๊ฒ์ด๋ค. ๋ฐ๋ผ์ 5432 ํฌํธ์์ ์ถฉ๋์ด ๋ฐ์ํ๋ ๋ฐ๋์ ์คํ์ด ๋์ง ์์๋ ๊ฒ. ์ด์ฉ์ง ์คํ์์ผ๋ ๊ฒ ์๋๋ฐ ์๋ ๋ก๊ทธ๊ฐ ๊ณ์ ๋ ์ ๋ญ์ง? ์ถ์๋ค..
[23122] LOG: could not bind IPv6 address "::1": Address already in use
[23122] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
[23122] LOG: could not bind IPv4 address "127.0.0.1": Address already in use
[23122] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
[23122] WARNING: could not create listen socket for "localhost"
[23122] FATAL: could not create any TCP/IP sockets
[23122] LOG: database system is shut down
์๋ก ๋ค๋ฅธ ๋ฒ์ ์ postgresql์ ์ค์นํ๋ค๊ฐ ์ญ์ ํจ & ํ๋ก์ธ์ค ๊ฐ์ ์ข
๋ฃ์ํค๋ ๊ณผ์ ์์ kill -9 [pid]
๋ฅผ ์ฌ์ฉํด์.. ๋น์ ์ ์ข
๋ฃ๋๋ ๋ฐ๋์ ํด๋น ํ์ผ์ด ๋ฏธ์ฒ ์ญ์ ๋์ง ๋ชปํ ๊ฒ ์๋๊ฐ? ์ถ๋ค. ๊ฒฐ๊ณผ์ ์ผ๋ก ์๋ ๋ ๋ช
๋ น์ด๋ก ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ค.
sudo rm /tmp/.s.PGSQL.5432.lock
sudo rm /tmp/.s.PGSOL.5432
๋.
์ฐธ๊ณ ๋งํฌ
Homebrew Postgresql Service not Starting Resolved
Unable to start Postgres Server because of permission denied on lock file
์ค๋์ ๊ตํ
- ๋ก๊ทธ๋ฅผ ์ ํ์ธํ ๊ฒ
kill -9
๋จ๋ฐํ์ง ์๊ธฐ