センサデータ向け ファイルシステム

キーワード: IoTデータ NAS統合 Union mount Fuse (Filesystem in Userspace)

スケーラブル 低コスト ストレージシステム 複数のディスクを束ねる

keyword: IoT data NAS integrated Union mount Fuse (Filesystem in Userspace)

Scalable Low cost Storage system Combining multiple directories

研究背景 (Research background)

IoTが急激な広がりを見せている昨今ですが、日々増加し続ける大量のセンサデータを保存するためのストレージを用意することはコスト面で大きな問題となり得ます。 IoTシステムはスモールスタートで始まることが多く、限られた予算の中で検証を迫られることが多いからです。 渡辺研究室で取り組んでいる軍艦島モニタリングプロジェクトも今でこそ50個を超えるセンサが稼働していますが、最初はカメラ1台から始まりました。 しかしこの現場では、安価なNAS (Network Attached Storage) を用いることでストレージ全体のコストを抑えることができたものの、拡張できないことや管理の大変さなどの新たな課題が浮上しました。

With the rapid spread of IoT these days, preparing storage to store the ever-increasing amount of sensor data can be a major cost issue. This is because IoT systems often start with a small start and are often forced to verify within a limited budget. The Gunkanjima Monitoring Project, which Watanabe Laboratory is working on, now has more than 50 sensors in operation, but it started with a single camera. Gunkanjima is an island that prospered as a coal mining city more than 100 years ago and was registered as a World Heritage Site in 2015. The target of preservation is a reinforced concrete coal mine city, but the buildings are collapsing. The Gunkanjima Monitoring Project contributes in terms of accumulating valuable data on historic buildings. However, at this site, although the cost of the entire storage can be reduced by using an inexpensive NAS (Network Attached Storage), new problems such as the inability to expand the storage capacity and the difficulty in managing the storage have arisen.

研究内容 (Research content)

新たに浮上した課題を解決するため、我々はIoTデータ向けの複数NAS統合型ファイルシステム「DIY-SDFS (Do It Yourself-Sensor Data FileSystem) 」を開発しました。 DIY-SDFSは、FUSE (Filesystem in Userspace) を用いて開発された仮想ファイルシステムで、オンサイトにおいて複数のNASを束ね1つのファイルシステムとして利用することを想定しています。 DIY-SDFSでは、ファイルシステムを止めずに新しいNASを追加することができる、保存するNASがストレージ残量によって自動的に切り替わるなど、IoTのためのファイルシステムとして必要最小限の機能を提供しています。 具体的には、時系列IoTデータを効率よく管理するために以下の5つの特徴を備えています。

(1) 複数のNASが1つのファイルシステムとして見える
(2) 設定ファイルの書き換えだけサービスの再起動なしに新しいNASを追加できる
(3) あるNASの残り容量が少なくなった場合には自動的に残り容量の多いNASに保存される
(4) 日付が近いファイルが同じNASに保存されやすくなる仕組みを提供している
(5) 1つのNASだけ取り出しても通常のファイル操作ができる

In order to solve the new problem, we have developed a multi-NAS integrated file system "DIY-SDFS (Do It Yourself-Sensor Data File System)" for IoT data. DIY-SDFS is a virtual file system developed using FUSE (Filesystem in Userspace), and it is assumed that multiple NAS will be integrated onsite and used as one file system. DIY-SDFS provides the minimum necessary functions as a file system for IoT, such as being able to add a new NAS without stopping the file system and automatically switching the NAS to save according to the remaining storage capacity. Specifically, it has the following five features to efficiently manage time-series IoT data.

1) Multiple NAS can be handled as one file system.
2) Users can add a new NAS simply by rewriteing the configuration file.
3) When the remaining capacity of the NAS decreases, it is automatically saved on another NAS.
4) Files with similar dates are saved on the same NAS.
5) Users can perform normal operations on one of the integrated NAS.

仮想ファイルシステムのイメージ図
図1 複数のディレクトリを束ねる仮想ファイルシステムの世界
DIY-SDFSのアーキテクチャ
図2 DIY-SDFSのアーキテクチャ

DIY-SDFSの使い方 (How to use DIY-SDFS)

動作環境

正しく動作する検証を行ったのは以下の環境です。

ubuntu 16.04 LTS
ubuntu 18.04 LTS


インストール (install)


$ cat << EOF > /etc/apt/sources.list.d/watalab-software.list
deb [trusted=yes] https://www-int.ist.osaka-u.ac.jp/debs/ AMD64/
EOF
$ sudo apt update
$ sudo apt install diy-sdfs


アンインストール (uninstall)


$ sudo apt remove diy-sdfs
$ rm /etc/apt/sources.list.d/watalab-software.list


マウントコマンド


$ diy-sdfs -m [mountpoint]


DIY-SDFSパス

DIY-SDFSでは、日付ごとにセンサデータを保存するためのフォーマットをDIY-SDFSパスとして統一することで、複数のNASを統合しやすい仕組みを実現しています。 具体的には、/diy-sdfs にDIY-SDFSをマウントした場合、/diy-sdfs/[センサデータの種類]/[年]/[月]/[日]/[ファイル名] の形式で統一しています。 例えば、2021年4月1日の加速度センサのファイル名がacc.csvだった場合、
DIY-SDFSパスは /diy-sdfs/acc/2021/04/01/acc.csv となります。

設定ファイルの記述内容

ユーザーはDIY-SDFSの設定ファイルを編集することにより、データを保存するNASの指定や新しいNASの追加を行うことができます。 設定ファイルはDIY-SDFS上のディレクトリのパスパターンと対応先のNASのマウントポイントのペアで記述します。 ワイルドカードを使用することもできます。 例えば、DIY-SDFSが /diy-sdfsに、3台のNASがそれぞれ /mnt/nas01, /mnt/nas02, /mnt/nas03にマウントされているとき、設定ファイルを以下のように記述すると記載されている順に容量が無くなるまで順番に保存されるようになります。


----/etc/diy-sdfs.conf----

/␣/mnt/nas01
/␣/mnt/nas02
/␣/mnt/nas03

---------------------------------
␣は半角スペース

DIY-SDFSは取得したセンサデータの年や月によって、保存するNASを指定することができます。 例えば、設定ファイルに以下のように記述した場合は、2019年1月から9月のセンサデータは /mnt/nas01に、2019年10月から12月と2020年のセンサデータは /mnt/nas02に、2021年のセンサデータは /mnt/nas03 に保存されるようになります。 DIY-SDFSは設定ファイルに記述されているパスパターンと最も長くプレフィックスマッチングNASから順にファイルの読み込み、書き込みを行います。


----/etc/diy-sdfs.conf----

/*/2019␣/mnt/nas01
/*/2019/10␣/mnt/nas02
/*/2019/11␣/mnt/nas02
/*/2019/12␣/mnt/nas02
/*/2020␣/mnt/nas02
/*/2021␣/mnt/nas03

---------------------------------

もちろん、DIY-SDFSパスは毎日取得するようなセンサデータのための推奨設定ではあるので、自由に変更して利用することもできます。 DIY-SDFSはIoTセンサデータを扱うために必要最小限の機能を持ったファイルシステムです。 各々の環境によって設定ファイルを書き換えてDIY-SDFSを利用することで、誰でも簡単に安価でスケーラブルな独自のストレージシステムを構築することができます。

DIY-SDFS Path

In DIY-SDFS, a format for storing sensor data is standardized as an DIY-SDFS path. Specifically, when DIY-SDFS is mounted on /diy-sdfs, it is standardized in the following format.


/diy-sdfs/[sensor type]/[year]/[month]/[day]/[name]


For example, if the acceleration sensor data on April 1th, 2021 is acc.csv, the DIY-SDFS path is following.


/diy-sdfs/acc/2021/04/01/acc.csv


Configuration file format

Reading the configuration file of the path conversion mechanism is implemented as a thread and is executed periodically. The thread acquires the NAS mount point information described in the configuration file and checks the remaining capacity of each mounted NAS. The configuration file is given as a pair of the path pattern of the directory on SDFS, and the mount point of the corresponding NAS. The path pattern is described as an absolute path with the mount point as the root. Users can utilize wildcards. SDFS is mounted on /sdfs, and three NAS are mounted as /mnt/nas01, /mnt/nas02, and /mnt/nas03. At this point, if the configuration file /etc/sdfs.conf contains the following, the files are saved in the order they were written until the capacity is exceeded.


----/etc/diy-sdfs.conf----

/␣/mnt/nas01
/␣/mnt/nas02
/␣/mnt/nas03

---------------------------------
␣ : Half-width space

In SDFS, users can select the NAS to save according to the type, year, and month of the acquired sensor data. If the setting file is described as follows, sensor data from January to September 2019 will be saved in /mnt/nas01. In addition, sensor data from October to December 2019 and 2020 will be saved to /mnt/nas02, and sensor data for 2021 will be saved to /mnt/nas03.


----/etc/diy-sdfs.conf----

/*/2019␣/mnt/nas01
/*/2019/10␣/mnt/nas02
/*/2019/11␣/mnt/nas02
/*/2019/12␣/mnt/nas02
/*/2020␣/mnt/nas02
/*/2021␣/mnt/nas03

---------------------------------

By using DIY-SDFS, anyone can easily build an inexpensive and scalable storage system.

軍艦島モニタリングプロジェクトウェブサイト

DIY-SDFS GitHub Repository

トップへ戻る