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/   # 对应各服务的主目录 
相关推荐
HIT_Weston8 小时前
16、【ubuntu】【gitlab】【补充】服务器断电后,重启服务器,gitlab无法访问
服务器·ubuntu·gitlab
LinkTime_Cloud2 天前
GitLab 将停止为中国区用户提供服务,60天迁移期如何应对? | LeetTalk Daily
大数据·运维·gitlab
sin22012 天前
GitLab安装及使用
gitlab
极小狐2 天前
从 GitLab.com 到 JihuLab.com 的迁移指南
gitlab·devsecops·devops·极狐gitlab·安全合规
web135085886353 天前
使用docker compose安装gitlab
docker·容器·gitlab
墨理学AI4 天前
GitHub 桌面版配置 |可视化界面进行上传到远程仓库 | gitLab 配置【把密码存在本地服务器】
gitlab·github·github 桌面版
月如琉璃4 天前
1.gitlab 服务器搭建流程
服务器·gitlab
刘大辉在路上4 天前
突发!!!GitLab停止为中国大陆、港澳地区提供服务,60天内需迁移账号否则将被删除
git·后端·gitlab·版本管理·源代码管理
tingkeiii5 天前
gitlab克隆仓库报错fatal: unable to access ‘仓库地址xxxxxxxx‘
gitlab
dami_king5 天前
项目开源能够带来什么?从中得到了什么?
开源·gitlab·github