UbuntuのPostgreSQLでダミーデータをinsertしてほっといてたらフリーズしており、その後psqlもエラーになるようになった。
psql: error: could not connect to server: そのようなファイルやディレクトリはありません Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
この問題をwebで検索するがmacの話ばかりで解決にならなかったのでメモ。
pg_lsclustresを見ると10と12がある。 ubuntuを18.04から20.04にアップデートしたときの名残り?
pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file 10 main 5432 down,binaries_missing postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log 12 main 5433 online postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
10はいらないので消す。
pg_dropcluster 10 main
なんとなく動いた。
psql -l
List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | template0 | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (3 rows)