GitLab使用外部提供的Redis緩存數(shù)據(jù)庫的方法詳解
缺省的情況下GitLab的官方鏡像中提供了一個Redis,如果希望把此緩存數(shù)據(jù)庫放在GitLab的容器之外的話需要怎么做呢?這篇文章結(jié)合示例進行說明具體的做法。
環(huán)境準(zhǔn)備
配置文件: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]#
啟動命令
執(zhí)行命令:docker-compose up -d
結(jié)果確認(rèn)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服務(wù)
步驟1: 設(shè)定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
執(zhí)行命令:gitlab-ctl reconfigure
或者
執(zhí)行命令:docker-compose restart
執(zhí)行日志示例如下所示:
# 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! #
注:雖然提示已經(jīng)完成了,后續(xù)的處理一般還需要稍等,可根據(jù)docker logs命令獲取的日志信息來以及docker ps返回的狀態(tài)信息來確認(rèn)是否真正結(jié)束。
步驟4 : 結(jié)果確認(rèn)
登錄之后可以正常進行root密碼的重置
重置之后也可以使用新的密碼正常登錄
進入到GitLab容器中可以看到內(nèi)置的Redis的服務(wù)已經(jīng)不在運行了
[root@liumiaocn gitlab]# docker exec -it gitlab_gitlab_1 sh # gitlab-ctl status run: alertmanager: (pid 1629) 714s; run: log: (pid 972) 1117s run: gitaly: (pid 1609) 718s; run: log: (pid 462) 1337s run: gitlab-exporter: (pid 2412) 671s; run: log: (pid 893) 1152s run: gitlab-workhorse: (pid 2405) 672s; run: log: (pid 831) 1183s run: grafana: (pid 1644) 713s; run: log: (pid 1443) 778s run: logrotate: (pid 864) 1167s; run: log: (pid 873) 1166s run: nginx: (pid 846) 1178s; run: log: (pid 855) 1177s run: postgres-exporter: (pid 1638) 713s; run: log: (pid 1008) 1103s run: postgresql: (pid 498) 1323s; run: log: (pid 523) 1322s run: prometheus: (pid 1584) 719s; run: log: (pid 940) 1130s run: sidekiq: (pid 2399) 672s; run: log: (pid 811) 1194s run: sshd: (pid 30) 1381s; run: log: (pid 29) 1381s run: unicorn: (pid 3147) 499s; run: log: (pid 792) 1203s #
連接外部的Redis服務(wù)即可可以看到相關(guān)的緩存數(shù)據(jù)內(nèi)容了。
[root@liumiaocn gitlab]# docker exec -it redis sh # redis-cli -h 192.168.163.151 -p 6379 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>
總結(jié)
到此這篇關(guān)于GitLab: 如何使用外部提供的Redis緩存數(shù)據(jù)庫的文章就介紹到這了,更多相關(guān)gitlab使用外部Redis緩存數(shù)據(jù)庫內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Redis數(shù)據(jù)庫基礎(chǔ)與ASP.NET?Core緩存實現(xiàn)
- 面試常問:如何保證Redis緩存和數(shù)據(jù)庫的數(shù)據(jù)一致性
- SpringBoot集成Redis數(shù)據(jù)庫,實現(xiàn)緩存管理
- 詳解redis緩存與數(shù)據(jù)庫一致性問題解決
- Spring AOP實現(xiàn)Redis緩存數(shù)據(jù)庫查詢源碼
- 詳解JavaEE 使用 Redis 數(shù)據(jù)庫進行內(nèi)容緩存和高訪問負(fù)載
- node.js利用redis數(shù)據(jù)庫緩存數(shù)據(jù)的方法
- redis緩存數(shù)據(jù)庫中數(shù)據(jù)的方法
相關(guān)文章
VSCode讓終端默認(rèn)在當(dāng)前文件的路徑啟動(方法推薦)
這篇文章主要介紹了VSCode中如何讓終端默認(rèn)在當(dāng)前文件的路徑啟動,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-03-03vscode?ssh遠(yuǎn)程連接服務(wù)器的思考淺析
這篇文章主要為大家介紹了vscode?ssh遠(yuǎn)程連接服務(wù)器的思考淺析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-02-02關(guān)于Unity動畫狀態(tài)機Animator使用教程
這篇文章主要介紹了關(guān)于Unity動畫狀態(tài)機Animator的使用教程,有需要的朋友可以借鑒參考下,希望可以對廣大讀者朋友能夠有所幫助2021-09-09Elasticsearch?在地理信息空間索引的探索和演進問題分析
本文梳理了Elasticsearch對于數(shù)值索引實現(xiàn)方案的升級和優(yōu)化思考,從2015年至今數(shù)值索引的方案經(jīng)歷了多個版本的迭代,實現(xiàn)思路從最初的字符串模擬到KD-Tree,技術(shù)越來越復(fù)雜,能力越來越強大,應(yīng)用場景也越來越豐富,感興趣的朋友跟隨小編一起看看吧2022-06-06unity下載并和vs2019關(guān)聯(lián)的步驟詳解
這篇文章主要介紹了unity下載并和vs2019關(guān)聯(lián)的步驟,文中通過圖文介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08提高github下載速度的方法可達(dá)到2MB/s(100%有效)
這篇文章主要介紹了提高github下載速度的方法可達(dá)到2MB/s(100%有效),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08