How To Install Swift on Ubuntu 11.10
1. install Ubuntu 11.10
2. install dependencies and the core code
apt-get install python-software-properties
add-apt-repository ppa:swift-core/release
apt-get update
apt-get install curl gcc git-core memcached python-configobj python-coverage
python-dev python-nose python-setuptools python-simplejson python-xattr sqlite3
xfsprogs python-webob python-eventlet python-greenlet
python-pastedeploy python-netifaces swift-proxy swift swift-account
swift-container swift-object
3. create user 'swift'
useradd swift
4. Using a partition for storage
Assuming there is only 1 partition (/dev/sdb) and we use folders for different zones. When using 1 partition for 1 zone, adapt this instruction accordingly.
fdisk /dev/sdb
#set up a single partitionmkfs.xfs -i size=1024 /dev/sdb1
Edit /etc/fstab and add
/dev/sdb1 /mnt/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 0
mkdir /mnt/sdb1
mount /mnt/sdb1
mkdir /mnt/sdb1/1 /mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4
mkdir /srv
for x in {1..4}; do ln -s /mnt/sdb1/$x /srv/$x; done
mkdir -p /etc/swift/object-server /etc/swift/container-server /etc/swift/account-server /srv/1/node/sdb1 /srv/2/node/sdb2 /srv/3/node/sdb3 /srv/4/node/sdb4 /var/run/swift
5. Setting up rsync
1. Create /etc/rsyncd.conf:
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 127.0.0.1
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 127.0.0.1
[account6012]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/account6012.lock
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/account6012.lock
[account6022]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/account6022.lock
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/account6022.lock
[account6032]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/account6032.lock
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/account6032.lock
[account6042]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/account6042.lock
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/account6042.lock
[container6011]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/container6011.lock
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/container6011.lock
[container6021]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/container6021.lock
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/container6021.lock
[container6031]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/container6031.lock
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/container6031.lock
[container6041]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/container6041.lock
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/container6041.lock
[object6010]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/object6010.lock
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/object6010.lock
[object6020]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/object6020.lock
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/object6020.lock
[object6030]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/object6030.lock
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/object6030.lock
[object6040]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/object6040.lock
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/object6040.lock
2. Edit the following line in /etc/default/rsync:
RSYNC_ENABLE=true
3. service rsync restart
6. Optional: Setting up rsyslog for individual logging
1. Create /etc/rsyslog.d/10-swift.conf:
# Uncomment the following to have a log containing all logs together
#local1,local2,local3,local4,local5.* /var/log/swift/all.log
#local1,local2,local3,local4,local5.* /var/log/swift/all.log
# Uncomment the following to have hourly proxy logs for stats processing
#$template HourlyProxyLog,"/var/log/swift/hourly/%$YEAR%%$MONTH%%$DAY%%$HOUR%"
#local1.*;local1.!notice ?HourlyProxyLog
#$template HourlyProxyLog,"/var/log/swift/hourly/%$YEAR%%$MONTH%%$DAY%%$HOUR%"
#local1.*;local1.!notice ?HourlyProxyLog
local1.*;local1.!notice /var/log/swift/proxy.log
local1.notice /var/log/swift/proxy.error
local1.* ~
local1.notice /var/log/swift/proxy.error
local1.* ~
local2.*;local2.!notice /var/log/swift/storage1.log
local2.notice /var/log/swift/storage1.error
local2.* ~
local2.notice /var/log/swift/storage1.error
local2.* ~
local3.*;local3.!notice /var/log/swift/storage2.log
local3.notice /var/log/swift/storage2.error
local3.* ~
local3.notice /var/log/swift/storage2.error
local3.* ~
local4.*;local4.!notice /var/log/swift/storage3.log
local4.notice /var/log/swift/storage3.error
local4.* ~
local4.notice /var/log/swift/storage3.error
local4.* ~
local5.*;local5.!notice /var/log/swift/storage4.log
local5.notice /var/log/swift/storage4.error
local5.* ~
local5.notice /var/log/swift/storage4.error
local5.* ~
2. Edit /etc/rsyslog.conf and make the following change:
$PrivDropToGroup adm
3.
mkdir -p /var/log/swift/hourly
chown -R syslog.adm /var/log/swift
service rsyslog restart
7. Swift configuration files
1. Create /etc/swift/proxy-server.conf:
[DEFAULT]
bind_port = 8080
user = swift
log_facility = LOG_LOCAL1
bind_port = 8080
user = swift
log_facility = LOG_LOCAL1
[pipeline:main]
pipeline = healthcheck cache tempauth proxy-server
pipeline = healthcheck cache tempauth proxy-server
[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true
[filter:tempauth]
use = egg:swift#tempauth
user_admin_admin = admin .admin .reseller_admin
user_test_tester = testing .admin
user_test2_tester2 = testing2 .admin
user_test_tester3 = testing3
use = egg:swift#tempauth
user_admin_admin = admin .admin .reseller_admin
user_test_tester = testing .admin
user_test2_tester2 = testing2 .admin
user_test_tester3 = testing3
[filter:healthcheck]
use = egg:swift#healthcheck
use = egg:swift#healthcheck
[filter:cache]
use = egg:swift#memcache
use = egg:swift#memcache
2. Create /etc/swift/swift.conf:
[swift-hash]
# random unique string that can never change (DO NOT LOSE)
swift_hash_path_suffix = changeme
# random unique string that can never change (DO NOT LOSE)
swift_hash_path_suffix = changeme
3. Create /etc/swift/account-server/1.conf:
[DEFAULT]
devices = /srv/1/node
mount_check = false
bind_port = 6012
user = swift
log_facility = LOG_LOCAL2
devices = /srv/1/node
mount_check = false
bind_port = 6012
user = swift
log_facility = LOG_LOCAL2
[pipeline:main]
pipeline = account-server
pipeline = account-server
[app:account-server]
use = egg:swift#account
use = egg:swift#account
[account-replicator]
vm_test_mode = yes
vm_test_mode = yes
[account-auditor]
[account-reaper]
4. Create other account-server conf files:
cd /etc/swift/account-server
cp 1.conf 2.conf
cp 1.conf 3.conf
cp 1.conf 4.conf
Edit 2.conf, 3.conf, 4.conf and change the following lines accordingly
devices = /srv/1/node -> /srv/x/node
bind_port = 6012 -> 60x2
log_facility = LOG_LOCAL2 -> LOG_LOCALx+1
5. /etc/swift/container-server/1.conf:
[DEFAULT]
devices = /srv/1/node
mount_check = false
bind_port = 6011
user = swift
log_facility = LOG_LOCAL2
devices = /srv/1/node
mount_check = false
bind_port = 6011
user = swift
log_facility = LOG_LOCAL2
[pipeline:main]
pipeline = container-server
pipeline = container-server
[app:container-server]
use = egg:swift#container
use = egg:swift#container
[container-replicator]
vm_test_mode = yes
vm_test_mode = yes
[container-updater]
[container-auditor]
[container-sync]
6. Create other container-server conf files:
cd /etc/swift/container-server
cp 1.conf 2.conf
cp 1.conf 3.conf
cp 1.conf 4.conf
Edit 2.conf, 3.conf, 4.conf and change the following lines accordingly
devices = /srv/1/node -> /srv/x/node
bind_port = 6011 -> 60x1
log_facility = LOG_LOCAL2 -> LOG_LOCALx+1
7. Create /etc/swift/object-server/1.conf:
[DEFAULT]
devices = /srv/1/node
mount_check = false
bind_port = 6010
user = swift
log_facility = LOG_LOCAL2
devices = /srv/1/node
mount_check = false
bind_port = 6010
user = swift
log_facility = LOG_LOCAL2
[pipeline:main]
pipeline = object-server
pipeline = object-server
[app:object-server]
use = egg:swift#object
use = egg:swift#object
[object-replicator]
vm_test_mode = yes
vm_test_mode = yes
[object-updater]
[object-auditor]
8. Create other object-server conf files:
cd /etc/swift/object-server
cp 1.conf 2.conf
cp 1.conf 3.conf
cp 1.conf 4.conf
Edit 2.conf, 3.conf, 4.conf and change the following lines accordingly
devices = /srv/1/node -> /srv/x/node
bind_port = 6010 -> 60x0
log_facility = LOG_LOCAL2 -> LOG_LOCALx+1
8 Create helper scripts
1. Script to make rings
cd /etc/swift
vi remakerings.sh
Insert following script and save file:
#!/bin/bash
#!/bin/bash
cd /etc/swift
rm -f .builder *.ring.gz backups/.builder backups/*.ring.gz
swift-ring-builder object.builder create 18 3 1
swift-ring-builder object.builder add z1-192.168.1.65:6010/sdb1 1
swift-ring-builder object.builder add z2-192.168.1.65:6020/sdb2 1
swift-ring-builder object.builder add z3-192.168.1.65:6030/sdb3 1
swift-ring-builder object.builder add z4-192.168.1.65:6040/sdb4 1
swift-ring-builder object.builder rebalance
swift-ring-builder container.builder create 18 3 1
swift-ring-builder container.builder add z1-192.168.1.65:6011/sdb1 1
swift-ring-builder container.builder add z2-192.168.1.65:6021/sdb2 1
swift-ring-builder container.builder add z3-192.168.1.65:6031/sdb3 1
swift-ring-builder container.builder add z4-192.168.1.65:6041/sdb4 1
swift-ring-builder container.builder rebalance
swift-ring-builder account.builder create 18 3 1
swift-ring-builder account.builder add z1-192.168.1.65:6012/sdb1 1
swift-ring-builder account.builder add z2-192.168.1.65:6022/sdb2 1
swift-ring-builder account.builder add z3-192.168.1.65:6032/sdb3 1
swift-ring-builder account.builder add z4-192.168.1.65:6042/sdb4 1
swift-ring-builder account.builder rebalance
swift-ring-builder object.builder add z1-192.168.1.65:6010/sdb1 1
swift-ring-builder object.builder add z2-192.168.1.65:6020/sdb2 1
swift-ring-builder object.builder add z3-192.168.1.65:6030/sdb3 1
swift-ring-builder object.builder add z4-192.168.1.65:6040/sdb4 1
swift-ring-builder object.builder rebalance
swift-ring-builder container.builder create 18 3 1
swift-ring-builder container.builder add z1-192.168.1.65:6011/sdb1 1
swift-ring-builder container.builder add z2-192.168.1.65:6021/sdb2 1
swift-ring-builder container.builder add z3-192.168.1.65:6031/sdb3 1
swift-ring-builder container.builder add z4-192.168.1.65:6041/sdb4 1
swift-ring-builder container.builder rebalance
swift-ring-builder account.builder create 18 3 1
swift-ring-builder account.builder add z1-192.168.1.65:6012/sdb1 1
swift-ring-builder account.builder add z2-192.168.1.65:6022/sdb2 1
swift-ring-builder account.builder add z3-192.168.1.65:6032/sdb3 1
swift-ring-builder account.builder add z4-192.168.1.65:6042/sdb4 1
swift-ring-builder account.builder rebalance
9 Adjust user/permission
chown -R swift:swift /mnt/sdb1/* /etc/swift /srv/[1-4]/ /var/run/swift
# – Make sure to include the trailing slash after /srv/[1-4]/Add to /etc/rc.local (before the exit 0):
mkdir /var/run/swift
chown swift:swift /var/run/swift
10 Start swift
chmod +x /etc/swift/remakerings.sh
/etc/swift/remakerings.sh
swift-init main start
swift-init rest start