tags: [gitlab]
categories: [工具]
前言
GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的 web服务,GitLab是可以部署到自己的服务器 上,数据库等一切信息都掌握在自己手上,适合团队内部协作开发
GitLab有点吃资源,我的1核2G服务器自安装后巨卡无比,建议在配置更好的服务器或者直接在自己的虚拟上测试,会方便很多
安装相关依赖
# 前两个是ssh服务,后面是邮件服务,gitlab需要发送邮件yum -y install openssh-server openssh-clients postfix# 这个和gitlab的安装有关yum -y policycoreutils policycoreutils-python# 启动sshd服务systemctl enable sshd && sudo systemctl start sshd# 修改postfix配置文件,启动并设置开机自启,修改内容在括号里面vim /etc/postfix/main.cf(inet_interfaces = allinet_protocols = ipv4)systemctl start postfixsystemctl enable postfix# 有防火墙注意关闭防火墙,没有firewalld建议安装, 82是我的端口号firewall-cmd --zone=public --add-port=82/tcp --permanentfirewall-cmd --add-service=http --permanentfirewall-cmd --add-service=ssh --permanentfirewall-cmd --reload
下载镜像文件和安装
建议去清华大学镜像站下载,地址:GITLAB社区版地,下载rpm安装包
rpm -ivh gitlab-ce-12.9.1-ce.0.el6.x86_64.rpm
出现以下界面代表安装成功了
GITLAB命令
# 启动gitlabgitlab-ctl start# 停止gitlabgitlab-ctl stop# 查看gitlab状态gitlab-ctl status
修改配置
# 编辑gitlab配置文件vim /etc/gitlab/gitlab.rb修改项开始===>该地址为访问GITLAB地址,需要加上前面的端口号external_url 'http://该服务器IP:82'# 该配置是为了防止和8080端口冲突,个人测试尤其注意,如果你单独服务来部署,当我没说unicorn['port'] = 8282gitlab_workhorse['auth_backend'] = "http://localhost:8282"<===修改项结束# 重新配置gitlab-ctl reconfigure# 重启gitlabgitlab-ctl restart
问题记录
- rpm安装失败
- 这种情况,一般都是以来没安装好导致的,需要保证安装之前
policycoreutilsopenssh-serveropenssh-clientspostfix这四个都安装好了
- 这种情况,一般都是以来没安装好导致的,需要保证安装之前
policycoreutils-python安装失败,执行yum install policycoreutils-python -y提示无该软件
这种情况我遇到了,是因为centOS8该软件已经修改为新的名称所致,帖子在这
postfix启动失败
一般都是没加括号里面的配置,加上之后重新启动即可
- 访问直接是无响应,404
这种情况一般都是网络限制,检查防火墙限制
# 查看防火墙状态firewall-cmd --state# 查看防火墙开放端口firewall-cmd --permanent --zone=public --list-ports
如果是云服务器的话,安全组配置需要添加
- 以上都完成了访问GITLAB还是502

建议多等等QAQ
卸载GITLAB
rpm卸载gitlab
sudo rpm -e gitlab-ce
2. 杀死守护进程```shellkill -9 1220
- 删除gitlab文件
find / -name gitlab|xargs rm -rf
[root@iZm5e5d84aus1oanps2omoZ opt]# gitlab-ci-multi-runner registerRunning in system-mode.Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):http://114.215.86.43:82/Please enter the gitlab-ci token for this runner:9aNqD5sETsx4swx7hbGWPlease enter the gitlab-ci description for this runner:[iZm5e5d84aus1oanps2omoZ]: zoombar-runnerPlease enter the gitlab-ci tags for this runner (comma separated):deployWhether to run untagged builds [true/false]:[false]: falseWhether to lock Runner to current project [true/false]:[false]: falseRegistering runner... succeeded runner=9aNqD5sEPlease enter the executor: shell, docker, docker-ssh, parallels, ssh, virtualbox, docker+machine, docker-ssh+machine, kubernetes:shellRunner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
配置GITLAB HTTPS域名访问
证书设置
将创建好的证书放到/etc/gitlab/ssl目录下,证书获取详见我的另外一篇博客https://www.yuque.com/guyuefangyuan/blog/og9wzl,
修改配置文件
找到/etc/gitlab/gitlab.rb文件,涉及到的配置修改项如下
# 访问的链接external_url 'https://gitlab.zoombar.fun'# nginx开启nginx['enable'] = true# 访问http重定向到httpnginx['redirect_http_to_https'] = true# 重定向端口nginx['redirect_http_to_https_port'] = 80# 证书路径nginx['ssl_certificate'] = "/etc/gitlab/ssl/cert.cer"# key路径nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/cert.key"
更新Gitlab配置
# 重新配置gitlab-ctl reconfigure
修改nginx 配置文件
# 修改nginx配置文件vim /var/opt/gitlab/nginx/conf/gitlab-http.conf#添加了一栏 ssl onserver {listen *:443 ssl http2;server_name gitlab.zoombar.fun;server_tokens off; ## Don't show the nginx version number, a security best practicessl on;## Increase this if you want to upload large attachments## Or if you want to accept large git objects over httpclient_max_body_size 0;## Strong SSL Security## https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html & https://cipherli.st/ssl_certificate /etc/gitlab/ssl/cert.cer;ssl_certificate_key /etc/gitlab/ssl/cert.key;......
重启GitLab
gitlab-ctl restart
