用psycopg2连接到gitlab生产postgresql数据库?
问题描述:
我正在尝试使用psycopg2连接到GitLab生产(与omnibus包一起安装)postgresql数据库。用psycopg2连接到gitlab生产postgresql数据库?
我的配置是象下面这样:
onn = psycopg2.connect(database="gitlabhq_production", user="gitlab-psql", host="/var/opt/gitlab/postgresql", port="5432")
它提供了以下错误:
sudo -u gitlab-psql -i bash /opt/gitlab/embedded/bin/psql --port 5432 -h /var/opt/gitlab/postgresql -d gitlabhq_production
作用:
FATAL: Peer authentication failed for user "gitlab-psql"
我可以连接到PostgreSQL服务器上的命令行任何人都知道什么是正确的参数传入?
答
对等身份验证通过检查用户进程正在运行。在您的命令行示例中,使用sudo
切换到gitlab-psql
。
有两种方法来解决这个问题:
-
指定密码到
gitlab-psql
Postgres的用户(不系统用户!),并使用通过Python连接。设置密码就是你需要像这样一个超级用户身份运行另一个查询:sudo -u postgres psql -c "ALTER USER gitlab-psql WITH PASSWORD 'ReplaceThisWithYourLongAndSecurePassword';"
-
运行Python脚本
gitlab-psql
像这样:sudo -u gitlab-psql python /path/to/your/script.py
请问综合-gitlab应用需要在向postgresql用户gitlab-psql添加密码后通过gitlab-ctl reconfigure进行的任何更改? –