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/   # 对应各服务的主目录 
相关推荐
测试开发技术2 天前
git rm 命令与系统的 rm 命令有什么区别?
git·gitlab·github·面试题
云和数据.ChenGuang3 天前
关闭 GitLab 升级提示的详细方法
运维·自动化·gitlab·es运维
读创商闻3 天前
极狐GitLab CEO 柳钢——极狐 GitLab 打造中国企业专属 AI 编程平台,引领编程新潮流
人工智能·gitlab
小川zs3 天前
gitee某个分支合并到gitlab目标分支
gitee·gitlab
你的人类朋友3 天前
✨【GitLab】【CI/CD】核心概念一览
gitlab·自动化运维·devops
Gold Steps.4 天前
基于 Gitlab、Jenkins与Jenkins分布式、SonarQube 、Nexus 的 CiCd 全流程打造
运维·ci/cd·gitlab·jenkins
咚咚?4 天前
基于gitlab 构建CICD发布到K8S 平台
容器·kubernetes·gitlab
荔枝吻8 天前
【保姆级喂饭教程】GitLab创建用户规范,分支开发规范,提交日志规范
gitlab·git规范·分支规范
云畅新视界8 天前
从 CODING 停服到极狐 GitLab “接棒”,软件研发工具市场风云再起
人工智能·gitlab