根據阿里雲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:~ $ 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章