一、安装条件

采用官方推荐方式:下载Omnibus软件包安装程序,其中内存要求至少为4G

二、Ominibus安装

文档地址:https://about.gitlab.com/install/#centos-7

1.安装依赖服务
[root@localhost ~]# sudo yum install -y curl policycoreutils-python openssh-server
[root@localhost ~]# sudo systemctl enable sshd
[root@localhost ~]# sudo systemctl start sshd
[root@localhost ~]# sudo firewall-cmd --permanent --add-service=http
[root@localhost ~]# sudo firewall-cmd --permanent --add-service=https
[root@localhost ~]# sudo systemctl reload firewalld
2.安装postfox
[root@localhost ~]# sudo yum install postfix
[root@localhost ~]# sudo systemctl enable postfix
[root@localhost ~]# sudo systemctl start postfix
3.add源
//官方源安装,如果受不了它的速度可以跳过以下步骤,使用清华源安装
[root@localhost ~]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
[root@localhost ~]# sudo EXTERNAL_URL="http://192.168.10.217" yum install -y gitlab-ee
//使用清华源安装gitlab
[root@localhost ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm

三、GitLab管理

  • 基本配置
    [root@localhost ~]# vim /etc/gitlab/gitlab.rb
    external_url 'http://192.168.10.217'
    [root@localhost ~]# gitlab-ctl reconfigure        //重新刷新配置
    [root@localhost ~]# gitlab-ctl restart
    
  • 初始密码

    初始账户: root 密码: 5iveL!fe //密码根据自己的需求配置

  • 配置邮箱告警

    配置gitlab的邮箱的时候,一定要使用ssl,然后是465的邮箱端口,不然会出现发送不了的情况。

    [root@localhost ~]# cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bak
    [root@localhost ~]# vim /etc/gitlab/gitlab.rb
    添加如下内容:
    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp.sina.com"
    gitlab_rails['smtp_tls'] = true
    gitlab_rails['smtp_port'] = 465
    gitlab_rails['smtp_user_name'] = "xiangys_0134@sina.com"
    gitlab_rails['smtp_password'] = "123456"
    gitlab_rails['smtp_domain'] = "smtp.sina.com"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_openssl_verify_mode'] = 'none'
    
    gitlab_rails['gitlab_email_enabled'] = true
    gitlab_rails['gitlab_email_from'] = 'xiangys_0134@sina.com'
    gitlab_rails['gitlab_email_display_name'] = 'Gitlab'
    
    [root@localhost ~]# gitlab-ctl reconfigure    //重新刷新配置
    [root@localhost ~]# gitlab-ctl restart
    
  • 邮件测试
    [root@localhost ~]# gitlab-rails console
    irb(main):001:0> Notify.test_email('250919938@qq.com', '邮件标题', '邮件正文').deliver_now
    

四、备份还原

  • 创建备份目录
    [root@localhost ~]# mkdir /data/backups/gitlab -p
    [root@localhost ~]# chown -R git. /data/backups/gitlab
    
  • 修改配置文件
    [root@localhost ~]# vim  /etc/gitlab/gitlab.rb            //修改如下内容:
    gitlab_rails['backup_path'] = "/data/backups/gitlab"
    gitlab_rails['backup_keep_time'] = 604800
    
    [root@localhost ~]# gitlab-ctl reconfigure
    [root@localhost ~]# gitlab-ctl restart
    
  • 执行定时任务
    [root@localhost ~]# crontab -e
    */10 * * * * sudo -H -u root bash -c '/usr/bin/gitlab-rake gitlab:backup:create'
    
  • 获取到备份包
    [root@localhost ~]# ls /data/backups/gitlab -hrnt
    
  • 还原版本

    通过包恢复

    [root@localhost gitlab]# gitlab-rake gitlab:backup:restore BACKUP=1571120410_2019_10_15_12.3.5
    //1571120410_2019_10_15_12.3.5 表示版本号
    [root@localhost gitlab]# gitlab-ctl restart
    [root@localhost gitlab]# gitlab-rake gitlab:check SANITIZE=true
    
最后修改日期: 2019年10月15日

作者

留言

撰写回覆或留言

发布留言必须填写的电子邮件地址不会公开。