Gitlab 不会在替代端口上创建 Postgres 实例

Gitlab will not create Postgres instance on alternative port

我是 运行 CentOS 7 上最新版本的 GitLab CE Omnibus 软件包。在同一台机器上我还有其他 Postgres 数据库 运行。例如,我似乎无法将内置 Postgres 实例的端口更改为 5433。

我已将以下两行添加到 /еtc/gitlab/gitlab.rb

postgresql['enable'] = true
postgresql['port'] = 5433

并且我执行了以下命令:

# gitlab-ctl reconfigure
# gitlab-rake gitlab:setup

第二个失败并出现以下错误:

Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"gitlabhq_production", "pool"=>10, "username"=>"gitlab", "password"=>nil, "host"=>nil, "port"=>5433, "socket"=>nil}
-- enable_extension("plpgsql")
rake aborted!
PG::Error: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5433"?

我不会用gitlab,所以看了下installation docs。 GitLab 没有 "its own" PostgreSQL 安装。它使用 PostgreSQL 的标准安装(基于包的安装)。

sudo apt-get install -y postgresql postgresql-client libpq-dev

所以您可以通过两种不同的方式解决您的问题。由于您已经安装了 PostgreSQL 并且 运行 在端口 5432 (?) 上,您可以将 GitLab 配置为使用 that 实例。

或者您可以将新安装的 PostgreSQL 设置为侦听端口 5433(在 postgresql.conf 中设置),并将 GitLab 配置为使用 that 实例。

无论你走哪条路,你都必须获得 listening 配置(PostgreSQL)和 talking 配置(GitLab)才能匹配,并且您必须让他们 both 同意身份验证。 PostgreSQL 通过配置文件 pg_hba.conf 控制身份验证。 Ruby on Rails 通过配置文件 database.yml 控制身份验证。我假设 GitLab 使用 database.yml 和 gitlab.rb 的某种组合,但我不确定。

PostgreSQL 和 Rails 都编写了日志文件,您会发现它们有助于追踪错误消息的根本原因。 PostgreSQL 设置在 postgresql.conf 中(搜索 "ERROR REPORTING")。默认日志文件是 /var/log/postgresql/postgresql-9.4-main.log for version 9.4 under Ubuntu Linux; CentOS 可能使用不同的目录。 Rails 写入项目的 log/ 目录(与 app、config、test 等同级)