CentOS7 安装部署GitLab服务器

 

一,安装   安装,2:连接出错502 3:解决ok
安装,2:连接出错502 3:解决ok
502 
GitLab is not responding. 
Please contact your GitLab administrator if this problem persists.

一、安装中 安装依赖软件

yum -y install policycoreutils openssh-server openssh-clients postfix

2.设置postfix开机自启,并启动,postfix支持gitlab发信功能

systemctl enable postfix && systemctl start postfix

3.下载gitlab安装包,然后安装

centos 6系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6

centos 7系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7

我的是centos7,所以我在https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7中找了个gitlab8.0.0版本,建议下载一个比较新的版本,我这里选了一个比较旧的版本仅仅是实验

下载rpm包并安装:

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm

rpm -i gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm

4.修改gitlab配置文件指定服务器ip和自定义端口:

vim  /etc/gitlab/gitlab.rb

退出并保存

ps:注意这里设置的端口不能被占用,默认是8080端口,如果8080已经使用,请自定义其它端口,并在防火墙设置开放相对应得端口

5.重置并启动GitLab

执行:

gitlab-ctl reconfigure

gitlab-ctl restart

复制代码

ok: run: gitlab-git-http-server: (pid 3922) 1s
ok: run: logrotate: (pid 3929) 0s
ok: run: nginx: (pid 3936) 1s
ok: run: postgresql: (pid 3941) 0s
ok: run: redis: (pid 3950) 0s
ok: run: sidekiq: (pid 3955) 0s
ok: run: unicorn: (pid 3961) 1s

复制代码

提示“ok: run:”表示启动成功

6.紧接着访问 GitLab页面  502出错

GitLab is not responding. 

三,安装中出现的问题

这里记录一下解决问题的大概经过,也算给自己长经验。 
安装好GitLab,开启服务,发现有502错误。这是开始寻找解决办法,各种百度。 
1.找到/var/log/gitlab/nginx中的错误日志文件,发现有如下错误/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket failed (2: No such file or directory),然后用 nc命令创建了这个socket文件,最终权限设为 srwxrwxrwx,用户和组设置为git:git,但发现这个方法行不通。这时差不多找到了问题的所在了,应该就是unicorn的问题。然后看官方教程,可以使用

gitlab-ctl tail unicorn #查看gitlab 服务启动日志


来跟踪unicorn的状态,这时候悲催的发现原来时8080端口被占用了

听说 gitlab 安装中会出现的问题还是比较多的,不过在我安装的过程中好像没有遇到多少问题!

1,在浏览器中访问GitLab出现502错误

GitLab的安装实战GitLab的安装实战

首先就是端口占用问题,gitlab 启动会使用 80 端口,所以建议你在启动 gitlab 前先将不需要的服务都关掉,或者修改默认端口:

sudo vim /etc/gitlab/gitlab.rb

修改external_url,直接增加端口号即可,比如我这里用8800端口:

external_url 'http://localhost:8800'

然后执行:

sudo gitlab-ctl reconfigure   #依然会提示端口占用,,继续第二步 修改listen与port

2,8080端口冲突

除了 80 这个端口外,还有一个unicorn用的端口,默认是8080,如果8080端口被其他程序占用。那么unicorn就会无法启动,显示为502错误,”GitLab is not responding”。

解决办法:修改 /etc/gitlab/gitlab.rb

unicorn['listen'] = '127.0.0.1'

unicorn['port'] = 8801       #此处监听ip和port与上面external_url 不能一致。。本人就是因为设置一致导致出现一直出现端口占用。。。

然后运行:

gitlab-ctl reconfigur
gitlab-ctl restart

四,gitlab 常用命令

gitlab-ctl start
 
gitlab-ctl stop
 
gitlab-ctl status
 
gitlab-ctl restart

Gitlab 默认的日志文件存放在/var/log/gitlab 目录下:
gitlab-rake gitlab:check SANITIZE=true --trace    # 检查gitlab;
gitlab-ctl tail #查看所有日志

gitlab-ctl tail nginx/gitlab_access.log #查看nginx访问日志

参考地址:1:502  https://blog.csdn.net/wangxicoding/article/details/43738137

2: 指令:https://blog.csdn.net/linuxnews/article/details/54604768

猜你喜欢

转载自blog.csdn.net/qq_32447321/article/details/80860359