LoginSignup
1
1

More than 1 year has passed since last update.

[OCI] gcsfuseを使用してGoogle Cloud Storage バケットをComputeインスタンスにファイルシステムとしてマウントしてみた

Last updated at Posted at 2022-02-26

はじめに

こちらの記事では、Microsoftから提供されているblobfuseを使用してAzure Blob Storageのコンテナ内にあるバックアップファイルを直接OCIのMySQL DBシステムにリストアしてみました。

今回は、Googleから提供されているgcsfuseを使用して、Google Cloud Storage バケットを OCIのComputeインスタンスにファイルシステムとしてマウントしてみました。
また、cpコマンドを用いたGoogle Cloud Storage バケットからComputeインスタンスへのファイルコピーのパフォーマンスを計測してみました。

1.gcsfuseのインストール

gcsfuseをインストールするためのリポジトリを設定します。

[opc@compute1 /]$ sudo tee /etc/yum.repos.d/gcsfuse.repo > /dev/null <<EOF
> [gcsfuse]
> name=gcsfuse (packages.cloud.google.com)
> baseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64
> enabled=1
> gpgcheck=1
> repo_gpgcheck=0
> gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
>        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
> EOF
[opc@compute1 /]$

yumコマンドでgcsfuseをインストールします。

[opc@compute1 ~]$ sudo yum install -y gcsfuse
Loaded plugins: langpacks, osmsplugin, ulninfo
This system is receiving updates from OSMS.
gcsfuse                                                                                     | 1.4 kB  00:00:00     
gcsfuse/primary                                                                             | 2.5 kB  00:00:00     
gcsfuse                                                                                                      16/16
<略>
Resolving Dependencies
--> Running transaction check
---> Package gcsfuse.x86_64 0:0.28.1-1 will be installed
--> Processing Dependency: fuse for package: gcsfuse-0.28.1-1.x86_64
--> Running transaction check
---> Package fuse.x86_64 0:2.9.4-1.0.9.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================
 Package               Arch                 Version                          Repository                       Size
===================================================================================================================
Installing:
 gcsfuse               x86_64               0.28.1-1                         gcsfuse                         4.0 M
Installing for dependencies:
 fuse                  x86_64               2.9.4-1.0.9.el7                  ol7_latest-x86_64                88 k

Transaction Summary
===================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 4.1 M
Installed size: 12 M
Downloading packages:
(1/2): fuse-2.9.4-1.0.9.el7.x86_64.rpm                                                      |  88 kB  00:00:00     
warning: /var/cache/yum/x86_64/7Server/gcsfuse/packages/4d9c7e630b6a8c14c6c054f5c23107be50e8d8a3b2707e6bef66ef6a236bb5c4-gcsfuse-0.28.1-1.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 3e1ba8d5: NOKEY
Public key for 4d9c7e630b6a8c14c6c054f5c23107be50e8d8a3b2707e6bef66ef6a236bb5c4-gcsfuse-0.28.1-1.x86_64.rpm is not installed
4d9c7e630b6a8c14c6c054f5c23107be50e8d8a3b2707e6bef66ef6a236bb5c4-gcsfuse-0.28.1-1.x86_64.rp | 4.0 MB  00:00:00     
-------------------------------------------------------------------------------------------------------------------
Total                                                                              6.2 MB/s | 4.1 MB  00:00:00     
Retrieving key from https://packages.cloud.google.com/yum/doc/yum-key.gpg
Importing GPG key 0x307EA071:
 Userid     : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2021-03-01-08_01_09.pub)"
 Fingerprint: 7f92 e05b 3109 3bef 5a3c 2d38 feea 9169 307e a071
 From       : https://packages.cloud.google.com/yum/doc/yum-key.gpg
Importing GPG key 0x836F4BEB:
 Userid     : "gLinux Rapture Automatic Signing Key (//depot/google3/production/borg/cloud-rapture/keys/cloud-rapture-pubkeys/cloud-rapture-signing-key-2020-12-03-16_08_05.pub) <glinux-team@google.com>"
 Fingerprint: 59fe 0256 8272 69dc 8157 8f92 8b57 c5c2 836f 4beb
 From       : https://packages.cloud.google.com/yum/doc/yum-key.gpg
Retrieving key from https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
Importing GPG key 0x3E1BA8D5:
 Userid     : "Google Cloud Packages RPM Signing Key <gc-team@google.com>"
 Fingerprint: 3749 e1ba 95a8 6ce0 5454 6ed2 f09c 394c 3e1b a8d5
 From       : https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : fuse-2.9.4-1.0.9.el7.x86_64                                                                     1/2 
  Installing : gcsfuse-0.28.1-1.x86_64                                                                         2/2 
  Verifying  : gcsfuse-0.28.1-1.x86_64                                                                         1/2 
  Verifying  : fuse-2.9.4-1.0.9.el7.x86_64                                                                     2/2 

Installed:
  gcsfuse.x86_64 0:0.28.1-1                                                                                        

Dependency Installed:
  fuse.x86_64 0:2.9.4-1.0.9.el7                                                                                    

Complete!
[opc@compute1 ~]$

fusermountのパーミッションを変更します。
こちらのパーミッションを変更しないと、一般ユーザではgcsfuseが実行できませんでした。

[opc@compute1 ~]$ sudo chmod o+rx /usr/bin/fusermount

2.Google Cloud Storage バケットの作成

Google Cloud Storageのバケットを作成します。
今回はasia-northeast1リージョンにgcs_bucket_999という名前のバケットを作成しました。
スクリーンショット 2022-02-26 15.27.30.png

3. gcsfuseの設定

Google Cloud Storageのキーファイル保存用のディレクトリを作成します。

[opc@compute1 ~]$ mkdir .gcs

GCPのコンソールから、サービスアカウントのキーファイル(JSON)をダウンロードします。
スクリーンショット 2022-02-26 15.22.31.png

サービスアカウントのキーファイルをSCPで/home/opc/.gcsにアップロードします。

キーファイルのパーミッションを変更します。

[opc@compute1 ~]$ cd .gcs/
[opc@compute1 .gcs]$ chmod 600 warm-scout-342411-893dec4d7ee7.json
[opc@compute1 .gcs]$ ls -l
total 4
-rw-------. 1 opc opc 2335 Feb 26 05:41 warm-scout-342411-893dec4d7ee7.json
[opc@compute1 .gcs]$ 

環境変数GOOGLE_APPLICATION_CREDENTIALSにキーファイルの場所を設定します。

export GOOGLE_APPLICATION_CREDENTIALS="/home/opc/.gcs/warm-scout-342411-893dec4d7ee7.json"

4. gcsfuseを使用したバケットのマウント

マウントポイントを作成します。

[opc@compute1 .gcs]$ cd
[opc@compute1 ~]$ mkdir mnt_gcs

gscfuseでGoogle Cloud Storageのバケットgcs_bucket_999をマウントポイント/home/opc/mnt_gcsにマウントします。

[opc@compute1 ~]$ gcsfuse gcs_bucket_999 /home/opc/mnt_gcs
Using mount point: /home/opc/mnt_gcs
Opening GCS connection...
Opening bucket...
Mounting file system...
File system has been successfully mounted.
[opc@compute1 ~]$

無事マウントできたようです。

5.gcsfuseの動作確認

マウントポイントにファイルを作成してみます。

[opc@compute1 ~]$ touch /home/opc/mnt_gcs/test.txt
[opc@compute1 ~]$ ls -l /home/opc/mnt_gcs/
total 0
-rw-r--r--. 1 opc opc 0 Feb 26 06:11 test.txt
[opc@compute1 ~]$

GCPのコンソールでバケットgcs_bucket_999の内容を確認してみます。
スクリーンショット 2022-02-26 15.13.00.png
バケット内にファイルが作成されていることが確認できました。

6.ファイルコピーのパフォーマンス計測

gcsfuseを用いたGoogle Cloud StorageバケットからComputeインスタンスへのファイルコピーのパフォーマンスを計測するために、GCPのコンソールから約2.2GBのファイル(Cent8.vmdk)をアップロードしました。
スクリーンショット 2022-02-26 15.47.01.png
マウントポイントの内容を確認してみます。

[opc@compute1 ~]$ ls -l /home/opc/mnt_gcs/
total 2257408
-rw-r--r--. 1 opc opc 2311585792 Feb 26 06:41 Cent8.vmdk
-rw-r--r--. 1 opc opc          0 Feb 26 06:44 test.txt
[opc@compute1 ~]$ 

Cent8.vmdkが確認できました。
cpコマンドでコピーを実行して、timeコマンドで所要時間を確認してみます。
VM.Standard3.Flex 1 OCPU/16GBメモリの環境での実行結果です。

[opc@compute1 ~]$ time cp /home/mnt_gcs/Cent8.vmdk .

real	0m18.987s
user	0m0.013s
sys 	0m1.666s
[opc@compute1 ~]$

VM.Standard3.Flex 1 OCPU/16GBメモリ/ネットワーク帯域1Gbpsの環境では、約2.2GBのファイルがおよそ19秒でコピーできました。
転送レートは約116MB/s = 928Mbpsとなりました。

VM.Standard3.Flex 2 OCPU/16GBメモリの環境での実行結果です。

[opc@compute1 ~]$ time cp ./mnt_gcs/Cent8.vmdk .

real	0m9.350s
user	0m0.019s
sys 	0m1.699s
[opc@compute1 ~]$ 

VM.Standard3.Flex 2 OCPU/16GBメモリ/ネットワーク帯域2Gbpsの環境では、約2.2GBのファイルがおよそ9.4秒でコピーできました。
転送レートは約236MB/s = 1.89Gbpsとなりました。

VM.Standard3.Flex 3 OCPU/16GBメモリの環境での実行結果です。

[opc@compute1 ~]$ time cp ./mnt_gcs/Cent8.vmdk .

real	0m8.308s
user	0m0.019s
sys 	0m1.571s
[opc@compute1 ~]$ 

VM.Standard3.Flex 2 OCPU/16GBメモリネットワーク帯域3Gbpsの環境では、約2.2GBのファイルがおよそ8.3秒でコピーできました。
転送レートは約266MB/s = 2.12Gbpsとなりました。

なお、こちらの値はあくまで今回の環境での実測値であり、性能を保証するものではありません。

参考情報

Cloud Storage FUSE
GitHub:GoogleCloudPlatform/gcsfuse

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1