说明:1swift搭建主要参考与官网SAIO的参考。http://swift.openstack.org/development_saio.html若初次接触请注意认证方式!后面遇到的时候会具体提到。一切已官网的参考为主要依据。2预备知识。openstack及其相关请参看其他参考,不再赘述。linu
说明:
1 swift 搭建主要参考与官网SAIO的参考。
http://swift.openstack.org/development_saio.html
若初次接触请注意认证方式!后面遇到的时候会具体提到。一切已官网的参考为主要依据。
2 预备知识。
openstack及其相关 请参看其他参考,不再赘述。
linux 初学者请注意一下几个命令的用法。后续操作中会用到,请预先学习:
cp ls df fdisk tar rm ls wget
mkdir apt-get(初学者只要知道这几个命令是做什么用的即可)
安装过程:(已官网的顺序为例,不同的地方我会强调出来)
我会上传脚本~(配置的,安装的
一起只要简单的几步。但我还是希望大家能看完手工配置一遍。脚本在最后有说明怎么用。言归正传。开始了)
一、系统及swift版本
Ubuntu Server
ISO: http://mirror.lupaworld.com/ubuntu-releases//oneiric/ubuntu-11.10-desktop-amd64.iso
(说明:为了方便初学者:系统安装时默认用户名为swift,免去初学者之后操作忘记切换用户
其实本人觉得无所谓~ 要是没有用swift 也别改了~ 后面我会强调注意的地方)
swift
版本下载: https://launchpad.net/swift/+download
本人选用的是1.4.4的tar包( swift-1.4.4.tar.gz)
地址: http://launchpad.net/swift/essex/1.4.4/+download/swift-1.4.4.tar.gz
请根据自己的需求选择选择对应的版本下载
二、SAIO的安装
2.1、安装依赖包
Installing dependencies and the core code
As root on guest (you’ll have to log in as you,
then sudo su -):
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
Install anything else you want, like screen, ssh, vim, etc.
以上上官网上的顺序。说明:
1 主要是配置环境及下载代码。 建议选用64bit的ubuntu 否则
第二步可能出现问题
2 初学者主要别忘了每条命令前加 sudo 即:sudo apt-get install
python-software-properties
3 由于网络问题或其他可能导致运行上面下载安装失败 请多次重复下载。
4 第四步
不建议安装官网说明那么下载。大多数下载会失败。建议分开下载。如:
sudo apt-get install curl gcc git-core memcached
python-configobj
sudo apt-get
install python-coverage python-dev
python-nose python-setuptools
sudo apt-get install python-simplejson
python-xattr sqlite3 xfsprogs python-webob python-eventlet
sudo apt-get install spython-greenlet
python-pastedeploy python-netifaces
本人这块遇到 python-setuptools python-webob 这两个下载经常失败 (可以手工下载tar包)请在 https://launchpad.net/ubuntu/ 网站搜索对应组件下载
5 对于第五步说明: 本人只下载了 vim ssh (ssh 建议下载vim 为个人习惯问题)
sudo apt-get install ssh
2.2 设置存储(loopback 模式)
官网中提供两种模式的存储 本人使用loopback 模式。
Using a loopback device for storage
If you want to use a loopback device instead of another
partition, follow these instructions.
1. mkdir /srv
2. dd if=/dev/zero of=/srv/swift-disk bs=1024
count=0 seek=1000000
(modify seek to make a larger or smaller partition)
3. mkfs.xfs -i size=1024 /srv/swift-disk
4. Edit /etc/fstab and
add
/srv/swift-disk /mnt/sdb1 xfs
loop,noatime,nodiratime,nobarrier,logbufs=8 0 0
5. mkdir /mnt/sdb1
6. mount /mnt/sdb1
7. mkdir /mnt/sdb1/1 /mnt/sdb1/2 /mnt/sdb1/3
/mnt/sdb1/4
8. chown
: /mnt/sdb1/*
9. for x in {1..4}; do ln -s /mnt/sdb1/$x /srv/$x;
done
10. 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
11. chown -R :
/etc/swift /srv/[1-4]/
/var/run/swift ? Make sure to include
the trailing slash after /srv/[1-4]/
12. Add to /etc/rc.local (before
the exit 0):
mkdir /var/run/swift chown
: /var/run/swift
说明 这一段没有什么好说的 初学者可以不动脑子按照这操作就可以了~(本人后续会写一个配置的脚本放在后面,就不用这么麻烦的输入了~)
2.3 设置参数及config
说明
配置参数这几步初学者完全按照SAIO的参数配即可(但是默认的认证时tempauth。)我会把默认的参数和有认证的参数分别上传上来。官网tempauth这种认证方式不用修改任何参数。完全复制粘贴就可以了~
注意放在对应的文件夹下。
Setting up rsync
1. Create /etc/rsyncd.conf:
uid = gid = 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
[account6022] 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 [account6042] 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 [container6021] 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 [container6041] 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 [object6020] 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 [object6040] 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:
3. service rsync restart
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 # 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 local1.*;local1.!notice
/var/log/swift/proxy.log local1.notice /var/log/swift/proxy.error
local1.* ~ local2.*;local2.!notice /var/log/swift/storage1.log
local2.notice /var/log/swift/storage1.error local2.* ~
local3.*;local3.!notice /var/log/swift/storage2.log local3.notice
/var/log/swift/storage2.error local3.* ~ local4.*;local4.!notice
/var/log/swift/storage3.log local4.notice
/var/log/swift/storage3.error local4.* ~ local5.*;local5.!notice
/var/log/swift/storage4.log local5.notice
/var/log/swift/storage4.error local5.* ~
2. Edit /etc/rsyslog.conf and make the following
change:
3. mkdir -p /var/log/swift/hourly
4. chown -R syslog.adm /var/log/swift
5. service rsyslog restart
Getting the code and setting up test environment
Sample configuration files are provided with all defaults in
line-by-line comments.
Do these commands as you on guest.
1. mkdir ~/bin
2. Check out the swift repo with git
clone https://github.com/openstack/swift.git
3. Build a development installation of swift, for
example: cd ~/swift; sudo python setup.py
develop
4. Edit ~/.bashrc and add
to the end:
export SWIFT_TEST_CONFIG_FILE=/etc/swift/func_test.conf export
PATH=${PATH}:~/bin
5. . ~/.bashrc
Configuring each node
Sample configuration files are provided with all defaults in
line-by-line comments.
1.
Create /etc/swift/proxy-server.conf:
[DEFAULT] bind_port = 8080 user =
log_facility = LOG_LOCAL1 [pipeline:main] pipeline = healthcheck
cache tempauth proxy-server [app:proxy-server] 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
[filter:healthcheck] use = egg:swift#healthcheck [filter:cache] 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
3.
Create /etc/swift/account-server/1.conf:
[DEFAULT] devices = /srv/1/node mount_check = false bind_port =
6012 user = log_facility = LOG_LOCAL2
[pipeline:main] pipeline = account-server [app:account-server] use
= egg:swift#account [account-replicator] vm_test_mode = yes
[account-auditor] [account-reaper]
4.
Create /etc/swift/account-server/2.conf:
[DEFAULT] devices = /srv/2/node mount_check = false bind_port =
6022 user = log_facility = LOG_LOCAL3
[pipeline:main] pipeline = account-server [app:account-server] use
= egg:swift#account [account-replicator] vm_test_mode = yes
[account-auditor] [account-reaper]
5.
Create /etc/swift/account-server/3.conf:
[DEFAULT] devices = /srv/3/node mount_check = false bind_port =
6032 user = log_facility = LOG_LOCAL4
[pipeline:main] pipeline = account-server [app:account-server] use
= egg:swift#account [account-replicator] vm_test_mode = yes
[account-auditor] [account-reaper]
6.
Create /etc/swift/account-server/4.conf:
[DEFAULT] devices = /srv/4/node mount_check = false bind_port =
6042 user = log_facility = LOG_LOCAL5
[pipeline:main] pipeline = account-server [app:account-server] use
= egg:swift#account [account-replicator] vm_test_mode = yes
[account-auditor] [account-reaper]
7.
Create /etc/swift/container-server/1.conf:
[DEFAULT] devices = /srv/1/node mount_check = false bind_port =
6011 user = log_facility = LOG_LOCAL2
[pipeline:main] pipeline = container-server [app:container-server]
use = egg:swift#container [container-replicator] vm_test_mode = yes
[container-updater] [container-auditor] [container-sync]
8.
Create /etc/swift/container-server/2.conf:
[DEFAULT] devices = /srv/2/node mount_check = false bind_port =
6021 user = log_facility = LOG_LOCAL3
[pipeline:main] pipeline = container-server [app:container-server]
use = egg:swift#container [container-replicator] vm_test_mode = yes
[container-updater] [container-auditor] [container-sync]
9.
Create /etc/swift/container-server/3.conf:
[DEFAULT] devices = /srv/3/node mount_check = false bind_port =
6031 user = log_facility = LOG_LOCAL4
[pipeline:main] pipeline = container-server [app:container-server]
use = egg:swift#container [container-replicator] vm_test_mode = yes
[container-updater] [container-auditor] [container-sync]
10.
Create /etc/swift/container-server/4.conf:
[DEFAULT] devices = /srv/4/node mount_check = false bind_port =
6041 user = log_facility = LOG_LOCAL5
[pipeline:main] pipeline = container-server [app:container-server]
use = egg:swift#container [container-replicator] vm_test_mode = yes
[container-updater] [container-auditor] [container-sync]
11. Create /etc/swift/object-server/1.conf:
[DEFAULT] devices = /srv/1/node mount_check = false bind_port =
6010 user = log_facility = LOG_LOCAL2
[pipeline:main] pipeline = object-server [app:object-server] use =
egg:swift#object [object-replicator] vm_test_mode = yes
[object-updater] [object-auditor]
12. Create /etc/swift/object-server/2.conf:
[DEFAULT] devices = /srv/2/node mount_check = false bind_port =
6020 user = log_facility = LOG_LOCAL3
[pipeline:main] pipeline = object-server [app:object-server] use =
egg:swift#object [object-replicator] vm_test_mode = yes
[object-updater] [object-auditor]
13. Create /etc/swift/object-server/3.conf:
[DEFAULT] devices = /srv/3/node mount_check = false bind_port =
6030 user = log_facility = LOG_LOCAL4
[pipeline:main] pipeline = object-server [app:object-server] use =
egg:swift#object [object-replicator] vm_test_mode = yes
[object-updater] [object-auditor]
14. Create /etc/swift/object-server/4.conf:
[DEFAULT] devices = /srv/4/node mount_check = false bind_port =
6040 user = log_facility = LOG_LOCAL5
[pipeline:main] pipeline = object-server [app:object-server] use =
egg:swift#object [object-replicator] vm_test_mode = yes
[object-updater] [object-auditor]
2.4、安装swift
你的swift放在哪里了? 找到它解压安装 这里用到了 tar 命令 没问题吧?
tar xvjf swift-1.4.4.tar.gz
cd
~/ swift-1.4.4 ; sudo python
setup.py develop
2.5 创建运行swift运行的脚本
和官网的一致。完全安官网的来即可。同样我上传了已经写好的脚本可以加载使用
即可。
Create ~/bin/resetswift.
If you are using a loopback device
substitute /dev/sdb1 with /srv/swift-disk.
If you did not set up rsyslog for individual logging, remove
the find /var/log/swift... line:
#!/bin/bash swift-init all stop find /var/log/swift -type f
-exec rm -f {} \; sudo umount /mnt/sdb1 sudo mkfs.xfs -f -i
size=1024 /dev/sdb1 sudo mount /mnt/sdb1 sudo mkdir /mnt/sdb1/1
/mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4 sudo chown
: /mnt/sdb1/* mkdir -p
/srv/1/node/sdb1 /srv/2/node/sdb2 /srv/3/node/sdb3 /srv/4/node/sdb4
sudo rm -f /var/log/debug /var/log/messages /var/log/rsyncd.log
/var/log/syslog sudo service rsyslog restart sudo service memcached
restart
Create ~/bin/remakerings:
#!/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-127.0.0.1:6010/sdb1 1 swift-ring-builder object.builder add
z2-127.0.0.1:6020/sdb2 1 swift-ring-builder object.builder add
z3-127.0.0.1:6030/sdb3 1 swift-ring-builder object.builder add
z4-127.0.0.1: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-127.0.0.1:6011/sdb1 1
swift-ring-builder container.builder add z2-127.0.0.1:6021/sdb2 1
swift-ring-builder container.builder add z3-127.0.0.1:6031/sdb3 1
swift-ring-builder container.builder add z4-127.0.0.1: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-127.0.0.1:6012/sdb1 1 swift-ring-builder account.builder add
z2-127.0.0.1:6022/sdb2 1 swift-ring-builder account.builder add
z3-127.0.0.1:6032/sdb3 1 swift-ring-builder account.builder add
z4-127.0.0.1:6042/sdb4 1 swift-ring-builder account.builder
rebalance
Create ~/bin/startmain:
#!/bin/bash swift-init main start
Create ~/bin/startrest:
#!/bin/bash swift-init rest start