---
title: "openstack swift"
author: "jetway"
date: "2014-08-06T14:02:42Z"
tags: []
categories: ["行业应用"]
slug: "openstack-swift"
draft: false
lastmod: "2014-08-06T14:02:42Z"
id: 2100938
url: "https://jetway.iteye.com/blog/2100938"
---

**说明：这里用来举例的是swift 1.1。文章成稿时的最新版本为swift1.4.2-dev。两个版本之间有很大区别，但整体结构上变化不大，并不影响对swift的理解。swift1.4.\*版本的简明安装会在稍后更新。特此说明。**

   

**1swift安装**

约定  
ubuntu 用户：swift  
swift用户 home 目录： /home/swift  
swift工作目录： /etc/swift  
网段：192.168.1.*

**1.1简明安装**  
说明：  
简明安装只是为了简化说明swift安装的操作流程，可按照实际需要修改相应脚本文件！  
**1.1.1SAIO**  
0准备工作  
请到http://code.google.com/p/swift-cn-doc/downloads/list下载脚本文件和配置文件SAIO.tar.gz，SAIO文件夹结构如下：

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

01. SAIO
02. ├── bin
03. │   ├── remakerings
04. │   ├── resetswift
05. │   ├── startmain
06. │   └── startrest
07. ├── conf
08. │   ├── account-server
09. │   ├── auth-server.conf
10. │   ├── container-server
11. │   ├── object-server
12. │   ├── proxy-server.conf
13. │   └── swift.conf
14. ├── rsyncd.conf
15. ├── start
16. └── swift.tar.gz

```
SAIO
├── bin
│   ├── remakerings
│   ├── resetswift
│   ├── startmain
│   └── startrest
├── conf  
│   ├── account-server
│   ├── auth-server.conf
│   ├── container-server
│   ├── object-server
│   ├── proxy-server.conf
│   └── swift.conf
├── rsyncd.conf
├── start
└── swift.tar.gz
```

1 初始化环境：  
复制start 到swift home目录，确保有执行权限，执行

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. chmod u+x start
2. sudo ./start

```
chmod u+x start
sudo ./start
```

2 源代码安装swift1.1:  
复制swift.tar.gz 到 swift home目录 ,解压

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. tar zxvf swift.tar.gz

```
tar zxvf swift.tar.gz
```

进入解压后的目录，安装 swift 1.1

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. cd swift
2. sudo python setup.py develop

```
cd swift
sudo python setup.py develop
```

3 配置swift:  
复制conf文件夹下的所有配置文件到 swift 工作目录

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. cp –r SAIO/conf/* /etc/swift

```
cp –r SAIO/conf/* /etc/swift
```

配置rsync

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. cp SAIO/rsyncd.conf /etc
2. sudo service rsync restart

```
cp SAIO/rsyncd.conf /etc
sudo service rsync restart
```

注意：如果提示

rsync daemon not enabled in /etc/default/rsync ,not starting ...

请编辑/etc/default/rsync中的line8：RSYNC\_ENABLE=false为

RSYNC\_ENABLE=true

 

4 运行：  
复制bin/文件夹到 swift home目录

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. cp –r SAIO/bin/ /home/swift

```
cp –r SAIO/bin/ /home/swift
```

创建ring

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. remakerings

```
remakerings
```

开启服务(主要是auth,proxy,account,container,和object)

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. startmain

```
startmain
```

5 测试swift是否工作

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. swift-auth-add-user -K devauth -a test tester testing

```
swift-auth-add-user -K devauth -a test tester testing
```

如显示类似输出，则正常：

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. http://127.0.0.1:8080/v1/AUTH\_aca75b738fe846dfa0c3dcb905719525

```
http://127.0.0.1:8080/v1/AUTH_aca75b738fe846dfa0c3dcb905719525
```

检测account test的状态

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. st -A http://127.0.0.1:11000/v1.0 -U test:tester -K testing stat

```
st -A http://127.0.0.1:11000/v1.0 -U test:tester -K testing stat
```

如显示类似输出，则正常

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. Account: AUTH\_aca75b738fe846dfa0c3dcb905719525
2. Containers: 0
3. Objects: 0
4. Bytes: 0

```
Account: AUTH_aca75b738fe846dfa0c3dcb905719525
Containers: 0
Objects: 0
Bytes: 0
```

一些注意事项：  
1） “4运行”中会提示：

**\[plain]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

1. Unable to increase file descriptor limit. Running as non-root?

```
Unable to increase file descriptor limit. Running as non-root?
```

此为正常现象，忽略它。  
2） “5测试”之前，请检查几个地方的文件属性是否正常（所属用户、读写权限）。包括：  
/etc/swift  
/var/run/swift  
3） 运用ps 和 netstat 查看进程和服务情况，下为示例：

**\[html]** [view plain](http://blog.csdn.net/zzcase/article/details/6582826 "view plain")[copy](http://blog.csdn.net/zzcase/article/details/6582826 "copy")[print](http://blog.csdn.net/zzcase/article/details/6582826 "print")[?](http://blog.csdn.net/zzcase/article/details/6582826 "?")

01. swift@node31:~$ sudo netstat -nupta
02. Active Internet connections (servers and established)
03. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
04. tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 4789/memcached
05. tcp 0 0 0.0.0.0:6030 0.0.0.0:* LISTEN 5785/python
06. tcp 0 0 0.0.0.0:6031 0.0.0.0:* LISTEN 5780/python
07. tcp 0 0 0.0.0.0:6032 0.0.0.0:* LISTEN 5775/python
08. tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 5498/python
09. tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 5106/vsftpd
10. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 581/sshd
11. tcp 0 0 0.0.0.0:11000 0.0.0.0:* LISTEN 6847/python
12. tcp 0 0 0.0.0.0:6040 0.0.0.0:* LISTEN 5783/python
13. tcp 0 0 0.0.0.0:6041 0.0.0.0:* LISTEN 5778/python
14. tcp 0 0 0.0.0.0:6010 0.0.0.0:* LISTEN 5784/python
15. tcp 0 0 0.0.0.0:6042 0.0.0.0:* LISTEN 5773/python
16. tcp 0 0 0.0.0.0:6011 0.0.0.0:* LISTEN 5779/python
17. tcp 0 0 0.0.0.0:6012 0.0.0.0:* LISTEN 5774/python
18. tcp 0 0 0.0.0.0:6020 0.0.0.0:* LISTEN 5786/python
19. tcp 0 0 0.0.0.0:6021 0.0.0.0:* LISTEN 5781/python
20. tcp 0 0 0.0.0.0:6022 0.0.0.0:* LISTEN 5776/python
21. tcp 0 0 127.0.0.1:873 0.0.0.0:* LISTEN 6700/rsync
22. tcp 0 0 127.0.0.1:34865 127.0.0.1:11211 ESTABLISHED 5509/python
23. tcp 0 0 127.0.0.1:11211 127.0.0.1:34865 ESTABLISHED 4789/memcached
24. tcp6 0 0 :::22 :::* LISTEN 581/sshd
25. udp 0 0 127.0.0.1:11211 0.0.0.0:* 4789/memcached

```
swift@node31:~$ sudo netstat -nupta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 4789/memcached
tcp 0 0 0.0.0.0:6030 0.0.0.0:* LISTEN 5785/python
tcp 0 0 0.0.0.0:6031 0.0.0.0:* LISTEN 5780/python
tcp 0 0 0.0.0.0:6032 0.0.0.0:* LISTEN 5775/python
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 5498/python
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 5106/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 581/sshd
tcp 0 0 0.0.0.0:11000 0.0.0.0:* LISTEN 6847/python
tcp 0 0 0.0.0.0:6040 0.0.0.0:* LISTEN 5783/python
tcp 0 0 0.0.0.0:6041 0.0.0.0:* LISTEN 5778/python
tcp 0 0 0.0.0.0:6010 0.0.0.0:* LISTEN 5784/python
tcp 0 0 0.0.0.0:6042 0.0.0.0:* LISTEN 5773/python
tcp 0 0 0.0.0.0:6011 0.0.0.0:* LISTEN 5779/python
tcp 0 0 0.0.0.0:6012 0.0.0.0:* LISTEN 5774/python
tcp 0 0 0.0.0.0:6020 0.0.0.0:* LISTEN 5786/python
tcp 0 0 0.0.0.0:6021 0.0.0.0:* LISTEN 5781/python
tcp 0 0 0.0.0.0:6022 0.0.0.0:* LISTEN 5776/python
tcp 0 0 127.0.0.1:873 0.0.0.0:* LISTEN 6700/rsync
tcp 0 0 127.0.0.1:34865 127.0.0.1:11211 ESTABLISHED 5509/python
tcp 0 0 127.0.0.1:11211 127.0.0.1:34865 ESTABLISHED 4789/memcached
tcp6 0 0 :::22 :::* LISTEN 581/sshd
udp 0 0 127.0.0.1:11211 0.0.0.0:* 4789/memcached
```

4） /var/log/syslog 中记载了client实时的操作，并记录了运行错误，可以作为查错的参考。