设为首页 收藏本站
查看: 1667|回复: 0

[经验分享] OpenStack Swift安装与配置

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-1-9 08:49:55 | 显示全部楼层 |阅读模式
OpenStack Swift安装与配置

OCT 15TH, 2013

准备环境


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3


192.168.30.150   proxy server
192.168.30.151    storage server
192.168.30.152    storage server



网络配置

Proxy 代理节点网络(单网卡)


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8
[color=#586e75 !important]9
[color=#586e75 !important]10
[color=#586e75 !important]11
[color=#586e75 !important]12


auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.30.150
netmask 255.255.255.0
gateway 192.168.30.1
network 192.168.30.0
broadcast 192.168.30.255
dns-nameservers 218.201.4.3



存储节点网络(单网卡) 存储节点1:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8
[color=#586e75 !important]9
[color=#586e75 !important]10
[color=#586e75 !important]11
[color=#586e75 !important]12


auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.30.151
netmask 255.255.255.0
gateway 192.168.30.1
network 192.168.30.0
broadcast 192.168.30.255
dns-nameservers 218.201.4.3



存储节点2:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8
[color=#586e75 !important]9
[color=#586e75 !important]10
[color=#586e75 !important]11
[color=#586e75 !important]12


auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.30.152
netmask 255.255.255.0
gateway 192.168.30.1
network 192.168.30.0
broadcast 192.168.30.255
dns-nameservers 218.201.4.3



安装公共组件

以下操作在所有节点全部安装:

添加源


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4


cat > /etc/apt/sources.list.d/grizzly.list << _END_
deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/grizzly main
deb  http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/grizzly main
_END_



更新源


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4


sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 5EDB1B62EC4926EA
apt-get update
apt-get upgrade
apt-get install ubuntu-cloud-keyring



 

安装 Swift


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3


os_swift="python-swift swift swift-proxy swift-account swift-container swift-object python-memcache xfsprogs"
os_keystone="python-keystone python-keystoneclient"
apt-get install -y $os_swift $os_keystone



安装之后需要手工创建 swift相关配置文件:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4


mkdir /etc/swift
touch /etc/swift/swift.conf
touch /etc/swift/proxy-server.conf
chown -R swift:swift /etc/swift



添加 swift.conf内容:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6


cat > /etc/swift/swift.conf << _END_
[swift-hash]
# od -t x8 -N 8 -A n < /dev/random
# The above command can be used to generate random a string.
swift_hash_path_suffix = 50ea1ddb6e88b991
_END_



将以下内容添加到 /etc/swift/proxy-server.conf内容:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8
[color=#586e75 !important]9
[color=#586e75 !important]10
[color=#586e75 !important]11
[color=#586e75 !important]12
[color=#586e75 !important]13
[color=#586e75 !important]14
[color=#586e75 !important]15
[color=#586e75 !important]16
[color=#586e75 !important]17
[color=#586e75 !important]18
[color=#586e75 !important]19
[color=#586e75 !important]20
[color=#586e75 !important]21
[color=#586e75 !important]22
[color=#586e75 !important]23
[color=#586e75 !important]24
[color=#586e75 !important]25
[color=#586e75 !important]26
[color=#586e75 !important]27
[color=#586e75 !important]28
[color=#586e75 !important]29
[color=#586e75 !important]30
[color=#586e75 !important]31
[color=#586e75 !important]32
[color=#586e75 !important]33
[color=#586e75 !important]34
[color=#586e75 !important]35
[color=#586e75 !important]36
[color=#586e75 !important]37
[color=#586e75 !important]38
[color=#586e75 !important]39
[color=#586e75 !important]40
[color=#586e75 !important]41
[color=#586e75 !important]42
[color=#586e75 !important]43
[color=#586e75 !important]44
[color=#586e75 !important]45
[color=#586e75 !important]46
[color=#586e75 !important]47
[color=#586e75 !important]48
[color=#586e75 !important]49
[color=#586e75 !important]50
[color=#586e75 !important]51
[color=#586e75 !important]52
[color=#586e75 !important]53
[color=#586e75 !important]54
[color=#586e75 !important]55


[DEFAULT]
bind_port = 8080
bind_ip = 0.0.0.0
user = swift
swift_dir = /etc/swift
log_facility = LOG_LOCAL0
log_level = DEBUG
[pipeline:main]
pipeline = catch_errors healthcheck cache authtoken keystoneauth container-quotas account-quotas proxy-server
[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true
[filter:keystoneauth]
use = egg:swift#keystoneauth
operator_roles = Member,admin
[filter:authtoken]
paste.filter_factory = keystone.middleware.auth_token:filter_factory
service_protocol = http
service_port = 5000
service_host = 192.168.30.150
auth_port = 35357
auth_host = 192.168.30.150
auth_protocol = http
admin_tenant_name = service
admin_user = swift
admin_password = password
signing_dir = /etc/swift
[filter:cache]
use = egg:swift#memcache
set log_name = cache
memcache_servers = 192.168.30.150:11211
[filter:catch_errors]
use = egg:swift#catch_errors
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:proxy-logging]
use = egg:swift#proxy_logging
[filter:ratelimit]
use = egg:swift#ratelimit
[filter:container-quotas]
use = egg:swift#container_quotas
[filter:account-quotas]
use = egg:swift#account_quotas



如果不使用 Keystone 认证,请使用以下的配置文件:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8
[color=#586e75 !important]9
[color=#586e75 !important]10
[color=#586e75 !important]11
[color=#586e75 !important]12
[color=#586e75 !important]13
[color=#586e75 !important]14
[color=#586e75 !important]15
[color=#586e75 !important]16
[color=#586e75 !important]17
[color=#586e75 !important]18
[color=#586e75 !important]19
[color=#586e75 !important]20
[color=#586e75 !important]21
[color=#586e75 !important]22
[color=#586e75 !important]23
[color=#586e75 !important]24
[color=#586e75 !important]25
[color=#586e75 !important]26


[DEFAULT]
bind_port = 8080
bind_ip = 192.168.30.150
user = swift
[pipeline:main]
pipeline = healthcheck cache tempauth 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
memcache_servers = 192.168.30.150:11211



格式: user = 登录的时候就是:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3


login = admin:admin
password = admin
privileges = .admin .reseller_admin



配置rsyslog


[color=#586e75 !important]1
[color=#586e75 !important]2


echo "local0.*    /var/log/swift/proxy-server.log" >> /etc/rsyslog.conf
mkdir /var/log/swift



配置 环 Ring


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4


cd /etc/swift
sudo swift-ring-builder account.builder create 6 2 1
sudo swift-ring-builder container.builder create 6 2 1
sudo swift-ring-builder object.builder create 6 2 1



说明


  • 第一个数字:6表示分区(环)将被处理为26th,即使用2的6次方个分区,创建完之后应有 64个分区
  • 第二个数字:每个存储对象保存2份,即创建2个副本;由于偶只有两台storage,故只写2
  • 第三个数字:1表示限制分区数据转移的时间,此处表示1小时,即分区被连续移动两次之间的最小时间间隔

添加设备 添加新设备到Ring上,但add操作不会分配partitions到新的设备上,只有运行“rebalance”命令后才会进行分区的分配,所以这种方式可以有这种优势: 允许一次添加多个设备,只执行一次rebalance就可以了,以下操作步骤:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8


sudo swift-ring-builder account.builder add z1-192.168.30.151:6002/sdb1 100
sudo swift-ring-builder account.builder add z2-192.168.30.152:6002/sdb1 100
sudo swift-ring-builder container.builder add z1-192.168.30.151:6001/sdb1 100
sudo swift-ring-builder container.builder add z2-192.168.30.152:6001/sdb1 100
sudo swift-ring-builder object.builder add z1-192.168.30.151:6000/sdb1 100
sudo swift-ring-builder object.builder add z2-192.168.30.152:6000/sdb1 100



查看 Ring信息 可通过以下命令查到到Ring和Ring中的设备信息: * 查询account信息:

    swift-ring-builder account.builder



  • 查询container信息:

      swift-ring-builder container.builder

  • 查询object信息

      swift-ring-builder object.builder

  • 生成 Ring 如果确认一切之后,最终还要生成Ring,来进行分区的分配,即之前提到的rebalance:



[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3


sudo swift-ring-builder account.builder rebalance
sudo swift-ring-builder container.builder rebalance
sudo swift-ring-builder object.builder rebalance



设置权限


[color=#586e75 !important]1
[color=#586e75 !important]2


chown -R swift:swift /etc/swift
chown -R swift:swift /var/cache/swift




存储节点安装与配置

添加设备: 先创建分区,另外一定要是 XFS文件系统


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5


mkdir -p /srv/node/sdb1
chown -R swift:swift /srv/node/
mkfs.xfs -i size=1024 /dev/sdb1 -f
echo "/dev/sdb1 /srv/node/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab
mount /srv/node/sdb1  



设置 rsyncd.conf


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8
[color=#586e75 !important]9
[color=#586e75 !important]10
[color=#586e75 !important]11
[color=#586e75 !important]12
[color=#586e75 !important]13
[color=#586e75 !important]14
[color=#586e75 !important]15
[color=#586e75 !important]16
[color=#586e75 !important]17
[color=#586e75 !important]18
[color=#586e75 !important]19
[color=#586e75 !important]20
[color=#586e75 !important]21
[color=#586e75 !important]22
[color=#586e75 !important]23
[color=#586e75 !important]24


uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.30.151
[account]
max_connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/account.lock
[container]
max_connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/container.lock
[object]
max_connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/object.lock



设置 rsync开机自启动

sudo sed -i 's/RSYNC_ENABLE=false/RSYNC_ENABLE=true/g' /etc/default/rsync

启动 rsync服务

sudo service rsync start

创建/etc/account-server.conf:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8
[color=#586e75 !important]9
[color=#586e75 !important]10
[color=#586e75 !important]11
[color=#586e75 !important]12
[color=#586e75 !important]13
[color=#586e75 !important]14
[color=#586e75 !important]15
[color=#586e75 !important]16
[color=#586e75 !important]17
[color=#586e75 !important]18
[color=#586e75 !important]19


[DEFAULT]
bind_ip = 0.0.0.0
bind_port = 6002
workers = 1
user = swift
swift_dir = /etc/swift
devices = /srv/node
[pipeline:main]
pipeline = account-server
[app:account-server]
use = egg:swift#account
[account-replicator]
[account-auditor]
[account-reaper]




创建/etc/container-server.conf


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8
[color=#586e75 !important]9
[color=#586e75 !important]10
[color=#586e75 !important]11
[color=#586e75 !important]12
[color=#586e75 !important]13
[color=#586e75 !important]14
[color=#586e75 !important]15
[color=#586e75 !important]16
[color=#586e75 !important]17
[color=#586e75 !important]18
[color=#586e75 !important]19
[color=#586e75 !important]20
[color=#586e75 !important]21


[DEFAULT]
bind_ip = 0.0.0.0
bind_port = 6001
workers = 1
user = swift
swift_dir = /etc/swift
devices = /srv/node
[pipeline:main]
pipeline = container-server
[app:container-server]
use = egg:swift#container
[container-replicator]
[container-updater]
[container-auditor]
[container-sync]



创建/etc/object-server.conf


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8
[color=#586e75 !important]9
[color=#586e75 !important]10
[color=#586e75 !important]11
[color=#586e75 !important]12
[color=#586e75 !important]13
[color=#586e75 !important]14
[color=#586e75 !important]15
[color=#586e75 !important]16
[color=#586e75 !important]17
[color=#586e75 !important]18
[color=#586e75 !important]19
[color=#586e75 !important]20
[color=#586e75 !important]21
[color=#586e75 !important]22
[color=#586e75 !important]23


[DEFAULT]
bind_ip = 0.0.0.0
bind_port = 6000
workers = 1
user = swift
swift_dir = /etc/swift
devices = /srv/node
[pipeline:main]
pipeline = recon object-server
[app:object-server]
use = egg:swift#object
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
[object-replicator]
[object-updater]
[object-auditor]



重启服务

在所有存储节点重启以下服务:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8
[color=#586e75 !important]9
[color=#586e75 !important]10
[color=#586e75 !important]11


sudo swift-init object-server start
sudo swift-init object-replicator start
sudo swift-init object-updater start
sudo swift-init object-auditor start
sudo swift-init container-server start
sudo swift-init container-replicator start
sudo swift-init container-updater start
sudo swift-init container-auditor start
sudo swift-init account-server start
sudo swift-init account-replicator start
sudo swift-init account-auditor start



在代理节点启动以下服务:


[color=#586e75 !important]1


sudo swift-init all restart



Swift操作

获得 X-Storage-Url 和 X-Auth-Token:

curl -k -v -H 'X-Storage-User: admin:admin' -H 'X-Storage-Pass: admin' http://192.168.30.150:8080/auth/v1.0

如果正确,将会返回以下类似信息:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7
[color=#586e75 !important]8
[color=#586e75 !important]9
[color=#586e75 !important]10
[color=#586e75 !important]11
[color=#586e75 !important]12
[color=#586e75 !important]13
[color=#586e75 !important]14
[color=#586e75 !important]15
[color=#586e75 !important]16
[color=#586e75 !important]17
[color=#586e75 !important]18
[color=#586e75 !important]19


* About to connect() to 192.168.30.150 port 8080 (#0)
*   Trying 192.168.30.150... 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.30.150:8080
> Accept: */*
> X-Storage-User: admin:admin
> X-Storage-Pass: admin
>
< HTTP/1.1 200 OK
< X-Storage-Url: http://192.168.30.150:8080/v1/AUTH_admin
< X-Auth-Token: AUTH_tk8a85916d63b14c568a4633b7920623c5
< Content-Type: text/html; charset=UTF-8
< X-Storage-Token: AUTH_tk8a85916d63b14c568a4633b7920623c5
< Content-Length: 0
< Date: Tue, 15 Oct 2013 01:49:59 GMT
<
* Connection #0 to host 192.168.30.150 left intact
* Closing connection #0



 
检查账号

    curl -k -v -H 'X-Auth-Token: <token-from-x-auth-token-above>' <url-from-xstorage-url-above>  

这里的token-from-x-auth-token-above 就是上面输出的 AUTH_tk8a85916d63b14c568a4633b7920623c5,url-from-xstorage-url-above对应:http://192.168.30.150:8080/v1/AUTH_admin
检测 swift 命令是否工作正常

    swift -A http://192.168.30.150:8080/auth/v1.0 -U admin:admin -K admin stat

正常输出类似以下信息:


[color=#586e75 !important]1
[color=#586e75 !important]2
[color=#586e75 !important]3
[color=#586e75 !important]4
[color=#586e75 !important]5
[color=#586e75 !important]6
[color=#586e75 !important]7


   Account: AUTH_admin
Containers: 0
   Objects: 0
     Bytes: 0
Accept-Ranges: bytes
X-Timestamp: 1381806617.24083
Content-Type: text/plain; charset=utf-8



上传

swift -A http://192.168.30.150:8080/auth/v1.0 -U admin:admin -K admin upload test apache-tomcat-6.0.36.tar.gz

删除

swift -A http://192.168.30.150:8080/auth/v1.0 -U admin:admin -K admin delete test apache-tomcat-6.0.36.tar.gz

排错思路


  • 直接看控制台打印的日志
  • 检查配置文件是否正确
  • 通过观察日志,例如/var/log/syslog
  • 修改配置文件之后,需要重启对应的服务

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-162049-1-1.html 上篇帖子: 使用devstack安装openstack过程总结 下篇帖子: Python下的云计算(OpenStack技术书籍)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表