1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[備忘録] homebrewでインストールしたpostgreSQLの起動が失敗する

Posted at

homebrewでインストールしたpostgreSQLの起動が失敗したので備忘録。

postgreSQLを起動する

postgreSQLはHomebrewでインストール済み。

$ brew services run postgresql@14
==> Successfully started `postgresql@14` (label: homebrew.mxcl.postgresql@14)

brew services runで起動すると、無事に起動したように見えるが
psqlを実行しようとするとエラーになる。

$ 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を確認するとコケている

$ brew services
Name          Status     User File
postgresql@14 error  256 nako ~/Library/LaunchAgents/homebrew.mxcl.postgresql@14.plist

ログを確認する

/opt/homebrew/var/log/postgresql@14.log にログを吐いているようなので、そちらを見てみる。

$ view /opt/homebrew/var/log/postgresql@14.log
〜 略 〜
2023-09-09 21:31:23.054 JST [84735] FATAL:  could not create shared memory segment: Cannot allocate memory
2023-09-09 21:31:23.054 JST [84735] DETAIL:  Failed system call was shmget(key=5133258, size=56, 03600).
2023-09-09 21:31:23.054 JST [84735] HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMALL parameter.  You might need to reconfigure the kernel with larger SHMALL.
        The PostgreSQL documentation contains more information about shared memory configuration.

割り当てられているshared memoryが足りないらしい。

共有メモリの値を変更する

/etc/sysctl.confファイルを作成し、設定を記述する。

$ sudo vim /etc/sysctl.conf

kern.sysv.shmmax=536870912
kern.sysv.shmmin=1
kern.sysv.shmmni=4096
kern.sysv.shmseg=1024
kern.sysv.shmall=131072

Macを再起動する

カーネルパラメータを変更したので再起動する。

参考にした記事

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?