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/   # 对应各服务的主目录 
相关推荐
jasnet_u2 天前
如何重置Gitlab的root用户密码
gitlab
全栈工程师修炼指南3 天前
告别手动构建!Jenkins 与 Gitlab 完美协作,根据参数自动化触发CI/CD流水线实践
运维·ci/cd·自动化·gitlab·jenkins
xiaok5 天前
分支管理提交代码
git·gitlab·github
*老工具人了*5 天前
Terraform整合到GitLab+Jenkins工具链
gitlab·jenkins·terraform
走上未曾设想的道路6 天前
中标麒麟7.4为gitlab添加Registry
gitlab
韩zj7 天前
docker部署Gitlab社区版,步骤以及外网访问出现502的解决方式
docker·容器·gitlab
走上未曾设想的道路7 天前
gitlab流水线与k8s集群的联通
kubernetes·gitlab
走上未曾设想的道路7 天前
中标麒麟7.4部署gitlab-runner
gitlab
xiaok8 天前
把代码上传到gitee的时候,怎么忽略node_modules文件夹
git·gitlab·github
deeper_wind8 天前
OpenEuler部署gitlab(小白的“升级打怪”成长之路)
gitlab