环境概述:

博主的gitlab环境为:
gitlab gitlab-ee:14.6.0-ee.0 采用docker部署
ci/cd:采用gitlab runner 和docker excutor方式
仅为博主遇到的一些问题记录,不一定适合你的环境,请谨慎操作。

问题一:编译docker镜像一直失败

$ export IMAGE_FULL_NAME=$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
$ echo "======== start build docker image ========"
======== start build docker image ========
$ docker build -t $IMAGE_FULL_NAME .
error during connect: Post "http://docker:2375/v1.24/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&t=10.182.225.33%3A8281%2Famblyopic%2test-project%3Adev-1495c883&target=&ulimits=null&version=1": dial tcp: lookup docker on 10.175.17.139:53: no such host
ERROR: Job failed: exit code 1

修改runner的配置文件解决:

  [runners.docker]
    tls_verify = false
    image = "10.255.255.33:8281/base/maven:3.6.0-jdk-8-alpine"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    //选择docker编译,下面一行比较重要,要不然会报错
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]  
    shm_size = 0

参考: https://www.cnblogs.com/xxred/p/11548254.html

问题二: 运行一段时间之后gitlab报500错误

gitlab采用docker部署之后运行一段时间之后提交代码会报502或者500错误。查看日志发现很多如下错误:

$ cat /var/log/gitlab/gitlab-rails/production.log

writing value to /dev/shm/gitlab/sidekiq/gauge_all_sidekiq_0-1.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/gauge_all_sidekiq_0-1.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/gauge_all_sidekiq_0-1.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/histogram_sidekiq_0-0.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/histogram_sidekiq_0-0.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/histogram_sidekiq_0-0.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/histogram_sidekiq_0-0.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/histogram_sidekiq_0-0.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/histogram_sidekiq_0-0.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/histogram_sidekiq_0-0.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/histogram_sidekiq_0-0.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/histogram_sidekiq_0-0.db failed with unmapped file
writing value to /dev/shm/gitlab/sidekiq/histogram_sidekiq_0-0.db failed with unmapped file
writing value to /dev/shm/gitlab/puma/histogram_puma_5-1.db failed with unmapped file
writing value to /dev/shm/gitlab/puma/histogram_puma_5-1.db failed with unmapped file
writing value to /dev/shm/gitlab/puma/histogram_puma_5-1.db failed with unmapped file
writing value to /dev/shm/gitlab/puma/histogram_puma_5-1.db failed with unmapped file
writing value to /dev/shm/gitlab/puma/histogram_puma_5-1.db failed with unmapped file
writing value to /dev/shm/gitlab/puma/histogram_puma_5-1.db failed with unmapped file
writing value to /dev/shm/gitlab/puma/histogram_puma_5-1.db failed with unmapped file
writing value to /dev/shm/gitlab/puma/histogram_puma_5-1.db failed with unmapped file
writing value to /dev/shm/gitlab/puma/histogram_puma_5-1.db failed with unmapped file

原因是 /dev/shm/小了无法存储所有的指标数据
修改docker-compose文件,将/dev/shm改大

version: '3.4'
services:
    gitlab:
      image: 'gitlab/gitlab-ee:14.6.0-ee.0'
      restart: unless-stopped
      hostname: 'gitlab'
       shm_size: '2gb' //比较重要,docker部署容易导致监控数据写入打满

参考: https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/5476

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐