【发布时间】:2021-03-25 09:14:51
【问题描述】:
我正在寻找有关如何在基于 Docker Swarm 的 Gitlab 实例中配置 Azure PostgreSQL DB 的帮助。
最初,我遵循https://docs.gitlab.com/13.6/ee/administration/postgresql/external.html 中的文档。然而我发现默认提供的用户是 username 的形式,而 Azure 要求它是 username@hostname 的形式。我尝试在 gitlab.rb 文件 (gitlab_rails['db_username'] = 'username@hostname') 中传递用户名,但它仍然失败,即使将 @ 替换为 %40 作为 URI 编码。
经过一番广泛的搜索,我找到了这个文档 - https://docs.gitlab.com/13.6/ee/administration/environment_variables.html,它建议使用DATABASE_URL 环境变量以postgresql://username:password@hostname:port/dbname 的形式设置完整的连接字符串,我这样做了,它确实解决了 Gitlab 的问题本身与 Azure PostgreSQL 通信(在这种情况下,我根据 Azure 要求将用户名替换为 username%40hostname)。
唉,成功是短暂的,后来我发现Puma和Sidekiq都无法连接到数据库,总是抛出以下错误:
==> /var/log/gitlab/sidekiq/current <==
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
经过一番搜索,发现gitlab-ctl在启动Gitlab实例时生成如下文件:
# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.
production:
adapter: postgresql
encoding: unicode
collation:
database: <database>
username: "<username>"
password:
host: "/var/opt/gitlab/postgresql"
port: 5432
socket:
sslmode:
sslcompression: 0
sslrootcert:
sslca:
load_balancing: {"hosts":[]}
prepared_statements: false
statement_limit: 1000
connect_timeout:
variables:
statement_timeout:
(删除的数据库和用户名)
它几乎忽略了DATABASE_URL env 变量并假定 gitlab.rb 中现在不存在的配置参数。
所以,现在,我有点别无选择,想知道是否有人遇到过类似的问题,如果有,您如何克服这个问题。
感谢任何帮助。
提前致谢。
【问题讨论】:
标签: gitlab sidekiq gitlab-omnibus azure-postgresql gitlab-ee