基于GitLab+Jenkin-CICD方案实践

前言

笔录于2022-

安装Gitlab:

[root@gitlab-service ~]# yum install wget -y
[root@gitlab-service ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.1.0-ce.0.el7.x86_64.rpm --no-check-certificate
[root@gitlab-service ~]# yum install gitlab-ce-14.1.0-ce.0.el7.x86_64.rpm -y
 Installing : gitlab-ce-14.1.0-ce.0.el7.x86_64                                                                               1/1 
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`  #注意 GitLab 无法检测到实例的有效主机名,需要修改 URL 路径在 /etc/gitlab/gitlab.rb
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure

[root@gitlab-service ~]# vim /etc/gitlab/gitlab.rb 
...
external_url 'http://20.20.10.193' #本机IP

[root@server-hub ~]#  gitlab-ctl reconfigure #修改完后,使用gitlab-ctl reconfigure重新加载配置gitlab使配置生效,加载需要一会
[root@server-hub ~]#  gitlab-ctl start  #启动
[root@server-hub ~]# gitlab-ctl status #查看状态

 

GitLab常用组件

  • nginx #静态Web服务器

  • gitlab-shell #用于处理Git命令

  • gitlab-workhorse #轻量级的反向代理服务器

  • logrotate #日志文件管理工具

  • postgresql #数据库

  • redis #缓存数据库

  • unicorn #GitLab Rails应用是托管在这个服务器上面的

 

GitLab服务参数

常用参数如下:

  • /opt/gitlab #应用代码和相应的依赖程序

  • /etc/gitlab #配置文件目录

  • /etc/gitlab/gitlab.rb #gitlab配置文件

  • /var/log/gitlab #gitlab各个组件产生的日志/var/opt/gitlab/git-data/repositories #库默认存储目录

  • /var/opt/gitlab/backups/ #备份文件生成的目录

  • /var/opt/gitlab/gitlab-rails/etc/unicorn.rb #unicorn配置文件

  • /var/opt/gitlab/nginx/conf/gitlab-http.conf #nginx配置文件

 

GitLab常用命令

  • gitlab-ctl start #启动全部服务(也可指定单个服务)

  • gitlab-ctl restart #重启全部服务(也可指定单个服务)

  • gitlab-ctl stop #停止全部服务(也可指定单个服务)

  • gitlab-ctl reconfigure #使配置文件生效(修改主配置文件后使用)

  • gitlab-ctl show-config #验证配置文件

  • gitlab-ctl uninstall #卸载gitlab(保留数据)

  • gitlab-ctl cleanse #删除所有数据,从新开始

  • gitlab-ctl tail <service name> #查看服务的日志

登录GitLab

浏览器访问GitLab服务器地址:http://server_ip

  默认用户名:root

  root初始密码所在文件:cat /etc/gitlab/initial_root_password

 

 

  

GitLab 部署完成:

 

 

 修改密码

部署完成后,下次登录还是需要看密码配置文件,所以一般部署完成后第一件事就是改密码,密码不验证复杂度,长度需满足8位:

 

 修改Root密码

 

 

 

 

posted @ 2023-01-27 11:22  xiao智  阅读(44)  评论(0编辑  收藏  举报