root@node1 \~\]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x67bd3d87.
Command (m for help): **n**
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): **+10G**
Partition 1 of type Linux and of size 10 GiB is set
Command (m for help): **w**
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
在上述步骤执行完毕之后,Linux 系统会自动把这个硬盘主分区抽象成/dev/sdb1 设备文件。可以使用file 命令查看该文件的属性,但有些时候系统并没有自动把分区信息同步给Linux 内核,而且这种情况似乎还比较常见(但不能算作是严重的bug)。可以输入partprobe 命令手动将分区信息同步到内核,而且一般推荐连续两次执行该命令,效果会更好。如果使用这个命令都无法解决问题,那么就重启计算机。
\[root@node1 \~\]# file /dev/sdb1
/dev/sdb1: block special
\[root@node1 \~\]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
\[root@node1 \~\]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
\[root@node1 \~\]# file /dev/sdb1
/dev/sdb1: block special
**②格式化和挂载**
\[root@node1 \~\]# mkfs.ext4 /dev/sdb1
\[root@node1 \~\]# mkdir /harbordata
\[root@node1 \~\]# mount /dev/sdb1 /harbordata/
\[root@node1 \~\]# df -h

root@node1 harbor\]# ss -lntup \| grep docker
tcp LISTEN 0 128 127.0.0.1:1514 \*:\* users:(("docker-proxy",pid=26691,fd=4))
tcp LISTEN 0 128 \*:80 \*:\* users:(("docker-proxy",pid=27275,fd=4))
tcp LISTEN 0 128 \[::\]:80 \[::\]:\* users:(("docker-proxy",pid=27279,fd=4))
②harbor实际就是启动了一些docker服务
\[root@node1 harbor\]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
be75291d7f54 goharbor/nginx-photon:v2.8.4 "nginx -g 'daemon of..." About a minute ago Up About a minute (healthy) 0.0.0.0:80-\>8080/tcp, :::80-\>8080/tcp nginx
8391933a9bd0 goharbor/harbor-jobservice:v2.8.4 "/harbor/entrypoint...." About a minute ago Up 58 seconds (healthy) harbor-jobservice
d4be8400acb4 goharbor/harbor-core:v2.8.4 "/harbor/entrypoint...." About a minute ago Up About a minute (healthy) harbor-core
root@node1 harbor\]# docker tag goharbor/harbor-db:v2.8.4 node1:80/test/harbor-db:v2.8.4
\[root@node1 harbor\]# docker image ls \| grep test
node1:80/test/harbor-db v2.8.4 5b8af16d7420 6 days ago 174MB
(3)登录harbor仓库
root@node1 harbor\]# docker login node1:8081
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
(4)上传镜像
root@node1 harbor\]# docker push node1:8081/test/harbor-db:v2.8.4
The push refers to repository \[node1:80/test/harbor-db