いろいろ準備中

さくらVPSにs3fsをインストール

8月 11th, 2011 Posted in aws, s3, さくら

環境

さくらVPS、CentOS 5.5 x86_64

インストール

現時点でのs3fs の最新版(1.59)では、以下のライブラリが必要となっています

  • fuse 2.8.4
  • libcurl 7.0
  • libxml-2.0 2.6
  • libcrypto 0.9

curlのインストール

# yum install curl-devel -y

libxml2のインストール

# yum install libxml2-devel -y

FUSEのインストール

$ wget http://sourceforge.net/projects/fuse/files/fuse-2.X/2.8.5/fuse-2.8.5.tar.gz/download
$ tar zxvf fuse-2.8.5.tar.gz
$ cd fuse-2.8.5
$ ./configure
$ make
# make install

s3fsをインストール

$ wget http://s3fs.googlecode.com/files/s3fs-1.59.tar.gz
$ tar zxvf s3fs-1.59.tar.gz 
$ cd s3fs-1.59
$ ./configure --prefix=/usr
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for g++... g++
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 g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for DEPS... no
configure: error: Package requirements (fuse >= 2.8.4 libcurl >= 7.0 libxml-2.0 >= 2.6 libcrypto >= 0.9) were not met:
 
No package 'fuse' found
 
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
 
Alternatively, you may set the environment variables DEPS_CFLAGS
and DEPS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

fuseのパッケージが見つからないというエラーがでました

しょんぼり技術メモさんの記事を参考に

$ find / -name 'fuse.pc' 2> /dev/null
/root/fuse-2.8.5/fuse.pc
/usr/local/lib/pkgconfig/fuse.pc

から、PKG_CONFIG_PATHを指定して、再度configureを実施。

$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig 
$ ./configure --prefix=/usr
$ make
# make install

s3との接続

s3fsのインストールが終了しました。以下のどれかの方法で、s3をマウントできるようです

  1. コマンドラインオプションで、passwd_fileを指定
  2. AWSACCESSKEYID と AWSSECRETACCESSKEY の環境変数を設定
  3. ホームディレクトリにある .passwd-s3fs ファイルを使用
  4. /etc/passwd-s3fs ファイルを使用

3番目と、4番目の方法を説明します

.passwd-s3fs ファイルを使う場合(上記3番目の方法)

AWSアクセスキーとAWSシークレットキーが記載された .passwd-s3fsファイルをホームディレクトリに作成します

$ touch ~/.passwd-s3fs
$ vi ~/.passwd-s3fs  # 以下のとおり編集します。
AWSアクセスキー:AWSシークレットキー

/etc/passwd-s3fs を使用する場合(上記4番目の方法)

$ touch /etc/passwd-s3fs
$ vi /etc/passwd-s3fs # 以下のとおり編集します。
AWSアクセスキー:AWSシークレットキー

s3のマウント

はじめてのマウントする場合 modprobe を実行します。

# modprobe fuse

s3をマウントします。

# s3fs バケット名 マウントポイント

確認をします。

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda2              17G  1.6G   15G  10% /
/dev/hda1              99M   12M   82M  13% /boot
tmpfs                 250M     0  250M   0% /dev/shm
fuse                  256T     0  256T   0% /mnt/s3

うまくマウントされました( /mnt/s3 にマウントしています)。

fstabの設定

再起動時に自動的にマウントするように設定をします。

# vi /etc/fstab
s3fs#バケット名 マウントポイント fuse allow_other,default_acl=public-read 0 0

起動時に以下のようなメッセージが表示された場合

fuse: device not found, try 'modprobe fuse' first

/etc/rc.d/rc.sysinit のfstab設定の前でmodprobe fuseを実行します。
だいたい 「. /etc/init.d/functions」の記述のあたりです。

...
. /etc/init.d/functions
 
 # for s3fs
modprobe fuse # この記述を追加
...

再起動をして、s3がマウントされていれば成功です

参考

コメントを投稿する