Tuesday, 9 January 2018

How to mount s3 bucket on local machine

If we want to use our s3 bucket as a hard disk and want to mount same on our server then we need to perform following steps:-

Kernel >= 2.6.32
S3fs = 1.74
Fuse = 2.8.4
libcurl >=7.0
Libxml >=2.6

  1. Create API Key Set :- Create access key and security key and download.
Login AWS console → My account → AWS management console → create an user account with API key set and download key.
Define user policy, allowing s3 access to an account.
  1. Go to IAM → identity & access management → user → create → Download Key
  2. Select created user → give access permission → Amazons3fullaccess

   2) Create Bucket:-
Create bucket → name → region (from properties we can manage access)

   3) login in server and create password file :-
Vim /etc/passwd-s3fs
Write accesskey:securitykey

Change permission :-
chmod 640 /etc/passwd-s3fs

4) Install & configure packages :-
~)# yum install gcc gcc-c++ curl-devel libxml2-devel curl libxml2-devel openssl-devel mlocate
Download fuse package:-
~)# cd /usr/src
src)#  tar-zxvf fuse-2.8.4.tar.gz
src)# cd fuse-2.8.4
fuse-2.8.4)# ./configure --prefix=/usr/local
fuse-2.8.4)# make
fuse-2.8.4)# make install
fuse-2.8.4)# ldconfig
fuse-2.8.4)# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
fuse-2.8.4)# pkg-config --modversion fuse (check version of fuse)
Download s3fs package :-
~) cd /usr/src
src)# tar -zxvf s3fs-1.74.tar.gz
src)# cd s3fs-1.74
s3fs-1.74)# ./configure --prefix=/usr/local
s3fs-1.74)# make
s3fs-1.74)# make install
s3fs-1.74)# s3fs --version (check version)

Now s3fs and fuse both are successfully installed, now this time to create directory and mount with s3:-
~) mkdir /s3-demo
~) s3fs lakhan-bucket /s3-demo   (where lakhan-bucket is name of bucket which you need to mount)
~) df -h :- (check is it mounted or not)
Permanent Mount s3 bucket on local machine:-
If you want to mount the S3 bucket permanently, add the following entry in the /etc/fstab

s3fs#lakhan-bucket  /s3-demo  fuse allow_user,use_cache=time 0 0
Lakhan-bucket = this is the bucket name
/s3-demo = this is the mounting directory
Fuse :- file system
allow_other – It allows other users to access the file.
use_cache – Local folder to use for local file cache

Errors and resolutions :-
  1. If got error :- libfuse.so.2: cannot open shared object file

Then there is fuse library is missing, Install same by following command.
Yum install fuse-libs :- It will be of 251k package.
Then try to install the fuse in system then it will work.
2) if got error :- fuse >=fuse 2.8.4,or no fuse is installed then check following things:-

  1. Are you installing with root user
  2. Are you installing version fuse-2.8.4
  3. This happen because of fuse configuration, remove fuse and again install same with root user, It generally happen when you install with other users.

No comments:

install winrar on CentOS 6.x

Steps to install  WinRar  on Cent Os machine in order to un-rar a rar archive transferred from windows machine. Download Links For L...