Setup With OpenStackSwift

Note: Since Seafile Server 5.0.0, all config files are moved to the central conf folder. Read More.

Note: This documentation is obsolete. Please refer to the new documentation about how to use Swift.

Starting from professional server 2.0.5, Seafile can use S3-compatible cloud storage (such as OpenStack/Swift) as backend. This document will use Swift as example.

Seafile Server Preparation

To setup Seafile Professional Server with OpenStack Swift:

For best performance, Seafile requires install memcached and enable memcache for objects.

We recommend to allocate 128MB memory for memcached. Edit /etc/memcached.conf

  1. # Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
  2. # Note that the daemon will grow to this size, but does not start out holding this much
  3. # memory
  4. # -m 64
  5. -m 128

Swift Preparation

In a production environment, you’ll configure Swift with S3 middleware and use Keystone for authentication. The following instructions assumes you’ve already setup Swift with Keystone authentication. We’ll focus on the change you need to make Swift work with S3 middleware.

Install Swift3

This middleware implements S3 API for Swift.

  1. git clone https://github.com/fujita/swift3.git
  2. cd swift3
  3. sudo python setup.py install

Install keystonmiddleware

This middleware contains the s3token filter for authentication between S3 API and Keystone. If you’ve configured Swift to work with Keystone, you should have this middleware installed already.

  1. git clone https://github.com/openstack/keystonemiddleware.git
  2. cd keystonmiddleware
  3. sudo pip install -r requirements.txt
  4. sudo python setup.py install

Modify proxy-server.conf for Swift

On Ubuntu, the config file is /etc/swift/proxy-server.conf.

First check whether you’ve replaced tempauth with authtoken keystoneauth in the main pipeline. This should have been done if you configured Swift to work with Keystone.

Add swift3 s3token to [pipeline:main]:

  1. [pipeline:main]
  2. pipeline = [...] swift3 s3token authtoken keystoneauth proxy-server

Add filters:

  1. [filter:swift3]
  2. use = egg:swift3#swift3
  3. [filter:s3token]
  4. paste.filter_factory = keystonemiddleware.s3_token:filter_factory
  5. auth_port = 35357
  6. auth_host = [keystone-ip]
  7. auth_protocol = http

Restart Swift

  1. swift-init proxy restart

Accessing Swift via S3 API

To access it via S3 API, you’ll need AWS-like access key id and secret access key. Generate it with the following command for your specific tenant and user (You should change the tenant-id and user-id):

  1. keystone ec2-credentials-create --tenant-id=d6fdc8460c7b46d0ad24aa23667b85c3 --user-id=b66742a744eb4fc98abd945781bf969d

After successfully setup S3 middleware, you should be able to access it with any S3 clients. The next thing you need to do is to create buckets for Seafile. With Python boto library you can do as follows (replace key_id and secret_key with your own):

  1. import boto
  2. import boto.s3.connection
  3. connection = boto.connect_s3(
  4. aws_access_key_id='<key_id>',
  5. aws_secret_access_key='<secret_key>',
  6. port=8080,
  7. host='swift-proxy-server-address',
  8. is_secure=False,
  9. calling_format=boto.s3.connection.OrdinaryCallingFormat())
  10. connection.create_bucket('seafile-commits')
  11. connection.create_bucket('seafile-fs')
  12. connection.create_bucket('seafile-blocks')

Each S3 bucket maps to a container in Swift. So you can use native Swift command line to check the containers. For example:

  1. swift -V 2 -A http://[keystone_ip]:5000/v2.0 -U [tenant]:[user] -K [pas] list

Modify seafile.conf

Append the following lines to seafile.conf (replace key_id and secret_key with your own)

  1. [block_backend]
  2. name = s3
  3. bucket = seafile-blocks
  4. key_id = <key_id>
  5. key = <secret_key>
  6. host = <swift-proxy-server-address>:8080
  7. path_style_request = true
  8. memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
  9. [commit_object_backend]
  10. name = s3
  11. bucket = seafile-commits
  12. key_id = <key_id>
  13. key = <secret_key>
  14. host = <swift-proxy-server-address>:8080
  15. path_style_request = true
  16. memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
  17. [fs_object_backend]
  18. name = s3
  19. bucket = seafile-fs
  20. key_id = <key_id>
  21. key = <secret_key>
  22. host = <swift-proxy-server-address>:8080
  23. path_style_request = true
  24. memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100

Using memcached cluster

In a cluster environment, you may want to use a memcached cluster. In the above configuration, you have to specify all the memcached server node addresses in seafile.conf

  1. memcached_options = --SERVER=192.168.1.134 --SERVER=192.168.1.135 --SERVER=192.168.1.136 --POOL-MIN=10 --POOL-MAX=100

Run and Test

Now you can start Seafile by ./seafile.sh start and ./seahub.sh start and visit the website.