说明:这里用来举例的是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文件夹结构如下:
- 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
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目录,确保有执行权限,执行
- chmod u+x start
- sudo ./start
chmod u+x start
sudo ./start
2 源代码安装swift1.1:
复制swift.tar.gz 到 swift home目录 ,解压
- tar zxvf swift.tar.gz
tar zxvf swift.tar.gz
进入解压后的目录,安装 swift 1.1
- cd swift
- sudo python setup.py develop
cd swift
sudo python setup.py develop
3 配置swift:
复制conf文件夹下的所有配置文件到 swift 工作目录
- cp –r SAIO/conf/* /etc/swift
cp –r SAIO/conf/* /etc/swift
配置rsync
- cp SAIO/rsyncd.conf /etc
- 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目录
- cp –r SAIO/bin/ /home/swift
cp –r SAIO/bin/ /home/swift
创建ring
- remakerings
remakerings
开启服务(主要是auth,proxy,account,container,和object)
- startmain
startmain
5 测试swift是否工作
- swift-auth-add-user -K devauth -a test tester testing
swift-auth-add-user -K devauth -a test tester testing
如显示类似输出,则正常:
- http://127.0.0.1:8080/v1/AUTH_aca75b738fe846dfa0c3dcb905719525
http://127.0.0.1:8080/v1/AUTH_aca75b738fe846dfa0c3dcb905719525
检测account test的状态
- 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
如显示类似输出,则正常
- Account: AUTH_aca75b738fe846dfa0c3dcb905719525
- Containers: 0
- Objects: 0
- Bytes: 0
Account: AUTH_aca75b738fe846dfa0c3dcb905719525
Containers: 0
Objects: 0
Bytes: 0
一些注意事项:
1) “4运行”中会提示:
- 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 查看进程和服务情况,下为示例:
- 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
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实时的操作,并记录了运行错误,可以作为查错的参考。