2010-11-04 14:25:23 -05:00
==============================================================
Instructions for a Multiple Server Swift Installation (Ubuntu)
==============================================================
Prerequisites
-------------
* Ubuntu Server 10.04 LTS installation media
.. note:
Swift can run with other distros, but for this document we will focus
on installing on Ubuntu Server, ypmv (your packaging may vary).
Basic architecture and terms
----------------------------
- *node* - a host machine running one or more Swift services
2011-05-26 02:24:12 +00:00
- *Proxy node* - node that runs Proxy services; also runs TempAuth
2010-11-04 14:25:23 -05:00
- *Storage node* - node that runs Account, Container, and Object services
- *ring* - a set of mappings of Swift data to physical devices
This document shows a cluster using the following types of nodes:
- one Proxy node
- Runs the swift-proxy-server processes which proxy requests to the
2011-03-14 02:56:37 +00:00
appropriate Storage nodes. The proxy server will also contain
2011-05-26 02:24:12 +00:00
the TempAuth service as WSGI middleware.
2010-11-04 14:25:23 -05:00
- five Storage nodes
2012-05-22 10:57:10 +02:00
- Runs the swift-account-server, swift-container-server, and
2010-11-04 14:25:23 -05:00
swift-object-server processes which control storage of the account
databases, the container databases, as well as the actual stored
objects.
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
.. note ::
Fewer Storage nodes can be used initially, but a minimum of 5 is
recommended for a production cluster.
This document describes each Storage node as a separate zone in the ring.
It is recommended to have a minimum of 5 zones. A zone is a group of nodes
that is as isolated as possible from other nodes (separate servers, network,
power, even geography). The ring guarantees that every replica is stored
in a separate zone. For more information about the ring and zones, see: :doc: `The Rings <overview_ring>` .
2010-11-24 10:55:29 -06:00
To increase reliability, you may want to add additional Proxy servers for performance which is described in :ref: `add-proxy-server` .
2010-11-23 16:30:38 -06:00
2010-11-04 14:25:23 -05:00
Network Setup Notes
-------------------
This document refers to two networks. An external network for connecting to the Proxy server, and a storage network that is not accessibile from outside the cluster, to which all of the nodes are connected. All of the Swift services, as well as the rsync daemon on the Storage nodes are configured to listen on their STORAGE_LOCAL_NET IP addresses.
2011-03-04 16:35:02 -06:00
.. note ::
Run all commands as the root user
2010-11-04 14:25:23 -05:00
General OS configuration and partitioning for each node
-------------------------------------------------------
#. Install the baseline Ubuntu Server 10.04 LTS on all nodes.
#. Install common Swift software prereqs::
apt-get install python-software-properties
2011-08-31 19:08:02 +00:00
add-apt-repository ppa:swift-core/release
2010-11-04 14:25:23 -05:00
apt-get update
2012-05-22 10:57:10 +02:00
apt-get install swift python-swiftclient openssh-server
2010-11-04 14:25:23 -05:00
#. Create and populate configuration directories::
mkdir -p /etc/swift
chown -R swift:swift /etc/swift/
2011-03-04 16:35:02 -06:00
#. On the first node only, create /etc/swift/swift.conf::
2010-11-04 14:25:23 -05:00
2011-03-04 16:35:02 -06:00
cat >/etc/swift/swift.conf <<EOF
2010-11-04 14:25:23 -05:00
[swift-hash]
2013-03-20 01:35:41 +02:00
# random unique strings that can never change (DO NOT LOSE)
swift_hash_path_prefix = `od -t x8 -N 8 -A n </dev/random`
2011-03-04 16:35:02 -06:00
swift_hash_path_suffix = `od -t x8 -N 8 -A n </dev/random`
EOF
#. On the second and subsequent nodes: Copy that file over. It must be the same on every node in the cluster!::
2012-05-22 10:57:10 +02:00
scp firstnode.example.com:/etc/swift/swift.conf /etc/swift/
2011-03-04 16:35:02 -06:00
#. Publish the local network IP address for use by scripts found later in this documentation::
export STORAGE_LOCAL_NET_IP=10.1.2.3
export PROXY_LOCAL_NET_IP=10.1.2.4
2010-11-04 14:25:23 -05:00
2013-03-18 13:57:19 -04:00
#. Create directory /var/run/swift and change the ownership to the user and group
which Swift services will run under. Since the directory is only needed for runtime,
when system shuts down, the directory will be gone. It is necessary to have
the directory recreated when system is restarted. To do that, also add the
2013-03-21 09:45:13 -04:00
following lines into /etc/rc.local before line "exit 0".::
2013-03-18 13:57:19 -04:00
mkdir -p /var/run/swift
chown swift:swift /var/run/swift
2013-03-26 14:56:44 -04:00
#. Create directory /var/cache/swift and /srv/node. Change the ownership of the
directory /var/cache/swift to the user and group which Swift account, container
or object services will run under. These directories are needed only for storage
node (account, container or object server). The ownership of /srv/node should
be root:root, this is to ensure that when storage disks unmounted unexpectedly,
the objects for swift will not be created in the directory /srv/node. If you have
a node only runs proxy server, you can skip this step.::
mkdir -p /var/cache/swift /srv/node/
chown swift:swift /var/cache/swift
2010-11-04 14:25:23 -05:00
.. note ::
2012-05-22 10:57:10 +02:00
The random string of text in /etc/swift/swift.conf is
used as a salt when hashing to determine mappings in the ring.
2010-11-04 14:25:23 -05:00
2010-11-23 16:30:38 -06:00
.. _config-proxy:
2010-11-04 14:25:23 -05:00
Configure the Proxy node
------------------------
.. note ::
It is assumed that all commands are run as the root user
#. Install swift-proxy service::
apt-get install swift-proxy memcached
#. Create self-signed cert for SSL::
cd /etc/swift
openssl req -new -x509 -nodes -out cert.crt -keyout cert.key
2011-03-04 16:35:02 -06:00
.. note ::
2012-04-26 20:29:08 +00:00
If you don't create the cert files, Swift silently uses http internally rather than https. This document assumes that you have created
these certs, so if you're following along step-by-step, create them. In a
2012-04-23 16:27:43 -05:00
production cluster, you should terminate SSL before the proxy server. SSL
support is provided for testing purposes only.
2011-03-04 16:35:02 -06:00
#. Modify memcached to listen on the default interfaces. Preferably this should be on a local, non-public network. Edit the IP address in /etc/memcached.conf, for example::
2010-11-04 14:25:23 -05:00
2011-03-04 16:35:02 -06:00
perl -pi -e "s/-l 127.0.0.1/-l $PROXY_LOCAL_NET_IP/" /etc/memcached.conf
2010-11-04 14:25:23 -05:00
#. Restart the memcached server::
service memcached restart
#. Create /etc/swift/proxy-server.conf::
2011-03-04 16:35:02 -06:00
cat >/etc/swift/proxy-server.conf <<EOF
2010-11-04 14:25:23 -05:00
[DEFAULT]
cert_file = /etc/swift/cert.crt
key_file = /etc/swift/cert.key
bind_port = 8080
workers = 8
user = swift
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[pipeline:main]
2013-06-06 19:41:13 -06:00
pipeline = healthcheck proxy-logging cache tempauth proxy-logging proxy-server
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[app:proxy-server]
use = egg:swift#proxy
2010-11-29 15:52:51 -08:00
allow_account_management = true
2012-02-09 07:40:00 -06:00
account_autocreate = true
2012-05-22 10:57:10 +02:00
2013-06-06 19:41:13 -06:00
[filter:proxy-logging]
use = egg:swift#proxy_logging
2011-05-26 02:24:12 +00:00
[filter:tempauth]
use = egg:swift#tempauth
2011-05-26 02:17:42 +00:00
user_system_root = testpass .admin https://$PROXY_LOCAL_NET_IP:8080/v1/AUTH_system
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[filter:healthcheck]
use = egg:swift#healthcheck
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[filter:cache]
use = egg:swift#memcache
2011-05-16 22:59:57 -05:00
memcache_servers = $PROXY_LOCAL_NET_IP:11211
2011-03-04 16:35:02 -06:00
EOF
2010-11-04 14:25:23 -05:00
.. note ::
2012-05-22 10:57:10 +02:00
If you run multiple memcache servers, put the multiple IP:port listings
2010-11-04 14:25:23 -05:00
in the [filter:cache] section of the proxy-server.conf file like:
`10.1.2.3:11211,10.1.2.4:11211` . Only the proxy server uses memcache.
2011-05-16 22:59:57 -05:00
#. Create the account, container and object rings. The builder command is basically creating a builder file with a few parameters. The parameter with the value of 18 represents 2 ^ 18th, the value that the partition will be sized to. Set this "partition power" value based on the total amount of storage you expect your entire ring to use. The value of 3 represents the number of replicas of each object, with the last value being the number of hours to restrict moving a partition more than once.
2012-02-22 18:40:22 -07:00
::
2010-11-04 14:25:23 -05:00
cd /etc/swift
swift-ring-builder account.builder create 18 3 1
swift-ring-builder container.builder create 18 3 1
swift-ring-builder object.builder create 18 3 1
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
.. note ::
For more information on building rings, see :doc: `overview_ring` .
2012-05-22 10:57:10 +02:00
2011-03-04 16:35:02 -06:00
#. For every storage device in /srv/node on each node add entries to each ring::
2010-11-04 14:25:23 -05:00
2011-03-04 16:35:02 -06:00
export ZONE= # set the zone number for that storage device
export STORAGE_LOCAL_NET_IP= # and the IP address
export WEIGHT=100 # relative weight (higher for bigger/faster disks)
export DEVICE=sdb1
swift-ring-builder account.builder add z$ZONE-$STORAGE_LOCAL_NET_IP:6002/$DEVICE $WEIGHT
swift-ring-builder container.builder add z$ZONE-$STORAGE_LOCAL_NET_IP:6001/$DEVICE $WEIGHT
swift-ring-builder object.builder add z$ZONE-$STORAGE_LOCAL_NET_IP:6000/$DEVICE $WEIGHT
2010-11-04 14:25:23 -05:00
.. note ::
Assuming there are 5 zones with 1 node per zone, ZONE should start at
1 and increment by one for each additional node.
#. Verify the ring contents for each ring::
swift-ring-builder account.builder
swift-ring-builder container.builder
swift-ring-builder object.builder
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
#. Rebalance the rings::
swift-ring-builder account.builder rebalance
swift-ring-builder container.builder rebalance
swift-ring-builder object.builder rebalance
.. note ::
Rebalancing rings can take some time.
#. Copy the account.ring.gz, container.ring.gz, and object.ring.gz files
to each of the Proxy and Storage nodes in /etc/swift.
#. Make sure all the config files are owned by the swift user::
chown -R swift:swift /etc/swift
#. Start Proxy services::
swift-init proxy start
Configure the Storage nodes
---------------------------
.. note ::
Swift *should* work on any modern filesystem that supports
2011-03-04 16:35:02 -06:00
Extended Attributes (XATTRS). We currently recommend XFS as it
2010-11-04 14:25:23 -05:00
demonstrated the best overall performance for the swift use case after
2011-03-04 16:35:02 -06:00
considerable testing and benchmarking at Rackspace. It is also the
2012-05-22 10:57:10 +02:00
only filesystem that has been thoroughly tested. These instructions
2011-03-04 16:35:02 -06:00
assume that you are going to devote /dev/sdb1 to an XFS filesystem.
2010-11-04 14:25:23 -05:00
#. Install Storage node packages::
apt-get install swift-account swift-container swift-object xfsprogs
#. For every device on the node, setup the XFS volume (/dev/sdb is used
2013-03-26 14:56:44 -04:00
as an example), add mounting option inode64 when your disk is bigger than
1TB to archive a better performance.::
2010-11-04 14:25:23 -05:00
fdisk /dev/sdb (set up a single partition)
2013-03-26 14:56:44 -04:00
mkfs.xfs -i size=512 /dev/sdb1
2010-11-04 14:25:23 -05:00
echo "/dev/sdb1 /srv/node/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab
mkdir -p /srv/node/sdb1
mount /srv/node/sdb1
2013-03-26 14:56:44 -04:00
chown swift:swift /srv/node/sdb1
2010-11-04 14:25:23 -05:00
#. Create /etc/rsyncd.conf::
2011-03-04 16:35:02 -06:00
cat >/etc/rsyncd.conf <<EOF
2010-11-04 14:25:23 -05:00
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
2011-03-04 16:35:02 -06:00
address = $STORAGE_LOCAL_NET_IP
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[account]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/account.lock
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[container]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/container.lock
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[object]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/object.lock
2011-03-04 16:35:02 -06:00
EOF
2010-11-04 14:25:23 -05:00
2011-03-04 16:35:02 -06:00
#. Edit the RSYNC_ENABLE= line in /etc/default/rsync::
2010-11-04 14:25:23 -05:00
2011-03-04 16:35:02 -06:00
perl -pi -e 's/RSYNC_ENABLE=false/RSYNC_ENABLE=true/' /etc/default/rsync
2010-11-04 14:25:23 -05:00
#. Start rsync daemon::
service rsync start
.. note ::
The rsync daemon requires no authentication, so it should be run on
a local, private network.
#. Create /etc/swift/account-server.conf::
2011-03-04 16:35:02 -06:00
cat >/etc/swift/account-server.conf <<EOF
2010-11-04 14:25:23 -05:00
[DEFAULT]
2011-03-04 16:35:02 -06:00
bind_ip = $STORAGE_LOCAL_NET_IP
2010-11-04 14:25:23 -05:00
workers = 2
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[pipeline:main]
pipeline = account-server
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[app:account-server]
use = egg:swift#account
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[account-replicator]
[account-auditor]
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[account-reaper]
2011-03-04 16:35:02 -06:00
EOF
2010-11-04 14:25:23 -05:00
#. Create /etc/swift/container-server.conf::
2011-03-04 16:35:02 -06:00
cat >/etc/swift/container-server.conf <<EOF
2010-11-04 14:25:23 -05:00
[DEFAULT]
2011-05-16 22:59:57 -05:00
bind_ip = $STORAGE_LOCAL_NET_IP
2010-11-04 14:25:23 -05:00
workers = 2
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[pipeline:main]
pipeline = container-server
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[app:container-server]
use = egg:swift#container
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[container-replicator]
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[container-updater]
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[container-auditor]
2013-01-12 23:37:25 +01:00
[container-sync]
2011-03-04 16:35:02 -06:00
EOF
2010-11-04 14:25:23 -05:00
#. Create /etc/swift/object-server.conf::
2011-03-04 16:35:02 -06:00
cat >/etc/swift/object-server.conf <<EOF
2010-11-04 14:25:23 -05:00
[DEFAULT]
2011-05-16 22:59:57 -05:00
bind_ip = $STORAGE_LOCAL_NET_IP
2010-11-04 14:25:23 -05:00
workers = 2
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[pipeline:main]
pipeline = object-server
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[app:object-server]
use = egg:swift#object
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[object-replicator]
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[object-updater]
2012-05-22 10:57:10 +02:00
2010-11-04 14:25:23 -05:00
[object-auditor]
2011-03-04 16:35:02 -06:00
EOF
2012-02-22 18:40:22 -07:00
#. Start the storage services. If you use this command, it will try to start
every service for which a configuration file exists, and throw a warning
for any configuration files which don't exist::
2011-03-04 16:35:02 -06:00
swift-init all start
2012-02-22 18:40:22 -07:00
Or, if you want to start them one at a time, run them as below.
Note that if the server program in question generates any output on its
stdout or stderr, swift-init has already redirected the command's output
to /dev/null. If you encounter any difficulty, stop the server and run it
by hand from the command line. Any server may be started using
"swift-$SERVER-$SERVICE /etc/swift/$SERVER-config", where $SERVER might
be object, continer, or account, and $SERVICE might be server,
replicator, updater, or auditor.
::
2011-03-04 16:35:02 -06:00
swift-init object-server start
swift-init object-replicator start
swift-init object-updater start
swift-init object-auditor start
swift-init container-server start
swift-init container-replicator start
swift-init container-updater start
swift-init container-auditor start
swift-init account-server start
swift-init account-replicator start
swift-init account-auditor start
2010-11-04 14:25:23 -05:00
2010-11-23 16:30:38 -06:00
Create Swift admin account and test
-----------------------------------
2011-03-14 02:56:37 +00:00
You run these commands from the Proxy node.
2010-12-01 17:08:49 -08:00
2010-11-04 14:25:23 -05:00
#. Get an X-Storage-Url and X-Auth-Token::
2011-05-16 22:59:57 -05:00
curl -k -v -H 'X-Storage-User: system:root' -H 'X-Storage-Pass: testpass' https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0
2010-11-04 14:25:23 -05:00
#. Check that you can HEAD the account::
curl -k -v -H 'X-Auth-Token: <token-from-x-auth-token-above>' <url-from-x-storage-url-above>
2011-06-14 11:04:06 -05:00
#. Check that `` swift `` works (at this point, expect zero containers, zero objects, and zero bytes)::
2010-11-04 14:25:23 -05:00
2011-06-14 11:04:06 -05:00
swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass stat
2010-11-04 14:25:23 -05:00
2011-06-14 11:04:06 -05:00
#. Use `` swift `` to upload a few files named 'bigfile[1-2].tgz' to a container named 'myfiles'::
2010-11-04 14:25:23 -05:00
2011-06-14 11:04:06 -05:00
swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass upload myfiles bigfile1.tgz
swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass upload myfiles bigfile2.tgz
2010-11-04 14:25:23 -05:00
2011-06-14 11:04:06 -05:00
#. Use `` swift `` to download all files from the 'myfiles' container::
2010-11-04 14:25:23 -05:00
2011-06-14 11:04:06 -05:00
swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass download myfiles
2010-11-04 14:25:23 -05:00
2011-06-14 11:04:06 -05:00
#. Use `` swift `` to save a backup of your builder files to a container named 'builders'. Very important not to lose your builders!::
2011-03-04 16:35:02 -06:00
2011-06-14 11:04:06 -05:00
swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass upload builders /etc/swift/*.builder
2011-03-04 16:35:02 -06:00
2011-06-14 11:04:06 -05:00
#. Use `` swift `` to list your containers::
2011-03-04 16:35:02 -06:00
2011-06-14 11:04:06 -05:00
swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass list
2011-03-04 16:35:02 -06:00
2011-06-14 11:04:06 -05:00
#. Use `` swift `` to list the contents of your 'builders' container::
2011-03-04 16:35:02 -06:00
2011-06-14 11:04:06 -05:00
swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass list builders
2011-03-04 16:35:02 -06:00
2011-06-14 11:04:06 -05:00
#. Use `` swift `` to download all files from the 'builders' container::
2011-03-04 16:35:02 -06:00
2011-06-14 11:04:06 -05:00
swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass download builders
2011-03-04 16:35:02 -06:00
2010-11-23 16:30:38 -06:00
.. _add-proxy-server:
Adding a Proxy Server
---------------------
2012-05-22 10:57:10 +02:00
For reliability's sake you may want to have more than one proxy server. You can set up the additional proxy node in the same manner that you set up the first proxy node but with additional configuration steps.
2010-11-23 16:30:38 -06:00
Once you have more than two proxies, you also want to load balance between the two, which means your storage endpoint also changes. You can select from different strategies for load balancing. For example, you could use round robin dns, or an actual load balancer (like pound) in front of the two proxies, and point your storage url to the load balancer.
2012-05-22 10:57:10 +02:00
See :ref: `config-proxy` for the initial setup, and then follow these additional steps.
2010-11-23 16:30:38 -06:00
#. Update the list of memcache servers in /etc/swift/proxy-server.conf for all the added proxy servers. If you run multiple memcache servers, use this pattern for the multiple IP:port listings: `10.1.2.3:11211,10.1.2.4:11211` in each proxy server's conf file.::
[filter:cache]
use = egg:swift#memcache
2011-05-16 22:59:57 -05:00
memcache_servers = $PROXY_LOCAL_NET_IP:11211
2010-11-23 16:30:38 -06:00
2011-05-26 02:17:42 +00:00
#. Change the storage url for any users to point to the load balanced url, rather than the first proxy server you created in /etc/swift/proxy-server.conf::
2010-12-01 21:28:41 -08:00
2011-05-26 02:24:12 +00:00
[filter:tempauth]
use = egg:swift#tempauth
2011-05-26 02:17:42 +00:00
user_system_root = testpass .admin http[s]://<LOAD_BALANCER_HOSTNAME>:<PORT> /v1/AUTH_system
2010-11-24 10:55:29 -06:00
2012-05-22 10:57:10 +02:00
#. Next, copy all the ring information to all the nodes, including your new proxy nodes, and ensure the ring info gets to all the storage nodes as well.
2010-11-23 16:30:38 -06:00
2012-05-22 10:57:10 +02:00
#. After you sync all the nodes, make sure the admin has the keys in /etc/swift and the ownership for the ring file is correct.
2010-11-23 16:30:38 -06:00
2010-11-04 14:25:23 -05:00
Troubleshooting Notes
---------------------
2012-05-22 10:57:10 +02:00
If you see problems, look in var/log/syslog (or messages on some distros).
2010-11-04 14:25:23 -05:00
2012-05-22 10:57:10 +02:00
Also, at Rackspace we have seen hints at drive failures by looking at error messages in /var/log/kern.log.
2010-11-04 14:25:23 -05:00
There are more debugging hints and tips in the :doc: `admin_guide` .