EdgeX Foundry初體驗(二)--安裝部署(用戶篇)


 

=====1. 環境設置 ======

OS: CentOS Linux release 7.8.2003 (Core)

IP:  192.168.0.133/24

=====2. 應用設置======

A)安裝Docker 和Docker Compose:

docker-ce的安裝前如果存在系統自帶的docker,且版本較低,可以使用下面命令刪除舊版本

yum remove docker docker-common docker-selinux docker-engine

更新yum包

sudo yum update

 安裝需要的軟件包

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

添加軟件源信息

sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 

更新安裝docker-ce

sudo yum makecache fast
sudo yum -y install docker-ce

開啟docker-ce

sudo systemctel restart docker
sudo systemctl enable docker
# 注意:
# 官方軟件源默認啟用了最新的軟件,您可以通過編輯軟件源的方式獲取各個版本的軟件包。例如官方並沒有將測試版本的軟件源置為可用,您可以通過以下方式開啟。同理可以開啟各種測試版本等。
# 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安裝成功:

~]# 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的安裝:

更新軟件源

yum -y install epel-release
yum -y install python-pip

安裝docker-compose

pip install docker-compose

 驗證docker-compose安裝成功

~]# 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中)

 ~]# 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環境使用下面的腳本:

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io

D)查看要下周的核心鏡像和拉取下載鏡像

查看要下載的鏡像名稱

~]# 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.

這里只是拉取鏡像,但是並未啟動鏡像

~]# 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,容器將在終端運行。如果后續想要使用終端,必須先停止容器。

~]# 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了的時候可以關閉鏡像

~]# 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了的時候可以刪除鏡像(謹慎操作)

Stop and remove containers, networks, images, and volumes~]# docker-compose down
~]# docker-compose down

H) 接上面的E, 啟動以后驗證鏡像容器啟動情況:

docker-compose ps -a
或者 docker ps -a --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}\t{{.RunningFor}}" 

如下:edgex-config-seed 在啟動后不久就會更改狀態為Exit 0(這是正常情況,暫時不用管)

~]# 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服務(看下面紅色標注的端口):

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

~]# 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 d9571ba3ad7d
2020-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

 ~]# 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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM