EdgeXFoundry初体验(⼆)--安装部署(⽤户篇)
=====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 mirrors.aliyun/docker-ce/linux/po
更新安装docker-ce
sudo yum makecache fast
sudo yum -y install docker-ce
开启docker-ce
sudo systemctel restart docker
sudo systemctl enable docker
# 注意:
# 官⽅软件源默认启⽤了最新的软件,您可以通过编辑软件源的⽅式获取各个版本的软件包。例如官⽅并没有将测试版本的软件源置为可⽤,您可以通过以下⽅式开启。同理可以开启各种测试版本等。# vim /pos.po
# 将[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.-s docker-ce-stable
# docker-ce.x86_64 17.-s @docker-ce-stable
# docker-ce.x86_64 17.-s docker-ce-stable
# Available Packages
# Step2: 安装指定版本的Docker-CE: (VERSION例如上⾯的17.s)
# 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的安装:
更新软件源
pip install docker-compose
验证docker-compose安装成功
~]# docker-compose version
docker-compose version 1.26.0, build unknown
docker-py version: 4.2.1exited
CPython version: 3.8.2
OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017
=====3. EdgeX 部署======
A) 访问下载地址:
查看使⽤哪个版本的compose-file⽂件:此例⼦使⽤ EdgeX Foundry, Delhi, version 0.7.1 也就是下图中顺序第三个delhi/compose-files
下载⽂件:(此⽂件中包含了运⾏edgex的所有核⼼镜像)
B) 下载此⽂件内容到⽂件l中(此例默认放在/root中)
~]# ll
total 16
-rw-------. 1 root root 1249 anaconda-ks.cfg
-rw-r--r--. 1 root root 11419 l
~]# pwd
/root
C)由于你懂的原因,这⾥添加加速器:
此例采⽤的是daocloud的加速器,具体可以参考:
Linux环境使⽤下⾯的脚本:
curl -sSL get.daocloud.io/daotools/set_mirror.sh | sh -s 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
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)访问:
到此 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/tc 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-rul 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
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论