GitLab使用外部提供的Redis缓存数据库的方法详解
缺省的情况下GitLab的官方镜像中提供了一个Redis,如果希望把此缓存数据库放在GitLab的容器之外的话需要怎么做呢?这篇文章结合示例进行说明具体的做法。
环境准备
配置文件:GitLab
version:'2' services: #VersionControlservice: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@liumiaocnredis]#catdocker-compose.yml version:'2' services: #redismaster master: image:redis:5.0.9 container_name:redis restart:always command:redis-server--port6379 ports: -6379:6379 volumes: -./data:/data [root@liumiaocnredis]#
启动命令
执行命令:docker-composeup-d
结果确认GitLab
[root@liumiaocngitlab]#docker-composeps NameCommandStatePorts --------------------------------------------------------------------------------------------------------------------- gitlab_gitlab_1/assets/wrapperUp(healthy)0.0.0.0:30022->22/tcp,0.0.0.0:443->443/tcp,0.0.0.0:35001->80/tcp [root@liumiaocngitlab]#
Redis
[root@liumiaocnredis]#docker-composeps NameCommandStatePorts ----------------------------------------------------------------------- redisdocker-entrypoint.shredis...Up0.0.0.0:6379->6379/tcp [root@liumiaocnredis]#
使用外部Redis服务
步骤1:设定gitlab.rb
[root@liumiaocnredis]#dockerexec-itgitlab_gitlab_1sh #cd/etc/gitlab #ls gitlab-secrets.jsonssh_host_ecdsa_keyssh_host_ed25519_keyssh_host_rsa_keytrusted-certs gitlab.rb ssh_host_ecdsa_key.pubssh_host_ed25519_key.pubssh_host_rsa_key.pub #cp-pgitlab.rbgitlab.rb.org #vigitlab.rb # #diffgitlab.rbgitlab.rb.org 585,586c585,586#gitlab_rails['redis_host']="127.0.0.1" >#gitlab_rails['redis_port']=6379 1049c1049 #redis['enable']=true #
步骤2:验证连接
[root@liumiaocnredis]#dockerexec-itgitlab_gitlab_1sh #redis-cli-h192.168.163.151-p6379 192.168.163.151:6379>ping PONG 192.168.163.151:6379>keys* (emptylistorset) 192.168.163.151:6379>
步骤3:gitlab-ctlreconfigure
执行命令:gitlab-ctlreconfigure
或者
执行命令:docker-composerestart
执行日志示例如下所示:
#gitlab-ctlreconfigure StartingChefClient,version14.14.29 resolvingcookbooksforrunlist:["gitlab"] SynchronizingCookbooks: -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) InstallingCookbookGems: CompilingCookbooks... Recipe:gitlab::default ...省略 Recipe:monitoring::gitlab-exporter *runit_service[gitlab-exporter]actionrestart(uptodate) Runninghandlers: Runninghandlerscomplete ChefClientfinished,14/654resourcesupdatedin03minutes13seconds gitlabReconfigured! #
注:虽然提示已经完成了,后续的处理一般还需要稍等,可根据dockerlogs命令获取的日志信息来以及dockerps返回的状态信息来确认是否真正结束。
步骤4:结果确认
登录之后可以正常进行root密码的重置
重置之后也可以使用新的密码正常登录
进入到GitLab容器中可以看到内置的Redis的服务已经不在运行了
[root@liumiaocngitlab]#dockerexec-itgitlab_gitlab_1sh #gitlab-ctlstatus run:alertmanager:(pid1629)714s;run:log:(pid972)1117s run:gitaly:(pid1609)718s;run:log:(pid462)1337s run:gitlab-exporter:(pid2412)671s;run:log:(pid893)1152s run:gitlab-workhorse:(pid2405)672s;run:log:(pid831)1183s run:grafana:(pid1644)713s;run:log:(pid1443)778s run:logrotate:(pid864)1167s;run:log:(pid873)1166s run:nginx:(pid846)1178s;run:log:(pid855)1177s run:postgres-exporter:(pid1638)713s;run:log:(pid1008)1103s run:postgresql:(pid498)1323s;run:log:(pid523)1322s run:prometheus:(pid1584)719s;run:log:(pid940)1130s run:sidekiq:(pid2399)672s;run:log:(pid811)1194s run:sshd:(pid30)1381s;run:log:(pid29)1381s run:unicorn:(pid3147)499s;run:log:(pid792)1203s #
连接外部的Redis服务即可可以看到相关的缓存数据内容了。
[root@liumiaocngitlab]#dockerexec-itredissh #redis-cli-h192.168.163.151-p6379 192.168.163.151:6379>ping PONG 192.168.163.151:6379>keys* 1)"resque:gitlab:cron_job:repository_check_worker" 2)"resque:gitlab:cron_job:container_expiration_policy_worker" 3)"resque:gitlab:cron_job:import_export_project_cleanup_worker" 4)"resque:gitlab:cron_job:container_expiration_policy_worker:enqueued" 5)"gitlab:exclusive_lease:user_update_tracked_fields:1" 6)"resque:gitlab:cron_job:pages_domain_verification_cron_worker" 7)"cache:gitlab:broadcast_message_current_banner_json" ...省略 94)"cache:gitlab:flipper/v1/feature/prometheus_metrics_measure_import_export_clean_up_cpu_duration" 95)"resque:gitlab:cron_job:remove_unreferenced_lfs_objects_worker:enqueued" 96)"resque:gitlab:cron_job:prune_old_events_worker:enqueued" 97)"cache:gitlab:flipper/v1/feature/soft_email_confirmation" 98)"session:gitlab:2::ad9aec16d58b972dc89d245757ab7b87b4fcb5c08b9fdcb4572be5ebe4807cba" 99)"resque:gitlab:queues" 192.168.163.151:6379>
总结
到此这篇关于GitLab:如何使用外部提供的Redis缓存数据库的文章就介绍到这了,更多相关gitlab使用外部Redis缓存数据库内容请搜索毛票票以前的文章或继续浏览下面的相关文章希望大家以后多多支持毛票票!
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。