

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Raspberry Pi의 Managed Integrations Hub SDK Docker 컨테이너
<a name="raspberrypi-container-docker-sdk"></a>

**참고**  
 Raspberry Pi에서 AWS IoT Hub SDK를 구현하는 것은 학습 및 테스트 목적으로만 사용되는 데모 프로젝트이며 프로덕션 환경에서는 사용할 수 없습니다. 이 데모에서는 쉽게 개발할 수 있도록 다음 구성을 설정합니다.  
 **AWS 보안 인증 정보 스토리지**: 데모 목적으로만 보안 인증 정보와 인증서가 액세스 가능한 위치에 저장되어 테스트 및 개발이 더 쉬워집니다. 프로덕션 환경은 AWS Secrets Manager또는 Systems Manager Parameter Store와 같은 보안 스토리지 솔루션을 사용해야 합니다. 저장 데이터 암호화를 구현하고 AWS IoT 보안 지침을 따라야 합니다.  
 **컨테이너 권한**: 데모는 승격된 권한으로 실행되어 호스트 리소스에 대한 무제한 액세스를 허용하고 개발 워크플로를 간소화합니다. 프로덕션 환경에서 컨테이너는 최소한의 필수 권한으로 작동해야 합니다.  
 **네트워크 브리지 구성**: 데모는 더 쉬운 디버깅 및 모니터링을 위해 내부 네트워크 트래픽을 노출하는 네트워크 브리지 구성을 사용합니다. 프로덕션 환경에서는 적절한 네트워크 격리 및 세분화를 구현하여 내부 네트워크 트래픽에 대한 무단 액세스를 방지합니다.  
 **USB 디바이스 권한**: 개발 주변 장치 및 테스트 디바이스를 쉽게 연결할 수 있도록 무제한 USB 디바이스 액세스가 활성화됩니다. 프로덕션의 경우 엄격한 USB 디바이스 제어 및 검증을 구현하여 디바이스 스푸핑 공격을 방지합니다.  
 이러한 구성은 간단한 테스트를 가능하게 하며 프로덕션 환경에서 사용해서는 안 됩니다. 프로덕션에 배포할 때는 호스트 시스템 손상 및 자격 증명에 대한 무단 액세스를 방지하기 위한 보안 모범 사례를 따르십시오.

## 사전 조건
<a name="required-hardware-software"></a>

Docker 컨테이너의 경우 다음 사전 조건이 필요합니다.
+ [Raspberry Pi 이미저](https://www.raspberrypi.com/software/)를 다운로드하여 설치합니다.
+ [SD 카드를](https://www.amazon.com/dp/B0CWPPDS3D?ref=ppx_yo2ov_dt_b_fed_asin_title) 받습니다.
+ [2.4Ghz 64비트 쿼드 코어 CPU(8GB RAM)로 Raspberry Pi 5](https://www.amazon.com/CanaKit-Raspberry-Starter-Kit-PRO/dp/B0CRSNCJ6Y/)를 설정합니다.
+ [Sonoff Zigbee USB 동글](https://www.amazon.com/Plus-ZBDongle-Interface-Pre-Installed-Coordinated-Zigbee2MQTT/dp/B0B6P22YJC/)을 연결합니다.
+ [Sonoff Zigbee USB 동글에 대한 플래시 펌웨어](supported-raspberry.md#sonoff-zigbee-firmware-flashing).
+ [Silicon Labs SLUSB001A 동글](https://www.digikey.com/en/products/detail/silicon-labs/SLUSB001A/9867108)을 연결합니다.
+ [AWS 계정에 가입합니다](https://docs.aws.amazon.com/iot-mi/latest/devguide/setting-up.html#sign-up-for-aws).
+ [AWS CLI 관리형 통합 AWS CLI 명령 참조에서 최신 버전의를](https://docs.aws.amazon.com/cli/latest/reference/iot-managed-integrations/) 설치합니다.
+ IP 주소 또는 호스트 이름을 사용하여 Raspberry Pi에 대한 SSH 액세스.

## Raspberry Pi에서 Managed Integrations Hub SDK Docker 컨테이너 사용
<a name="docker-container-deployment"></a>

1. [ 관리형 통합 Raspberry Pi Hub SDK Docker를 다운로드합니다](https://d2no7dt1utuyzo.cloudfront.net/IotMI-HubSDK-RaspberryPi/1.0.0/IotMI-HubSDK-Docker-v1.0.0.tar.gz).

1. SCP를 사용하여 파일을 Raspberry Pi에 복사합니다.

   ```
   scp ~/path/to/IotMI-HubSDK-Docker-v1.0.0.tar.gz [username]@raspberrypi.local:~
   ```

1. SSH를 통해 Raspberry Pi에 연결합니다.

   ```
   ssh hub123456@raspberrypi.local
   ```

1. 없는 경우 Docker를 설치합니다.

   ```
   # Install Docker
   cd
   curl -fsSL https://get.docker.com | sudo sh
   
   # Add your user to docker group
   sudo usermod -aG docker $USER
   exit # exit ssh
   
   # Log in again
   ```

1. 없는 경우 Docker Compose를 설치합니다.

   ```
   # Install Docker Compose
   sudo apt-get update
   sudo apt-get install -y docker-compose-plugin
   ```

1. Hub SDK 파일을 추출합니다.

   ```
   # Navigate to the home directory
   cd
   
   # Extract the hub-docker.tar.gz file
   tar -xzf IotMI-HubSDK-Docker-v1.0.0.tar.gz
   ```

1. hub-docker 디렉터리로 이동합니다.

   ```
   cd IotMI-HubSDK-Docker
   ```

1. [Hub 온보딩 설정을](https://docs.aws.amazon.com/iot-mi/latest/devguide/managedintegrations-sdk-v2-cookbook-hubsetup.html) 완료하여 인증 및 설정을 구성합니다.
**참고**  
이 단계를 수행하려면 `YUL` 또는 `DUB` 리전에 있어야 합니다.

1. Docker 컨테이너를 시작합니다.

   ```
   # The first time it's called, it will build the container
   docker compose up -d
   docker compose logs -f
   ```

**예상 결과**:

```
[+] Running 1/1
 ✔ Container iotmi-hubsdk-docker-hubsdk-1  Started
hubsdk-1  | -\-\-\-\-\-\-Checking USB dongles-\-\-\-\-\-\-\-\-\-\-\-\-
hubsdk-1  | -\-\-\-\-\-\-Stopping SDK running processes-\-\-
hubsdk-1  | iotmi_mqtt_proxy: no process found
hubsdk-1  | ace_eventmgr: no process found
hubsdk-1  | ace_zigbee_service: no process found
hubsdk-1  | zwave_svc: no process found
hubsdk-1  | iotmi_cdmb: no process found
hubsdk-1  | iotmi_device_agent: no process found
hubsdk-1  | iotmi_lpw_provisioner: no process found
hubsdk-1  | iotmi_log_daemon: no process found
hubsdk-1  | -\-\-\-\-\-\-Starting Hub SDK-\-\-\-\-\-\-\-\-\-\-\-\-
hubsdk-1  | -\-\-\-\-\-\-Creating logs directory-\-\-\-\-\-\-\-\-\-
hubsdk-1  | Logs directory created.
hubsdk-1  | -\-\-\-\-\-\-Verifying Middleware paths-\-\-\-\-\-\-
hubsdk-1  | All middleware libraries exist
hubsdk-1  | -\-\-\-\-\-\-Verifying Middleware pre reqs-\-\-
hubsdk-1  | AIPC and KVstroage directories exist
hubsdk-1  | -\-\-\-\-\-\-Starting HubOnboarding-\-\-\-\-\-\-\-\-\-\-
hubsdk-1  | -\-\-\-\-\-\-Starting MQTT Proxy-\-\-\-\-\-\-\-\-\-\-
hubsdk-1  | -\-\-\-\-\-\-Staring Log Daemon-\-\-
hubsdk-1  | -\-\-\-\-\-\-Starting Event Manager-\-\-\-\-\-\-\-\-\-\-
hubsdk-1  | -\-\-\-\-\-\-Starting Zigbee Service-\-\-\-\-\-\-\-\-\-
hubsdk-1  | -\-\-\-\-\-\-Starting Zwave Service-\-\-\-\-\-\-\-\-\-
hubsdk-1  | /data/aws/iotmi/middleware/AceZwave/bin /data/aws/iotmi
hubsdk-1  | /data/aws/iotmi
hubsdk-1  | -\-\-\-\-\-\-Starting CDMB-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
hubsdk-1  | -\-\-\-\-\-\-Starting Agent-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
hubsdk-1  | -\-\-\-\-\-\-Starting Provisioner-\-\-\-\-\-\-\-\-\-\-\-\-\-
hubsdk-1  | -\-\-\-\-\-\-Checking SDK status-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
hubsdk-1  | root         105  0.2  0.2 1093488 16608 ?       Sl   20:51   0:00 ./iotmi_mqtt_proxy -C /data/aws/iotmi/config/iotmi_config.json
hubsdk-1  | Process 'iotmi_mqtt_proxy' is running.
hubsdk-1  | root         183  0.0  0.0 236272  3152 ?        Sl   20:51   0:00 ./middleware/AceCommon/bin/ace_eventmgr
hubsdk-1  | Process 'ace_eventmgr' is running.
hubsdk-1  | root         190 12.0  0.1 319264  8352 ?        Sl   20:51   0:04 ./middleware/AceZigbee/bin/ace_zigbee_service
hubsdk-1  | Process 'ace_zigbee_service' is running.
hubsdk-1  | root         200  0.0  0.1 1365792 12480 ?       Sl   20:51   0:00 ./zwave_svc
hubsdk-1  | Process 'zwave_svc' is running.
hubsdk-1  | root         233  0.0  0.0 1198704 5760 ?        Sl   20:51   0:00 ./iotmi_cdmb
hubsdk-1  | Process 'iotmi_cdmb' is running.
hubsdk-1  | root         268  0.2  0.2 2017424 21968 ?       Sl   20:51   0:00 ./iotmi_device_agent
hubsdk-1  | Process 'iotmi_device_agent' is running.
hubsdk-1  | root         311  0.1  0.1 1523072 13008 ?       Sl   20:51   0:00 ./iotmi_lpw_provisioner
hubsdk-1  | Process 'iotmi_lpw_provisioner' is running.
hubsdk-1  | root         132  0.0  0.0 875024  7232 ?        Sl   20:51   0:00 ./iotmi_log_daemon
hubsdk-1  | Process 'iotmi_log_daemon' is running.
hubsdk-1  | -\-\-\-\-\-Successfully Started Hub SDK-\-\-\-
```

Hub SDK를 성공적으로 시작한 후에서 디바이스 온보딩 및 관리를 진행합니다[디바이스 온보딩 및 운영을 위한 사용자 안내 설정](managedintegrations-sdk-v2-cookbook-ugs.md).

**참고**  
Docker 컨테이너 bash 쉘에 액세스하려면 다음 명령을 실행합니다.  

  ```
  docker compose exec hubsdk bash
  ```
재부팅 후 컨테이너를 다시 시작하려면 다음 명령을 실행합니다.  

  ```
  docker compose up -d
  ```
Hub SDK를 업데이트하려면 다음 폴더의 바이너리를 바꿉니다.  

  ```
  hub-docker/iotmi
  ```
데이터를 보존하면서 컨테이너를 안전하게 다시 시작하려면 다음을 수행합니다.  

  ```
  docker compose down
  docker compose up -d
  docker compose logs -f
  ```