CentOS7部署GitLab-ce-16.7.0-ce.0.el7

文章目录

下载地址

gitlab 下载地址

上传服务器

复制代码
scp -r C:\Users\xxx.xxxx\Downloads\gitlab-ce-16.7.0-ce.0.el7.x86_64.rpm root@xxx.xxx.xxx.xxx:/usr/local/soft_resource

安装

bash 复制代码
rpm -ivh gitlab-ce-16.7.0-ce.0.el7.x86_64.rpm
bash 复制代码
[root@localhost soft_resource]# rpm -ivh gitlab-ce-16.7.0-ce.0.el7.x86_64.rpm
警告:gitlab-ce-16.7.0-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:gitlab-ce-16.7.0-ce.0.el7        ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
  


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=16-7

[root@localhost soft_resource]# 

访问配置

external_url修改

访问需修改配置文件,将external_url 设置为具体的ip加端口号

bash 复制代码
vim /etc/gitlab/gitlab.rb

防火墙端口开放

bash 复制代码
firewall-cmd --zone=public --add-port=7070/tcp --permanent
firewall-cmd --reload #修改后需要重新加载防火墙生效

# 显示success表示成功
# --zone=public表示作用域为公共的
# --add-port=7070/tcp添加tcp协议的端口端口号为7070
# --permanent永久生效,如果没有此参数,则只能维持当前 服 务生命周期内,重新启动后失效;

重新加载配置

bash 复制代码
#重新加载gitlab的配置,过程较慢,需要几分钟,耐心等待,gitlab Reconfigured!即成功
gitlab-ctl reconfigure

访问GitLab

复制代码
ip加端口即可访问gitlab
http://xxx.xxx.xxx.xxx:xxxx/

出现502访问错误

网上给出的建议有:

1、服务器资源不足,按top查询,后经判断不是这个原因

2、端口问题,大部分人是这个问题,但是网上的资料修改的值也是五花八门,而且有的较新的社区版已经废弃了某些配置,找到一个可行的解决方案,不能单修改external_url还需要修改puma['port']。后面总结经验性方法是,在gitlab.rb文件中,搜索像8080这样的,或者所部署服务器上已经占用过的端口,然后进行相应的属性修改。

bash 复制代码
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
##!
##! Note: During installation/upgrades, the value of the environment variable
##! EXTERNAL_URL will be used to populate/replace this value.
##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
#external_url 'http://gitlab.example.com'
external_url 'http://xx.xx.x.xxx:23333'
bash 复制代码
################################################################################
## GitLab Puma
##! Tweak puma settings.
##! Docs: https://docs.gitlab.com/ee/administration/operations/puma.html
################################################################################

# puma['enable'] = true
# puma['ha'] = false
# puma['worker_timeout'] = 60
# puma['worker_processes'] = 2
# puma['min_threads'] = 4
# puma['max_threads'] = 4

### Advanced settings
# puma['listen'] = '127.0.0.1'
# puma['port'] = 8080
 puma['port'] = 23334
# puma['socket'] = '/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket'

继续访问

修改配置后,再用命令重启配置和服务

bash 复制代码
gitlab-ctl reconfigure & gitlab-ctl restart

gitlab账户和密码修改

可能安装过程中不记得账号和密码,可以在gitlab服务器做修改,默认root用户,修改root密码。

bash 复制代码
gitlab-rails console -e production
bash 复制代码
user = User.where(username:"root").first
bash 复制代码
user.password = "root"
bash 复制代码
user.password_confirmation ="root"
bash 复制代码
user.save!

如果出现以下提示,表示密码格式太简单了。不能包含常见账号信息,且需要最少8字符长度。

bash 复制代码
/opt/gitlab/embedded/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8/lib/active_record/validations.rb:80:in `raise_validation_error': Validation failed: Password must not contain commonly used combinations of words and letters, Password is too short (minimum is 8 characters) (ActiveRecord::RecordInvalid)

换一个,然后再重复上面的流程

bash 复制代码
[root@localhost gitlab]# gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
 GitLab:       14.10.5 (02cdf459a13) FOSS
 GitLab Shell: 13.25.1
 PostgreSQL:   12.7
-----------------------------------------------------------[ booted in 122.86s ]
Loading production environment (Rails 6.1.4.7)
irb(main):005:0> user = User.where(username:"root").first
=> #<User id:1 @root>
irb(main):006:0> user.password = "root"
=> "root"
irb(main):007:0> user.password_confirmation ="root"
=> "root"
irb(main):008:0> user.save!
/opt/gitlab/embedded/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8/lib/active_record/validations.rb:80:in `raise_validation_error': Validation failed: Password must not contain commonly used combinations of words and letters, Password is too short (minimum is 8 characters) (ActiveRecord::RecordInvalid)
irb(main):009:0> user = User.where(username:"root").first
=> #<User id:1 @root>
irb(main):010:0> user.password = "xxx@8888"
=> "xxx@8888"
irb(main):011:0> user.password_confirmation ="xxx@8888"
=> "xxx@8888"
irb(main):012:0> user.save!
=> true
irb(main):013:0> 

GitLab常用命令

bash 复制代码
# 开启,关闭,重启: gitlab组件
gitlab-ctl {start|stop|restart|status} 		
gitlab-ctl start
gitlab-ctl stop
gitlab-ctl restart
gitlab-ctl status
 
# 重载配置文件(重新编译gitlab的配置)
gitlab-ctl reconfigure
 
# 验证配置文件
gitlab-ctl show-config   
 
# 检查gitlab
gitlab-rake gitlab:check SANITIZE=true --trace    
 
# 查看日志
gitlab-ctl tail
gitlab-ctl tail nginx/gitlab_access.log
gitlab-ctl tail nginx/gitlab_error.log
 
# 常用目录
日志地址:/var/log/gitlab/   # 对应各服务的打印日志 
服务地址:/var/opt/gitlab/   # 对应各服务的主目录 
相关推荐
Aliex_git6 天前
Dockerfile 优化实践笔记
笔记·学习·gitlab
成为你的宁宁7 天前
Jenkins 自动化部署前后端分离若依项目全攻略:涵盖环境配置、Maven/Node.js 工具安装、GitLab 项目协同,及前后端构建、服务器推送与代码更新验证全步骤
node.js·自动化·gitlab·jenkins·maven
sunshinebo7 天前
一次 GitLab 无法启动的排查:Docker 日志把 500G 磁盘打满
docker·eureka·gitlab
何以不说话7 天前
DevOps、Git 和 GitLab
git·gitlab·devops
ZAEQgyKFs10 天前
永磁同步电机模型预测电流控制+滑模控制 [1]速度环采用滑模控制 滑模控制器采用新型趋近律与扰...
gitlab
马克Markorg10 天前
使用 Docker Compose 本地部署 GitLab 教程
docker·容器·gitlab
大尚来也13 天前
CI/CD 流水线搭建实战:GitHub Actions vs GitLab CI 2026 深度对比与选型指南
ci/cd·gitlab·github
ProgramHan14 天前
github、gitlab、gitee分别都是什么,为什么不能访问?
gitee·gitlab·github
Aliex_git16 天前
Gitlab Runner 配置实践
笔记·学习·ci/cd·gitlab
阿莫西林夹馍16 天前
GitLab的IP地址发生变更导致Runner掉线
gitlab