文档章节

Ubuntu 12.04 OpenStack Swift单节点部署手册

Honghe
 Honghe
发布于 2013/07/30 20:56
字数 1912
阅读 3992
收藏 61

OpenStack Swift单节点部署手册

部署环境

  • VMware Workstation 9 (推荐版本,低版本亦可,只要能安装Ubuntu 12.04)
  • Ubuntu 12.04 Server 32 bit
  • OpenStack Swift v1.8 (Grizzly)

说明

  • 此文档为基于官方修改的只针对Ubuntu 12.04,完整的参阅官方文档
  • 本部署为开发环境,Swift配置为以root权限运行,生产环境推荐新建用户swift
  • 选择Ubuntu 12.04因其默认内核为3.5,减少部署时的麻烦
  • Ubuntu Server安装时不选其它组件,最小化安装
  • 以下安装命令全部以root身份运行

Ubuntu 更改为国内源(非必需):

sudo vi /etc/apt/sources.list
%s/cn.archive.ubuntu.com/mirrors.ustc.edu.cn/g #修改前面一部分
%s/security.ubuntu.com/mirrors.ustc.edu.cn/g #修改security的源地址
sudo apt-get update
sudo apt-get upgrade

安装依赖

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

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/openstack/swift.git 
安装Swift的开发版本
cd ~/swift
git checkout -t origin/stable/grizzly # checkout稳定分支1.8
python setup.py develop
cd .. 
从git上获取python-swiftclient代码,下载到本地
git clone https://github.com/openstack/python-swiftclient.git 
安装python-swiftclient的开发版本
cd ~/python-swiftclient
python setup.py develop
cd ..

配置各结点

创建文件/etc/swift/proxy-server.conf,
[DEFAULT]
bind_port = 8080
user = root
log_facility = LOG_LOCAL1
eventlet_debug = true

[pipeline:main]
pipeline = healthcheck cache tempauth proxy-logging 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

[filter:proxy-logging]
use = egg:swift#proxy_logging
创建文件/etc/swift/swift.conf,
[swift-hash]
# random unique strings that can never change (DO NOT LOSE)
swift_hash_path_prefix = rui
swift_hash_path_suffix = jie
Create /etc/swift/account-server/1.conf:
[DEFAULT]
devices = /srv/1/node
mount_check = false
disable_fallocate = true
bind_port = 6012
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/2/node
mount_check = false
disable_fallocate = true
bind_port = 6022
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/3/node
mount_check = false
disable_fallocate = true
bind_port = 6032
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/4/node
mount_check = false
disable_fallocate = true
bind_port = 6042
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/1/node
mount_check = false
disable_fallocate = true
bind_port = 6011
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/2/node
mount_check = false
disable_fallocate = true
bind_port = 6021
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/3/node
mount_check = false
disable_fallocate = true
bind_port = 6031
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/4/node
mount_check = false
disable_fallocate = true
bind_port = 6041
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/1/node
mount_check = false
disable_fallocate = true
bind_port = 6010
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/2/node
mount_check = false
disable_fallocate = true
bind_port = 6020
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/3/node
mount_check = false
disable_fallocate = true
bind_port = 6030
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/4/node
mount_check = false
disable_fallocate = true
bind_port = 6040
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/1 /mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4
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

chmod +x ~/bin/*

编辑~/.bashrc,在最后添加如下两行
export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf
export PATH=${PATH}:~/bin

<!-- lang: shell -->
. ~/.bashrc
remakerings
cp ~/swift/test/sample.conf /etc/swift/test.conf
开启Swift
startmain
检查Swift工作
swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat
正确情况下,应该输出以下信息
Account: AUTH_test
Containers: 0
Objects: 0
Bytes: 0
Accept-Ranges: bytes
重启main服务
swift-init main restart
swift-init
swift-init命令有许多参数,具体查看帮助

ps

Markdown写博客挺友好

参考:
http://www.cnblogs.com/fczjuever/archive/2013/05/11/3073151.html http://docs.openstack.org/developer/swift/development_saio.html

© 著作权归作者所有

Honghe

Honghe

粉丝 58
博文 127
码字总数 35797
作品 3
福州
高级程序员
私信 提问
加载中

评论(4)

Honghe
Honghe 博主

引用来自“zhouxingxing”的评论

引用来自“Honghe”的评论

引用来自“zhouxingxing”的评论

hello,想问下 你们用swift 做什么,自己企业的后端存储 还是要做产品呢

暂时以内部网盘的形式开发。可以给些建议哈

没啥建议啊,我今年一直没弄openstack的东西,,,貌似下个季度开始要回到openstack,swift是很成熟的产品,做内部网盘非常好

哦哦,欢迎回归,,,
zhouxingxing
zhouxingxing

引用来自“Honghe”的评论

引用来自“zhouxingxing”的评论

hello,想问下 你们用swift 做什么,自己企业的后端存储 还是要做产品呢

暂时以内部网盘的形式开发。可以给些建议哈

没啥建议啊,我今年一直没弄openstack的东西,,,貌似下个季度开始要回到openstack,swift是很成熟的产品,做内部网盘非常好
Honghe
Honghe 博主

引用来自“zhouxingxing”的评论

hello,想问下 你们用swift 做什么,自己企业的后端存储 还是要做产品呢

暂时以内部网盘的形式开发。可以给些建议哈
zhouxingxing
zhouxingxing
hello,想问下 你们用swift 做什么,自己企业的后端存储 还是要做产品呢
云计算相关资料/博客/网上收集的关于OpenStack的一些资源

OpenStack Nova code:https://bugs.launchpad.net/nova OpenStack Blog:http://planet.openstack.org/ OpenStack 官方文档:http://docs.openstack.org/cactus/openstack-compute/admin/co......

DongZhang
2012/02/02
361
0
一键部署OpenStack OneStack

这是一个一键部署OpenStack的工具。目前能够完整而正确在Ubuntu12.04(precise)安装部署OpenStack,其它Linux系统没有做,欢迎补充和完善。 一键完整部署OpenStack,可以自定义配置,无需交...

蓝狐乐队
2014/04/18
277
0
OpenStack 简单安装(fuel)

OPENSTACK 涉及到的组件比较多,对大家学习安装过程带来很多的问题,现在找到 一个MIRANTIS 公司出的安装OPENSTACK的工具。本人测试方便可用(在Mac OS X10.9.2和CentOS 6.4上测试过 )。值得推...

hzchenkj
2018/06/28
0
0
OpenStack简介和相关资料 --- 转

最近2个星期在尝试用OpenStack搭建私有云,提供方便的虚拟机部署和管理。写一篇博客记录一下相关资料。 1. OpenStack简介 OpenStack是一个开源软件,它提供了一个部署云的平台。为虚拟计算或...

DongZhang
2012/02/02
555
0
在 Ubuntu 上安装和配置 OpenStack Nova

OpenStack 是由 Rackspace 和 NASA 共同开发的云计算平台,帮助服务商和企业内部实现类似于 Amazon EC2 和 S3 的云基础架构服务(Infrastructure as a Service, IaaS)。OpenStack 包含两个主...

鉴客
2012/03/10
1K
0

没有更多内容

加载失败,请刷新页面

加载更多

哪些情况下适合使用云服务器?

我们一直在说云服务器价格适中,具备弹性扩展机制,适合部署中小规模的网站或应用。那么云服务器到底适用于哪些情况呢?如果您需要经常原始计算能力,那么使用独立服务器就能满足需求,因为他...

云漫网络Ruan
55分钟前
3
0
Kafka 2.3 Producer (0.9以后版本适用)

kafka0.9版本以后用java重新编写了producer,废除了原来scala编写的版本。 这里直接使用最新2.3版本,0.9以后的版本都适用。 注意引用的包为:org.apache.kafka.clients.producer import ja...

实时计算
今天
3
0
Java 中的 String 有没有长度限制

转载: https://juejin.im/post/5d53653f5188257315539f9a String是Java中很重要的一个数据类型,除了基本数据类型以外,String是被使用的最广泛的了,但是,关于String,其实还是有很多东西...

低至一折起
今天
15
0
OpenStack 简介和几种安装方式总结

OpenStack :是一个由NASA和Rackspace合作研发并发起的,以Apache许可证授权的自由软件和开放源代码项目。项目目标是提供实施简单、可大规模扩展、丰富、标准统一的云计算管理平台。OpenSta...

小海bug
昨天
11
0
DDD(五)

1、引言 之前学习了解了DDD中实体这一概念,那么接下来需要了解的就是值对象、唯一标识。值对象,值就是数字1、2、3,字符串“1”,“2”,“3”,值时对象的特征,对象是一个事物的具体描述...

MrYuZixian
昨天
8
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部