默认情况下GitLab只允许本地用户登录后台PostgreSQL。
即,/var/opt/gitlab/postgresql/data/pg_hba.conf内容如下:
local all all peer map=gitlab
为了不影响原有用户,新增一个用于外部直接访问后台数据库的新用户。
创建一个使用密码登录的用户。
# su - gitlab-psql $ psql -h /var/opt/gitlab/postgresql -d gitlabhq_production gitlabhq_production=# CREATE USER app_viewer; gitlabhq_production=# ALTER USER app_viewer password 'xxx';
新增以下行:
host all app_viewer 127.0.0.1/32 md5 host all app_viewer ::1/128 md5
$ vim /var/opt/gitlab/postgresql/data/postgresql.conf listen_addresses = '*' port = 5432
# vim /etc/gitlab/gitlab.rb postgresql['listen_address'] = '*' postgresql['port'] = 5432
# gitlab-ctl restart postgresql