• gitlab


    docker 启动gitlab

    # docker search gitlab
    NAME                                         DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
    gitlab/gitlab-ce                             GitLab Community Edition docker image based …   2929                                    [OK]
    sameersbn/gitlab                             Dockerfile to build a GitLab image for the D…   1152                                    [OK]
    gitlab/gitlab-runner                         GitLab CI Multi Runner used to fetch and run…   614                                     [OK]
    twang2218/gitlab-ce-zh                       汉化的 GitLab 社区版 Docker Image                     219                                     [OK]
    
    # docker run -d -p 465:465 -p 8443:443 -p 19280:19280 -p 19222:22 --privileged=true --name gitlab --restart always
    -v /root/data/gitlab/config:/etc/gitlab
    -v /root/data/gitlab/logs:/var/log/gitlab
    -v /root/data/gitlab/data:/var/opt/gitlab
    twang2218/gitlab-ce-zh

    centos7安装gitlab

    添加gitlab源

    cat >/etc/yum.repos.d/gitlab-ce.repo <<EOF
    [gitlab-ce]
    name=gitlab-ce
    baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
    repo_gpgcheck=0
    gpgcheck=0
    enabled=1
    gpgkey=https://packages.gitlab.com/gpg.key
    EOF

    安装git工具包

    yum makecache
    yum -y install curl policycoreutils openssh-server openssh-clients postfix  cronie git wget patch
    systemctl restart postfix
    systemctl enable postfix
    #yum install gitlab-ce git    #自动安装最新版
    yum install gitlab-ce-12.3.5 git -y    #安装指定版本,我这里选用了v12.3.5

    加载配置

    确保80端口没有被占用
    # lsof -i:80
    
    修改配置文件
    # vim /etc/gitlab/gitlab.rb
    external_url 'http://gitlab.cnntp.cn'
    
    加载配置
    # gitlab-ctl reconfigure

    启动gitlab

    gitlab-ctl restart
    gitlab-ctl status

    开户访问web界面
    第一次访问,系统会要求重置新密码,管理员的用户名为root

    登录完成,点击右上角的Settings进行Preferences设置,在语言项选择中文,此时刷新后,可以看到标题和右侧的导航栏是变为中文的,但是具体的项目并没有中文显示,所以会变成中文+英文的LOW爆显示

    修改默认访问端口

    # gitlab-ctl stop
    
    # vim /etc/gitlab/gitlab.rb
    external_url 'http://192.168.0.138:12580'
    nginx['listen_port'] = 12580
    nginx['listen_https'] = false
    nginx['listen_addresses'] = ['*']
    unicorn['listen'] = '127.0.0.1'
    unicorn['port'] = 8088
    prometheus['listen_address'] = 'localhost:9099'
    
    # vim /var/opt/gitlab/gitlab-rails/etc/unicorn.rb
    listen "127.0.0.1:8088", :tcp_nopush => true
    
    # vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
      listen *:12580;
      server_name 192.168.0.138;
        set $http_host_with_default "192.168.0.138:12580";
    
    # vim /var/opt/gitlab/gitlab-shell/config.yml
    gitlab_url: "http://127.0.0.1:8088"
    
    # vim /var/opt/gitlab/gitlab-rails/etc/gitlab.yml
        host: 192.168.0.138
        port: 12580
        https: false
    
    重启查看日志
    gitlab-ctl reconfigure
    gitlab-rake gitlab:check SANITIZE=true --trace    #配置检查
    gitlab-ctl restart
    gitlab-ctl tail    #日志输出,可用于排错

    汉化gitlab

    https://gitlab.com/xhang/gitlab/tree/12-3-stable-zh#

    如果要下载指定版本的汉化包,命令如下:

    cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
    12.3.5
    wget https://gitlab.com/xhang/gitlab/-/archive/v12.3.5-zh/gitlab-v12.3.5-zh.tar.gz
    tar -zxf gitlab-v12.3.5-zh.tar.gz

    覆盖文件进行汉化

    汉化包和你的gitlab版本一定要一样

    # gitlab-ctl stop
    # cp -fr /opt/gitlab/embedded/service/gitlab-rails{,gao-`date +%Y%m%d`}
    # tar xf gitlab-v12.3.5-zh.tar.gz 
    # cp -rf ./gitlab-v12.3.5-zh/* /opt/gitlab/embedded/service/gitlab-rails/
    
    # gitlab-ctl reconfigure    
    # gitlab-ctl restart

    再次访问gitlab页面,就可以显示中文界面,如图:

    gitlab配置邮箱服务

    服务端配置

    cat >> /etc/gitlab/gitlab.rb<<EOF
    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp.163.com"
    gitlab_rails['smtp_port'] = 465
    gitlab_rails['smtp_user_name'] = "发件箱名.163.com"
    gitlab_rails['smtp_password'] = "授权码"
    gitlab_rails['smtp_domain'] = "163.com"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_tls'] = true
    gitlab_rails['gitlab_email_from'] = '发件箱名.163.com'
    user['git_user_email'] = "发件箱名.163.com"
    EOF

    测试发邮件

    # gitlab-rails console
    --------------------------------------------------------------------------------
     GitLab:       12.3.5 (2417d5becc7)
     GitLab Shell: 10.0.0
     PostgreSQL:   10.9
    --------------------------------------------------------------------------------
    Loading production environment (Rails 5.2.3)
    irb(main):001:0> Notify.test_email('56xxxxxxx@qq.com', '邮件标题', '邮件正文').deliver_now

    gitlab迁移

    备份原有服务器上gitlab数据信息:

    使用以下命令进行备份。
    /usr/bin/gitlab-rake gitlab:backup:create
    
    默认备份完成的文件存放目录为:/var/opt/gitlab/backups。若该目录下不存在,则需要查看/etc/gitlab/gitlab.rb配置中对应的gitlab_rails['backup_path']选项所指定的目录。

    将原有服务器上的gitlab配置文件、备份数据scp到新服务器的对应目录下:

    #scp gitlab仓库备份数据
    scp  /NFS/1533614595_2018_08_07_9.2.5_gitlab_backup.tar 
    
    #scp gitlab的配置文件
    scp /etc/gitlab/gitlab.rb xx.xx.xx.xx:/etc/gitlab/gitlab.rb
    scp /etc/gitlab/gitlab-secrets.json xx.xx.xx.xx:/etc/gitlab/gitlab-secrets.json

    在新服务器重新进行gitlab配置,同时进行数据恢复:

    gitlab-ctl reconfigure
    
    gitlab-rake gitlab:backup:restore BACKUP=1533614595_2018_08_07_9.2.5
    其中1533614595_2018_08_07_9.2.5对应的为gitlab备份tar包的版本号。
    
    保守起见,先进行gitlab-ctl reconfigure,然后启动服务。
    gitlab-ctl start
    gitlab更改默认nginx

    在gitlab.rb中修改为以下配置:

    #访问域名,域名请换成自己的实际域名
    external_url 'http://192.168.0.138:12580'
    gitlab_rails['trusted_proxies'] = ['127.0.0.1']
    
    #gitlab 数据存放位置
    #git_data_dir "/data/gitlab"
    #gitlab 附件上传位置
    #gitlab_rails['uploads_directory'] = "/data/gitlab/uploads"
    
    #gitlab 环境协议及访问地址
    ## 该地址将用在ngx 的 upstream 配置中,很重要,网上示例大多都写成了 server unix:/var/opt/gitlab/gitlab-workhorse/socket fail_timeout=0;实际报ngx 的 502 Bad Gateway 错误
    gitlab_workhorse['listen_network'] = "tcp"
    gitlab_workhorse['listen_addr'] = "127.0.0.1:8085"
    
    #gitlab 监听地址及端口
    unicorn['listen'] = '127.0.0.1'
    unicorn['port'] = 8088
    
    #扩展WEB服务(指现有nginx的)的LINUX启动用户,请根据实际环境配置
    web_server['external_users'] = ['nobody']
    
    #关闭自带的ngx
    nginx['enable'] = false

    使用单独的nginx配置gitlabserver.conf

    upstream gitlab-workhorse {
        #该处与gitlab 中的 gitlab_workhorse 一致
        server 127.0.0.1:8085;
    }
    
    server {
        listen 12580;
        #listen [::]:80 ipv6only=on default_server;
        server_name gitlab.68.com;
        server_tokens off; ## Don't show the nginx version number, a security best practice
        #return 301 https://$http_host$request_uri;
        location / {
            #proxy_pass http://gitlab.68.com:12580;
            proxy_pass http://gitlab-workhorse;
        }
        access_log /usr/local/openresty/nginx/logs/gitlab_access.log;
        error_log /usr/local/openresty/nginx/logs/gitlab_error.log;
    }

    重启 nginx、gitlab服务

    # gitlab-ctl restart
    # systemctl restart nginx.service
    
    访问可能出现报502。原因是nginx用户无法访问gitlab用户的socket文件。 重启gitlab需要重新授权
    # chmod -R o+x /var/opt/gitlab/gitlab-rails
  • 相关阅读:
    线程之同步函数
    selenium破解极验验证
    数据结构--树
    数据结构--线性表
    数据结构--栈
    数据结构--队列
    代理的初步理解
    javamail+ical4j发送会议提醒
    阿里云学习之IOT物联网套件(客户端与服务端的后台数据传输)
    位图数据结构原理分析总结
  • 原文地址:https://www.cnblogs.com/yuezhimi/p/13087013.html
Copyright © 2020-2023  润新知