Skip to main content

gitlab설치

Gitlab 설치 가이드

  1. 설치파일 다운로드
    $ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
  2. Gitlab config 설정(변경이 필요한 사항만 기재)
     $> vi /etc/gitlab/gitlab.rb
    #################################################
    external_url 'http://{{서버IP}}:8080'
    
    gitlab_rails['artifacts_path'] = "/opt/gitlab/gitlab-rails/shared/artifacts"
    gitlab_rails['external_diffs_storage_path'] = "/opt/gitlab/gitlab-rails/shared/external-diffs"
    gitlab_rails['lfs_enabled'] = true
    gitlab_rails['lfs_storage_path'] = "/opt/gitlab/gitlab-rails/shared/lfs-objects"
    gitlab_rails['backup_path'] = "/opt/gitlab/backups"
    gitlab_rails['shared_path'] = '/opt/gitlab/gitlab-rails/shared'
    gitlab_rails['dir'] = "/opt/gitlab/gitlab-rails"
    gitlab_rails['uploads_directory'] = "/opt/gitlab/gitlab-rails/uploads"
    gitlab_rails['redis_socket'] = "/opt/gitlab/redis/redis.socket"
    gitlab_rails['registry_path'] = "/opt/gitlab/gitlab-rails/shared/registry"
    gitlab_rails['registry_key_path'] = "/opt/gitlab/gitlab-rails/certificate.key"
    
    registry['dir'] = "/opt/gitlab/registry"
    registry['rootcertbundle'] = "/opt/gitlab/registry/certificate.crt"
    
    gitlab_workhorse['listen_addr'] = "/opt/gitlab/gitlab-workhorse/socket"
    gitlab_workhorse['auth_backend'] = "http://localhost:8080"
    gitlab_workhorse['dir'] = "/opt/gitlab/gitlab-workhorse"
    
    user['home'] = "/opt/gitlab"
    
    unicorn['port'] = 8080
    unicorn['socket'] = '/opt/gitlab/gitlab-rails/sockets/gitlab.socket'
    
    puma['socket'] = '/opt/gitlab/gitlab-rails/sockets/gitlab.socket'
    
    gitlab_shell['auth_file'] = "/opt/gitlab/.ssh/authorized_keys"
    gitlab_shell['dir'] = "/opt/gitlab/gitlab-shell"
    
    postgresql['port'] = 25432
    postgresql['data_dir'] = "/opt/gitlab/postgresql/data"
    postgresql['shared_buffers'] = "3GB"
    postgresql['dir'] = "/opt/gitlab/postgresql"
    postgresql['home'] = "/opt/gitlab/postgresql"
    
    redis['enable'] = true
    redis['dir'] = "/opt/gitlab/redis"
    redis['maxclients'] = "20000"
    redis['maxmemory'] = "128m"
    redis['maxmemory_policy'] = "allkeys-lru"
    redis['maxmemory_samples'] = "5"
    redis['tcp_backlog'] = 511
    redis['tcp_timeout'] = "120"
    redis['tcp_keepalive'] = "300"
    
    web_server['home'] = '/opt/gitlab/nginx'
    nginx['dir'] = "/opt/gitlab/nginx"
    
    gitlab_pages['dir'] = "/opt/gitlab/gitlab-pages"
    
    gitlab_rails['pages_path'] = "/opt/gitlab/gitlab-rails/shared/pages"
    gitlab_ci['builds_directory'] = '/opt/gitlab/gitlab-ci/builds'
    
    mattermost['home'] = '/opt/gitlab/mattermost'
    mattermost['file_directory'] = "/opt/gitlab/mattermost/data"
    mattermost['plugin_directory'] = "/opt/gitlab/mattermost/plugins"
    mattermost['plugin_client_directory'] = "/opt/gitlab/mattermost/client-plugins"
    
    prometheus['home'] = '/opt/gitlab/prometheus'
    prometheus['log_directory'] = '/var/log/gitlab/prometheus'
    prometheus['rules_files'] = ['/opt/gitlab/prometheus/rules/*.rules']
     prometheus['flags'] = {
      'storage.tsdb.path' => "/opt/gitlab/prometheus/data",
      'storage.tsdb.retention.time' => "15d",
      'config.file' => "/opt/gitlab/prometheus/prometheus.yml"
    }
    
    alertmanager['home'] = '/opt/gitlab/alertmanager'
    alertmanager['flags'] = {
      'storage.path' => "/opt/gitlab/alertmanager/data",
      'config.file' => "/opt/gitlab/alertmanager/alertmanager.yml"
    }
    
    node_exporter['home'] = '/opt/gitlab/node-exporter'
     node_exporter['flags'] = {
      'collector.textfile.directory' => "/opt/gitlab/node-exporter/textfile_collector"
    }
    
     redis_exporter['flags'] = {
      'redis.addr' => "unix:///opt/gitlab/redis/redis.socket",
    }
    
    postgres_exporter['home'] = '/opt/gitlab/postgres-exporter'
    
    gitlab_exporter['home'] = "/opt/gitlab/gitlab-exporter"
    
    grafana['home'] = '/opt/gitlab/grafana'
    
    gitaly['dir'] = "/opt/gitlab/gitaly"
     gitaly['env'] = {
     'PATH' => "/opt/gitlab/bin:/opt/gitlab/embedded/bin:/bin:/usr/bin",
     'HOME' => '/opt/gitlab'
    }
     gitaly['socket_path'] = "/opt/gitlab/gitaly/gitaly.socket"
     gitaly['certificate_path'] = "/opt/gitlab/gitaly/certificate.pem"
     gitaly['key_path'] = "/opt/gitlab/gitaly/key.pem"
    
    storage_check['target'] = 'unix:///opt/gitlab/gitlab-rails/sockets/gitlab.socket'
    
    letsencrypt['wwwroot'] = '/opt/gitlab/nginx/www'
    
    gitlab_rails['packages_storage_path'] = "/opt/gitlab/gitlab-rails/shared/packages"
    gitlab_rails['dependency_proxy_storage_path'] = "/opt/gitlab/gitlab-rails/shared/dependency_proxy"
  3. Gitlab구성
    $> gitlab-ctl reconfigure
    ...
    $>  gitlab-ctl status
    run: alertmanager: (pid 53654) 128s; run: log: (pid 51389) 343s
    run: gitaly: (pid 53701) 127s; run: log: (pid 50464) 435s
    run: gitlab-exporter: (pid 53722) 127s; run: log: (pid 51157) 363s
    run: gitlab-workhorse: (pid 53725) 127s; run: log: (pid 50986) 382s
    run: grafana: (pid 53749) 126s; run: log: (pid 51725) 300s
    run: logrotate: (pid 53765) 126s; run: log: (pid 51079) 373s
    run: nginx: (pid 53773) 125s; run: log: (pid 51012) 381s
    run: node-exporter: (pid 53781) 125s; run: log: (pid 51118) 369s
    run: postgres-exporter: (pid 53788) 125s; run: log: (pid 51435) 339s
    run: postgresql: (pid 53874) 124s; run: log: (pid 50596) 428s
    run: prometheus: (pid 53883) 124s; run: log: (pid 51320) 349s
    run: redis: (pid 53898) 123s; run: log: (pid 50307) 457s
    run: redis-exporter: (pid 53973) 123s; run: log: (pid 51250) 357s
    run: sidekiq: (pid 53987) 120s; run: log: (pid 50943) 386s
    run: unicorn: (pid 53999) 119s; run: log: (pid 50895) 394s
  4. redis socket 파일 위치 변경 ( gitlab-ctl status 실행결과시 redis가 down되어 있는 경우 조치)
    $> vi /opt/gitlab/redis/redis.conf
    ...
    unixsocket /opt/gitlab/redis/redis.socket
    ...
  5. gitlab 재시작 후 상태 확인
    $> gitlab-ctl restart
    $> gitlab-ctl status
    run: alertmanager: (pid 13812) 32s; run: log: (pid 10837) 369s
    run: gitaly: (pid 13828) 31s; run: log: (pid 9829) 454s
    run: gitlab-exporter: (pid 13851) 31s; run: log: (pid 10641) 388s
    run: gitlab-workhorse: (pid 13862) 30s; run: log: (pid 10372) 410s
    run: grafana: (pid 13878) 30s; run: log: (pid 11193) 334s
    run: logrotate: (pid 13892) 30s; run: log: (pid 10493) 400s
    run: nginx: (pid 13898) 29s; run: log: (pid 10425) 406s
    run: node-exporter: (pid 13907) 29s; run: log: (pid 10532) 396s
    run: postgres-exporter: (pid 13990) 28s; run: log: (pid 10911) 364s
    run: postgresql: (pid 14000) 28s; run: log: (pid 9974) 446s
    run: prometheus: (pid 14009) 27s; run: log: (pid 10769) 376s
    run: redis: (pid 14024) 27s; run: log: (pid 9733) 460s
    run: redis-exporter: (pid 14031) 27s; run: log: (pid 10695) 382s
    run: sidekiq: (pid 14038) 26s; run: log: (pid 10323) 416s
    run: unicorn: (pid 14050) 25s; run: log: (pid 10280) 421s