自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Harbor多實例高可用共享存儲搭建

系統(tǒng) Linux
Harbor 選擇在線部署,使用 docker-compose 部署,docker-compose 和 Docker 部署環(huán)境本文不在介紹,網(wǎng)上可以搜索到相關(guān)文檔。

[[399729]]

多實例共享存儲架構(gòu)圖


本文 LB 不使用 Nginx,使用阿里SLB。

本文架構(gòu)需要考慮三個問題

1、共享存儲的選取,Harbor的后端存儲目前支持AWS S3、Openstack Swift, Ceph等。本文使用阿里云極速性NAS,磁盤IO性能比單塊磁盤讀寫性能要好。使用 NFS V3 版本掛載。

2、Session 不能在不同的實例上共享,所以Harbor Redis 需要單獨部署,并且多個實例連接相同的Redis。

3、Harbor多實例數(shù)據(jù)庫問題,必須單獨部署一個數(shù)據(jù)庫,并且多個實例連接相同的數(shù)據(jù)庫。

注意:生產(chǎn)環(huán)境如果使用阿里云NAS,推薦使用 極速性NAS,不推薦使用 通用型NAS。

阿里云NAS性能參考文檔 https://help.aliyun.com/document_detail/124577.html?spm=a2c4g.11186623.6.552.2eb05ea0HJUgUB

部署資源

部署

Harbor 選擇在線部署,使用 docker-compose 部署,docker-compose 和 Docker 部署環(huán)境本文不在介紹,網(wǎng)上可以搜索到相關(guān)文檔。

1、掛載阿里云極速性NAS

harbor1 和 harbor2 機器都需要執(zhí)行掛載 NAS

配置開機自動掛載,打開 /etc/fstab 配置文件,添加掛載命令。

  1. # 創(chuàng)建 NAS 掛載目錄 
  2. $ mkdir /data 
  3.  
  4. # 提高同時發(fā)起的NFS請求數(shù)量 
  5. $ sudo echo "options sunrpc tcp_slot_table_entries=128" >>  /etc/modprobe.d/sunrpc.conf 
  6. $ sudo echo "options sunrpc tcp_max_slot_table_entries=128" >>  /etc/modprobe.d/sunrpc.conf 

掛載NFS v4文件系統(tǒng),添加以下命令:

  1. file-system-id.region.nas.aliyuncs.com:/ /data nfs vers=4,minorversion=0,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport 0 0 

如果您要掛載NFS v3文件系統(tǒng),添加以下命令:

  1. file-system-id.region.nas.aliyuncs.com:/ /data nfs vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport 0 0 

  1. # 在 /etc/fstab 配置文件添加好掛載,并執(zhí)行掛載 
  2. $ mount -a 
  3.  
  4. # 檢查掛載,如果結(jié)果中存在NFS文件系統(tǒng)的掛載地址,則說明掛載成功 
  5. $ df -h | grep aliyun 

2、臨時部署單機 Harbor

在 harbor1 機器上操作

  1. # 在線部署Harbor 
  2. $ cd /opt/ 
  3. $ wget https://github.com/goharbor/harbor/releases/download/v2.2.1/harbor-online-installer-v2.2.1.tgz 
  4. $ tar xf harbor-online-installer-v2.2.1.tgz 
  5. $ cd /opt/harbor 
  6. $ cp harbor.yml.tmpl harbor.yml 
  7.  
  8. # 創(chuàng)建harbor數(shù)據(jù)存儲 
  9. $ mkdir /data/harbor 
  10.  
  11. # 添加域名證書,已有域名SSL證書 
  12. $ mkdir /data/harbor/cert 
  13.  
  14. # 把SSL證書公鑰和私鑰上傳到 /data/harbor/cert 目錄中 
  15. $ scp harbor.example.pem root@192.168.10.10:/data/harbor/cert/ 
  16. $ scp harbor.example.key root@192.168.10.10:/data/harbor/cert/ 
  17.  
  18. # 配置 harbor.yml 文件,下面是修改后文件與原文件比較結(jié)果 
  19. $ diff harbor.yml harbor.yml.tmpl 
  20.  
  21. 5c5 
  22. < hostname: harbor.example.com 
  23. --- 
  24. > hostname: reg.mydomain.com 
  25. 17,18c17,18 
  26. <   certificate: /data/harbor/cert/harbor.example.pem 
  27. <   private_key: /data/harbor/cert/harbor.example.key 
  28. --- 
  29. >   certificate: /your/certificate/path 
  30. >   private_key: /your/private/key/path 
  31. 29c29 
  32. < external_url: https://harbor.example.com 
  33. --- 
  34. > # external_url: https://reg.mydomain.com:8433 
  35.  
  36. < data_volume: /data/harbor 
  37. --- 
  38. > data_volume: /data 
  39.  
  40. # 生成配置文件 
  41. $ cd /opt/harbor 
  42.  
  43. # harbor開啟helm charts 和 鏡像漏洞掃描 
  44. $ ./prepare --with-notary --with-trivy --with-chartmuseum 
  45.  
  46. # 安裝 
  47. $ ./install.sh --with-notary --with-trivy --with-chartmuseum 
  48.  
  49. # 查看 
  50. $ docker-compose ps 

3、單獨部署Harbor數(shù)據(jù)庫和Redis

  1. # 創(chuàng)建 postgres 和 redis 存儲目錄 
  2. $ mkdir -p /data/harbor-redis /data/harbor-postgresql 
  3.  
  4. # 修改所屬組 
  5. $ chown -R 999.999 /data/harbor-redis /data/harbor-postgresql 

  1. # 創(chuàng)建 postgres 和 redis docker-compose.yml 文件 
  2. $ vim docker-compose.yml 
  3.  
  4. version: '2.3' 
  5.  
  6. services: 
  7.   redis: 
  8.     image: goharbor/redis-photon:v2.2.1 
  9.     container_name: harbor-redis 
  10.     restart: always 
  11.     cap_drop: 
  12.       - ALL 
  13.     cap_add: 
  14.       - CHOWN 
  15.       - SETGID 
  16.       - SETUID 
  17.     volumes: 
  18.       - /data/harbor-redis:/var/lib/redis 
  19.     networks: 
  20.       - harbor-db 
  21.     ports: 
  22.       - 6379:6379 
  23.   postgresql: 
  24.     image: goharbor/harbor-db:v2.2.1 
  25.     container_name: harbor-postgresql 
  26.     restart: always 
  27.     cap_drop: 
  28.       - ALL 
  29.     cap_add: 
  30.       - CHOWN 
  31.       - DAC_OVERRIDE 
  32.       - SETGID 
  33.       - SETUID 
  34.     environment: 
  35.       POSTGRES_USER: postgres 
  36.       POSTGRES_PASSWORD: test2021 
  37.     volumes: 
  38.       - /data/harbor-postgresql:/var/lib/postgresql/data:z 
  39.     networks: 
  40.       - harbor-db 
  41.     ports: 
  42.       - 5432:5432 
  43.  
  44. networks: 
  45.  harbor-db: 
  46.    driver: bridge 
  47.  
  48. # 部署 postgres 和 redis 
  49. $ docker-compose up -d 

4、導(dǎo)入 postgres 數(shù)據(jù)

  1. # 進入臨時harbor-db容器導(dǎo)出相關(guān)表及數(shù)據(jù) 
  2. $ docker exec -it -u postgres harbor-db bash 
  3.  
  4. # 導(dǎo)出數(shù)據(jù) 
  5. $ pg_dump -U postgres registry > /tmp/registry.sql 
  6. $ pg_dump -U postgres notarysigner > /tmp/notarysigner.sql 
  7. $ pg_dump -U postgres notaryserver > /tmp/notaryserver.sql 
  8.  
  9. # 將數(shù)據(jù)導(dǎo)入單獨部署的PostgreSQL數(shù)據(jù)庫 
  10. $ psql -h 192.168.10.10 -U postgres registry -W < /tmp/registry.sql 
  11. $ psql -h 192.168.10.10 -U postgres notarysigner -W < /tmp/notarysigner.sql 
  12. $ psql -h 192.168.10.10 -U postgres notaryserver -W < /tmp/notaryserver.sql 

5、清理臨時部署單機Harbor數(shù)據(jù)和相關(guān)配置文件

  1. # 清理harbr數(shù)據(jù)和配置文件 
  2. $ cp -a /data/harbor/cert /tmp/ 
  3. $ rm -rf /data/harbor/* 
  4. $ rm -rf /opt/harbor 
  5. $ cp -a /tmp/cert /data/harbor/ 
  6.  
  7. # 重新創(chuàng)建配置文件 
  8. $ cd /opt/ 
  9. $ tar xf harbor-online-installer-v2.2.1.tgz 
  10. $ cd /opt/harbor 
  11.  
  12. # 修改配置文件,連接單獨部署postgres和redis,注釋harbor自帶的postgres和redis 
  13. $ cp harbor.yml.tmpl harbor.yml 
  14. $ diff harbor.yml harbor.yml.tmpl 
  15.  
  16. 5c5 
  17. < hostname: harbor.example.com 
  18. --- 
  19. > hostname: reg.mydomain.com 
  20. 17,18c17,18 
  21. <   certificate: /data/harbor/cert/harbor.example.pem 
  22. <   private_key: /data/harbor/cert/harbor.example.key 
  23. --- 
  24. >   certificate: /your/certificate/path 
  25. >   private_key: /your/private/key/path 
  26. 29c29 
  27. < external_url: https://harbor.example.com 
  28. --- 
  29. > # external_url: https://reg.mydomain.com:8433 
  30.  
  31. 37c37 
  32. < # database
  33. --- 
  34. database
  35. 39c39 
  36. <   # password: root123 
  37. --- 
  38. >   password: root123 
  39. 41c41 
  40. <   # max_idle_conns: 50 
  41. --- 
  42. >   max_idle_conns: 50 
  43. 44c44 
  44. <   # max_open_conns: 1000 
  45. --- 
  46. >   max_open_conns: 1000 
  47. 47c47 
  48.  
  49. < data_volume: /data/harbor 
  50. --- 
  51. > data_volume: /data 
  52.  
  53. 135,158c135,158 
  54. < external_database: 
  55. <   harbor: 
  56. <     host: 192.168.10.10 
  57. <     port: 5432 
  58. <     db_name: registry 
  59. <     username: postgres 
  60. <     password: test2021 
  61. <     ssl_mode: disable 
  62. <     max_idle_conns: 50 
  63. <     max_open_conns: 1000 
  64. <   notary_signer: 
  65. <     host: 192.168.10.10 
  66. <     port: 5432 
  67. <     db_name: notarysigner 
  68. <     username: postgres 
  69. <     password: test2021 
  70. <     ssl_mode: disable 
  71. <   notary_server: 
  72. <     host: 192.168.10.10 
  73. <     port: 5432 
  74. <     db_name: notaryserver 
  75. <     username: postgres 
  76. <     password: test2021 
  77. <     ssl_mode: disable 
  78. --- 
  79. > # external_database: 
  80. > #   harbor: 
  81. > #     host: harbor_db_host 
  82. > #     port: harbor_db_port 
  83. > #     db_name: harbor_db_name 
  84. > #     username: harbor_db_username 
  85. > #     password: harbor_db_password 
  86. > #     ssl_mode: disable 
  87. > #     max_idle_conns: 2 
  88. > #     max_open_conns: 0 
  89. > #   notary_signer: 
  90. > #     host: notary_signer_db_host 
  91. > #     port: notary_signer_db_port 
  92. > #     db_name: notary_signer_db_name 
  93. > #     username: notary_signer_db_username 
  94. > #     password: notary_signer_db_password 
  95. > #     ssl_mode: disable 
  96. > #   notary_server: 
  97. > #     host: notary_server_db_host 
  98. > #     port: notary_server_db_port 
  99. > #     db_name: notary_server_db_name 
  100. > #     username: notary_server_db_username 
  101. > #     password: notary_server_db_password 
  102. > #     ssl_mode: disable 
  103. 161,175c161,175 
  104. < external_redis: 
  105. <   # support redis, redis+sentinel 
  106. <   # host for redis: <host_redis>:<port_redis> 
  107. <   # host for redis+sentinel: 
  108. <   #  <host_sentinel1>:<port_sentinel1>,<host_sentinel2>:<port_sentinel2>,<host_sentinel3>:<port_sentinel3> 
  109. <   host: 192.168.10.10:6379 
  110. <   password
  111. <   # sentinel_master_set must be set to support redis+sentinel 
  112. <   #sentinel_master_set: 
  113. <   # db_index 0 is for core, it's unchangeable 
  114. <   registry_db_index: 1 
  115. <   jobservice_db_index: 2 
  116. <   chartmuseum_db_index: 3 
  117. <   trivy_db_index: 5 
  118. <   idle_timeout_seconds: 30 
  119. --- 
  120. > # external_redis: 
  121. > #   # support redis, redis+sentinel 
  122. > #   # host for redis: <host_redis>:<port_redis> 
  123. > #   # host for redis+sentinel: 
  124. > #   #  <host_sentinel1>:<port_sentinel1>,<host_sentinel2>:<port_sentinel2>,<host_sentinel3>:<port_sentinel3> 
  125. > #   host: redis:6379 
  126. > #   password
  127. > #   # sentinel_master_set must be set to support redis+sentinel 
  128. > #   #sentinel_master_set: 
  129. > #   # db_index 0 is for core, it's unchangeable 
  130. > #   registry_db_index: 1 
  131. > #   jobservice_db_index: 2 
  132. > #   chartmuseum_db_index: 3 
  133. > #   trivy_db_index: 5 
  134. > #   idle_timeout_seconds: 30 

  1. # 部署第一個節(jié)點 harbor 
  2. $ cd /opt/harbor 
  3.  
  4. # harbor開啟helm charts 和 鏡像漏洞掃描 
  5. $ ./prepare --with-notary --with-trivy --with-chartmuseum 
  6.  
  7. # 安裝 
  8. $ ./install.sh --with-notary --with-trivy --with-chartmuseum 
  9.  
  10. # 查看 
  11. $ docker-compose ps 
  12.  
  13. # 拷貝配置到 harbor2 機器上 
  14. $ scp -r /opt/harbor 192.168.10.11:/opt/ 

在 harbor2 機器上操作

  1. # 部署第二個節(jié)點 harbor 
  2. $ cd /opt/harbor 
  3.  
  4. # harbor開啟helm charts 和 鏡像漏洞掃描 
  5. $ ./prepare --with-notary --with-trivy --with-chartmuseum 
  6.  
  7. # 安裝 
  8. $ ./install.sh --with-notary --with-trivy --with-chartmuseum 
  9.  
  10. # 查看 
  11. $ docker-compose ps 

6、配置阿里云SLB

不具體介紹SLB配置方法,具體配置方法參考下面阿里云SLB配置文檔,配置 443端口,使用 TCP 協(xié)議,后端映射到兩臺 harbor1 和 harbor2 443端口上。

SLB配置方法請參考阿里云文檔 https://help.aliyun.com/document_detail/205495.html?spm=a2c4g.11174283.6.666.f9aa1192jngFKC

 

責(zé)任編輯:姜華 來源: YP小站
相關(guān)推薦

2014-10-09 10:04:23

CentOS集群

2017-11-13 11:07:32

Nginx搭建高可用

2020-10-28 07:10:07

Nginx高可用高并發(fā)

2019-11-27 16:34:00

配置

2020-07-24 08:50:17

Redis數(shù)據(jù)庫

2023-11-13 09:03:10

2018-11-30 12:11:11

Oracle存儲配置

2013-10-28 01:44:56

mysql載均衡高可用環(huán)境

2024-04-26 08:28:08

高可用存儲架構(gòu)

2018-05-25 09:31:00

數(shù)據(jù)存儲高可用

2023-05-24 08:14:55

2021-06-17 06:29:16

kube-vip Kubernetes開源項目

2019-10-09 16:02:16

NginxKeepalivedLvs

2012-02-22 10:13:43

虛擬化桌面虛擬化VMware View

2018-06-21 08:23:35

云存儲高可用應(yīng)用

2013-09-09 09:39:02

云數(shù)據(jù)庫京東云

2020-11-20 09:23:01

高可用異地淘寶

2012-11-19 11:05:01

實時遷移高可用性虛擬機遷移

2024-04-26 00:28:14

異地多活架構(gòu)
點贊
收藏

51CTO技術(shù)棧公眾號