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

发布时间:2024年01月09日

下载地址

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

安装

rpm -ivh gitlab-ce-16.7.0-ce.0.el7.x86_64.rpm
[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加端口号

vim /etc/gitlab/gitlab.rb

在这里插入图片描述

防火墙端口开放

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

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

重新加载配置

#重新加载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这样的,或者所部署服务器上已经占用过的端口,然后进行相应的属性修改。

## 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'
################################################################################
## 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'

继续访问

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

gitlab-ctl reconfigure & gitlab-ctl restart

在这里插入图片描述

gitlab账户和密码修改

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

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

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

/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)

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

[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常用命令

# 开启,关闭,重启: 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/   # 对应各服务的主目录 
文章来源:https://blog.csdn.net/baidu_35751704/article/details/135480386
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。