OshiHa.com

ConoHaでAlpine Linux 3.8

ConoHaオブジェクトストレージのマウント

2018/09/04  2018/09/25

◆◇◆ 【衝撃価格】VPS512MBプラン!月額630円/1時間1円【ConoHa】 ◆◇◆

Conoha のオブジェクトストレージを Alpine Linux のファイルシステムにマウントするため、CloudFuse を導入する。
CloudFuse はソースからビルドして導入する。

1. 必要ライブラリの導入

alpine:~$ sudo apk add git g++ make curl fuse-dev pkgconfig curl-dev libxml2-dev json-c-dev file-dev

2. cloudfuse のインストール

alpine:~$ su -
alpine:~# cd /tmp
alpine:/tmp# git clone https://github.com/redbo/cloudfuse
Cloning into 'cloudfuse'...
remote: Counting objects: 585, done.
remote: Total 585 (delta 0), reused 0 (delta 0), pack-reused 585
Receiving objects: 100% (585/585), 303.48 KiB | 906.00 KiB/s, done.
Resolving deltas: 100% (326/326), done.
alpine:/tmp# cd cloudfuse
alpine:/tmp/cloudfuse# ./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for a BSD-compatible install... /usr/bin/install -c
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for XML... yes
checking for JSONC... yes
checking for CURL... yes
checking for FUSE... yes
checking for OPENSSL... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for ANSI C header files... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for stdint.h... (cached) yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking fuse.h usability... no
checking fuse.h presence... no
checking for fuse.h... no
checking curl/curl.h usability... yes
checking curl/curl.h presence... yes
checking for curl/curl.h... yes
checking libxml/tree.h usability... no
checking libxml/tree.h presence... no
checking for libxml/tree.h... no
checking openssl/crypto.h usability... yes
checking openssl/crypto.h presence... yes
checking for openssl/crypto.h... yes
checking for an ANSI C-conforming const... yes
checking for uid_t in sys/types.h... yes
checking for mode_t... yes
checking for off_t... yes
checking for size_t... (cached) yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for struct stat.st_blocks... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking whether time.h and sys/time.h may both be included... yes
checking for sys/time.h... (cached) yes
checking for unistd.h... (cached) yes
checking for alarm... yes
checking for working mktime... yes
checking return type of signal handlers... void
checking for vprintf... yes
checking for _doprnt... no
checking for ftruncate... yes
checking for memmove... yes
checking for strcasecmp... yes
checking for strchr... yes
checking for strdup... yes
checking for strncasecmp... yes
checking for strrchr... yes
checking for strstr... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
alpine:/tmp/cloudfuse# make
gcc -Wall -g -O2 -I/usr/include/libxml2   -I/usr/include/fuse -D_FILE_OFFSET_BITS=64   -I/usr/include/json-c  -o cloudfuse cloudfsapi.c cloudfuse.c -lxml2  -lcurl  -lfuse -pthread  -lssl -lcrypto  -ljson-c
alpine:/tmp/cloudfuse# make install
/usr/bin/install -c cloudfuse /usr/local/bin/cloudfuse

3. cloudfuse の設定

cloudfuseコマンドを使って Object Storage を利用するには、Object Storage にアクセスするための情報(url, username, password)が必要となる。

ホームディレクトリに .cloudfuse ファイルを作成し、次のようにオブジェクト・ストレージの認証エンドポイント、ユーザー名、パスワード(API Key)の情報を記述する。
alpine:/tmp/cloudfuse# vi ~/.cloudfuse

username=gncu********
tenant=gnct********
password=********
authurl=https://identity.tyo1.conoha.io/v2.0
verify_ssl=True

パーミッションの変更
alpine:/tmp/cloudfuse# chmod 600 ~/.cloudfuse

マウントポイントの作成
alpine:/tmp/cloudfuse# mkdir /mnt/object_storage

4. 手動マウント

alpine:~$ modprobe fuse
alpine:~$ sudo cloudfuse /mnt/object_storage -o nonempty -o allow_other

5. 自動マウント

Nextcloud の保存先をマウント先に指定する。
先に、Nextcloud のデータはすべて消去(移動)しておくこと。
alpine:~$ sudo vi /etc/fstab

# 最終行に追加
cloudfuse /var/lib/nextcloud/data/*****/files fuse auto,_netdev,gid=103,umask=007,allow_other,defaults  0 0

設定後(再起動後)に以下を実行してマウント完了。
alpine:~$ sudo mount -a

6. マウント状況の確認

alpine:~$ sudo df -h
Filesystem                Size      Used Available Use% Mounted on
devtmpfs                 10.0M         0     10.0M   0% /dev
shm                     497.0M         0    497.0M   0% /dev/shm
/dev/vda3                47.0G      1.8G     42.8G   4% /
tmpfs                    99.4M    216.0K     99.2M   0% /run
/dev/vda1                92.8M     19.1M     66.8M  22% /boot
cloudfuse                 8.0T         0      8.0T   0% /var/lib/nextcloud/data/*****/files

◆◇◆ 【衝撃価格】VPS512MBプラン!月額630円/1時間1円【ConoHa】 ◆◇◆

ConoHa VPSの攻略
Alpine Linux 3.8

TOP