この文書の現在のバージョンと選択したバージョンの差分を表示します。
— |
mae3xx_tips:hulft_iot:start [2017/08/26 06:29] (現在) admin 作成 |
||
---|---|---|---|
ライン 1: | ライン 1: | ||
+ | ====== HULFT IoT の利用 ====== | ||
+ | |||
+ | [[https://www.hulft.com/software/hulft-iot|{{:playground:hulft_iot:hulft_iot_logo.png|HULFT IoT}}]] | ||
+ | |||
+ | \\ | ||
+ | |||
+ | ===== 前提作業 ===== | ||
+ | |||
+ | 本書では、HULFT IoT Agent(以下Agent)を MA-E3xx に導入する際の手順について掲載します。\\ | ||
+ | まずは、HULFT IoT に同梱されている「ファーストステップガイド」を確認し、HULFT IoT Manager の環境構築を実施してください。 | ||
+ | |||
+ | \\ | ||
+ | |||
+ | ===== HULFT IoT Agent の導入 ===== | ||
+ | | ||
+ | MA-E3xx に Agent をインストールします。\\ | ||
+ | Agentのインストールは、root ユーザで実行してください。 | ||
+ | | ||
+ | \\ | ||
+ | |||
+ | ==== セットアップ ==== | ||
+ | | ||
+ | MA-E3xx に、提供媒体内の Agent のモジュールを展開します。\\ | ||
+ | インストール先のOSに該当するモジュールを選んでください。 | ||
+ | |||
+ | MA-E3xx に入れるモジュールは以下になります。\\ | ||
+ | |||
+ | ''HULFT\_IoT\_Agent\_Linux\_AArch32\_{バージョン}.tar.gz'' | ||
+ | |||
+ | なお、本手順ではファイル名が「''HULFT_IoT\_Agent\_Linux\_AArch32\_V110.tar.gz''」として記載します。\\ | ||
+ | モジュール名については下記を参照してください。 | ||
+ | |||
+ | **HULFT IoT Agent for Linux** | ||
+ | |||
+ | <code> | ||
+ | \-+-HULFT_IoT_Agent <DIR> | ||
+ | +-huliotcore HULFT IoT Agent 制御モジュール | ||
+ | +-huliotsend HULFT IoT Agent 配信モジュール | ||
+ | +-huliotservice HULFT IoT Agent サービスモジュール | ||
+ | +-huliotsetup HULFT IoT Agent インストーラー | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | === 1. インストール作業用ディレクトリの作成 === | ||
+ | |||
+ | MA-E3xx で任意のディレクトリに、Agent のインストール作業用ディレクトリを作成します。 | ||
+ | |||
+ | <code> | ||
+ | # mkdir /tmp/module | ||
+ | | ||
+ | # mv HULFT_IoT_Agent_Linux_AArch32_V110.tar.gz /tmp/module/ | ||
+ | | ||
+ | # ls -l | ||
+ | total 1220 | ||
+ | -rw-r--r-- 1 root root 1249266 Feb 17 07:03 HULFT_IoT_Agent_Linux_AArch32_V110.tar.gz | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | | ||
+ | === 2. Agent のモジュールの展開 === | ||
+ | |||
+ | インストール作業用ディレクトリに展開します。 | ||
+ | | ||
+ | <code> | ||
+ | # tar -xzvf HULFT_IoT_Agent_Linux_AArch32_V110.tar.gz | ||
+ | ./HULFT_IoT_Agent/ | ||
+ | ./HULFT_IoT_Agent/huliotsetup | ||
+ | ./HULFT_IoT_Agent/huliotsend | ||
+ | ./HULFT_IoT_Agent/huliotservice | ||
+ | ./HULFT_IoT_Agent/huliotcore | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | | ||
+ | === 3. Agent のインストール === | ||
+ | | ||
+ | Agent のインストール作業用ディレクトリで以下のコマンドを実行し、Agent をインストールします。 \\ | ||
+ | コマンドは絶対パスまたは相対パスで指定してください。 | ||
+ | | ||
+ | セットアップコマンド の Usage は以下の通りです。 | ||
+ | | ||
+ | <code> | ||
+ | ./huliotsetup --help | ||
+ | Argument has not been specified. [--key] | ||
+ | | ||
+ | Usage: setup [OPTION] | ||
+ | Available Options | ||
+ | [--path INSTALL_PATH] | ||
+ | To specify the installation path. | ||
+ | If omitted, create and install "huliot" folder in the same hierarchy. | ||
+ | --key Activation-Key | ||
+ | Specify the activation key. | ||
+ | --server SERVER_NAME[:SERVER_PORT] | ||
+ | Specify the host information at the time of connection. | ||
+ | [--proxy PROXY_NAME[:PROXY_PORT]] | ||
+ | Specifies the proxy server to use when connecting. | ||
+ | [--proxy-user USERNAME:PASSWORD] | ||
+ | To specify the user information of the proxy. | ||
+ | [--ssl] To communicate with HTTPS. The default is to communicate with HTTP. | ||
+ | [--start] To start after the installation. | ||
+ | [--devicename DeviceName] | ||
+ | To specify the name of the device. | ||
+ | [--version] Print version information and then exit. | ||
+ | [--help] Print this message and then exit. | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | == パラメータの説明 == | ||
+ | | ||
+ | --path {$INSTALL_PATH} | ||
+ | |||
+ | <code> | ||
+ | Agentのインストール先ディレクトリ(省略可) | ||
+ | 省略した場合、「/opt/hulftiot」ディレクトリが作成され、Agentがインストールされます。 | ||
+ | </code> | ||
+ | | ||
+ | --key {$ACTIVATION_KEY} | ||
+ | |||
+ | <code> | ||
+ | 接続先の Manager のアクティベーションキー | ||
+ | アクティベーションキーを確認する方法については、「3-1. HULFT IoTのアクティベーションキーの確認方法」を参照してください。 | ||
+ | </code> | ||
+ | | ||
+ | --server {$SERVER_NAME:$SERVER_PORT} | ||
+ | |||
+ | <code> | ||
+ | 接続先の Manager が起動しているサーバ名および Manager のポート番号 | ||
+ | {$:SERVER_PORT} を省略すると、ポート番号は「8765」が使用されます。 | ||
+ | </code> | ||
+ | | ||
+ | --proxy {$PROXY_NAME:$PROXY_PORT} | ||
+ | <code> | ||
+ | Manager への接続時に使用するプロキシサーバ名およびプロキシサーバのポート番号(省略可) | ||
+ | {:$PROXY_PORT} を省略すると、ポート番号は「80」が使用されます。 | ||
+ | </code> | ||
+ | | ||
+ | --proxy-user {$USERNAME:$PASSWORD} | ||
+ | <code> | ||
+ | Manager への接続時に使用するプロキシサーバのユーザー名とパスワード(省略可) | ||
+ | </code> | ||
+ | | ||
+ | --ssl | ||
+ | <code> | ||
+ | HTTPS による Manager との通信(省略可) | ||
+ | 省略時は HTTP による通信が行われます。 | ||
+ | </code> | ||
+ | | ||
+ | --devicename {$DEVICE_NAME} | ||
+ | <code> | ||
+ | Agent をインストールする任意の機器名(省略可) | ||
+ | 省略時はインストール環境に設定されているホスト名が設定されます。 | ||
+ | </code> | ||
+ | | ||
+ | --start | ||
+ | <code> | ||
+ | インストール後に Agent を起動(省略可) | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | | ||
+ | === 3-1. HULFT IoT のアクティベーションキーの確認 === | ||
+ | |||
+ | IoT 機器に Agent をインストールする場合は、Manager への接続を有効にするためのキーが必要です。\\ | ||
+ | Manager への接続を有効にすることをアクティベーションといい、アクティベーションに使用する文字列をアクティベーションキーといいます。\\ | ||
+ | アクティベーションキーを確認する場合は、Manager の操作画面で[ライセンス]を選択し、\\ | ||
+ | ライセンス画面でHULFT IoTのアクティベーションキーを確認します。 | ||
+ | | ||
+ | {{hulftiot_agent_01.png?1024|HULFT IoT Manager のライセンス画面}} | ||
+ | |||
+ | \\ | ||
+ | |||
+ | セットアップコマンドの実行例 | ||
+ | | ||
+ | <code> | ||
+ | ./huliotsetup --key 12345678-1234-1234-1234-123456789abc --server HOST01 | ||
+ | </code> | ||
+ | | ||
+ | 下記以外は、省略値でセットアップを実行する例です。 | ||
+ | | ||
+ | <code> | ||
+ | ACTIVATION_KEY:12345678-1234-1234-1234-123456789abc | ||
+ | SERVER_NAME:HOST01 | ||
+ | </code> | ||
+ | | ||
+ | | ||
+ | 実行した結果、/opt/hulftiot 配下に ファイルが作成されます。 | ||
+ | | ||
+ | <code> | ||
+ | -rw-r--r-- 1 root root 159 May 29 03:19 agent.conf | ||
+ | -rwxr-xr-x 1 root root 2291296 May 29 03:19 huliotcore | ||
+ | -rwxr-xr-x 1 root root 228936 May 29 03:19 huliotsend | ||
+ | -rwxr-xr-x 1 root root 83488 May 29 03:19 huliotservice | ||
+ | </code> | ||
+ | | ||
+ | | ||
+ | agent.conf には コマンドに指定したパラメータが設定されています。 | ||
+ | | ||
+ | <code> | ||
+ | # less agent.conf | ||
+ | | ||
+ | devicename = | ||
+ | server_hostname = HOST01:8765 | ||
+ | proxy = | ||
+ | proxy_user = | ||
+ | protocol = 0 | ||
+ | cert_verification = 0 | ||
+ | activation_key = 12345678-1234-1234-1234-123456789abc | ||
+ | </code> | ||
+ | | ||
+ | | ||
+ | 以上でAgentのインストールは完了です。 | ||
+ | |||
+ | \\ | ||
+ | |||
+ | === 4. Agent のアクティベーション === | ||
+ | |||
+ | MA-E3xx で、インストールした Agent を起動すると、アクティベーション(Manager との接続の有効化)が実行されます。 \\ | ||
+ | Agent のインストール先ディレクトリで、以下のコマンドを実行します。 \\ | ||
+ | Agent の起動は、root ユーザで実行してください。コマンドは、絶対パスまたは相対パスで指定してください。 | ||
+ | | ||
+ | <code> | ||
+ | ./huliotservice | ||
+ | </code> | ||
+ | | ||
+ | Agent を起動すると、アクティベーション(Managerとの接続の有効化)が実行されます。 \\ | ||
+ | これで、Agent の起動は完了です。 | ||
+ | |||
+ | \\ | ||
+ | |||
+ | === 4-1. Agent のアクティベーションの確認 === | ||
+ | | ||
+ | Manager の操作画面で[エージェント]を選択し、エージェント一覧画面で Agent の情報が表示されることを確認します。\\ | ||
+ | | ||
+ | {{hulftiot_agent_02.png?1024|HULFT IoT Manager のエージェント画面}} | ||
+ | |||
+ | \\ | ||
+ | |||
+ | また、アクティベーションの初回実行時に、インストール先ディレクトリの agent.conf に 一意の agent_id が設定されます。 | ||
+ | |||
+ | <code> | ||
+ | # less agent.conf | ||
+ | devicename = | ||
+ | server_hostname = HOST01:8765 | ||
+ | proxy = | ||
+ | proxy_user = | ||
+ | protocol = 0 | ||
+ | cert_verification = 0 | ||
+ | activation_key = 12345678-1234-1234-1234-123456789abc | ||
+ | agent_id = aba798d1-c67c-499e-aa25-02ed69dd1b9c | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | === 5. 疎通テスト === | ||
+ | |||
+ | HULFT IoT に同梱されている「ファーストステップガイド」を確認し、Agent から HULFT へのファイル転送の疎通テストを実施してください。 | ||
+ | |||
+ | \\ | ||
+ | |||
+ | === 6. Agent のサービス化 === | ||
+ | |||
+ | 機器起動時に自動的にAgentが立ち上がるようにするための設定として、Upstartへのサービス登録の手順を記載します。 | ||
+ | |||
+ | 上記手順にてAgentが起動した状態の場合、Agentを停止させてください。\\ | ||
+ | Agent の停止は、root ユーザで実行してください。 | ||
+ | | ||
+ | killコマンドの実行例 | ||
+ | |||
+ | <code> | ||
+ | kill `cat huliotservice.pid` | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | == 6-1. 定義ファイルの作成 == | ||
+ | |||
+ | 以下の定義ファイルを作成し、設定を記載してください。 | ||
+ | |||
+ | <code> | ||
+ | /etc/init/hulftiot-agent.conf | ||
+ | </code> | ||
+ | |||
+ | <file generic hulftiot-agent.conf> | ||
+ | description "hulftiot-agent" | ||
+ | |||
+ | start on runlevel [345] | ||
+ | stop on runlevel [0126] | ||
+ | |||
+ | respawn | ||
+ | expect daemon | ||
+ | |||
+ | exec /opt/hulftiot/huliotservice | ||
+ | </file> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | == 6-2. Service として認識されたか確認する == | ||
+ | |||
+ | 以下のコマンドを実行してください。 | ||
+ | |||
+ | <code> | ||
+ | sudo initctl list |grep hulftiot-agent | ||
+ | </code> | ||
+ | |||
+ | 認識されていれば、以下のように出力されます。 | ||
+ | |||
+ | <code> | ||
+ | hulftiot-agent stop/waiting | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | == 6-3. Serviceとして起動する == | ||
+ | |||
+ | 以下のコマンドを実行してください。 | ||
+ | |||
+ | <code> | ||
+ | sudo initctl start hulftiot-agent | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | == 6-4. Service のステータス確認 == | ||
+ | |||
+ | 以下のコマンドを実行してください。 | ||
+ | |||
+ | <code> | ||
+ | sudo initctl status hulftiot-agent | ||
+ | </code> | ||
+ | |||
+ | サービスが無効になっている場合、以下のように表示されます。 | ||
+ | |||
+ | <code> | ||
+ | hulftiot-agent stop/waiting | ||
+ | </code> | ||
+ | |||
+ | サービスが有効化され起動している場合、以下のように表示されます。 | ||
+ | |||
+ | <code> | ||
+ | hulftiot-agent start/running, process 6232 | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | === 7. Agent のインストールに失敗した場合 === | ||
+ | |||
+ | Agent のインストール作業で、以下のような場合はインストールに失敗している可能性があります。\\ | ||
+ | |||
+ | - コマンド実行は成功したが、Agent が起動しない。 | ||
+ | |||
+ | - Manager から Agent を認識できない。 | ||
+ | |||
+ | このような場合は、Agent を正しくインストールする必要があります。\\ | ||
+ | 以下の手順でアンインストールした後、再度、インストールを実行してください。 | ||
+ | |||
+ | \\ | ||
+ | |||
+ | * 1. Agent の終了 | ||
+ | |||
+ | Agent のインストール先ディレクトリで kill コマンドを実行し、Agent を停止します。 | ||
+ | Agent の停止は、root ユーザで実行してください。 | ||
+ | | ||
+ | kill コマンドの実行例 | ||
+ | |||
+ | <code> | ||
+ | kill `cat huliotservice.pid` | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | * 2. インストール先ディレクトリの削除 | ||
+ | |||
+ | ディレクトリ削除の実行例 | ||
+ | | ||
+ | <code> | ||
+ | rm -rf /opt/hulftiot/ | ||
+ | </code> | ||