服务器信息
Model:Dell PowerEdge R730xd |
部署Harbor先决条件
Python should be version 2.7 or higher
Centos 7 Python版本默认Python 2.7.5,满足条件,跳过Docker engine should be version 1.10 or higher(https://docs.docker.com/engine/installation/)
vim /etc/yum.repos.d/docker.repo |
- Docker Compose needs to be version 1.6.0 or higher(https://docs.docker.com/compose/install/)
curl -L "https://github.com/docker/compose/releases/download/1.10.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose |
开始部署Harbor
下载Harbor最新版本
https://github.com/vmware/harbor/releases/download/0.5.0/harbor-offline-installer-0.5.0.tgz
#本次采用离线安装包安装 |
解压安装包cd /opt/tuniu/docker
tar zxvf harbor-offline-installer-0.5.0.tgz
创建相关目录mkdir -p /opt/tuniu/docker/harbor/{ssl,data,logs}
拷贝证书至SSL目录ll /opt/tuniu/docker/harbor/ssl/
-r-------- 1 root root 3766 Jan 25 13:47 tuniu.io.crt
-r-------- 1 root root 1679 Jan 25 13:47 tuniu.io.key
拷贝旧版本Harbor数据至data、log目录vim /opt/tuniu/docker/harbor/Deploy/docker-compose.yml (10.10.10.150)

拷贝registry、mysql对应数据至10.40.191.176:/opt/tuniu/docker/harbor/data/目录
拷贝logd对应数据至10.40.191.176:/opt/tuniu/docker/harbor/logs/目录
[root@harbor-hx-191-176 docker]# ll /opt/tuniu/docker/harbor/data/ |
数据库表升级
https://github.com/vmware/harbor/blob/master/docs/migration_guide.md
下载官方迁移工具docker pull vmware/harbor-db-migrator
docker run -ti --rm -e DB_USR=root -e DB_PWD=root123 -v /opt/tuniu/docker/harbor/data/database/:/var/lib/mysql vmware/harbor-db-migrator up head
Please backup before upgrade.
Enter y to continue updating or n to abort:y
Trying to start mysql server...
MySQL Community Server 5.6.33 is not running.
2017-01-25 08:42:16 0 [Note] mysqld (mysqld 5.6.33) starting as process 7 ...
2017-01-25 08:42:17 7 [Note] Plugin 'FEDERATED' is disabled.
2017-01-25 08:42:17 7 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-01-25 08:42:17 7 [Note] InnoDB: The InnoDB memory heap is disabled
2017-01-25 08:42:17 7 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-01-25 08:42:17 7 [Note] InnoDB: Memory barrier is not used
2017-01-25 08:42:17 7 [Note] InnoDB: Compressed tables use zlib 1.2.8
2017-01-25 08:42:17 7 [Note] InnoDB: Using Linux native AIO
2017-01-25 08:42:17 7 [Note] InnoDB: Using CPU crc32 instructions
2017-01-25 08:42:17 7 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-01-25 08:42:17 7 [Note] InnoDB: Completed initialization of buffer pool
2017-01-25 08:42:17 7 [Note] InnoDB: Highest supported file format is Barracuda.
2017-01-25 08:42:17 7 [Note] InnoDB: Log scan progressed past the checkpoint lsn 27680688
2017-01-25 08:42:17 7 [Note] InnoDB: Database was not shutdown normally!
2017-01-25 08:42:17 7 [Note] InnoDB: Starting crash recovery.
2017-01-25 08:42:17 7 [Note] InnoDB: Reading tablespace information from the .ibd files...
2017-01-25 08:42:17 7 [Note] InnoDB: Restoring possible half-written data pages
2017-01-25 08:42:17 7 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Doing recovery: scanned up to log sequence number 27680698
2017-01-25 08:42:17 7 [Note] InnoDB: 128 rollback segment(s) are active.
2017-01-25 08:42:17 7 [Note] InnoDB: Waiting for purge to start
2017-01-25 08:42:17 7 [Note] InnoDB: 5.6.33 started; log sequence number 27680698
2017-01-25 08:42:17 7 [Note] Server hostname (bind-address): '*'; port: 3306
2017-01-25 08:42:17 7 [Note] IPv6 is available.
2017-01-25 08:42:17 7 [Note] - '::' resolves to '::';
2017-01-25 08:42:17 7 [Note] Server socket created on IP: '::'.
2017-01-25 08:42:17 7 [Warning] 'proxies_priv' entry '@ root@b55fac88ee06' ignored in --skip-name-resolve mode.
2017-01-25 08:42:17 7 [Note] Event Scheduler: Loaded 0 events
2017-01-25 08:42:17 7 [Note] mysqld: ready for connections.
Version: '5.6.33' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
MySQL Community Server 5.6.33 is running.
Performing upgrade head...
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Upgrade performed.
配置docker-compose.ymlvim /opt/tuniu/docker/harbor/docker-compose.yml
version: '2'
services:
log:
image: vmware/harbor-log:0.5.0
container_name: harbor-log
restart: always
volumes:
- /opt/tuniu/docker/harbor/logs/harbor/:/var/log/docker/
ports:
- 1514:514
registry:
image: library/registry:2.5.0
container_name: registry
restart: always
volumes:
- /opt/tuniu/docker/harbor/data/registry:/storage
- ./common/config/registry/:/etc/registry/
environment:
- GODEBUG=netdns=cgo
command:
["serve", "/etc/registry/config.yml"]
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "registry"
mysql:
image: vmware/harbor-db:0.5.0
container_name: harbor-db
restart: always
volumes:
- /opt/tuniu/docker/harbor/data/database:/var/lib/mysql
env_file:
- ./common/config/db/env
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "mysql"
ui:
image: vmware/harbor-ui:0.5.0
container_name: harbor-ui
env_file:
- ./common/config/ui/env
restart: always
volumes:
- ./common/config/ui/app.conf:/etc/ui/app.conf
- ./common/config/ui/private_key.pem:/etc/ui/private_key.pem
- /opt/tuniu/docker/harbor/data/ui:/harbor_storage
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "ui"
jobservice:
image: vmware/harbor-jobservice:0.5.0
container_name: harbor-jobservice
env_file:
- ./common/config/jobservice/env
restart: always
volumes:
- /opt/tuniu/docker/harbor/data/job_logs:/var/log/jobs
- ./common/config/jobservice/app.conf:/etc/jobservice/app.conf
depends_on:
- ui
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "jobservice"
proxy:
image: nginx:1.11.5
container_name: nginx
restart: always
volumes:
- ./common/config/nginx:/etc/nginx
ports:
- 80:80
- 443:443
depends_on:
- mysql
- registry
- ui
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "proxy"
```
<i class="fa fa-angle-double-right fa-lg"></i> 配置harbor.cfg
``` bash
vim /opt/tuniu/docker/harbor/harbor.cfg
## Configuration file of Harbor
#The IP address or hostname to access admin UI and registry service.
#DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname = tcr.tuniu.io
#The protocol for accessing the UI and token/notification service, by default it is http.
#It can be set to https if ssl is enabled on nginx.
ui_url_protocol = https
#Email account settings for sending out password resetting emails.
#Email server uses the given username and password to authenticate on TLS connections to host and act as identity.
#Identity left blank to act as username.
email_identity = Mail Config
email_server = xxxxx.tuniu.com
email_server_port = 25
email_username = xxxxx@tuniu.com
email_password = xxxxx
email_from = xxxxx@tuniu.com
email_ssl = false
##The initial password of Harbor admin, only works for the first time when Harbor starts.
#It has no effect after the first launch of Harbor.
#Change the admin password from UI after launching Harbor.
harbor_admin_password = XXXXX
##By default the auth mode is db_auth, i.e. the credentials are stored in a local database.
#Set it to ldap_auth if you want to verify a user's credentials against an LDAP server.
auth_mode = ldap_auth
#The url for an ldap endpoint.
ldap_url = ldaps://ldap.tuniu.org
#A user's DN who has the permission to search the LDAP/AD server.
#If your LDAP/AD server does not support anonymous search, you should configure this DN and ldap_search_pwd.
ldap_searchdn = cn=xxxxx,ou=应用账号(启用),ou=途牛服务账户,dc=tuniu-inc,dc=com
#the password of the ldap_searchdn
ldap_search_pwd = xxxxxxx
#The base DN from which to look up a user in LDAP/AD
ldap_basedn = ou=途牛用户账户,dc=tuniu-inc,dc=com
#Search filter for LDAP/AD, make sure the syntax of the filter is correct.
#ldap_filter = (objectClass=person)
# The attribute used in a search to match a user, it could be uid, cn, email, sAMAccountName or other attributes depending on your LDAP/AD
ldap_uid = sAMAccountName
#the scope to search for users, 1-LDAP_SCOPE_BASE, 2-LDAP_SCOPE_ONELEVEL, 3-LDAP_SCOPE_SUBTREE
ldap_scope = 3
#The password for the root user of mysql db, change this before any production use.
db_password = root123
#Turn on or off the self-registration feature
self_registration = on
#Determine whether the UI should use compressed js files.
#For production, set it to on. For development, set it to off.
use_compressed_js = on
#Maximum number of job workers in job service
max_job_workers = 3
#The expiration time (in minute) of token created by token service, default is 30 minutes
token_expiration = 30
#Determine whether the job service should verify the ssl cert when it connects to a remote registry.
#Set this flag to off when the remote registry uses a self-signed or untrusted certificate.
verify_remote_cert = on
#Determine whether or not to generate certificate for the registry's token.
#If the value is on, the prepare script creates new root cert and private key
#for generating token to access the registry. If the value is off, a key/certificate must
#be supplied for token generation.
customize_crt = on
#Information of your organization for certificate
crt_country = CN
crt_state = State
crt_location = CN
crt_organization = organization
crt_organizationalunit = organizational unit
crt_commonname = example.com
crt_email = example@example.com
#The flag to control what users have permission to create projects
#Be default everyone can create a project, set to "adminonly" such that only admin can create project.
project_creation_restriction = everyone
#The path of cert and key files for nginx, they are applied only the protocol is set to https
ssl_cert = /opt/tuniu/docker/harbor/ssl/tuniu.io.crt
ssl_cert_key = /opt/tuniu/docker/harbor/ssl/tuniu.io.key
#############
初始化配置文件[root@harbor-hx-191-176 harbor]# /opt/tuniu/docker/harbor/prepare
generated and saved secret key
Generated configuration file: /opt/tuniu/docker/harbor/common/config/nginx/nginx.conf
Generated configuration file: /opt/tuniu/docker/harbor/common/config/ui/env
Generated configuration file: /opt/tuniu/docker/harbor/common/config/ui/app.conf
Generated configuration file: /opt/tuniu/docker/harbor/common/config/registry/config.yml
Generated configuration file: /opt/tuniu/docker/harbor/common/config/db/env
Generated configuration file: /opt/tuniu/docker/harbor/common/config/jobservice/env
Generated configuration file: /opt/tuniu/docker/harbor/common/config/jobservice/app.conf
Generated configuration file: /opt/tuniu/docker/harbor/common/config/ui/private_key.pem
Generated configuration file: /opt/tuniu/docker/harbor/common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.
vim /opt/tuniu/docker/harbor/common/config/nginx/nginx.conf
构建
[root@harbor-hx-191-176 harbor]# docker-compose up -d |