Skip to content

S3rver on a Raspberry Pi 3 with Raspbian (Debian Jessie 8.0)

Christian Baun edited this page Apr 25, 2017 · 3 revisions

S3rver on a Raspberry Pi 3 with Raspbian (Debian Jessie 8.0)

The Raspberry Pi 3 single board computer from the Raspberry Pi Foundation has a 1.2 GHz quad-core ARMv8 processor, 1 GByte main memory and a 10/100 Mbps Ethernet interface.

Front of the Raspberry Pi 3 single board computer Back of the Raspberry Pi 3 single board computer

This installation tutorial explains the installation of a Raspberry Pi 3 device from scratch and the configuration of s3cmd on your computer.

This implies that you have already an installation of s3cmd on the system you want to use for the interaction with the S3rver storage service.

Fetch and decompress the operating system image

$ wget https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-03-03/2017-03-02-raspbian-jessie-lite.zip
$ unzip 2017-03-02-raspbian-jessie-lite.zip 

Write the image on a local micro SD card

Check which one is the correct device! If you use an internal card reader, it is often /dev/mmcblk0.

# dd bs=1M if=2017-03-02-raspbian-jessie-lite.img of=/dev/sdb && sync

Default login of this image is pi/raspberry. To become user root, execute sudo su.

Older Raspian versions started the SSH server by default. Because of security reasons (as explained here), all Raspian versions since version 2016-11-25 (see the release notes) have the SSH server disabled by default. To get the SSH server automativally activated during boot time, create a file ssh with any content (or just an empty file) inside the boot partition (it is the first partition) of the micro SD card.

# mount /dev/sdb1 /media/
# touch /media/ssh
# umount /media/

Start the Raspberry Pi Computer

Insert the micro SD card into the Raspberry Pi computer, connect it with the ethernet cable and the micro USB cable for power suppy and switch on the power supply. The operating system will try to fetch network configuration by using DHCP on the Ethernet interface per default. If you activated the SSH server, you can now log in via SSH.

The system used with this tutorial had these characteristics

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 8.0 (jessie)
Release:	8.0
Codename:	jessie
$ uname -a
Linux raspberrypi 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l GNU/Linux

Expand the File System to make use of the entire Capacity of the micro SD Card

$ sudo raspi-config

Expand the file system with raspi-config Expand the file system with raspi-config

Reduce the Amount of Memory for the GPU

This is not required for running the S3rver, but the Raspberry Pi 3 has just 1 GB of main memory which is not much at all and there is no need to waste 48 MB.

A part of the main memory (just 1 GB) is assigned to the GPU. A pure server does not need a GPU at all. The share can me specified via the raspi-config tool. The minimum value is 16 MB, which is more useful compared with the dafault value (64 MB).

Specify the memory split with raspi-config Specify the memory split with raspi-config

After the new value is specified and after a reboot, the new value should be visible:

# vcgencmd get_mem gpu
gpu=16M

Configure the Time Zone

This is not required for running the S3rver, but it is always useful to configure the operating system properly

$ sudo dpkg-reconfigure tzdata
$ cat /etc/timezone
Europe/Berlin

It is also possible to specify the time zone via the raspi-config tool.

Configure NTP to have the correct Time on the Raspberry Pi Computer

This is not required for running the S3rver, but it is always useful to have the correct time on a computer

$ sudo apt-get update && sudo apt-get install -y ntp ntpdate

Now the time sould be synchronized with several NTP servers.

$ ntpq -p 
remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*static-96-244-9 192.168.10.254   2 u  158  256  377  124.848    7.742   2.899
-ns.al-abrarcom. 193.11.166.20    2 u   24  256  377  137.600   -0.496   8.142
-hotel.zq1.de    235.106.237.243  3 u  159  256  377   35.700   -0.922   2.287
+www.mistersixt. 157.224.22.179   3 u  255  256  377   35.595    5.157   3.160
+fritz.box       192.86.14.67     3 u  198  256  377    0.465    6.749   2.049

Check the time and date:

# date -R
Tue, 25 Apr 2017 12:04:19 +0200

Install some packages

Some of them are not required for the installation of S3rver, but just nice to have.

$ sudo apt-get install -y curl htop joe nmap git npm

Install the S3rver

Install S3rver as user root.

# npm install s3rver -g

Create a symlink.

# ln -s /usr/bin/nodejs /usr/bin/node

This is required to get rid of this issue:

$ s3rver --help
/usr/bin/env: node: No such file or directory

Thanks to the symlink, the service should be available:

$ s3rver --help

  Usage: s3rver [options]

  Options:

-h, --help                  output usage information
--version                   output the version number
-h, --hostname [value]      Set the host name or ip for the server
-p, --port <n>              Set the port of the http server
-s, --silent                Suppress log messages
-i, --indexDocument [path]  Index Document for Static Web Hosting
-e, --errorDocument [path]  Custom Error Document for Static Web Hosting
-d, --directory [path]      Data directory
-c, --cors                  Enable CORS

Create a folder for the object data.

$ mkdir ~/s3test

Now, s3rver can be started.

$ s3rver -h <the_ip_of_your_raspberry> -p 8080 -d ~/s3test/

Important !!! If the IP address is not specified when s3rver is started, its port is only accessible from localhost.

Configure the ~/.s3cfg file to make s3cmd working with S3rver

Just these lines need to be modified:

access_key = 123
host_base = <the_ip_of_your_raspberry>:8080
host_bucket = <the_ip_of_your_raspberry>:8080
secret_key = abc
use_https = False

Now s3cmd should work properly with the S3rver service.

$  s3cmd mb s3://testbucket
Bucket 's3://testbucket/' created
$  s3cmd ls
2017-04-25 09:36  s3://testbucket
$  s3cmd rb s3://testbucket
Bucket 's3://testbucket/' removed

Some important Stuff

S3rver only accepts bucket names, which are encoded entirely in lower case letters. Each attempt to create a bucket which is encoded in upper case letters results in this error message:

error: [S3rver] Error creating bucket "S3PERF-TESTBUCKET" because the name is invalid

The default access key is 123, with the default secret access key is abc. It is unclear how to modify the specify different credentials.

Deploy Storage Services

Performance

Clone this wiki locally