安装Gitlab
准备工作:
- 安装之前硬盘可用空间建议10G以上,否则可能碰到因空间不足导致安装、配置问题。
- 关闭防火墙 systemctl stop firewalld.service
安装依赖
yum -y install epel-release curl openssh-server openssh-clients postfix cronie policycoreutils-python
下载安装包(centos6.x=el6, centos7.x=el7, centos8.x=el8按需选择)
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm --no-check-certificate
安装
rpm -ivh gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm
配置Gitlab
修改配置文件:vi /etc/gitlab/gitlab.rb
external_url 'http://192.168.200.100:8081'
重新加载配置文件
gitlab-ctl reconfigure
启动并检查运行状态
启动gitlab
gitlab-ctl start
正常运行后启动了很多进程和端口,其中8081是gitlab对外访问的端口
[root@localhost soft]# netstat -tpnl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 1217/nginx: master
tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 1231/redis_exporter
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 1235/prometheus
tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 1239/postgres_expor
tcp 0 0 127.0.0.1:9093 0.0.0.0:* LISTEN 1224/alertmanager
tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 1227/node_exporter
tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 1216/gitlab-workhor
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 1212/puma 4.3.3.git
tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 1233/puma 4.3.3.git
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 1217/nginx: master
tcp 0 0 127.0.0.1:8082 0.0.0.0:* LISTEN 1331/sidekiq 5.2.7
tcp 0 0 127.0.0.1:9236 0.0.0.0:* LISTEN 1306/gitaly
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 950/sshd
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN 1237/grafana-server
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1173/master
tcp6 0 0 :::9094 :::* LISTEN 1224/alertmanager
tcp6 0 0 ::1:9168 :::* LISTEN 1233/puma 4.3.3.git
tcp6 0 0 :::22 :::* LISTEN 950/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1173/master
设置管理账号root的密码
- 进入gitlab命令行
[root@localhost soft]# sudo gitlab-rails console -e production
--------------------------------------------------------------------------------
GitLab: 13.1.2 (2e7a6f64b07) FOSS
GitLab Shell: 13.3.0
PostgreSQL: 11.7
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.3.1)
irb(main):001:0>
- 查询所有账号信息
irb(main):001:0> User.all
=> #<ActiveRecord::Relation [#<User id:1 @root>]>
- 查出id = 1的root账号
irb(main):002:0> user=User.where(id:1).first
=> #<User id:1 @root>
- 设置root密码为 111111
irb(main):003:0> user.password='111111'
=> "111111"
irb(main):004:0> user.password_confirmation='111111'
=> "111111"
- 保存密码
irb(main):005:0> user.save!
Enqueued ActionMailer::MailDeliveryJob (Job ID: 2222b8da-6863-4909-8e35-c01ee88c9dd5) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#<GlobalID:0x00007f85c6d40ac8 @uri=#<URI::GID gid://gitlab/User/5>>]}
=> true
错误锦集
gitlab安装完后执行gitlab-ctl reconfigure时卡在
ruby_block[wait for redis service socket] action run

解决方法:
另起shell终端执行该命令,或先执行该命令再重新执行gitlab-ctl reconfigure
systemctl start gitlab-runsvdir
GitLab 报错 ConnectionBad: could not connect to server: No such...
解决方法:
1、按住CTRL+C强制结束
2、先停止 gitlab ,命令: sudo gitlab-ctl stop
3、执行命令: sudo chmod 755 /var/opt/gitlab/postgresql
4、执行命令:sudo systemctl restart gitlab-runsvdir
5、再次配置:sudo gitlab-ctl reconfigure
6、启动即可:sudo gitlab-ctl restart
502, whoops, gitlab is taking too much time to respond
原因:8080端口被占用,修改端口号并重启
随便修改成一个不会被占用的端口
unicorn['port'] = 8088
打开注释
postgresql['shared_buffers'] = "256MB"
打开注释
postgresql['max_connections'] = 200
gitlab常用命令
gitlab-ctl start # 启动所有 gitlab 组件;
gitlab-ctl stop # 停止所有 gitlab 组件;
gitlab-ctl restart # 重启所有 gitlab 组件;
gitlab-ctl status # 查看服务状态;
gitlab-ctl reconfigure # 重新加载配置并启动服务;
gitlab-ctl tail # 查看日志;
systemctl enable gitlab-runsvdir.service #开机启动
systemctl disable gitlab-runsvdir.service #禁开机启动
参考
https://www.yisu.com/zixun/672.html
https://blog.csdn.net/OldDirverHelpMe/article/details/106536972
https://www.cnblogs.com/easonscx/p/12608480.html
https://blog.csdn.net/huhuhuemail/article/details/80519433
https://blog.csdn.net/qq_36793589/article/details/111573754
https://cloud.tencent.com/developer/article/1511600