GitLab后台数据库连接方法
一、概要
默认情况下GitLab只允许本地用户登录后台PostgreSQL。
即,/var/opt/gitlab/postgresql/data/pg_hba.conf内容如下:
- snippet.conf
local all all peer map=gitlab
为了不影响原有用户,新增一个用于外部直接访问后台数据库的新用户。
二、配置方法
创建用户
创建一个使用密码登录的用户。
- snippet.sql
# 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';
修改pg_hba.conf
新增以下行:
- snippet.conf
host all app_viewer 127.0.0.1/32 md5 host all app_viewer ::1/128 md5
修改postgresql.conf
- snippet.conf
$ vim /var/opt/gitlab/postgresql/data/postgresql.conf listen_addresses = '*' port = 5432
修改gitlab.rb
- snippet.conf
# vim /etc/gitlab/gitlab.rb postgresql['listen_address'] = '*' postgresql['port'] = 5432
重启PostgreSQL
- snippet.bash
# gitlab-ctl restart postgresql
三、参考
打赏作者以资鼓励:
![]() | ![]() |