我在OSX上有一个Postgres 9.6实例,该实例已启动并正在运行,但是当我在具有sqitch status
的工作目录中尝试sqitch.conf
时,Sqitch会引发以下错误:
$ sqitch status
# On database db:pg:my_db
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
这很奇怪,因为我已经通过检查其状态并直接登录来检查Postgres是否正在运行:
$ pg_isready
/tmp:5432 - accepting connections
$ psql -U postgres
psql (9.6.19)
Type "help" for help.
postgres=#
sqitch
似乎只是一个问题。
有关更多详细信息,此Postgres是通过brew install postgresql@9.6
安装的,位于默认目录中:
$ which psql
/usr/local/opt/postgresql@9.6/bin/psql
关于Sqitch,我尝试同时使用Homebrew和Docker(我目前的方法)进行安装。 docker安装基于官方说明:
docker pull sqitch/sqitch
curl -L https://git.io/JJKCn -o sqitch && chmod +x sqitch
./sqitch status
我也尝试使用psql
显式设置sqitch config --user engine.pg.client /usr/local/opt/postgresql@9.6/bin/psql
无论如何,我仍然可以通过任何sqitch
命令获得以下信息:
$ sqitch status
# On database db:pg:my_db
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
我不确定我缺少什么,可以使用一些输入信息。预先感谢。
答案 0 :(得分:0)
我不知道安装了 Brew 的 Sqitch 是怎么回事,但是当您从 Docker 映像运行它时,该容器内部没有运行 Postgres,因此与 localhost 的连接将失败。您需要连接到容器外的 Postgres。如果您在 Mac 上运行它,这很简单:确保 Postgres is listening on the IP ports,而不仅仅是 Unix 域套接字,以及 specify host.docker.internal
as the host name,如下所示:
sqitch status db:pg://host.docker.internal/my_db