Google cloud storage fuse: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
No edit summary
No edit summary
Line 51: Line 51:
</pre>
</pre>


일반적으로
=== fstab setting ===
fstab 에 설정할때는 다음을 참조하자.
 
<pre>
<bucket name> <mount path> gcsfuse <options> 0 0
voipbin-voip-media-bucket-europe-west4 /mnt/media gcsfuse rw,allow_other,file_mode=777,dir_mode=777,key_file=/etc/service_account_gcsfuse.json,implicit_dirs 0 0
</pre>
fstab 변경이후, 변경내용을 적용하기 위해서는 '''$ sudo mount -a''' 를 입력하여야 한다.
 
* https://github.com/GoogleCloudPlatform/gcsfuse/blob/master/docs/mounting.md#mounting
* https://wiki.freepbx.org/pages/viewpage.action?pageId=168527092


== See also ==
== See also ==

Revision as of 06:48, 26 November 2020

Overview

Google cloud storage fuse 내용 정리.

Basic

Cloud storage FUSE is an open source FUSE adapter that allows user to mound Cloud Storage buckets as file systems on Linux or macOS systems. It also provides a way for applications to upload and download Cloud Storage objects using standard file system semantics. Cloud Storage FUSE can be run anywhere with connectivity to Cloud Storage, including Google Compute Engine VMs or on-premises systems.

Mount

gcsfuse 를 이용하면 google cloud storage 를 파일시스템으로 mount를 시킬 수 있다. 이 때 중요한 것은 --implicit-dirs 옵션을 붙여주여야 디렉토리 구조가 보인다는 것이다.

자세한 내용은 이곳(https://github.com/GoogleCloudPlatform/gcsfuse/blob/master/docs/mounting.md) 을 참조하자.

Implicit directories

By default, there is no allowance for the implicit existence of directories. Since the usual file system operation like mkdir will do the right thing, if the user sets up a bucket's structure using only gcsfuse then user will not notice anything odd about this. If, however, user uses some other tool to set up objects in GCS(such as the storage browser in the Google Developer Console), user may notice that not all objects are visible unitil user creates leading directories for them.

For example, say that user uses some other tool to set up a single object named "foo/bar" in user's bucket, then mount the bucket with gcsfuse. The file system will initially appear empty, since there is no "foo/" object. However if the user subsequently run `mkdir foo`, user will now see a directory named "foo" containing a file named "bar".

gcsfuse supports a flag called `--implicit-dirs` that changes the behavior. When this flag is enabled, name lookup requests from the kernel use the GCS API's Objects.list operation to search for objects that would implicitly define the existence of a directory with the name in question.

The use of `--implicit-dirs` has some drawbacks

  • The feature requires an additional request to GCS for each name lookup, which may have costs in terms of request budget and latency.
  • With this setup, it will appear as if there is a directory called "foo" containing a file called "bar". But when the user runs `rm foo/bar`, suddenly it will appear as if the file system is completely empty. This is contrary to expectations, since the user hasn't run `rmdir foo`.
  • gcsfuse sends a single Objects.list request to GCS, and treats the directory as being implicitly defined if the results are non-empty. In rare cases (notably when many objects have recently been deleted) Objects.list may return an artibrary number of empty responses with continuation token, even for a non-empty name range. In implicitly defined directory will fail to appear.

allow_other

--uid 옵션이나 --gid 옵션을 사용하지 않는다면 사용자 권한 문제로 마운트 된 디렉토리 접근이 불가능해진다. 간단한 해결책으로 -o alow_other 옵션을 사용하면 문제가 해결된다. 단, 보안에 취약해지므로 사용에 주의를 기울여야 한다.

systemd setting

[Unit]
Description=gcsfuse mount
After=network.target

[Service]
User=root
Type=forking
ExecStart=/usr/bin/gcsfuse \
  -o allow_other \
  --implicit-dirs \
  --key-file /etc/service_account.json \
  test-bucket-name \
  /mnt/target_directory
ExecStop=/bin/fusermount -u /mnt/media
Restart=always

[Install]
WantedBy=multi-user.target
Alias=gcsfuse.service

fstab setting

fstab 에 설정할때는 다음을 참조하자.

<bucket name> <mount path> gcsfuse <options> 0 0
voipbin-voip-media-bucket-europe-west4 /mnt/media gcsfuse rw,allow_other,file_mode=777,dir_mode=777,key_file=/etc/service_account_gcsfuse.json,implicit_dirs 0 0

fstab 변경이후, 변경내용을 적용하기 위해서는 $ sudo mount -a 를 입력하여야 한다.

See also