你好,游客 登录 注册 搜索
背景:
阅读新闻

OpenStack Swift集群部署流程与简单使用

[日期:2013-08-01] 来源:Linux社区  作者:fczjuever [字体:大 中 小]

3. 使用实例

  启动PC1和PC2上的Swift服务后,我们交替地在PC1和PC2上执行操作,并随机使用两者提供的storage-url,如果用户验证和存储服务全部正确,则表明Swift集群部署成功。

3.1 用curl测试

  我们先使用curl测试几个简单的命令。

  1. 在PC1上访问192.168.3.52,进行tester用户验证,获取Token和storage-url。

# curl -k -v -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass: testing' http://192.168.3.52:8080/auth/v1.0

* About to connect() to 192.168.3.52 port 8080 (#0)

* Trying 192.168.3.52... connected

> GET /auth/v1.0 HTTP/1.1

> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3

> Host: 192.168.3.52:8080

> Accept: */*

> X-Storage-User: test:tester

> X-Storage-Pass: testing

>

< HTTP/1.1 200 OK

< X-Storage-Url: http://192.168.3.52:8080/v1/AUTH_test

< X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1

< Content-Type: text/html; charset=UTF-8

< X-Storage-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1

< Content-Length: 0

< Date: Wed, 20 Mar 2013 06:13:15 GMT

<

* Connection #0 to host 192.168.3.52 left intact

* Closing connection #0

  2. 在PC1上访问192.168.3.52,查看test账户的状态信息。

# curl -k -v -H 'X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1' http://192.168.3.52:8080/v1/AUTH_test

* About to connect() to 192.168.3.52 port 8080 (#0)

* Trying 192.168.3.52... connected

> GET /v1/AUTH_test HTTP/1.1

> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3

> Host: 192.168.3.52:8080

> Accept: */*

> X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1

>

< HTTP/1.1 204 No Content

< Content-Length: 0

< Accept-Ranges: bytes

< X-Timestamp: 1363760036.52552

< X-Account-Bytes-Used: 0

< X-Account-Container-Count: 0

< Content-Type: text/html; charset=UTF-8

< X-Account-Object-Count: 0

< Date: Wed, 20 Mar 2013 06:13:56 GMT

<

* Connection #0 to host 192.168.3.52 left intact

* Closing connection #0

  3. 在PC1上访问192.168.3.53,查看test账户的状态信息。

# curl -k -v -H 'X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1' http://192.168.3.53:8080/v1/AUTH_test

* About to connect() to 192.168.3.53 port 8080 (#0)

* Trying 192.168.3.53... connected

> GET /v1/AUTH_test HTTP/1.1

> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3

> Host: 192.168.3.53:8080

> Accept: */*

> X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1

>

< HTTP/1.1 204 No Content

< Content-Length: 0

< Accept-Ranges: bytes

< X-Timestamp: 1363760036.52552

< X-Account-Bytes-Used: 0

< X-Account-Container-Count: 0

< Content-Type: text/html; charset=UTF-8

< X-Account-Object-Count: 0

< Date: Wed, 20 Mar 2013 06:15:19 GMT

<

* Connection #0 to host 192.168.3.53 left intact

* Closing connection #0

  4. 在PC2上访问192.168.3.52,查看test账户的状态信息。

# curl -k -v -H 'X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1' http://192.168.3.52:8080/v1/AUTH_test

* About to connect() to 192.168.3.52 port 8080 (#0)

* Trying 192.168.3.52... connected

> GET /v1/AUTH_test HTTP/1.1

> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3

> Host: 192.168.3.52:8080

> Accept: */*

> X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1

>

< HTTP/1.1 204 No Content

< Content-Length: 0

< Accept-Ranges: bytes

< X-Timestamp: 1363760036.52552

< X-Account-Bytes-Used: 0

< X-Account-Container-Count: 0

< Content-Type: text/html; charset=UTF-8

< X-Account-Object-Count: 0

< Date: Wed, 20 Mar 2013 06:17:01 GMT

<

* Connection #0 to host 192.168.3.52 left intact

* Closing connection #0

  上述测试一切正常,表明curl测试通过。

3.2 用Swift客户端测试

  接着,我们使用Swift客户端进行测试。

  1. 在PC1上访问192.168.3.53,查看test账户的状态信息。

# swift -A http://192.168.3.53:8080/auth/v1.0 -U test:tester -K testing stat

Account: AUTH_test

Containers: 0

Objects: 0

Bytes: 0

Accept-Ranges: bytes

X-Timestamp: 1363760036.52552

Content-Type: text/plain; charset=utf-8

 

  2. 在PC1上访问192.168.3.52,在test账户下创建名为myfiles的container。

# swift -A http://192.168.3.52:8080/auth/v1.0 -U test:tester -K testing post myfiles

 

 

  3. 在PC1上访问192.168.3.53,显示test账户下的container列表。

# swift -A http://192.168.3.53:8080/auth/v1.0 -U test:tester -K testing list

myfiles

 

  4. 在PC2上访问192.168.3.52,显示test账户下的container列表。

# swift -A http://192.168.3.52:8080/auth/v1.0 -U test:tester -K testing list

myfiles

 

  5. 在PC2上访问192.168.3.53,在刚才创建的container下上传文件。上传完成后,Swift服务端会以完整路径作为文件名。

# swift -A http://192.168.3.53:8080/auth/v1.0 -U test:tester -K testing upload myfiles ~/file

root/file

 

  6. 在PC1上访问192.168.3.52,显示刚才创建的container下的文件列表。

# swift -A http://192.168.3.52:8080/auth/v1.0 -U test:tester -K testing list myfiles

root/file

 

  7. 在PC1上访问192.168.3.52,下载刚才上传的文件。给定的文件名必须是其完整路径,例如上传的文件为~/file,服务端记录的文件名为root/file,于是下载时也要给文件名root/file,而不能是file。最终,文件会被下载到~/root目录下,成为~/root/file。可以使用额外的命令参数来决定下载位置,详情参考swift --help。

# swift -A http://192.168.3.52:8080/auth/v1.0 -U test:tester -K testing download myfiles root/file

root/file [headers 0.041s, total 0.065s, 0.000s MB/s]

  上述测试一切正常,表明Swift客户端测试通过。

4. 参考链接

4.1 官方连接

  • Instructions for a Multiple Server Swift Installation (Ubuntu)

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

  • SAIO - Swift All In One

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

  • Swift 1.8.0-dev documentation -> Deployment Guide

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

4.2 非官方链接

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款