简装gitlab

zlong.w Lv2

版本介绍

  1. 查看系统版本

    1
    2
    cat  /etc/redhat-release 
    # CentOS Linux release 7.6.1810 (Core)
  2. gitlab版本

    gitlab-ce-13.6.3-ce.0.el6.x86_64.rpm

  3. 各依赖版本

    cronie-1.4.11-23.el7.x86_64.rpm 定时任务服务

    openssh-server-7.4p1-21.el7.x86_64.rpm ssh服务

    postfix-2.10.1-9.el7.x86_64.rpm 邮件服务

    policycoreutils-python-2.5-34.el7.x86_64.rpm selinux
    的预配置文件和工具

依赖准备

搜索下载依赖 清华大学开源软件镜像站搜索gitlab-ce下载对应版本rpm包

安装

  1. 将依赖上传至Linux服务器

  2. 安装依赖

1
2
3
4
rpm -ivh cronie-1.4.11-23.el7.x86_64.rpm --force --nodeps                              
rpm -ivh openssh-server-7.4p1-21.el7.x86_64.rpm --force --nodeps
rpm -ivh postfix-2.10.1-9.el7.x86_64.rpm --force --nodeps
rpm -ivh policycoreutils-python-2.5-34.el7.x86_64.rpm --force --nodeps
  1. 配置依赖
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    ## 设置ssh开机自启动          
    systemctl enable sshd
    ## 启动ssh服务
    systemctl start sshd
    ## 将http添加到防火墙
    firewall-cmd --permanent --add-service=http
    ## 将https添加到防火墙(不开https也可以不添加)
    firewall-cmd --permanent --add-service=https
    ## 重启防火墙
    systemctl reload firewalld
    ## 设置邮件服务开机自启动
    systemctl enable postfix
    ## 启动邮件服务
    systemctl start postfix
  2. 安装gitlab
    1
    rpm -ivh gitlab-ce-13.6.3-ce.0.el6.x86_64.rpm

配置

  1. 修改配置文件
    1
    2
    3
    4
    5
    6
    vim /etc/gitlab/gitlab.rb    
    # 更改访问地址
    #格式:external_url 'http://ip:端口'
    external_url 'http://192.168.1.1:7021'
    #配置时区
    gitlab_rails['time_zone'] = 'Asia/Shanghai'
  2. 防火墙开放端口并重启防火墙,阿里云服务器需要再控制台也开放
    1
    2
    firewall-cmd --zone=public --add-port=7021/tcp --permanent 
    firewall-cmd --reload
  3. 重置Gitlab
    1
    gitlab-ctl reconfigure
  4. 启动gitlab
    1
    gitlab-ctl restart
  5. 查看gitlab日志
1
gitlab-ctl tail
启动后查看日志,看有没有报端口冲突错,有些端口默认8080,如果端口有占用的话需要注意以下位置:

/var/opt/gitlab/nginx/conf/gitlab-http.conf
查看nginx监听的端口跟gitlab.rb下监听的是不是一致,如果还是8080则需要改为跟gitlab.rb一致的

/var/opt/gitlab/gitlab-rails/etc/puma.rb

或者直接再/var/opt/gitlab/目录下全局搜索8080,搜到的改掉
1
grep -r "8080" 

备份与恢复

  1. 备份目录设置,默认在/var/opt/gitlab/backups
    1
    2
    3
    4
    5
    6
    7
    8
    9
    vim /etc/gitlab/gitlab.rb ##修改以下配置 
    gitlab_rails['manage_backup_path'] = true
    gitlab_rails['backup_path'] = "/data/gi tlab/backups" ##gitlab备份目录
    gitlab_rails['backup_archive_permissions']= 0644 ##生成的备份文件权限
    gitlab_rails['backup_keep_time'] = 7776000 ##备份保留天数为3个月(即90天,这里是7776000秒
    ## 创建文件夹并配置权限
    mkdir -p /data/gitlab/backups
    chown -R git.git /data/gitlab/backups
    chmod -R 777 /data/gitlab/backups
  2. 备份
    1
    2
    ##手动备份                   
    gitlab-rake gitlab:backup:create
  3. 恢复
    1
    2
    3
    4
    5
    6
    7
    8
    9
    ##停止相关数据连接服务       
    gitlab-ctl stop unicorn
    gitlab-ctl stop sidekiq
    ##查看状态
    gitlab-ctl status
    ## 恢复前需要把备份文件放到备份路径下/var/opt/gitlab/backups
    ##开始恢复
    ## 例如恢复:1614432908_2021_02_27_13.6.3_gitlab_backup.tar
    gitlab-rake gitlab:backup:restore BA CKUP=1614432908_2021_02_27_13.6.3
  • 标题: 简装gitlab
  • 作者: zlong.w
  • 创建于 : 2021-01-10 18:13:46
  • 更新于 : 2023-09-27 18:15:26
  • 链接: https://zlonx.cn/2021/01/10/简装gitlab/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。