您的位置:首页 - 教程 - Swift - 正文
swift 单独部署,开发和命令

部署环境

  • virtualBox
  • Ubuntu 14.04 desktop
  • OpenStack Swift (kilo)

说明

    • 此文档为基于官方修改的只针对Ubuntu 14.04,完整的参阅官方文档
    • 本部署为开发环境,Swift配置为以root权限运行,生产环境推荐新建用户swift
    • 以下安装命令全部以root身份运行

       

安装依赖

apt-get update
apt-get install curl gcc memcached rsync sqlite3 xfsprogs git python-setuptools
apt-get install python-coverage python-dev python-nose python-simplejson python-xattr python-eventlet python-greenlet python-pastedeploy python-netifaces python-pip python-dnspython python-mock

使用回环设备作为存储,若需要使用一个分区作为存储,参见官方文档

mkdir /srv
truncate -s 1GB /srv/swift-disk
mkfs.xfs /srv/swift-disk

修改/etc/fstab 添加如下行

/srv/swift-disk /mnt/sdb1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0

shell 执行一下命令

mkdir /mnt/sdb1
mount /mnt/sdb1
mkdir /mnt/sdb1/1 /mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4
chown root:root /mnt/sdb1/*
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 
mkdir -p /srv/1/node/sdb1 /srv/2/node/sdb2 /srv/3/node/sdb3 /srv/4/node/sdb4 /var/run/swift
chown -R root:root /etc/swift /srv/[1-4]/ /var/run/swift

编辑文件/etc/rc.local,在exit 0 之前添加如下4行:

mkdir -p /var/cache/swift /var/cache/swift2 /var/cache/swift3 /var/cache/swift4
chown <your-user-name>:<your-group-name> /var/cache/swift*
mkdir -p /var/run/swift
chown <your-user-name>:<your-group-name> /var/run/swift

设置Rsync

创建文件/etc/rsyncd.conf:

uid = root
gid = root
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

编辑文件/etc/default/rsync,设置参数RSYNC_ENABLE为true:

RSYNC_ENABLE=true

启动rsync服务

service rsync restart

确认rsync启动成功

rsync rsync://pub@localhost/

设置独立日志(非必需,略,见官方文档)


获取代码并设置测试环境

从git上获取swift代码,下载到本地

git clone https://github.com/pingandezhufu/swift

安装Swift的开发版本

cd ~/swift
git checkout -t origin/stable/kilo 
python setup.py develop
cd ..

从git上获取python-swiftclient代码,下载到本地

git clone https://github.com/pingandezhufu/python-swiftclient

安装python-swiftclient的开发版本

cd ~/python-swiftclient
python setup.py develop
cd ..

配置各结点

创建文件/etc/swift/proxy-server.conf,

 

编辑~/.bashrc,在最后添加如下两行:

首先shell执行

export PATH=${PATH}:~/bin
. ~/.bashrc

然后在.bashrc最后添加如下两行

/home/shang/bin/remakerings
cp ~/swift/test/sample.conf /etc/swift/test.conf

参考文档:

http://www.aboutyun.com/thread-7099-1-1.html

官方文档:

http://docs.openstack.org/developer/swift/development_saio.html


评论: