背景

公司拆分子公司,需要把现有Gitlab也分离出来。

搭建环境:

  • centos6.5
  • gitlab8.8.5

搭建方法:

  • Omnibus package installation

遇到问题:

安装完成,执行 #gitlab-ctl reconfigure 报错如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[execute] /opt/gitlab/embedded/bin/psql: symbol lookup error: /opt/gitlab/embedded/bin/psql: undefined symbol: PQconnectdbParams
[execute] /opt/gitlab/embedded/bin/psql: symbol lookup error: /opt/gitlab/embedded/bin/psql: undefined symbol: PQconnectdbParams

================================================================================
Error executing action `run` on resource 'execute[create gitlab database user]'
================================================================================

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '127'
---- Begin output of /opt/gitlab/embedded/bin/psql --port 5432 -h /var/opt/gitlab/postgresql -d template1 -c "CREATE USER gitlab" ----
STDOUT:
STDERR: /opt/gitlab/embedded/bin/psql: symbol lookup error: /opt/gitlab/embedded/bin/psql: undefined symbol: PQconnectdbParams
---- End output of /opt/gitlab/embedded/bin/psql --port 5432 -h /var/opt/gitlab/postgresql -d template1 -c "CREATE USER gitlab" ----
Ran /opt/gitlab/embedded/bin/psql --port 5432 -h /var/opt/gitlab/postgresql -d template1 -c "CREATE USER gitlab" returned 127

问题分析:

因为我的centos服务器上面已经装了postgresql的8.4.18版本;

1
2
3
4
[root@gitlab0 ~]# rpm -qa|grep postgres
postgresql-8.4.18-1.el6_4.x86_64
postgresql-devel-8.4.18-1.el6_4.x86_64
postgresql-libs-8.4.18-1.el6_4.x86_64

使用/opt/gitlab/embedded/bin/psql的时候找不到对应的库(/opt/gitlab/embedded/lib/postgresql)。

解决方法1:

卸载postgresql-8.4.18,卸载gitlab,然后重新安装gitlab。

卸载gitlab方法如下:

1
2
3
4
sudo gitlab-ctl stop
sudo gitlab-ctl uninstall
sudo gitlab-ctl cleanse
sudo rm -rf /opt/gitlab

解决方法2:

增加gitlab带的psql所需lib路径到系统LD_LIBRARY_PATH

1
2
3
4
5
6
7
8
9
# vi /etc/profile

export LD_LIBRARY_PATH=/opt/gitlab/embedded/lib:/tmp/product.......

# source /etc/profile

# echo $LD_LIBRARY_PATH

/opt/gitlab/embedded/lib:/tmp/product.......

PS:

  1. 增加/opt/gitlab/embedded/lib路径到$LD_LIBRARY_PATH最前面,因为是按顺序加载路径,所以如果加到最后面还是不能成功。
  2. 路径之间使用:分隔

然后再执行#gitlab-ctl reconfigure,即可成功。

1
gitlab Reconfigured!

查看postgresql版本:

1
2
3
4
[root@gitlab0 ~]# /opt/gitlab/embedded/bin/psql --version
psql (PostgreSQL) 9.2.16
[root@gitlab0 ~]# psql --version
psql (PostgreSQL) 8.4.18

参考链接:

http://dreamlikes.cn/archives/78