1.- 在Cloud9上创建Edge device (cloud9也是一部虚拟机,也可用EC2代替)

Create environment

AWS IoT Greengrass V2安装实验_AWS

进入cloud9

AWS IoT Greengrass V2安装实验_greengrass_02

AWS IoT Greengrass V2安装实验_AWS_03

安装greengrass环境

sudo yum update -y

sudo python3 -m pip install -U pip

sudo python3 -m pip install awsiotsdk

sudo yum install java

2.- 进入AWS IoT创建Core device

AWS IoT Greengrass V2安装实验_iot_04

AWS IoT Greengrass V2安装实验_greengrass_05

AWS IoT Greengrass V2安装实验_iot_06

将下面命令复制下来

AWS IoT Greengrass V2安装实验_greengrass_07

AWS IoT Greengrass V2安装实验_AWS_08

3.- cloud9安装Core device 

获取credential

AWS IoT Greengrass V2安装实验_greengrass_09

输入 AWS credentials

export AWS_ACCESS_KEY_ID=<AWS_ACCESS_KEY_ID>

export AWS_SECRET_ACCESS_KEY=<AWS_SECRET_ACCESS_KEY>

export AWS_SESSION_TOKEN=<AWS_SESSION_TOKEN>

安装

curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip && unzip greengrass-nucleus-latest.zip -d GreengrassInstaller

sudo -E java -Droot="/greengrass/v2" -Dlog.store=FILE -jar ./GreengrassInstaller/lib/Greengrass.jar --aws-region us-west-2 --thing-name GreengrassQuickStartCore-19401e97f32  --component-default-user ggc_user:ggc_group --provision true --setup-system-service true --deploy-dev-tools true

AWS IoT Greengrass V2安装实验_iot_10

AWS IoT Greengrass V2安装实验_AWS_11

查log:sudo tail -f /greengrass/v2/logs/greengrass.log

赋予权限

sudo visudo

将root ALL=(ALL) ALL 修改为 root ALL=(ALL:ALL) ALL

AWS IoT Greengrass V2安装实验_AWS_12


常用命令

sudo systemctl stop greengrass.service

sudo systemctl disable greengrass.service

sudo rm /etc/systemd/system/greengrass.service

sudo systemctl daemon-reload && sudo systemctl reset-failed

sudo rm -rf /greengrass/v2