Centos7中安裝EdgeX Foundry邊緣計算
=====1. 環境設定 ======
OS:CentOS Linux release 7.8.2003 (Core)
IP: 47.108.146.200
=====2. 應用設定======
A)安裝Docker 和Docker Compose:
docker-ce的安裝前如果存在系統自帶的docker,且版本較低,可以使用下面命令刪除舊版本
1 |
yum remove docker docker-common docker-selinux docker-engine
|
更新yum包
1 |
sudo yum update
|
安裝需要的軟體包
1 |
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
|
新增軟體源資訊
1 |
sudo yum-config-manager --add-repo https: //mirrors .aliyun.com /docker-ce/linux/centos/docker-ce .repo
|
更新安裝docker-ce
1 2 |
sudo yum makecache fast
sudo yum -y install docker-ce
|
開啟docker-ce
1 |
sudo systemctel restart docker<br> sudo systemctl enable docker
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# 注意:
# 官方軟體源預設啟用了最新的軟體,您可以通過編輯軟體源的方式獲取各個版本的軟體包。例如官方並沒有將測試版本的軟體源置為可用,您可以通過以下方式開啟。同理可以開啟各種測試版本等。
# vim /etc/yum.repos.d/docker-ee.repo
# 將[docker-ce-test]下方的enabled=0修改為enabled=1 #
# 安裝指定版本的Docker-CE:
# Step 1: 查詢Docker-CE的版本:
# yum list docker-ce.x86_64 --showduplicates | sort -r
# Loading mirror speeds from cached hostfile
# Loaded plugins: branch, fastestmirror, langpacks
# docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
# docker-ce.x86_64 17.03.1.ce-1.el7.centos @docker-ce-stable
# docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
# Available Packages
# Step2: 安裝指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.1-1.el7.centos)
# sudo yum -y install docker-ce-[VERSION]
|
使用docker version驗證docker安裝成功:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
~] # docker version
Client: Docker Engine - Community
Version: 19.03.11
API version: 1.40
Go version: go1.13.10
Git commit: 42e35e61f3
Built: Mon Jun 1 09:13:48 2020
OS /Arch : linux /amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.11
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 42e35e61f3
Built: Mon Jun 1 09:12:26 2020
OS /Arch : linux /amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
|
Docker-compose的安裝:
更新軟體源
1 2 |
yum -y install epel-release
yum -y install python-pip
|
安裝docker-compose
1 |
pip install docker-compose
|
驗證docker-compose安裝成功
1 2 3 4 5 |
~] # docker-compose version
docker-compose version 1.26.0, build unknown
docker-py version: 4.2.1
CPython version: 3.8.2
OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017
|
=====3. EdgeX 部署======
A) 訪問下載地址:https://github.com/edgexfoundry/developer-scripts/tree/master/releases
檢視使用哪個版本的compose-file檔案:此例子使用EdgeX Foundry, Delhi, version 0.7.1 也就是下圖中順序第三個delhi/compose-files
下載檔案:docker-compose-delhi-0.7.1.yml(此檔案中包含了執行edgex的所有核心映象)
B) 下載此檔案內容到檔案docker-compose.yml中(此例預設放在/root中)
1 2 3 4 5 6 |
~] # ll
total 16
-rw-------. 1 root root 1249 anaconda-ks.cfg
-rw-r--r--. 1 root root 11419 docker-compose.yml
~] # pwd
/root
|
C) 由於你懂的原因,這裡新增加速器:
此例採用的是daocloud的加速器,具體可以參考:https://www.daocloud.io/mirror
Linux環境使用下面的指令碼:
1 |
curl -sSL https: //get .daocloud.io /daotools/set_mirror .sh | sh -s http: //f1361db2 .m.daocloud.io
|
D)檢視要下週的核心映象和拉取下載映象
檢視要下載的映象名稱
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
~] # docker-compose config --services
volume
consul
config-seed
mongo
logging
notifications
metadata
data
command
scheduler
export -client
export -distro
rulesengine
device-virtual
ui
portainer
|
拉取下載映象:(全部一定要為done)
說明:Pulls images for services defined in a Compose file, but does not start the containers.
這裡只是拉取映象,但是並未啟動映象
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
~] # docker-compose pull
Pulling volume ... done
Pulling consul ... done
Pulling config-seed ... done
Pulling mongo ... done
Pulling logging ... done
Pulling notifications ... done
Pulling metadata ... done
Pulling data ... done
Pulling command ... done
Pulling scheduler ... done
Pulling export -client ... done
Pulling export -distro ... done
Pulling rulesengine ... done
Pulling device-virtual ... done
Pulling ui ... done
Pulling portainer ... done
|
E)啟動映象
注意:-d選項表示Docker Compose以分離模式執行EdgeX容器(即在後臺執行容器)如果沒有-d,容器將在終端執行。如果後續想要使用終端,必須先停止容器。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
~] # docker-compose up -d
Starting edgex-files ... done
Starting edgex-support-rulesengine ... done
Starting edgex-mongo ... done
Starting edgex-core-consul ... done
Starting root_portainer_1 ... done
Starting edgex-config-seed ... done
Starting edgex-support-logging ... done
Starting edgex-support-notifications ... done
Starting edgex-core-metadata ... done
Starting edgex-core-data ... done
Starting edgex- export -client ... done
Starting edgex-support-scheduler ... done
Starting edgex-core- command ... done
Starting edgex- export -distro ... done
Starting edgex-device-virtual ... done
|
F)(選看內容)如果不使用edgex了的時候可以關閉映象
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
~] # docker-compose stop
Stopping edgex- export -distro ... done
Stopping edgex-device-virtual ... done
Stopping edgex- export -client ... done
Stopping edgex-support-scheduler ... done
Stopping edgex-core- command ... done
Stopping edgex-support-notifications ... done
Stopping edgex-core-data ... done
Stopping edgex-core-metadata ... done
Stopping edgex-support-logging ... done
Stopping edgex-mongo ... done
Stopping root_portainer_1 ... done
Stopping edgex-core-consul ... done
Stopping edgex-support-rulesengine ... done
Stopping edgex-files ... done
|
G)(選看內容)如果徹底不使用edgex了的時候可以刪除映象(謹慎操作)
1 |
Stop and remove containers, networks, images, and volumes~] # docker-compose down
|
1 |
~] # docker-compose down
|
H) 接上面的E, 啟動以後驗證映象容器啟動情況:
1 |
docker-compose ps -a
|
1 |
或者 docker ps -a -- format "table {{.Names}}\t{{.Status}}\t{{.Ports}}\t{{.RunningFor}}" <em id = "__mceDel" style= " font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px" > < /em >
|
如下:edgex-config-seed 在啟動後不久就會更改狀態為Exit 0(這是正常情況,暫時不用管)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
~] # docker-compose ps -a
Name Command State Ports
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
edgex-config-seed /bin/sh -c /edgex/cmd/conf ... Exit 0
edgex-core- command /core-command --consul --p ... Up 0.0.0.0:48082->48082 /tcp
edgex-core-consul docker-entrypoint.sh agent ... Up 8300 /tcp , 8301 /tcp , 8301 /udp , 8302 /tcp , 8302 /udp , 0.0.0.0:8400->8400 /tcp , 0.0.0.0:8500->8500 /tcp , 0.0.0.0:8600->8600 /tcp , 8600 /udp
edgex-core-data /core-data --consul --prof ... Up 0.0.0.0:48080->48080 /tcp , 0.0.0.0:5563->5563 /tcp
edgex-core-metadata /core-metadata --consul -- ... Up 0.0.0.0:48081->48081 /tcp , 48082 /tcp
edgex-device-virtual /bin/sh -c java -jar -Djav ... Up 0.0.0.0:49990->49990 /tcp
edgex- export -client /export-client --consul -- ... Up 0.0.0.0:48071->48071 /tcp
edgex- export -distro /export-distro --consul -- ... Up 0.0.0.0:48070->48070 /tcp , 0.0.0.0:5566->5566 /tcp
edgex-files /bin/sh -c /usr/bin/tail - ... Up
edgex-mongo docker-entrypoint.sh /bin/ ... Up 0.0.0.0:27017->27017 /tcp
edgex-support-logging /support-logging --consul ... Up 0.0.0.0:48061->48061 /tcp
edgex-support-notifications /support-notifications --c ... Up 0.0.0.0:48060->48060 /tcp
edgex-support-rulesengine /bin/sh -c java -jar -Djav ... Up 0.0.0.0:48075->48075 /tcp
edgex-support-scheduler /support-scheduler --consu ... Up 0.0.0.0:48085->48085 /tcp
root_portainer_1 /portainer -H unix: ///var/ ... Up 0.0.0.0:9000->9000 /tcp
|
通過GUI介面檢視服務的情況:
在啟動的服務中有一個consul服務(看下面紅色標註的埠):
1 |
edgex-core-consul docker-entrypoint.sh agent ... Up 8300 /tcp , 8301 /tcp , 8301 /udp , 8302 /tcp , 8302 /udp , 0.0.0.0:8400->8400 /tcp , 0.0.0.0:8500->8500 /tcp , 0.0.0.0:8600->8600 /tcp , 8600 /udp
|
在瀏覽器輸入本機IP(192.168.0.133)訪問:http://192.168.0.133:8500
到此 edgex的核心服務安裝部署完畢。
********************************************************************************
附錄:如果需要跟蹤容器的日誌,使用docker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
~] # docker ps -a
6d5dbc2db5ba edgexfoundry /docker-core-config-seed-go :0.7.1 "/bin/sh -c '/edgex/…" 6 days ago Exited (0) About an hour ago edgex-config-seed
d9571ba3ad7d edgexfoundry /docker-edgex-mongo :0.6.0 "docker-entrypoint.s…" 6 days ago Up About an hour 0.0.0.0:27017->27017 /tcp edgex-mongo
8bd57e9d5699 portainer /portainer "/portainer -H unix:…" 6 days ago Exited (1) About an hour ago root_portainer_1
3d6a90a0645f consul:1.1.0 "docker-entrypoint.s…" 6 days ago Up About an hour 0.0.0.0:8400->8400 /tcp , 8301-8302 /udp , 0.0.0.0:8500->8500 /tcp , 8300-8302 /tcp , 8600 /udp , 0.0.0.0:8600->8600 /tcp edgex-core-consul
a8e1f475c2a9 edgexfoundry /docker-support-rulesengine :0.7.0 "/bin/sh -c 'java -j…" 6 days ago Up About an hour 0.0.0.0:48075->48075 /tcp edgex-support-rulesengine
b1c150571d8b edgexfoundry /docker-edgex-volume :0.6.0 "/bin/sh -c '/usr/bi…" 6 days ago Up About an hour~] # docker logs -f d9571ba3ad7d2020-06-10T12:31:50.021+0000 I ACCESS [conn19] Successfully authenticated as principal logging on logging
2020-06-10T12:31:54.216+0000 I NETWORK [thread1] connection accepted from 172.18.0.4:47838 #1496 (21 connections now open)
2020-06-10T12:31:54.217+0000 I - [conn1496] end connection 172.18.0.4:47838 (21 connections now open )
2020-06-10T12:32:00.487+0000 I ACCESS [conn27] Successfully authenticated as principal meta on metadata
2020-06-10T12:32:02.477+0000 I ACCESS [conn749] Successfully authenticated as principal core on coredata
2020-06-10T12:32:04.217+0000 I NETWORK [thread1] connection accepted from 172.18.0.4:48104 #1497 (21 connections now open)
2020-06-10T12:32:04.218+0000 I - [conn1497] end connection 172.18.0.4:48104 (21 connections now open )
2020-06-10T12:32:05.018+0000 I ACCESS [conn31] Successfully authenticated as principal logging on logging
2020-06-10T12:32:14.218+0000 I NETWORK [thread1] connection accepted from 172.18.0.4:48346 #1498 (21 connections now open)
2020-06-10T12:32:14.219+0000 I - [conn1498] end connection 172.18.0.4:48346 (21 connections now open )
2020-06-10T12:32:15.502+0000 I ACCESS [conn27] Successfully authenticated as principal meta on metadata
2020-06-10T12:32:17.476+0000 I ACCESS [conn30] Successfully authenticated as principal core on coredata
2020-06-10T12:32:20.019+0000 I ACCESS [conn66] Successfully authenticated as principal logging on logging
2020-06-10T12:32:24.220+0000 I NETWORK [thread1] connection accepted from 172.18.0.4:48614 #1499 (21 connections now open)
|
或者使用docker-compose
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
~] # docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
edgex-config-seed /bin/sh -c /edgex/cmd/conf ... Exit 0
edgex-core- command /core-command --consul --p ... Up 0.0.0.0:48082->48082 /tcp
edgex-core-consul docker-entrypoint.sh agent ... Up 8300 /tcp , 8301 /tcp , 8301 /udp , 8302 /tcp , 8302 /udp , 0.0.0.0:8400->8400 /tcp , 0.0.0.0:8500->8500 /tcp , 0.0.0.0:8600->8600 /tcp , 8600 /udp
edgex-core-data /core-data --consul --prof ... Up 0.0.0.0:48080->48080 /tcp , 0.0.0.0:5563->5563 /tcp
edgex-core-metadata /core-metadata --consul -- ... Up 0.0.0.0:48081->48081 /tcp , 48082 /tcp
edgex-device-virtual /bin/sh -c java -jar -Djav ... Up 0.0.0.0:49990->49990 /tcp
edgex- export -client /export-client --consul -- ... Up 0.0.0.0:48071->48071 /tcp
edgex- export -distro /export-distro --consul -- ... Up 0.0.0.0:48070->48070 /tcp , 0.0.0.0:5566->5566 /tcp
edgex-files /bin/sh -c /usr/bin/tail - ... Up
edgex-mongo docker-entrypoint.sh /bin/ ... Up 0.0.0.0:27017->27017 /tcp
edgex-support-logging /support-logging --consul ... Up 0.0.0.0:48061->48061 /tcp
edgex-support-notifications /support-notifications --c ... Up 0.0.0.0:48060->48060 /tcp
edgex-support-rulesengine /bin/sh -c java -jar -Djav ... Up 0.0.0.0:48075->48075 /tcp
edgex-support-scheduler /support-scheduler --consu ... Up 0.0.0.0:48085->48085 /tcp
root_portainer_1 /portainer -H unix: ///var/ ... Exit 1
|
~]# docker-compose logs -f mongo edgex-mongo | 2020-06-10T08:48:32.516+0000 I - [conn152] end connection 172.18.0.4:35464 (17 connections now open) edgex-mongo | 2020-06-10T08:48:39.969+0000 I ACCESS [conn31] Successfully authenticated as principal logging on logging edgex-mongo | 2020-06-10T08:48:42.516+0000 I NETWORK [thread1] connection accepted from 172.18.0.4:35692 #153 (17 connections now open) edgex-mongo | 2020-06-10T08:48:42.517+0000 I - [conn153] end connection 172.18.0.4:35692 (17 connections now open) edgex-mongo | 2020-06-10T08:48:45.495+0000 I ACCESS [conn29] Successfully authenticated as principal core on coredata edgex-mongo | 2020-06-10T08:48:45.517+0000 I ACCESS [conn23] Successfully authenticated as principal meta on metadata edgex-mongo | 2020-06-10T08:48:47.483+0000 I ACCESS [conn29] Successfully authenticated as principal core on coredata edgex-mongo | 2020-06-10T08:48:52.517+0000 I NETWORK [thread1] connection accepted from 172.18.0.4:35962 #154 (17 connections now open) edgex-mongo | 2020-06-10T08:48:52.518+0000 I - [conn154] end connection 172.18.0.4:35962 (17 connections now open) edgex-mongo | 2020-06-10T08:49:00.468+0000 I ACCESS [conn66] Successfully authenticated as principal logging on logging edgex-mongo | 2020-06-10T08:49:00.503+0000 I ACCESS [conn23] Successfully authenticated as principal meta on metadata edgex-mongo | 2020-06-10T08:49:02.486+0000 I ACCESS [conn30] Successfully authenticated as principal core on coredata