zoukankan      html  css  js  c++  java
  • Centos6安装Gitlab

    安装

    参考 https://about.gitlab.com/downloads/ 可以从清华的镜像下载安装包, 注意区分自己用的是哪个发行版 https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/

    1. iptables打开80端口

    # Firewall configuration written by system-config-firewall
    # Manual customization of this file is not recommended.
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT

    2. 安装依赖包

    yum install curl openssh-server openssh-clients postfix cronie

    3. 启动postfix服务, 并设为默认开启

    service postfix start
    chkconfig postfix on

    4. 安装gitlab

    rpm -i gitlab-ce-8.10.2-ce.0.el6.x86_64.rpm 
    # 安装结束后初始化配置 gitlab
    gitlab-ctl reconfigure

    5. 访问后发现会重定向回 http://localhost, 需要修改external_url

    vi /etc/gitlab/gitlab.rb 
    # 然后修改 external_url 'http://192.168.11.22'
    # 然后reconfigure
    gitlab-ctl reconfigure

    安装就完成了

    备份

    查看/etc/gitlab/gitlab.rb里的配置信息

    # gitlab_rails['manage_backup_path'] = true
    # gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
    # gitlab_rails['backup_archive_permissions'] = 0644 # See: http://doc.gitlab.com/ce/raketasks/backup_restore.html#backup-archive-permissions
    # gitlab_rails['backup_pg_schema'] = 'public'
    # gitlab_rails['backup_keep_time'] = 604800

    这是默认的备份配置, 需要检查一下默认的备份路径是否存在, 以及owner是否是git. 创建备份的命令很简单, 就是

    gitlab-rake gitlab:backup:create

    会依次导出postgresql, repository 和 uploads, 然后打成一个压缩包

    初始安装的Ubuntu18.04上的命令记录

    # Add /dev/vdb1
    fdisk -l
    vi /etc/fstab # add /dev/vdb1 /data ext4 defaults 0 0
    
    # change hostname
    hostnamectl set-hostname n139
    /etc/hosts
    
    # change ssh port
    vi /etc/ssh/sshd_config 
    
    # Enable UFW
    ufw status verbose
    ufw enable
    ufw status verbose
    ufw app list
    
    # install gitlab
    curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
    vi /etc/apt/sources.list.d/gitlab-ce.list 
    # add line
    # deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu bionic main
    apt update
    apt install gitlab-ce
    
    # Add 80 port
    ufw allow http
    
    # change external url
    vi /etc/gitlab/gitlab.rb 
    # This will take a while
    gitlab-ctl reconfigure
    
    # Install docker
    apt install docker.io
    
    # Add user, you must add with -m and -s /bin/bash milton, this is a bit weird in Aliyun Ubuntu
    useradd milton -m
    ll /home/
    ll /home/milton/ -a
    usermod -s /bin/bash milton
    passwd milton
    usermod -aG docker milton
    
    systemctl status docker
    
    # Add mirror for docker
    vi /etc/docker/daemon.json
    ----- add content
    {
      "registry-mirrors": [
        "https://x9o4p9lt.mirror.aliyuncs.com/"
      ]
    }
    -----
    
    # Install gitlab runner https://docs.gitlab.com/runner/install/ and https://docs.gitlab.com/runner/install/linux-repository.html
    curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
    apt install gitlab-runner
    
    # Build runner images
    docker build -t ubuntu_xenial_runner:1.0 ubuntu_xenial/
    docker build -t ubuntu_bionic_runner:1.0 ubuntu_bionic/
    
    # Register a runner
    gitlab-ci-multi-runner register --non-interactive --url "http://172.17.54.19/" --registration-token "GaSKjBbMmQKgqm_QBxjb" --description "Ubuntu 16.04 build runner" --executor "docker" --docker-image "ubuntu_xenial_runner:1.0"
    
    gitlab-ci-multi-runner register --non-interactive --url "http://172.17.54.19/" --registration-token "GaSKjBbMmQKgqm_QBxjb" --description "Ubuntu 18.04 build runner" --executor "docker" --docker-image "ubuntu_bionic_runner:1.0"
    

    对应的Dockerfile和setup.sh

    from ubuntu:xenial
    ADD setup.sh /opt/
    RUN /bin/bash /opt/setup.sh
    

    .

    #!/bin/sh
    
    # change mirror
    echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted" > /etc/apt/sources.list
    echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted" >> /etc/apt/sources.list
    echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial universe" >> /etc/apt/sources.list
    echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates universe" >> /etc/apt/sources.list
    echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial multiverse" >> /etc/apt/sources.list
    echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates multiverse" >> /etc/apt/sources.list
    echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse" >> /etc/apt/sources.list
    echo "deb http://security.ubuntu.com/ubuntu xenial-security main restricted" >> /etc/apt/sources.list
    echo "deb http://security.ubuntu.com/ubuntu xenial-security universe" >> /etc/apt/sources.list
    echo "deb http://security.ubuntu.com/ubuntu xenial-security multiverse" >> /etc/apt/sources.list
    
    # requirements
    apt-get update
    apt-get -y install apt-transport-https git dh-make build-essential autoconf autotools-dev qt5-default libssl-dev qt5keychain-dev
    

    如果需要Gitlab Runner优先使用本地docker上的image, 需要修改其配置, 位于/etc/gitlab-runner/config.toml , 增加pull_policy = "if-not-present" 注意有双引号

    [[runners]]
      name = "Ubuntu 18.04 x64 runner"
      url = "http://172.17.54.19/"
      token = "UsJyRYap61AxbJ3pY_in"
      executor = "docker"
      [runners.custom_build_dir]
      [runners.cache]
        [runners.cache.s3]
        [runners.cache.gcs]
      [runners.docker]
        tls_verify = false
        image = "ubuntu_bionic_runner:1.0"
        privileged = false
        disable_entrypoint_overwrite = false
        oom_kill_disable = false
        disable_cache = false
        volumes = ["/cache"]
        shm_size = 0
        pull_policy = "if-not-present"
    

      

  • 相关阅读:
    java project 和 java web project 获取路径问题
    java.lang.UnsupportedClassVersionError: *** : Unsupported major.minor version 51.0
    Hibernate Annotation (Hibernate 注解)
    远程访问(post 传参数) 以及IOUtils复制文件
    使用jdk中keytool生成证书
    Chrome 的滚动条修改.
    https原理及tomcat配置https方法
    HttpClient 访问 https 出现peer can't
    Dom4j解析xml
    Tomcat Server 配置
  • 原文地址:https://www.cnblogs.com/milton/p/5727701.html
Copyright © 2011-2022 走看看