Object Storage(Swift)安装过程——Havana
自从看了Havana安装文档有关Swift的安装一节,发现H版的安装过程与以前还是有些差别的。不过大致过程还是那些。下面简单介绍下我们安装的过程吧,具体请参考官方文档http://docs.openstack.org/havana/install-guide/install/apt/content/ch_swift.html
原创博客:http://www.cnblogs.com/awy-blog/p/3507044.html
一、安装前准备
- 对于keystone的安装,请参照有关Havana的安装指南http://www.cnblogs.com/awy-blog/p/3447176.html
- 安装过程中都必须在root下进行
$ sudo su
- 每个结点上都必须含有Havana Package:
# apt-get install python-software-properties
# add-apt-repository cloud-archive:havana
- 升级系统
#apt-get update
#apt-get upgrade
#apt-get dist-upgrade
二、统一安装
这一节的内容必须在每个结点上安装,无论是代理结点还是存储结点,这一步不能省,必须做到,每个结点上都一样。
2.1.安装核心Swift文件和OpenSSH
# apt-get install -y swift openssh-server rsync memcached python-netifaces python-xattr python-memcache
2.2.在所有结点上创建和填充配置目录
# mkdir -p /etc/swift
# chown -R swift:swift /etc/swift/
2.3.在所有结点上创建/etc/swift/swift.conf,内容如下:
[swift-hash] # random unique string that can never change (DO NOT LOSE) swift_hash_path_suffix = openstack
注:suffix的值在/etc/swift/swift.conf应该被设为随机字符串,且这个文件在集群中的所有结点都必须相同。
三、安装和配置存储结点
3.1.安装存储结点包:
# apt-get install swift-account swift-container swift-object xfsprogs
3.2.对于你想要用于存储结点上的每个设备,建立XFS卷,这里建设系统中有/dev/sdb1/(以这个为例,如果临时分出的空间,可以用fdisk新建分区,这里具体操作请查阅fdisk相关命令):
# mkdir -p /srv/node/sdb1 # mkfs.xfs /dev/sdb1 # echo "/dev/sdb1 /srv/node/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab # mount /srv/node/sdb1 # chown -R swift:swift /srv/node
3.3.创建/etc/rsyncd.conf:
uid = swift gid = swift log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid address = 10.10.10.54 #存储结点的IP地址 [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
3.4.在/etc/default/rsync编辑下列行:
RSYNC_ENABLE = true
3.5.启动rsync守护进程:
# service rsync start
3.6.创建swift recon缓存目录并赋予它权限:
# mkdir -p /var/swift/recon
# chown -R swift:swift /var/swift/recon
四、安装和配置代理结点
4.1.安装swift-proxy服务:
# apt-get install -y swift-proxy memcached python-keystoneclient python-swiftclient python-webob python-pip
4.2.为SSL创建self-signed cert
# cd /etc/swift
# openssl req -new -x509 -nodes -out cert.crt -keyout cert.key
4.3.修改memcached以监听默认的接口在本地、非公共的网络。在/etc/memcached.conf文件中编辑这一行:
sed -i 's/-l 127.0.0.1/-l 10.10.10.51/g' > /etc/memcached.conf
4.4.重启memcached服务:
# service memcached restart
4.5.仅在ubuntu上使用:因为发布的包不包含keystoneauth中间件的拷贝,确保proxy服务包含他们:
# apt-get install -y git
# git clone https://github.com/openstack/swift.git
# cd swift
# python setup.py install
# swift-init proxy start
4.6.创建/etc/swift/proxy-server.conf
[DEFAULT] bind_port = 8888 user = swift [pipeline:main] pipeline = healthcheck cache authtoken keystoneauth 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,swiftoperator [filter:authtoken] paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory # Delaying the auth decision is required to support token-less # usage for anonymous referrers ('.r:*'). delay_auth_decision = true # cache directory for signing certificate signing_dir = /home/swift/keystone-signing # auth_* settings refer to the Keystone server auth_protocol = http auth_host = 10.10.10.51 auth_port = 35357 # the same admin_token as provided in keystone.conf admin_token = ADMIN # the service tenant and swift userid and password created in Keystone admin_tenant_name = service admin_user = swift admin_password = 111111 [filter:cache] use = egg:swift#memcache [filter:catch_errors] use = egg:swift#catch_errors [filter:healthcheck] use = egg:swift#healthcheck
4.7.创建signing_dir并赋予它权限
# mkdir -p /home/swift/keystone-signing
# chown -R swift:swift /home/swift/keystone-signing
4.8.创建accout, container和object环(rings)。后面的数字第一个为存储分区数,第二个为备份次数,备份次数不能小于ZONE数目,第三个为延迟删除的时间。(红色部分可以修改,按照存储结点数修改)
# cd /etc/swift # swift-ring-builder account.builder create 18 1 1 # swift-ring-builder container.builder create 18 1 1 # swift-ring-builder object.builder create 18 1 1
4.9.对每个存储结点设备在每个结点添加entries到每个环节中:
# swift-ring-builder account.builder add z1-10.10.10.54:6002R10.10.10.54:6005/sdb1 100 # swift-ring-builder container.builder add z1-10.10.10.54:6001R10.10.10.54:6005/sdb1 100 # swift-ring-builder object.builder add z1-10.10.10.54:6000R10.10.10.54:6005/sdb1 100
4.10.验证每个环的内容:
# swift-ring-builder account.builder
# swift-ring-builder container.builder
# swift-ring-builder object.builder
4.11.平衡环:
# swift-ring-builder accout.builder rebalance
# swift-ring-builder container.builder rebalance
# swift-ring-builder object.builder rebalance
4.12.复制account.ring.gz, container.ring.gz和object.ring.gz文件到每个proxy和storage结点的/etc/swift:
# cd /etc/swift
# scp account.ring.gz container.ring.gz object.ring.gz storage@10.10.10.54:/etc/swift/
4.13.确定所有的配置文件都被swift用户所拥有:
# chown -R swift:swift /etc/swift
4.14.启动proxy服务:
# swift-init proxy restart
4.15.在存储结点上,启动所有服务:
# swift-init all restart
五、验证安装:
5.1.在proxy结点上操作,首先导入环境变量:
$ export OS_PASSWORD=ADMIN_PASS
$ export OS_AUTH_URL=http://controller:5000/v2.0
5.2.运行下列swift命令并带上正确认证服务的URL
$ swift -V 2.0 -A $OS_AUTH_URL -U service:swift -K $ADMINPASS stat Account: AUTH_16542d36818f480d94554438c1fc0761 Containers: 0 Objects: 0 Bytes: 0 Content-Type: text/plain; charset=utf-8 X-Timestamp: 1388986871.53485 X-Put-Timestamp: 1388986871.53485