来源:自学PHP网 时间:2020-09-17 11:13 作者:小飞侠 阅读:次
[导读] GitLab使用外部提供的Redis缓存数据库的方法详解...
缺省的情况下GitLab的官方镜像中提供了一个Redis,如果希望把此缓存数据库放在GitLab的容器之外的话需要怎么做呢?这篇文章结合示例进行说明具体的做法。 环境准备 配置文件:GitLab version: '2' services: # Version Control service: Gitlab gitlab: image: gitlab/gitlab-ce:12.10.5-ce.0 ports: - "35001:80" - "30022:22" - "443:443" volumes: - ./log/:/var/log/gitlab - ./data/:/var/opt/gitlab - ./conf/:/etc/gitlab restart: "no" 配置文件:Redis [root@liumiaocn redis]# cat docker-compose.yml version: '2' services: # redis master master: image: redis:5.0.9 container_name: redis restart: always command: redis-server --port 6379 ports: - 6379:6379 volumes: - ./data:/data [root@liumiaocn redis]# 启动命令
结果确认GitLab [root@liumiaocn gitlab]# docker-compose ps Name Command State Ports --------------------------------------------------------------------------------------------------------------------- gitlab_gitlab_1 /assets/wrapper Up (healthy) 0.0.0.0:30022->22/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:35001->80/tcp [root@liumiaocn gitlab]# Redis [root@liumiaocn redis]# docker-compose ps Name Command State Ports ----------------------------------------------------------------------- redis docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp [root@liumiaocn redis]# 使用外部Redis服务 步骤1: 设定gitlab.rb [root@liumiaocn redis]# docker exec -it gitlab_gitlab_1 sh # cd /etc/gitlab # ls gitlab-secrets.json ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key trusted-certs gitlab.rb ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub ssh_host_rsa_key.pub # cp -p gitlab.rb gitlab.rb.org # vi gitlab.rb # # diff gitlab.rb gitlab.rb.org 585,586c585,586 < gitlab_rails['redis_host'] = "192.168.163.151" < gitlab_rails['redis_port'] = 6379 --- > # gitlab_rails['redis_host'] = "127.0.0.1" > # gitlab_rails['redis_port'] = 6379 1049c1049 < redis['enable'] = false --- > # redis['enable'] = true # 步骤2: 验证连接 [root@liumiaocn redis]# docker exec -it gitlab_gitlab_1 sh # redis-cli -h 192.168.163.151 -p 6379 192.168.163.151:6379> ping PONG 192.168.163.151:6379> keys * (empty list or set) 192.168.163.151:6379> 步骤3: gitlab-ctl reconfigure
或者
执行日志示例如下所示: # gitlab-ctl reconfigure Starting Chef Client, version 14.14.29 resolving cookbooks for run list: ["gitlab"] Synchronizing Cookbooks: - package (0.1.0) - postgresql (0.1.0) - redis (0.1.0) - monitoring (0.1.0) - registry (0.1.0) - mattermost (0.1.0) - consul (0.1.0) - gitaly (0.1.0) - praefect (0.1.0) - letsencrypt (0.1.0) - nginx (0.1.0) - runit (4.3.0) - acme (4.1.1) - crond (0.1.0) - gitlab (0.0.1) Installing Cookbook Gems: Compiling Cookbooks... Recipe: gitlab::default ...省略 Recipe: monitoring::gitlab-exporter * runit_service[gitlab-exporter] action restart (up to date) Running handlers: Running handlers complete Chef Client finished, 14/654 resources updated in 03 minutes 13 seconds gitlab Reconfigured! # 注:虽然提示已经完成了,后续的处理一般还需要稍等,可根据docker logs命令获取的日志信息来以及docker ps返回的状态信息来确认是否真正结束。 步骤4 : 结果确认 登录之后可以正常进行root密码的重置 最新评论添加评论更多文章推荐
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习 京ICP备14009008号-1@版权所有www.zixuephp.com 网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com
添加评论 |