SE の雑記

SQL Server の情報をメインに Microsoft 製品の勉強内容を日々投稿

Raspberry Pi 4B に Azure SQL Edge をセットアップする

leave a comment

Azure SQL Edge が Public Preview となり、広く検証ができるようになりました。

現状の SQL Edge については ARM64/x64 の Linux 版を使用することができ、ARM64 については、Raspberry Pi 4B にもセットアップをすることができます。
(ARM64 の環境がない場合は、x64 の Linux 上にもセットアップすることが可能です。)

以前のバージョンの検証環境はあったのですが、最新化するついでに情報をまとめておこうかと。

私の場合は、Raspberry Pi 4B の 4GB のこのデバイスで動かしていますが、ハードウェア要件については Hardware Support に記載されています。

 image

Hardware Support

Azure SQL Edge requires a 64-bit processor, which can be from Intel, AMD or ARM, with a minimum of one processor and one GB of RAM on the host. While the startup memory footprint of Azure SQL Edge is close to 500 MB, the additional memory is needed for other IoT Edge modules running on the edge device.

最小のメモリ要件は 1GB となっていますので、Raspberry Pi 3 でも動作するのかもしれませんね。(未確認)

Market Place からデプロイする際の概要にもスペックは表示されています。

image

OS のインストール (Ubuntu 18.04 ARM64)

SQL Edge は、現時点では、 Azure IoT Edge を介した展開をサポートとなっているため、最初に IoT Edge ランタイムをインストール可能な環境をセットアップする必要があります。

今回は ARM64 の Ubuntu 18.04 を利用しますので、セットアップ手順については Debian ベースの Linux システムに Azure IoT Edge ランタイムをインストールする の内容となります。

OS の要件としては Operating System に記載されており、次のようになっています。

Operating System

Azure SQL Edge containers are currently based on Ubuntu 16.04 and as such are only supported to run on docker hosts running either Ubuntu 16.04 (recommended) or Ubuntu 18.04. Azure SQL Edge can also run on other operating system hosts, for example, other distributions of Linux or on Windows (using Docker CE or Docker EE), however these configurations are not extensively tested by Microsoft.

Azure SQL Edge is currently only supported for deployment through Azure IoT Edge. For more information on the supported systems for Azure IoT Edge, refer Azure IoT Edge supported systems.

The recommended configuration for running Azure SQL Edge on Windows is to configure an Ubuntu VM on the Windows host, and then run SQL Edge inside the linux VM.

Ubuntu 16.04 が推奨となっていますが、Ubuntu 18.04 もサポートをしていますので、今回は Ubuntu 18.04 を利用したいと思います。

Raspberry Pi 4 向けの Ubuntu 18.04 については Install Ubuntu Server on a Raspberry Pi 2, 3 or 4 から入手することができます。

image

 

イメージをダウンロードしファイルを展開して、img ファイルが入手できたら、Win32 Disk ImagerRufus を使用して、マイクロ SD に書き込みを行います。

image

書き込みが終わったらデバイスに刺して起動します。

初期のログインとパスワードについては、ubuntu / ubuntu となっていますのでこのユーザーでログインして、初期パスワードの変更を行います。

IP を確認したら SSH で接続した作業に移ります。
何回か試していたら SSH Error Invalid Format ? Ubuntu 18.04 と同じ状態になり、SSH できないことがあったので、これと同じ状態になった時には次のコマンドて対応していました。

ssh-keygen -A
systemctl restart sshd

 

SQL Edge をインストールする環境が整ったら、Azure のリソースを作成します。

 

Azure のリソースの作成

Azure で必要なリソースの作成は、Install software and set up resources for the tutorial に記載されていますが、ポータルからポチポチとやっておこうかと。

現状の SQL Edge は IoT Edge を介してのインストールとなりますので、最初に IoT Hub のリソースを作成します。

image

サイズについてですが、検証であれば、F1 で対応できるかと。

image

リソースの作成が完了したら、「IoT Edge」の「IoT Edge デバイスを追加する」から、デバイスの追加を行います。

image

デバイスを追加した後に確認ができる接続文字列が IoT Edge ランタイムの設定で必要となりますので、値を確認して控えておきます。

image

 

IoT Edge ランタイムのインストール

OS のインストールが終わったら、コンテナーランタイム (IoT Edge で推奨される Moby エンジン) と IoT Edge ランタイムのインストールを行います。

curl https://packages.microsoft.com/config/ubuntu/18.04/multiarch/prod.list > ./microsoft-prod.list

sudo cp ./microsoft-prod.list /etc/apt/sources.list.d/

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo cp ./microsoft.gpg /etc/apt/trusted.gpg.d/

sudo apt-get update

sudo apt-get install -y moby-engine moby-cli

sudo apt-get install -y iotedge

 

ランタイムのインストールが完了したら、設定ファイルにポータルで確認をしておいた接続文字列を入力します。

sudo vi /etc/iotedge/config.yaml

 

image

設定が完了したらデーモンの再起動を行います。

sudo systemctl restart iotedge

 

インストール後の確認については インストールの成功を確認する の内容で確認できます。

 

SQL Edge の展開

IoT Edge ランタイムのインストールが完了したら、デバイスに SQL Edge の展開を行います。

展開の方法については Deploy Azure SQL Edge (Preview) に記載されている流れとなります。

Azure ポータルの IoT Hub から、作成した IoT Edge デバイスを選択して、「モジュールの設定」をクリックします。

モジュールの追加を Market Place から実施し「Azure SQL Edge 」を追加します。

今回は、Developer を使用しています。

image

モジュールを追加したら、Name のリンクをクリックして、SA のパスワードを設定しておきます。

image

後の設定はデフォルトで展開を行います。

展開が実行されると、SQL Edge のコンテナーイメージが展開され起動されます。

image

デバイスの TCP:1433 を SQL Edge のコンテナーにリダイレクトしていますので、通常の SQL Server と同様の方法で接続することができます。

機能の検証については、Azure SQL Edge (Preview) documentation を見ながら進めていこうかと。

(以前の Preview の時の操作、ほとんど忘れてしまった…。)

Share

Written by Masayuki.Ozawa

5月 20th, 2020 at 11:29 pm

Posted in SQL Edge

Tagged with

Leave a Reply