Environment Build-Install Harbor Mirror Warehouse under CentOS

Keywords: Web Server Docker Vmware Nginx github

_harbor's Official Installation Guide This paper introduces three installation modes of harbor, which are online installation, offline installation and OVA installation. Due to the limitation of network environment, this paper mainly adopts offline installation.
_The official documents above indicate that you need to rely on Python 2.7 or more, Docker engine 1.10 or more, and Docker Compose 1.6.0 or more.
_CentOS 7.2 comes with Python 2.7.5

Python version.png

Docker has also been installed in advance:
Docker version.png

_So there's still a need to install Docker Compose

Install Docker Compose

Download Docker Compose

Download version 1.21.2 of Docker Compose. Reference document

sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
docker-compose.png
Modify docker-compose as an executable file:
chmod +x docker-compose
image.png
_Testing for Successful Installation

_Run the command [docker-compose version] to test whether the installation was successful:
Test.png

Install Harbor

Download offline installation packages

In the presence of GitHub Find the download address and download it. I downloaded version 1.5.1 here. The whole file is more than 800MB:

image.png

_decompression installation package
tar xvf harbor-offline-installer-v1.5.1.tgz
image.png
_Modify configuration file [harbor.cfg]
vi harbor.cfg

The necessary parameters are:

  1. hostname: The host name of the target host for accessing the UI and registering services. You can't use localhost and 127.0.0.1 because harbor needs to be accessed by an external client. I changed the IP address here.
    hostname.png
  2. ui_url_protocol: A protocol for accessing UI and token/notification services, default to http. If SSL authentication is enabled on Nginx, it can be set to https. The default http I use here is http.
    ui_url_protocol.png
  3. max_job_workers: The maximum number of replicated workers in the job service, which is written by default here, is 50. Considering the performance of my server, I changed it to 5 here.
    max_job_workers.png
  4. customize_crt: Set to on, the prepare script creates the private key and root certificate for generating/verifying registry tokens. If set to off, the key and root certificate will be provided by an external source. I set on.
    customize_crt.png
  5. ssl_cert: The location of the SSL certificate, which takes effect only when the protocol is set to https.
  6. ssl_cert_key: The location of the SSL key, which takes effect only when the protocol is set to https.
  7. Seckey_path: The path where the password is stored. It's better not to change it here. Otherwise, there will be an error later. I changed it to [/data/admin/].
    secretkey_path.png
  8. log_rotate_count: The number of log files that are retained and the previous logs are deleted iteratively when the maximum value is reached.
  9. log_rotate_size: In order to save space, I set up a maximum of five logs, each up to 200 MB.
    log.png
  10. db_password: The root password of MySQL database for DB authentication.
_Run [prepare] Update parameters
./prepare
prepare.png
_Start Installation

_Execute [install.sh] for installation

[root@localhost harbor]# ./install.sh 

[Step 0]: checking installation environment ...

Note: docker version: 17.03.2

Note: docker-compose version: 1.21.2

[Step 1]: loading Harbor images ...
52ef9064d2e4: Loading layer [==================================================>] 135.9 MB/135.9 MB
4a6862dbadda: Loading layer [==================================================>] 23.25 MB/23.25 MB
58b7d0c522b2: Loading layer [==================================================>]  24.4 MB/24.4 MB
9cd4bb748634: Loading layer [==================================================>] 7.168 kB/7.168 kB
c81302a14908: Loading layer [==================================================>] 10.56 MB/10.56 MB
7848e9ba72a3: Loading layer [==================================================>] 24.39 MB/24.39 MB
Loaded image: vmware/harbor-ui:v1.5.1
f1691b5a5198: Loading layer [==================================================>] 73.15 MB/73.15 MB
a529013c99e4: Loading layer [==================================================>] 3.584 kB/3.584 kB
d9b4853cff8b: Loading layer [==================================================>] 3.072 kB/3.072 kB
3d305073979e: Loading layer [==================================================>] 4.096 kB/4.096 kB
c9e17074f54a: Loading layer [==================================================>] 3.584 kB/3.584 kB
956055840e30: Loading layer [==================================================>] 9.728 kB/9.728 kB
Loaded image: vmware/harbor-log:v1.5.1
185db06a02d0: Loading layer [==================================================>] 23.25 MB/23.25 MB
835213979c70: Loading layer [==================================================>]  20.9 MB/20.9 MB
f74eeb41c1c9: Loading layer [==================================================>]  20.9 MB/20.9 MB
Loaded image: vmware/harbor-jobservice:v1.5.1
9bd5c7468774: Loading layer [==================================================>] 23.25 MB/23.25 MB
5fa6889b9a6d: Loading layer [==================================================>]  2.56 kB/2.56 kB
bd3ac235b209: Loading layer [==================================================>]  2.56 kB/2.56 kB
cb5d493833cc: Loading layer [==================================================>] 2.048 kB/2.048 kB
557669a074de: Loading layer [==================================================>]  22.8 MB/22.8 MB
f02b4f30a9ac: Loading layer [==================================================>]  22.8 MB/22.8 MB
Loaded image: vmware/registry-photon:v2.6.2-v1.5.1
5d3b562db23e: Loading layer [==================================================>] 23.25 MB/23.25 MB
8edca1b0e3b0: Loading layer [==================================================>] 12.16 MB/12.16 MB
ce5f11ea46c0: Loading layer [==================================================>]  17.3 MB/17.3 MB
93750d7ec363: Loading layer [==================================================>] 15.87 kB/15.87 kB
36f81937e80d: Loading layer [==================================================>] 3.072 kB/3.072 kB
37e5df92b624: Loading layer [==================================================>] 29.46 MB/29.46 MB
Loaded image: vmware/notary-server-photon:v0.5.1-v1.5.1
0a2f8f90bd3a: Loading layer [==================================================>] 401.3 MB/401.3 MB
41fca4deb6bf: Loading layer [==================================================>] 9.216 kB/9.216 kB
f2e28262e760: Loading layer [==================================================>] 9.216 kB/9.216 kB
68677196e356: Loading layer [==================================================>]  7.68 kB/7.68 kB
2b006714574e: Loading layer [==================================================>] 1.536 kB/1.536 kB
Loaded image: vmware/mariadb-photon:v1.5.1
a8c4992c632e: Loading layer [==================================================>] 156.3 MB/156.3 MB
0f37bf842677: Loading layer [==================================================>] 10.75 MB/10.75 MB
9f34c0cd38bf: Loading layer [==================================================>] 2.048 kB/2.048 kB
91ca17ca7e16: Loading layer [==================================================>] 48.13 kB/48.13 kB
5a7e0da65127: Loading layer [==================================================>]  10.8 MB/10.8 MB
Loaded image: vmware/clair-photon:v2.0.1-v1.5.1
0e782fe069e7: Loading layer [==================================================>] 23.25 MB/23.25 MB
67fc1e2f7009: Loading layer [==================================================>] 15.36 MB/15.36 MB
8db2141aa82c: Loading layer [==================================================>] 15.36 MB/15.36 MB
Loaded image: vmware/harbor-adminserver:v1.5.1
3f87a34f553c: Loading layer [==================================================>] 4.772 MB/4.772 MB
Loaded image: vmware/nginx-photon:v1.5.1
Loaded image: vmware/photon:1.0
ad58f3ddcb1b: Loading layer [==================================================>] 10.95 MB/10.95 MB
9b50f12509bf: Loading layer [==================================================>]  17.3 MB/17.3 MB
2c21090fd212: Loading layer [==================================================>] 15.87 kB/15.87 kB
38bec864f23e: Loading layer [==================================================>] 3.072 kB/3.072 kB
6e81ea7b0fa6: Loading layer [==================================================>] 28.24 MB/28.24 MB
Loaded image: vmware/notary-signer-photon:v0.5.1-v1.5.1
897a26fa09cb: Loading layer [==================================================>] 95.02 MB/95.02 MB
16e3a10a21ba: Loading layer [==================================================>] 6.656 kB/6.656 kB
85ecac164331: Loading layer [==================================================>] 2.048 kB/2.048 kB
37a2fb188706: Loading layer [==================================================>]  7.68 kB/7.68 kB
Loaded image: vmware/postgresql-photon:v1.5.1
bed9f52be1d1: Loading layer [==================================================>] 11.78 kB/11.78 kB
d731f2986f6e: Loading layer [==================================================>]  2.56 kB/2.56 kB
c3fde9a69f96: Loading layer [==================================================>] 3.072 kB/3.072 kB
Loaded image: vmware/harbor-db:v1.5.1
7844feb13ef3: Loading layer [==================================================>] 78.68 MB/78.68 MB
de0fd8aae388: Loading layer [==================================================>] 3.072 kB/3.072 kB
3f79efb720fd: Loading layer [==================================================>]  59.9 kB/59.9 kB
1c02f801c2e8: Loading layer [==================================================>] 61.95 kB/61.95 kB
Loaded image: vmware/redis-photon:v1.5.1
454c81edbd3b: Loading layer [==================================================>] 135.2 MB/135.2 MB
e99db1275091: Loading layer [==================================================>] 395.4 MB/395.4 MB
051e4ee23882: Loading layer [==================================================>] 9.216 kB/9.216 kB
6cca4437b6f6: Loading layer [==================================================>] 9.216 kB/9.216 kB
1d48fc08c8bc: Loading layer [==================================================>]  7.68 kB/7.68 kB
0419724fd942: Loading layer [==================================================>] 1.536 kB/1.536 kB
543c0c1ee18d: Loading layer [==================================================>] 655.2 MB/655.2 MB
4190aa7e89b8: Loading layer [==================================================>] 103.9 kB/103.9 kB
Loaded image: vmware/harbor-migrator:v1.5.0


[Step 2]: preparing environment ...
Clearing the configuration file: ./common/config/adminserver/env
Clearing the configuration file: ./common/config/ui/env
Clearing the configuration file: ./common/config/ui/app.conf
Clearing the configuration file: ./common/config/ui/private_key.pem
Clearing the configuration file: ./common/config/db/env
Clearing the configuration file: ./common/config/jobservice/env
Clearing the configuration file: ./common/config/jobservice/config.yml
Clearing the configuration file: ./common/config/registry/config.yml
Clearing the configuration file: ./common/config/registry/root.crt
Clearing the configuration file: ./common/config/nginx/nginx.conf
Clearing the configuration file: ./common/config/log/logrotate.conf
loaded secret from file: /data/admin/secretkey
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/adminserver/env
Generated configuration file: ./common/config/ui/env
Generated configuration file: ./common/config/registry/config.yml
Generated configuration file: ./common/config/db/env
Generated configuration file: ./common/config/jobservice/env
Generated configuration file: ./common/config/jobservice/config.yml
Generated configuration file: ./common/config/log/logrotate.conf
Generated configuration file: ./common/config/jobservice/config.yml
Generated configuration file: ./common/config/ui/app.conf
Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.


[Step 3]: checking existing instance of Harbor ...


[Step 4]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating harbor-db          ... done
Creating redis              ... done
Creating registry           ... done
Creating harbor-adminserver ... done
Creating harbor-ui          ... done
Creating harbor-jobservice  ... done
Creating nginx              ... done

 ----Harbor has been installed and started successfully.----

Now you should be able to visit the admin portal at http://192.168.242.132 . 
For more details, please visit https://github.com/vmware/harbor .

Installation completed, visit http://192.168.242.132 to try, 502 error, why?


502.png

_looks at the container through the command [docker ps], and finds that there are eight containers, of which the harbor-adminserver node has been in the Restarting state.
Container.png

View adminserver's log

tail -n 50 /var/log/harbor/adminserver.log

See the following error: failed to initialize the system: read/etc/adminserver/key: is a directory
image.png

_This is because the setting of secretkey in [usr/local/harbor/docker-compose.yml] is different from that of [harbor.cfg], [docker-compose.yml]:
docker-compose.yml.png

_Change the secretkey_path in [harbor.cfg] back to [data], then execute the docker-compose down, stop and delete all containers.
image.png

_Then delete the directory [data/secretkey]

rm -rf /data/secretkey

Rerun [prepare]

./prepare
image.png

Finally, create the container and start it up

docker-compose up –d
image.png

_Re-run [docker ps] to see the state of the container


image.png

It's all right. Visit [http://192.168.242.132] and see if you can make a normal visit:


image.png

_Log in with admin account
image.png

_Successful construction.

Posted by bfuzze_98 on Sun, 03 Feb 2019 03:24:15 -0800