美文网首页
gitlab安装配置

gitlab安装配置

作者: potenstop | 来源:发表于2019-06-10 10:44 被阅读0次

    环境

    os: ubuntu 18
    gitlab: 11.11.2

    1.首先是安装一些依赖服务

    sudo apt-get install curl openssh-server ca-certificates postfix
    

    2 官方推荐安装(因网络环境安装太慢)

    curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
    

    3 自己下载deb包安装

    下载地址: https://packages.gitlab.com/gitlab/gitlab-ce

    image.png
    下载时间会比较长 大概一个小时

    4 安装

    sudo dpkg -i gitlab-ce_11.11.2-ce.0_amd64.deb
    

    5 修改端口

    vi /etc/gitlab/gitlab.rb 修改下面两个
    nginx['listen_port'] = nil #默认值即80端口 修改为9091
    unicorn['port'] = 8080 #默认8080 修改为9092

    sudo gitlab-ctl reconfigure #重新加载配置
    sudo gitlab-ctl rerstart  #启动服务
    

    6 汉化

    下载汉化包 下载时间大概一个小时
    https://gitlab.com/xhang/gitlab/repository/11-11-stable-zh/archive.tar.bz2
    备份原有的代码 防止汉化失败

    tar -cf /opt/gitlab/embedded/service/gitlab-rails.tar /opt/gitlab/embedded/service/gitlab-rails
    

    上传到服务器

    tar jxvf gitlab-11-11-stable-zh.tar.bz2 
    cp -rf gitlab-11-11-stable-zh/*  /opt/gitlab/embedded/service/gitlab-rails/
    sudo gitlab-ctl reconfigure #重新加载配置
    sudo gitlab-ctl rerstart  #启动服务
    

    浏览器服务127.0.0.1:9091


    image.png

    7 设置root密码

    
    执行sudo gitlab-rails console production  开始重置密码
    找到root用户 u=User.where(id:1).first
    设置密码 u.password='123456'
    确认密码 u.password_confirmation='123456'
    保存 u.save!
    root@all-public:/tools# sudo gitlab-rails console production  
    -------------------------------------------------------------------------------------
     GitLab:       11.11.0 (0da38977aca)
     GitLab Shell: 9.1.0
     PostgreSQL:   9.6.11
    -------------------------------------------------------------------------------------
    Loading production environment (Rails 5.1.7)
    irb(main):001:0>  u=User.where(id:1).first
    => #<User id:1 @root>
    irb(main):002:0> u.password='123456'
    => "Wendi_1209"
    irb(main):003:0> u.password_confirmation='123456'
    => "Wendi_1209"
    irb(main):004:0> u.save!
    Enqueued ActionMailer::DeliveryJob (Job ID: 2985f6d5-214c-4348-aa4b-645d1bbdcc68) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", #<GlobalID:0x00007feca9fa1a20 @uri=#<URI::GID gid://gitlab/User/1>>
    => true
    irb(main):005:0> exit
    root@all-public:/tools# 
    

    8 集成ldap

    vim /etc/gitlab/gitlab.rb 追加以下配置 需要注意空格不能错行

    gitlab_rails['ldap_enabled'] = true
    ###! **remember to close this block with 'EOS' below**
    gitlab_rails['ldap_servers'] = YAML.load <<-'EOS' ###! **remember to close this block with 'EOS' below**
         main: # 'main' is the GitLab 'provider ID' of this LDAP server
           label: 'LDAP'
           host: '127.0.0.1'
           port: 389
           uid: 'uid'
           bind_dn: 'cn=admin,dc=domain,dc=com'
           password: '111111'
           encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
           verify_certificates: true
           active_directory: flase
           allow_username_or_email_login: true
           lowercase_usernames: false
           block_auto_created_users: false
           base: 'dc=domain,dc=com'
           user_filter: ''
    EOS
    

    配置解释
    host: 是搭建的ldap的ip,根据实际情况修改;
    uid: cn 那么就用cn对应的名登录 如果是uid 就用uid对应的名称登录 一般是uid
    bind_dn: ldap的管理员账号
    password: ldap的管理员
    encryption: ssl连接 如果ldap不是ssl则为plain
    verify_certificates: 10.0新增 如果使用加密方法,则启用SSL证书验证
    active_directory: 似乎是针对连接是否是ad域控的标示,因为这部分是ldap的配置,故为false
    allow_username_or_email_login: 用户登录是否用户名和邮箱都可以,方便用户故配置true
    lowercase_usernames: true 则用户名全被转换为小写
    block_auto_created_users: 严格控制GitLab安装上的活动用户数量
    base: 用户列表所在的目录

    sudo gitlab-ctl reconfigure #重新加载配置 
    sudo gitlab-rake gitlab:ldap:check  #手动检查ldap的配置
    sudo gitlab-ctl rerstart  #启动服务
    

    8 替换数据库为远程的PostgreSQL

    8.1 新建数据库

    CREATE DATABASE "gitlabhq_production" WITH ENCODING='UTF8' OWNER="gitlab" TEMPLATE="template1";
    
    
    

    8.2 修改配置

    vim /etc/gitlab/gitlab.rb 追加下面配置

    postgresql['enable'] = false
    gitlab_rails['db_adapter'] = "postgresql"
    gitlab_rails['db_encoding'] = "utf8"
    gitlab_rails['db_collation'] = nil
    gitlab_rails['db_database'] = "gitlabhq_production"
    gitlab_rails['db_pool'] = 10
    gitlab_rails['db_username'] = "postgresql"
    gitlab_rails['db_password'] = "123456"
    gitlab_rails['db_host'] = "192.168.1.50"
    gitlab_rails['db_port'] = 5432
    gitlab_rails['db_socket'] = nil
    gitlab_rails['db_sslmode'] = nil
    gitlab_rails['db_sslcompression'] = 0
    gitlab_rails['db_sslrootcert'] = nil
    gitlab_rails['db_prepared_statements'] = false
    gitlab_rails['db_statements_limit'] = 1000
    

    9 替换redis

    vim /etc/gitlab/gitlab.rb 追加下面配置

    redis['enable'] = false
    
    gitlab_rails['redis_host'] = "192.168.1.50"
    gitlab_rails['redis_port'] = 6379
    gitlab_rails['redis_ssl'] = false
    gitlab_rails['redis_password'] = "123456"
    gitlab_rails['redis_database'] = 10
    gitlab_rails['redis_enable_client'] = true
    

    卸载

    # 停止gitlab
    sudo gitlab-ctl stop
    
    # 查看进程
    ps -e | grep gitlab
    
    # 删除所有包含gitlab的文件及目录
    find / -name gitlab | xargs rm -rf
    
    # 卸载
    sudo apt-get remove gitlab-ce
    
    # 检查还有没有卸载的gitlab相关软件
    dpkg --get-selections | grep gitlab
    
    # 再执行
    sudo apt-get --purge remove gitlab-ce
    

    相关文章

      网友评论

          本文标题:gitlab安装配置

          本文链接:https://www.haomeiwen.com/subject/suwgxctx.html