根据阿里云docker公司的指导,记录树莓派集群配置步骤,并验证是否成功

 

 

 

3、为了使 DNS 主机名解析更容易一些,我在每个 Pi 设备上设置了本地主机名,如下所示:(该步骤未成功)

/etc/hosts


192.168.3.15    raspberrypi4b
192.168.3.12    raspberrypi3b

4、在每个 Pi 上,安装以下内容:

a.安装以下先决条件。

sudo apt-get install apt-transport-https ca-certificates software-properties-common -y

b.下载并安装 Docker。

curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh

c.让“pi”用户能够运行 Docker。

sudo usermod -aG docker pi

d.导入 Docker CPG 密钥。

sudo curl https://download.docker.com/linux/raspbian/gpg

e.设置 Docker Repo。

sudo nano /etc/apt/sources.list

f.添加以下行并保存:

deb https://download.docker.com/linux/raspbian/ stretch stable

g.为您的 Pi 打补丁以及更新。

 

sudo apt-get update
sudo apt-get upgrade

h.启动Docker服务。

pi@raspberrypi:~ $ systemctl start docker.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'docker.service'.
Multiple identities can be used for authentication:
 1.  ,,, (pi)
 2.  root
Choose identity to authenticate as (1-2): 1
Password: 
==== AUTHENTICATION COMPLETE ===

i.验证Docker是否已安装并正在运行。

pi@raspberrypi:~ $ sudo docker info
Client:
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 19.03.8
 Storage Driver: overlay2
  Backing Filesystem: <unknown>
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.19.97-v7+
 Operating System: Raspbian GNU/Linux 10 (buster)
 OSType: linux
 Architecture: armv7l
 CPUs: 4
 Total Memory: 926.1MiB
 Name: raspberrypi
 ID: 6T4Z:LLNQ:RFCA:O2DM:ZRJN:37WV:2CD2:S7VQ:ZOFO:542W:VDVR:7TGP
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
pi@raspberrypi:~ $ 

5、在将成为主节点的其中一个 Pi上,输入以下内容:

pi@raspberrypi:~ $ sudo docker swarm init
Swarm initialized: current node (ejdkwikkr02rnslhc6glcwntl) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-4d89i9lou2z3y59pmtch64ritf4hcf1osx22cs9lzzhvgh2lbr-ai4gucauseougfb2wg2emb8an 192.168.3.15:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

6,主节点运行

pi@raspberrypi:~ $ sudo docker swarm join-token manager
To add a manager to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-4d89i9lou2z3y59pmtch64ritf4hcf1osx22cs9lzzhvgh2lbr-9bp5qt9gv9oiiuqhvbvzrjb65 192.168.3.15:2377

从节点运行

pi@raspberrypi:~ $ sudo docker swarm join --token SWMTKN-1-4d89i9lou2z3y59pmtch64ritf4hcf1osx22cs9lzzhvgh2lbr-9bp5qt9gv9oiiuqhvbvzrjb65 192.168.3.15:2377
This node joined a swarm as a manager.

 

 

 

 

 

添加可视化管理时遇到问题及解决方法

pi@raspberrypi:~ $ docker pull dockersamples/visualizer:latest
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout
pi@raspberrypi:~ $ sudo docker pull dockersamples/visualizer:latest
sudo: unable to resolve host raspberrypi: Name or service not known
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout
pi@raspberrypi:~ $ docker pull dockersamples/visualizer:latest
Error response from daemon: Get https://registry-1.docker.io/v2/dockersamples/visualizer/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Adockersamples%2Fvisualizer%3Apull&service=registry.docker.io: net/http: TLS handshake timeout
pi@raspberrypi:~ $ su root
Password: 
su: Authentication failure
pi@raspberrypi:~ $ sudo passwd
sudo: unable to resolve host raspberrypi: Name or service not known
New password: 
Retype new password: 
Sorry, passwords do not match.
passwd: Authentication token manipulation error
passwd: password unchanged
pi@raspberrypi:~ $ sudo passwd root
sudo: unable to resolve host raspberrypi: Name or service not known
New password: 
Retype new password: 
passwd: password updated successfully
pi@raspberrypi:~ $ su root
Password: 
root@raspberrypi:/home/pi# ls
Desktop  Documents  Downloads  get-docker.sh  MagPi  Music  Pictures  Public  Templates  Videos
root@raspberrypi:/home/pi# cd /etc/docker/
root@raspberrypi:/etc/docker# ls
key.json
root@raspberrypi:/etc/docker# node daemon.json
bash: node: command not found
root@raspberrypi:/etc/docker# nano daemon.json
root@raspberrypi:/etc/docker# systemctl daemon-reload
root@raspberrypi:/etc/docker# systemctl restart docker
root@raspberrypi:/etc/docker# quit
bash: quit: command not found
root@raspberrypi:/etc/docker# exit
exit
pi@raspberrypi:~ $ docker pull dockersamples/visualizer:latest
latest: Pulling from dockersamples/visualizer
cd784148e348: Downloading 
f6268ae5d1d7: Download complete 
97eb9028b14b: Download complete 
9975a7a2a3d1: Download complete 
ba903e5e6801: Download complete 
7f034edb1086: Download complete 
cd5dbf77b483: Download complete 
5e7311667ddb: Download complete 
687c1072bfcb: Download complete 
aa18e5d3472c: Download complete 
a3da1957bd6b: Download complete 
e42dbf1c67c4: Download complete 
5a18b01011d2: Download complete 
latest: Pulling from dockersamples/visualizer
cd784148e348: Downloading [========>                                          ]  375.2kB/2.207MB
f6268ae5d1d7: Pulling fs layer 
97eb9028b14b: Pulling fs layer 
9975a7a2a3d1: Waiting 
ba903e5e6801: Waiting 
7f034edb1086: Waiting 
cd5dbf77b483: Waiting 
5e7311667ddb: Waiting 
687c1072bfcb: Waiting 
aa18e5d3472c: Waiting 
a3da1957bd6b: Waiting 
e42dbf1c67c4: Waiting 
5a18b01011d2: Waiting 
error pulling image configuration: Get https://registry-1.docker.io/v2/dockersamples/visualizer/blobs/sha256:f6411ebd974c39915c08af35b2bc8c35ea2df531a2cbfce1b9938d1e6ec09d88: net/http: TLS handshake timeout
pi@raspberrypi:~ $ docker service create \
> --name=viz\
> --publish=9090:8080/tcp \
> --constraint=node.role==manager \
> --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
> alexellis2/visualizer-arm:latest
Error response from daemon: rpc error: code = InvalidArgument desc = name must be valid as a DNS name component
pi@raspberrypi:~ $ 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值