部署环境

  • 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=  

shell 执行一下命令

mkdir /mnt/sdb1
mount /mnt/sdb1
mkdir /mnt/sdb1/ /mnt/sdb1/ /mnt/sdb1/ /mnt/sdb1/
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 =
path = /srv//node/
read only = false
lock file = /var/lock/account6012.lock [account6022]
max connections =
path = /srv//node/
read only = false
lock file = /var/lock/account6022.lock [account6032]
max connections =
path = /srv//node/
read only = false
lock file = /var/lock/account6032.lock [account6042]
max connections =
path = /srv//node/
read only = false
lock file = /var/lock/account6042.lock [container6011]
max connections =
path = /srv//node/
read only = false
lock file = /var/lock/container6011.lock [container6021]
max connections =
path = /srv//node/
read only = false
lock file = /var/lock/container6021.lock [container6031]
max connections =
path = /srv//node/
read only = false
lock file = /var/lock/container6031.lock [container6041]
max connections =
path = /srv//node/
read only = false
lock file = /var/lock/container6041.lock [object6010]
max connections =
path = /srv//node/
read only = false
lock file = /var/lock/object6010.lock [object6020]
max connections =
path = /srv//node/
read only = false
lock file = /var/lock/object6020.lock [object6030]
max connections =
path = /srv//node/
read only = false
lock file = /var/lock/object6030.lock [object6040]
max connections =
path = /srv//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
git checkout -t origin/stable/kilo 
python setup.py develop 
cd ..

提示错误:

重新下载安装 liberasurecode-1.0.7

网址:

https://bbuseruploads.s3.amazonaws.com/3f313ac6-68e0-4ed9-aed3-963c76794880/downloads/b30da25f-25ee-438c-bcbc-cd0003164624/liberasurecode-1.0.7.tar.gz?Signature=888aYhtKkkok4UKVGvXmqbRmiFQ%3D&Expires=1461687328&AWSAccessKeyId=AKIAIWY5XSVPZPDQYRQQ&versionId=null&response-content-disposition=attachment%3B%20filename%3D%22liberasurecode-1.0.7.tar.gz%22

配置各结点

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

Create /etc/swift/account-server/1.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL2
recon_cache_path = /var/cache/swift
eventlet_debug = true [pipeline:main]
pipeline = recon account-server [app:account-server]
use = egg:swift#account [filter:recon]
use = egg:swift#recon [account-replicator]
vm_test_mode = yes [account-auditor] [account-reaper]

Create /etc/swift/account-server/2.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL3
recon_cache_path = /var/cache/swift2
eventlet_debug = true [pipeline:main]
pipeline = recon account-server [app:account-server]
use = egg:swift#account [filter:recon]
use = egg:swift#recon [account-replicator]
vm_test_mode = yes [account-auditor] [account-reaper]

Create /etc/swift/account-server/3.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL4
recon_cache_path = /var/cache/swift3
eventlet_debug = true [pipeline:main]
pipeline = recon account-server [app:account-server]
use = egg:swift#account [filter:recon]
use = egg:swift#recon [account-replicator]
vm_test_mode = yes [account-auditor] [account-reaper]

Create /etc/swift/account-server/4.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL5
recon_cache_path = /var/cache/swift4
eventlet_debug = true [pipeline:main]
pipeline = recon account-server [app:account-server]
use = egg:swift#account [filter:recon]
use = egg:swift#recon [account-replicator]
vm_test_mode = yes [account-auditor] [account-reaper]

Create /etc/swift/container-server/1.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL2
recon_cache_path = /var/cache/swift
eventlet_debug = true [pipeline:main]
pipeline = recon container-server [app:container-server]
use = egg:swift#container [filter:recon]
use = egg:swift#recon [container-replicator]
vm_test_mode = yes [container-updater] [container-auditor] [container-sync]

Create /etc/swift/container-server/2.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL3
recon_cache_path = /var/cache/swift2
eventlet_debug = true [pipeline:main]
pipeline = recon container-server [app:container-server]
use = egg:swift#container [filter:recon]
use = egg:swift#recon [container-replicator]
vm_test_mode = yes [container-updater] [container-auditor] [container-sync]

Create /etc/swift/container-server/3.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL4
recon_cache_path = /var/cache/swift3
eventlet_debug = true [pipeline:main]
pipeline = recon container-server [app:container-server]
use = egg:swift#container [filter:recon]
use = egg:swift#recon [container-replicator]
vm_test_mode = yes [container-updater] [container-auditor] [container-sync]

Create /etc/swift/container-server/4.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL5
recon_cache_path = /var/cache/swift4
eventlet_debug = true [pipeline:main]
pipeline = recon container-server [app:container-server]
use = egg:swift#container [filter:recon]
use = egg:swift#recon [container-replicator]
vm_test_mode = yes [container-updater] [container-auditor] [container-sync]

Create /etc/swift/object-server/1.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL2
recon_cache_path = /var/cache/swift
eventlet_debug = true [pipeline:main]
pipeline = recon object-server [app:object-server]
use = egg:swift#object [filter:recon]
use = egg:swift#recon [object-replicator]
vm_test_mode = yes [object-updater] [object-auditor]

Create /etc/swift/object-server/2.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL3
recon_cache_path = /var/cache/swift2
eventlet_debug = true [pipeline:main]
pipeline = recon object-server [app:object-server]
use = egg:swift#object [filter:recon]
use = egg:swift#recon [object-replicator]
vm_test_mode = yes [object-updater] [object-auditor]

Create /etc/swift/object-server/3.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL4
recon_cache_path = /var/cache/swift3
eventlet_debug = true [pipeline:main]
pipeline = recon object-server [app:object-server]
use = egg:swift#object [filter:recon]
use = egg:swift#recon [object-replicator]
vm_test_mode = yes [object-updater] [object-auditor]

Create /etc/swift/object-server/4.conf:

[DEFAULT]
devices = /srv//node
mount_check = false
disable_fallocate = true
bind_port =
user = root
log_facility = LOG_LOCAL5
recon_cache_path = /var/cache/swift4
eventlet_debug = true [pipeline:main]
pipeline = recon object-server [app:object-server]
use = egg:swift#object [filter:recon]
use = egg:swift#recon [object-replicator]
vm_test_mode = yes [object-updater] [object-auditor]

创建Swift运行脚本

mkdir ~/bin

创建脚本~/bin/resetswift

因未创建rsyslog作为独立日志,已移除find /var/log/swift…这一行 
如果使用的是单独分区存储需要将/srv/swift-disk替换为/dev/sdb1

#!/bin/bash
swift-init all stop
sudo umount /mnt/sdb1
sudo mkfs.xfs -f /srv/swift-disk
sudo mount /mnt/sdb1
sudo mkdir /mnt/sdb1/ /mnt/sdb1/ /mnt/sdb1/ /mnt/sdb1/
sudo chown root:root /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
find /var/cache/swift* -type f -name *.recon -exec rm -f {} \;
sudo service rsyslog restart
sudo service memcached restart

创建脚本~/bin/remakerings

#!/bin/bash
cd /etc/swift
rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
swift-ring-builder object.builder create 10 3 1
swift-ring-builder object.builder add r1z1-127.0.0.1:6010/sdb1 1
swift-ring-builder object.builder add r1z2-127.0.0.1:6020/sdb2 1
swift-ring-builder object.builder add r1z3-127.0.0.1:6030/sdb3 1
swift-ring-builder object.builder add r1z4-127.0.0.1:6040/sdb4 1
swift-ring-builder object.builder rebalance
swift-ring-builder container.builder create 10 3 1
swift-ring-builder container.builder add r1z1-127.0.0.1:6011/sdb1 1
swift-ring-builder container.builder add r1z2-127.0.0.1:6021/sdb2 1
swift-ring-builder container.builder add r1z3-127.0.0.1:6031/sdb3 1
swift-ring-builder container.builder add r1z4-127.0.0.1:6041/sdb4 1
swift-ring-builder container.builder rebalance
swift-ring-builder account.builder create 10 3 1
swift-ring-builder account.builder add r1z1-127.0.0.1:6012/sdb1 1
swift-ring-builder account.builder add r1z2-127.0.0.1:6022/sdb2 1
swift-ring-builder account.builder add r1z3-127.0.0.1:6032/sdb3 1
swift-ring-builder account.builder add r1z4-127.0.0.1:6042/sdb4 1
swift-ring-builder account.builder rebalance

创建~/bin/startmain

#!/bin/bash
swift-init main start

创建~/bin/startrest

#!/bin/bash
swift-init rest start

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

首先shell执行

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

然后在.bashrc(位置在/root目录下)最后添加如下两行

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

开启Swift

./remakerings
./startmain

检查Swift工作

swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat
root@ubuntuServer0:/home/shang/bin# swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat
Account: AUTH_test
Containers:
Objects:
Bytes:
Content-Type: text/plain; charset=utf-
X-Timestamp: 1461911289.02292
X-Trans-Id: txb2b99c799b8a48dfa0b96-005722fef8
X-Put-Timestamp: 1461911289.02292

参考文档:

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

官方文档:

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

swift 单独部署,开发的更多相关文章

  1. silverlight如何通过单独部署的WCF站点访问sharepoint2013的图片库

    最近有项目silverlight通过单独部署的WCF站点访问sharepoint2013的图片库,需要做个笑脸墙效果如下: 结果开发完毕后无法在SP站点显示出来.使用VS自带的WCF工具进行测试.如下 ...

  2. 【Swift】iOS开发历险记(二)

    前言 这个系列主要是一些开发中遇到的坑记录分享,有助于初学者跨过这些坑,攒够 7 条发一篇. 声明  欢迎转载,但请保留文章原始出处:)  博客园:http://www.cnblogs.com 农民伯 ...

  3. 如何将phantomjs单独部署在服务端

    如何将phantomjs单独部署在服务端 文章目录 一. 容我分析(lao dao)几句 二. 服务端 Look here 服务端phantomjs搭建 web端搭建及如何调用phantomjs 三. ...

  4. t持久化与集群部署开发详解

    Quartz.net持久化与集群部署开发详解 序言 我前边有几篇文章有介绍过quartz的基本使用语法与类库.但是他的执行计划都是被写在本地的xml文件中.无法做集群部署,我让它看起来脆弱不堪,那是我 ...

  5. 使用docker-compose来部署开发环境

    docker-compose的作用 docker-comopse可以帮助我们快速搭建起开发环境,比如你可以去把redis,mongodb,rabbitmq,mysql,eureka,configser ...

  6. 【Swift】iOS开发笔记(二)

    前言 这个系列主要是一些开发中遇到的坑记录分享,有助于初学者跨过这些坑,攒够 7 条发一篇. 声明  欢迎转载,但请保留文章原始出处:)  博客园:http://www.cnblogs.com 农民伯 ...

  7. 百度分享不支持https的解决方案(单独部署静态文件)

    首先是参考了博客,下载百度分享的静态代码 static 链接为:https://www.cnblogs.com/mmzuo-798/p/6434576.html 后来在nginx的 nginx.con ...

  8. windows下在Eclipse中启动的tomcat没有乱码,单独部署到tomcat下乱码解决方案

    今天遇到了一个很奇怪的问题,在Eclipse中调试,运行项目一切正常,项目的所有编码都是统一的UTF-8.但是在单独部署到tomcat上的时候出现了中文乱码. 解决方案 第一步:确保项目,jsp页面, ...

  9. maven(多个模块)项目 部署 开发环境 问题处理历程【异常Name jdbc is not bound in this Context 异常java.lang.NoSuchMethodE】

    maven(多个模块)项目 部署 开发环境 问题处理历程[异常Name jdbc is not bound in this Context 异常java.lang.NoSuchMethodE] 201 ...

随机推荐

  1. Indesign中GREP的应用

    1.查找m2,m3中的2或3:代码:(?<=m|M)(2|3)(?!\d)(查找这个可以统一改成上标) 2.删除段首空格:代码:^\s+(?=\w{2,}) 3.删除尾随空白:代码:\s+$ 4 ...

  2. Bubble Cup 8 finals G. Run for beer (575G)

    题意: 给定一个带权无向图,每条边的代价为边权/当前速度,每次到达一个新节点,速度都会除以10. 求0号点到n-1号点的最小代价,如果多解输出点数最少的解,输出代价.路径点数.路径经过的点. 1< ...

  3. Codeforces Round #353 (Div. 2) ABCDE 题解 python

    Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring P ...

  4. AngularJS学习第一课

    AngularJS2与AngularJS1有很大的不同. AngularJS2支持ECMAScript6,为了提升性能,支持移动化开发(安卓.ios平台),因此升级为AngularJS 2,Angul ...

  5. HTML Select 标签选择后触发jQuery事件代码实例

    页面设计原由: 因为很多客户不知道如何来到我们公司,领导想让我在微信公众号上面做一个链接,客户可以直接通过微信公众号打开地图并导航到我们公司的办公地点. 实现起来并不难,但由于公司有很多办事处,所以需 ...

  6. JPA入门

    JPA是什么 JPA全称Java Persistence API,是一组用于将数据存入数据库的类和方法的集合.JPA通过JDK 5.0注解或XML描述对象-关系表的映射关系,并将运行期的实体对象持久化 ...

  7. MFC双缓存技术代码

    屏蔽背景刷新,在View中添加对WM_ERASEBKGND的响应,直接返回TRUE: BOOL CTEMV1View::OnEraseBkgnd(CDC* pDC) { // TODO: 在此添加消息 ...

  8. Eclipse的快捷键

    Ctrl+Shift+L调出eclipse的所有快捷键 不定期更新2016#8#19 如何配置快捷键:windown-preferences-General-key 一些操作  Ctrl+D   删除 ...

  9. awk命令和grep命令的使用

    1.遇到需求:用ping命令去检测系统网络延迟 跑 ping baidu.com -c 3,想要直接得到平均延迟. ping baidu.com -c 3 | grep rtt | awk -F \/ ...

  10. BZOJ 3639: Query on a tree VII

    Description 一棵树,支持三种操作,修改点权,修改颜色,问所有与他路径上颜色相同的点的最大权,包含这两个点. Sol LCT. 用LCT来维护重边,对于每个节点在建一个set用来维护轻边,这 ...