nginx 如何配置gitlab以使用现有的postgres服务器

oyxsuwqo  于 2024-01-06  发布在  Nginx
关注(0)|答案(2)|浏览(205)

默认情况下安装Gitlab时,无论您是否已经安装了Nginx和Postgres ..,都会安装它们。因此,由于我已经有了这两个,我正在尝试配置gitlab来使用它们,我已经为Nginx这样做了,使用:

  1. $ vi /etc/gitlab/gitlab.rb:
  2. # Disable GitLab's nginx completely
  3. nginx['enable'] = false
  4. # Set external web user which is 'nginx' on CentOS 7
  5. web_server['external_users'] = ['nginx']

字符串
但我需要知道如何做同样的postgres

c90pui9n

c90pui9n1#

根据这个文档,把它放在/etc/gitlab/gitlab.rb中:

  1. # Disable the built-in Postgres
  2. postgresql['enable'] = false
  3. # Fill in the connection details for database.yml
  4. gitlab_rails['db_adapter'] = 'postgresql'
  5. gitlab_rails['db_encoding'] = 'utf8'
  6. gitlab_rails['db_host'] = '127.0.0.1'
  7. gitlab_rails['db_port'] = 5432
  8. gitlab_rails['db_username'] = 'USERNAME'
  9. gitlab_rails['db_password'] = 'PASSWORD'

字符串
然后运行这个命令来应用这个值:sudo gitlab-ctl reconfigure。如果你选择了一个外部数据库,你还需要播种你的数据库。这个命令将使用omnibus-gitlab:sudo gitlab-rake gitlab:setup来完成。

wbgh16ku

wbgh16ku2#

Pierre的解决方案适用于新安装,但如果数据库中已经有数据,则需要进行迁移。最干净,最安全的方法是创建一个备份,其中也包含数据库:

  1. gitlab-rake gitlab:backup:create

字符串
备份文件将位于/var/opt/gitlab/backups
或者,您可以尝试:

  1. sudo -u gitlab-psql /opt/gitlab/embedded/bin/pg_dumpall --username=gitlab-psql --host=/var/opt/gitlab/postgresql


然后,您可以使用以下命令将DB导入到现有的Postgres示例中:

  1. psql -f /tmp/database.sql


然后你也需要重新配置和重新启动:

  1. gitlab-ctl start && gitlab-ctl reconfigure && gitlab-ctl restart


它以start开始,因为你需要确保GitLab正在运行。这是因为,无论听起来多么奇怪,如果GitLab停止,reconfigure就会失败:

  1. Errno::ENOENT: No such file or directory - connect(2) for /var/opt/gitlab/redis/redis.socket


这有点违反直觉,因为传统上您在示例停止时对配置进行更改。

但是无论是迁移还是干净安装,问题都来自第一次GitLab升级:

  1. gitlab preinstall: Automatically backing up only the GitLab SQL database (excluding everything else!)
  2. Dumping database ...
  3. Dumping PostgreSQL database gitlabhq_production ... pg_dump: server version: 10.4; pg_dump version: 9.6.8
  4. pg_dump: aborting because of server version mismatch
  5. Backup failed
  6. [FAILED]


正如它所指示的,你必须:

  1. sudo touch /etc/gitlab/skip-auto-migrations


所以现在软件包将成功更新,但GitLab仍然无法工作,你必须再次:

  1. gitlab-ctl reconfigure


要自动执行此操作,请执行以下操作:

  1. yum install yum-plugin-post-transaction-actions
  2. echo 'gitlab-ce:any:/bin/gitlab-ctl reconfigure' > /etc/yum/post-actions/gitlab-ce.action


有关所有的细节,请参阅:

展开查看全部

相关问题