11.各个节点-Swift组件.md


官方指导中,在安装cinder backup服务(Install and configure the backup serviceInstall and configure the backup service)时遇到需要先安装块存储服务 Block Storage service (Cinder) 和对象存储服务Object Storage service(Swift),故而记录此篇。

Optionally, install and configure the backup service. For simplicity, this configuration uses the Block Storage node and the Object Storage (swift) driver, thus depending on the Object Storage service.

You must install and configure a storage node prior to installing and configuring the backup service.

此前已经进行cinder块存储服务的相关安装部署工作,官方指导教程为Cinder Installation Guide

欢迎留言沟通,共同进步。



文章目录

  • 11.0 [Object Storage service overview](https://docs.openstack.org/swift/victoria/install/get_started.html)
  • 11.1 存储节点网络配置
  • object storage node1
  • 1.网卡配置
  • 2.完成域名与网络地址的映射
  • 3.主机名解析配置
  • object storage node2
  • 1.网卡配置
  • 2.完成域名与网络地址的映射
  • 3.主机名解析配置
  • 11.2 控制节点安装与配置
  • 1.先决条件
  • 环境变量
  • 要创建身份服务凭证
  • 创建对象存储服务 API 端点:
  • 2.相关软件安装与配置
  • 安装软件包:
  • 修改配置文件
  • 11.3 存储节点安装与配置
  • 1.先决条件
  • 2.[安装和配置组件](https://docs.openstack.org/swift/victoria/install/storage-install-rdo.html#install-and-configure-components)
  • 11.4控制节点创建和分发初始化rings
  • 1.[创建账号环](https://docs.openstack.org/swift/victoria/install/initial-rings.html#create-account-ring)
  • 2.[创建容器环](https://docs.openstack.org/swift/victoria/install/initial-rings.html#create-container-ring)
  • 3.[创建对象环](https://docs.openstack.org/swift/victoria/install/initial-rings.html#create-object-ring)
  • 4.[分发环配置文件](https://docs.openstack.org/swift/victoria/install/initial-rings.html#distribute-ring-configuration-files)
  • 11.5完成安装Finalize installation
  • 11.6验证安装Verify operation



Victoria官方指导教程:OpenStack Victoria Installation Guides

Swift组件官方安装教程:

- Victoria [Object Storage service(Swift)](https://docs.openstack.org/swift/victoria/install/)
- Latest [Object Storage service(Swift)](https://docs.openstack.org/swift/latest/install/)

11.0 Object Storage service overview

https://docs.openstack.org/swift/latest/install/get_started.html#object-storage-service-overview

The OpenStack Object Storage is a multi-tenant object storage system. It is highly scalable and can manage large amounts of unstructured data at low cost through a RESTful HTTP API.

It includes the following components:

  • Proxy servers (swift-proxy-server)
    Accepts OpenStack Object Storage API and raw HTTP requests to upload files, modify metadata, and create containers. It also serves file or container listings to web browsers. To improve performance, the proxy server can use an optional cache that is usually deployed with memcache.
  • Account servers (swift-account-server)
    Manages accounts defined with Object Storage.
  • Container servers (swift-container-server)
    Manages the mapping of containers or folders, within Object Storage.
  • Object servers (swift-object-server)
    Manages actual objects, such as files, on the storage nodes.
  • Various periodic processes
    Performs housekeeping tasks on the large data store. The replication services ensure consistency and availability through the cluster. Other periodic processes include auditors, updaters, and reapers.
  • WSGI middleware
    Handles authentication and is usually OpenStack Identity.
  • swift client
    Enables users to submit commands to the REST API through a command-line client authorized as either a admin user, reseller user, or swift user.
  • swift-init
    Script that initializes the building of the ring file, takes daemon names as parameter and offers commands. Documented in https://docs.openstack.org/swift/latest/admin_guide.html#managing-services.
  • swift-recon
    A cli tool used to retrieve various metrics and telemetry information about a cluster that has been collected by the swift-recon middleware.
  • swift-ring-builder
    Storage ring build and rebalance utility. Documented in https://docs.openstack.org/swift/latest/admin_guide.html#managing-the-rings.

11.1 存储节点网络配置

在openstack集群中部署对象存储节点之前,需要先为2个额外的存储节点配置网络

Configure networking

object storage node1

1.网卡配置

配置管理网络

  • Configure the management interface:
  • IP address: 10.0.0.51
  • Network mask: 255.255.255.0 (or /24)
  • Default gateway: 10.0.0.2根据实际情况进行配置
cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33.bak
vim /etc/sysconfig/network-scripts/ifcfg-ens33

管理网络配置结果为:

[root@controller ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
#BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
#IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=66e5a322-41bd-462d-bb10-b080ab3b3d44
DEVICE=ens33
ONBOOT=yes

# add follow
BOOTPROTO="static"
IPADDR="10.0.0.51"
NETMASK="255.255.255.0"
GATEWAY="10.0.0.2"
DNS1="1.1.1.1"

2.完成域名与网络地址的映射

[root@controller ~]# cat /etc/networks
default 0.0.0.0
loopback 127.0.0.0
link-local 169.254.0.0
NETWORKING=yes
GATEWAY=10.0.0.2

3.主机名解析配置

vim /etc/hosts
[root@controller ~]# cat /etc/hosts 
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.11 controller
10.0.0.31 compute1
10.0.0.32 compute2
# block1
10.0.0.41       block1
# object1
10.0.0.51       object1
# object2
10.0.0.52       object2

[root@controller ~]#

object storage node2

1.网卡配置

配置管理网络

  • Configure the management interface:
  • IP address: 10.0.0.52
  • Network mask: 255.255.255.0 (or /24)
  • Default gateway: 10.0.0.2根据实际情况进行配置
cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33.bak
vim /etc/sysconfig/network-scripts/ifcfg-ens33

管理网络配置结果为:

[root@controller ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
#BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
#IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=66e5a322-41bd-462d-bb10-b080ab3b3d44
DEVICE=ens33
ONBOOT=yes

# add follow
BOOTPROTO="static"
IPADDR="10.0.0.51"
NETMASK="255.255.255.0"
GATEWAY="10.0.0.2"
DNS1="1.1.1.1"

2.完成域名与网络地址的映射

[root@controller ~]# cat /etc/networks
default 0.0.0.0
loopback 127.0.0.0
link-local 169.254.0.0
NETWORKING=yes
GATEWAY=10.0.0.2

3.主机名解析配置

vim /etc/hosts
[root@controller ~]# cat /etc/hosts 
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.11 controller
10.0.0.31 compute1
10.0.0.32 compute2
# block1
10.0.0.41       block1
# object1
10.0.0.51       object1
# object2
10.0.0.52       object2

[root@controller ~]#

警告

某些发行版在/etc/hosts 文件中添加了一个无关的条目,该条目将实际主机名解析为另一个环回 IP 地址,例如127.0.1.1. 您必须注释掉或删除此条目以防止出现名称解析问题。不要删除 127.0.0.1 条目。

11.2 控制节点安装与配置

Install and configure the controller node

This section describes how to install and configure the proxy service that handles requests for the account, container, and object services operating on the storage nodes.

本节介绍如何安装和配置代理服务来处理对存储节点上运行的帐户、容器和对象服务的请求。为简单起见,本指南在控制器节点上安装和配置代理服务。但是,您可以在与存储节点具有网络连接的任何节点上运行代理服务。此外,您可以在多个节点上安装和配置代理服务以提高性能和冗余。有关详细信息,请参阅 部署指南。本节适用于 Red Hat Enterprise Linux 7 和 CentOS 7。

1.先决条件

环境变量

cd
source admin-openrc.sh

要创建身份服务凭证

  • 创建swift用户
cd
source admin-openrc.sh
openstack user create --domain default --password=111111 swift
openstack user list

or

openstack user create --domain default --password-prompt swift
  • adminswift用户添加角色

下面的命令没有输出。

openstack role add --project service --user swift admin
  • 创建swift服务实体:
openstack service create --name swift \
  --description "OpenStack Object Storage" object-store  openstack service list

创建对象存储服务 API 端点:

openstack endpoint create --region RegionOne \
object-store public http://controller:8080/v1/AUTH_%\(project_id\)s

openstack endpoint create --region RegionOne \
object-store internal http://controller:8080/v1/AUTH_%\(project_id\)s

openstack endpoint create --region RegionOne \
  object-store admin http://controller:8080/v1

2.相关软件安装与配置

默认配置文件因发行版而异。您可能需要添加这些部分和选项,而不是修改现有的部分和选项。此外,...配置片段中的省略号 ( ) 表示您应该保留的潜在默认配置选项。

安装软件包:

yum install openstack-swift-proxy python-swiftclient \
  python-keystoneclient python-keystonemiddleware \
  memcached

修改配置文件

  • 从 Object Storage 源存储库中获取代理服务配置文件:
curl -o /etc/swift/proxy-server.conf https://opendev.org/openstack/swift/raw/branch/master/etc/proxy-server.conf-sample
  • 编辑/etc/swift/proxy-server.conf文件

在该[DEFAULT]部分中,配置绑定端口、用户和配置目录:

[DEFAULT]
...
bind_port = 8080
user = swift
swift_dir = /etc/swift

在该[pipeline:main]部分中,删除tempurltempauth模块并添加authtokenkeystoneauth 模块:

[pipeline:main]
pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk ratelimit authtoken keystoneauth container-quotas account-quotas slo dlo versioned_writes proxy-logging proxy-server

注意:不要更改模块的顺序。有关启用附加功能的其他模块的更多信息,请参阅部署指南

在该[app:proxy-server]部分中,启用自动帐户创建:

[app:proxy-server]
use = egg:swift#proxy
...
account_autocreate = True

[filter:keystoneauth]部分中,配置操作员角色:

[filter:keystoneauth]
use = egg:swift#keystoneauth
...
operator_roles = admin,user

[filter:authtoken]部分,配置身份服务访问:

[filter:authtoken]
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
...
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_id = default
user_domain_id = default
project_name = service
username = swift
password = 111111
delay_auth_decision = True

替换SWIFT_PASS为您swift在身份服务中为用户选择的密码。

注意:注释掉或删除该[filter:authtoken] 部分中的任何其他选项。

在该[filter:cache]部分中,配置memcached位置:

[filter:cache]
use = egg:swift#memcache
...
memcache_servers = controller:11211

11.3 存储节点安装与配置

Install and configure the storage nodes

This section describes how to install and configure storage nodes that operate the account, container, and object services.

Note that installation and configuration vary by distribution.

本节介绍如何安装和配置运行帐户、容器和对象服务的存储节点。为简单起见,此配置引用了两个存储节点,每个节点包含两个空的本地块存储设备。说明使用/dev/sdb/dev/sdc,但您可以为特定节点替换不同的值。

尽管对象存储支持任何具有扩展属性 (xattr) 的文件系统,但测试和基准测试表明 XFS 上的性能和可靠性最好。有关水平扩展环境的更多信息,请参阅 部署指南

本节适用于 Red Hat Enterprise Linux 7 和 CentOS 7。

1.先决条件

在存储节点上安装和配置对象存储服务之前,您必须准备好存储设备。

注意:在每个存储节点上执行这些步骤。

安装支持的实用程序包:

yum install xfsprogs rsync

/dev/sdb/dev/sdc设备格式化为 XFS:

mkfs.xfs /dev/sdb
mkfs.xfs /dev/sdc

创建挂载点目录结构:

mkdir -p /srv/node/sdb
mkdir -p /srv/node/sdc

找到新分区的 UUID:

blkid

编辑/etc/fstab文件并将以下内容添加到其中:

UUID="<UUID-from-output-above>" /srv/node/sdb xfs noatime 0 2
UUID="<UUID-from-output-above>" /srv/node/sdc xfs noatime 0 2

挂载设备:

mount /srv/node/sdb
mount /srv/node/sdc

创建或编辑/etc/rsyncd.conf文件以包含以下内容:

  • 存储节点1
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 10.0.0.51

[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

替换address = MANAGEMENT_INTERFACE_IP_ADDRESS为存储节点上管理网络的IP地址。

  • 存储节点2
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 10.0.0.52

[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服务不需要身份验证,因此请考虑在生产环境中的专用网络上运行它。

启动rsyncd服务并配置它在系统启动时启动:

systemctl enable rsyncd.service
systemctl start rsyncd.service

2.安装和配置组件

默认配置文件因发行版而异。您可能需要添加这些部分和选项,而不是修改现有的部分和选项。此外,...配置片段中的省略号 ( ) 表示您应该保留的潜在默认配置选项。

注意:在每个存储节点上执行这些步骤。

安装软件包:

yum install openstack-swift-account openstack-swift-container openstack-swift-object

从 Object Storage 源存储库中获取记帐、容器和对象服务配置文件:

curl -o /etc/swift/account-server.conf https://opendev.org/openstack/swift/raw/branch/master/etc/account-server.conf-sample
curl -o /etc/swift/container-server.conf https://opendev.org/openstack/swift/raw/branch/master/etc/container-server.conf-sample
curl -o /etc/swift/object-server.conf https://opendev.org/openstack/swift/raw/branch/master/etc/object-server.conf-sample

编辑/etc/swift/account-server.conf文件并完成以下操作:

  • 在该[DEFAULT]部分中,配置绑定IP地址、绑定端口、用户、配置目录和挂载点目录:
[DEFAULT]
...
bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
bind_port = 6202
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = True

替换MANAGEMENT_INTERFACE_IP_ADDRESS为存储节点上管理网络的IP地址。

  • [pipeline:main]部分中,启用相应的模块:
[pipeline:main]
pipeline = healthcheck recon account-server

注意:有关启用附加功能的其他模块的更多信息,请参阅部署指南

  • 在该[filter:recon]部分,配置recon(meters)缓存目录:
[filter:recon]
use = egg:swift#recon
...
recon_cache_path = /var/cache/swift

编辑/etc/swift/container-server.conf文件并完成以下操作:

  • 在该[DEFAULT]部分中,配置绑定IP地址、绑定端口、用户、配置目录和挂载点目录:
[DEFAULT]
...
bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
bind_port = 6201
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = True

替换MANAGEMENT_INTERFACE_IP_ADDRESS为存储节点上管理网络的IP地址。

  • [pipeline:main]部分中,启用相应的模块:
[pipeline:main]
pipeline = healthcheck recon container-server

注意:有关启用附加功能的其他模块的更多信息,请参阅部署指南

  • 在该[filter:recon]部分,配置recon(meters)缓存目录:
[filter:recon]
use = egg:swift#recon
...
recon_cache_path = /var/cache/swift

编辑/etc/swift/object-server.conf文件并完成以下操作:

  • 在该[DEFAULT]部分中,配置绑定IP地址、绑定端口、用户、配置目录和挂载点目录:
[DEFAULT]
...
bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
bind_port = 6200
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = True

替换MANAGEMENT_INTERFACE_IP_ADDRESS为存储节点上管理网络的IP地址。

  • [pipeline:main]部分中,启用相应的模块:
[pipeline:main]
pipeline = healthcheck recon object-server

注意:有关启用附加功能的其他模块的更多信息,请参阅部署指南

  • 在该[filter:recon]部分中,配置 recon (meters) 缓存和锁定目录:
[filter:recon]
use = egg:swift#recon
...
recon_cache_path = /var/cache/swift
recon_lock_path = /var/lock

确保挂载点目录结构的正确所有权:

chown -R swift:swift /srv/node

创建recon目录并确保其拥有正确的所有权:

mkdir -p /var/cache/swift
chown -R root:swift /var/cache/swift
chmod -R 775 /var/cache/swift

在防火墙中启用必要的访问

firewall-cmd --permanent --add-port=6200/tcp
firewall-cmd --permanent --add-port=6201/tcp
firewall-cmd --permanent --add-port=6202/tcp

rsync 服务包括它自己的防火墙配置。从一个节点连接到另一个节点以确保允许访问。

11.4控制节点创建和分发初始化rings

Create and distribute initial rings

在启动对象存储服务之前,您必须创建初始帐户、容器和对象环。环构建器创建每个节点用来确定和部署存储架构的配置文件。为简单起见,本指南使用一个区域和两个分区,最大分区数为 2^10 (1024),每个对象有 3 个副本,并且多次移动分区之间的最短时间为 1 小时。对于对象存储,分区表示存储设备上的目录,而不是传统的分区表。有关详细信息,请参阅 部署指南

在控制器节点上执行这些步骤。

1.创建账号环

账户服务器使用账户环来维护容器列表。

切换到/etc/swift目录。

cd /etc/swift

创建基础account.builder文件:

swift-ring-builder account.builder create 10 3 1

注意:此命令不提供任何输出。

将每个存储节点添加到环中:

swift-ring-builder account.builder \
add --region 1 --zone 1 --ip STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS --port 6202 \
--device DEVICE_NAME --weight DEVICE_WEIGHT

替换STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS为存储节点上管理网络的IP地址。替换DEVICE_NAME为同一存储节点上的存储设备名称。例如使用安装中的第一个存储节点,配置存储节点/dev/sdb存储设备和权重为100:

swift-ring-builder account.builder add \
--region 1 --zone 1 --ip 10.0.0.51 --port 6202 --device sdb --weight 100

对每个存储节点上的每个存储设备重复此命令。在示例架构中,使用四种变体的命令:

# swift-ring-builder account.builder add \
  --region 1 --zone 1 --ip 10.0.0.51 --port 6202 --device sdb --weight 100
Device d0r1z1-10.0.0.51:6202R10.0.0.51:6202/sdb_"" with 100.0 weight got id 0
# swift-ring-builder account.builder add \
  --region 1 --zone 1 --ip 10.0.0.51 --port 6202 --device sdc --weight 100
Device d1r1z2-10.0.0.51:6202R10.0.0.51:6202/sdc_"" with 100.0 weight got id 1
# swift-ring-builder account.builder add \
  --region 1 --zone 2 --ip 10.0.0.52 --port 6202 --device sdb --weight 100
Device d2r1z3-10.0.0.52:6202R10.0.0.52:6202/sdb_"" with 100.0 weight got id 2
# swift-ring-builder account.builder add \
  --region 1 --zone 2 --ip 10.0.0.52 --port 6202 --device sdc --weight 100
Device d3r1z4-10.0.0.52:6202R10.0.0.52:6202/sdc_"" with 100.0 weight got id 3

验证环内容:

# swift-ring-builder account.builder
account.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 4 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1
The overload factor is 0.00% (0.000000)
Devices:    id  region  zone      ip address  port  replication ip  replication port      name weight partitions balance meta
             0       1     1       10.0.0.51  6202       10.0.0.51              6202      sdb  100.00          0 -100.00
             1       1     1       10.0.0.51  6202       10.0.0.51              6202      sdc  100.00          0 -100.00
             2       1     2       10.0.0.52  6202       10.0.0.52              6202      sdb  100.00          0 -100.00
             3       1     2       10.0.0.52  6202       10.0.0.52              6202      sdc  100.00          0 -100.00

重新平衡环:

# swift-ring-builder account.builder rebalance
Reassigned 1024 (100.00%) partitions. Balance is now 0.00.  Dispersion is now 0.00

2.创建容器环

容器服务器使用容器环来维护对象列表。但是,它不跟踪对象位置。

切换到/etc/swift目录。

cd /etc/swift

创建基础container.builder文件:

swift-ring-builder container.builder create 10 3 1

注意:此命令不提供任何输出。

将每个存储节点添加到环中:

# swift-ring-builder container.builder \
  add --region 1 --zone 1 --ip STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS --port 6201 \
  --device DEVICE_NAME --weight DEVICE_WEIGHT

替换STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS为存储节点上管理网络的IP地址。替换DEVICE_NAME为同一存储节点上的存储设备名称。例如使用安装中的第一个存储节点,配置存储节点/dev/sdb 存储设备和权重为100:

# swift-ring-builder container.builder add \
  --region 1 --zone 1 --ip 10.0.0.51 --port 6201 --device sdb --weight 100

每个存储节点上的每个存储设备重复此命令。在示例架构中,使用四种变体的命令:

# swift-ring-builder container.builder add \
  --region 1 --zone 1 --ip 10.0.0.51 --port 6201 --device sdb --weight 100
Device d0r1z1-10.0.0.51:6201R10.0.0.51:6201/sdb_"" with 100.0 weight got id 0
# swift-ring-builder container.builder add \
  --region 1 --zone 1 --ip 10.0.0.51 --port 6201 --device sdc --weight 100
Device d1r1z2-10.0.0.51:6201R10.0.0.51:6201/sdc_"" with 100.0 weight got id 1
# swift-ring-builder container.builder add \
  --region 1 --zone 2 --ip 10.0.0.52 --port 6201 --device sdb --weight 100
Device d2r1z3-10.0.0.52:6201R10.0.0.52:6201/sdb_"" with 100.0 weight got id 2
# swift-ring-builder container.builder add \
  --region 1 --zone 2 --ip 10.0.0.52 --port 6201 --device sdc --weight 100
Device d3r1z4-10.0.0.52:6201R10.0.0.52:6201/sdc_"" with 100.0 weight got id 3

验证环内容:

# swift-ring-builder container.builder
container.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 4 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1
The overload factor is 0.00% (0.000000)
Devices:    id  region  zone      ip address  port  replication ip  replication port      name weight partitions balance meta
             0       1     1       10.0.0.51  6201       10.0.0.51              6201      sdb  100.00          0 -100.00
             1       1     1       10.0.0.51  6201       10.0.0.51              6201      sdc  100.00          0 -100.00
             2       1     2       10.0.0.52  6201       10.0.0.52              6201      sdb  100.00          0 -100.00
             3       1     2       10.0.0.52  6201       10.0.0.52              6201      sdc  100.00          0 -100.00

重新平衡环:

# swift-ring-builder container.builder rebalance
Reassigned 1024 (100.00%) partitions. Balance is now 0.00.  Dispersion is now 0.00

3.创建对象环

对象服务器使用对象环来维护本地设备上的对象位置列表。

切换到/etc/swift目录。

cd /etc/swift

创建基础object.builder文件:

# swift-ring-builder object.builder create 10 3 1

注意:此命令不提供任何输出。

将每个存储节点添加到环中:

# swift-ring-builder object.builder \
  add --region 1 --zone 1 --ip STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS --port 6200 \
  --device DEVICE_NAME --weight DEVICE_WEIGHT

替换STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS为存储节点上管理网络的IP地址。替换DEVICE_NAME为同一存储节点上的存储设备名称。例如使用安装中的第一个存储节点,配置存储节点/dev/sdb存储设备和权重为100:

# swift-ring-builder object.builder add \
  --region 1 --zone 1 --ip 10.0.0.51 --port 6200 --device sdb --weight 100

每个存储节点上的每个存储设备重复此命令。在示例架构中,使用四种变体的命令:

# swift-ring-builder object.builder add \
  --region 1 --zone 1 --ip 10.0.0.51 --port 6200 --device sdb --weight 100
Device d0r1z1-10.0.0.51:6200R10.0.0.51:6200/sdb_"" with 100.0 weight got id 0
# swift-ring-builder object.builder add \
  --region 1 --zone 1 --ip 10.0.0.51 --port 6200 --device sdc --weight 100
Device d1r1z2-10.0.0.51:6200R10.0.0.51:6200/sdc_"" with 100.0 weight got id 1
# swift-ring-builder object.builder add \
  --region 1 --zone 2 --ip 10.0.0.52 --port 6200 --device sdb --weight 100
Device d2r1z3-10.0.0.52:6200R10.0.0.52:6200/sdb_"" with 100.0 weight got id 2
# swift-ring-builder object.builder add \
  --region 1 --zone 2 --ip 10.0.0.52 --port 6200 --device sdc --weight 100
Device d3r1z4-10.0.0.52:6200R10.0.0.52:6200/sdc_"" with 100.0 weight got id 3

验证环内容:

# swift-ring-builder object.builder
object.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 4 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1
The overload factor is 0.00% (0.000000)
Devices:    id  region  zone      ip address  port  replication ip  replication port      name weight partitions balance meta
             0       1     1       10.0.0.51  6200       10.0.0.51              6200      sdb  100.00          0 -100.00
             1       1     1       10.0.0.51  6200       10.0.0.51              6200      sdc  100.00          0 -100.00
             2       1     2       10.0.0.52  6200       10.0.0.52              6200      sdb  100.00          0 -100.00
             3       1     2       10.0.0.52  6200       10.0.0.52              6200      sdc  100.00          0 -100.00

重新平衡环:

# swift-ring-builder object.builder rebalance
Reassigned 1024 (100.00%) partitions. Balance is now 0.00.  Dispersion is now 0.00

4.分发环配置文件

  • 副本account.ring.gzcontainer.ring.gz以及 object.ring.gz文件复制到/etc/swift每个存储节点和运行代理服务的任何其他节点上目录。

11.5完成安装Finalize installation

Finalize installation for Red Hat Enterprise Linux and CentOS

注意:默认配置文件因发行版而异。您可能需要添加这些部分和选项,而不是修改现有的部分和选项。此外,...配置片段中的省略号 ( ) 表示您应该保留的潜在默认配置选项。

本节适用于 Red Hat Enterprise Linux 7 和 CentOS 7。

/etc/swift/swift.conf从 Object Storage 源存储库获取文件:

# curl -o /etc/swift/swift.conf \
  https://opendev.org/openstack/swift/raw/branch/master/etc/swift.conf-sample

编辑/etc/swift/swift.conf文件并完成以下操作:

  • [swift-hash]部分中,为您的环境配置哈希路径前缀和后缀。
[swift-hash]
...
swift_hash_path_suffix = HASH_PATH_SUFFIX
swift_hash_path_prefix = HASH_PATH_PREFIX

用唯一值替换 HASH_PATH_PREFIX 和 HASH_PATH_SUFFIX。

警告:将这些价值观保密,不要更改或丢失它们。

  • 在该[storage-policy:0]部分中,配置默认存储策略:
[storage-policy:0]
...
name = Policy-0
default = yes

swift.conf文件复制到/etc/swift每个存储节点和运行代理服务的任何其他节点上的目录。

在所有节点上,确保配置目录的正确所有权:

# chown -R root:swift /etc/swift

在控制器节点和运行代理服务的任何其他节点上,启动对象存储代理服务及其依赖项,并将它们配置为在系统启动时启动:

# systemctl enable openstack-swift-proxy.service memcached.service
# systemctl start openstack-swift-proxy.service memcached.service

在存储节点上,启动对象存储服务并将它们配置为在系统启动时启动:

# systemctl enable openstack-swift-account.service openstack-swift-account-auditor.service \
  openstack-swift-account-reaper.service openstack-swift-account-replicator.service
# systemctl start openstack-swift-account.service openstack-swift-account-auditor.service \
  openstack-swift-account-reaper.service openstack-swift-account-replicator.service
# systemctl enable openstack-swift-container.service \
  openstack-swift-container-auditor.service openstack-swift-container-replicator.service \
  openstack-swift-container-updater.service
# systemctl start openstack-swift-container.service \
  openstack-swift-container-auditor.service openstack-swift-container-replicator.service \
  openstack-swift-container-updater.service
# systemctl enable openstack-swift-object.service openstack-swift-object-auditor.service \
  openstack-swift-object-replicator.service openstack-swift-object-updater.service
# systemctl start openstack-swift-object.service openstack-swift-object-auditor.service \
  openstack-swift-object-replicator.service openstack-swift-object-updater.service

11.6验证安装Verify operation

Verify operation

验证对象存储服务的操作。

注意:在控制器节点上执行这些步骤。

注意:如果您使用的是 Red Hat Enterprise Linux 7 或 CentOS 7 并且这些步骤中的一个或多个不起作用,请检查/var/log/audit/audit.log文件中是否有 SELinux 消息表明拒绝对这些swift进程执行操作。如果存在,将/srv/node目录的安全上下文更改为swift_data_t类型、object_r 角色和system_u用户的最低安全级别 (s0) :

# chcon -R system_u:object_r:swift_data_t:s0 /srv/node

获取demo凭据:

$ . demo-openrc

显示服务状态:

$ swift stat
                        Account: AUTH_ed0b60bf607743088218b0a533d5943f
                     Containers: 0
                        Objects: 0
                          Bytes: 0
    X-Account-Project-Domain-Id: default
                    X-Timestamp: 1444143887.71539
                     X-Trans-Id: tx1396aeaf17254e94beb34-0056143bde
         X-Openstack-Request-Id: tx1396aeaf17254e94beb34-0056143bde
                   Content-Type: text/plain; charset=utf-8
                  Accept-Ranges: bytes

创建container1容器:

$ openstack container create container1
+---------------------------------------+------------+------------------------------------+
| account                               | container  | x-trans-id                         |
+---------------------------------------+------------+------------------------------------+
| AUTH_ed0b60bf607743088218b0a533d5943f | container1 | tx8c4034dc306c44dd8cd68-0056f00a4a |
+---------------------------------------+------------+------------------------------------+

将测试文件上传到container1容器:

$ openstack object create container1 FILE
+--------+------------+----------------------------------+
| object | container  | etag                             |
+--------+------------+----------------------------------+
| FILE   | container1 | ee1eca47dc88f4879d8a229cc70a07c6 |
+--------+------------+----------------------------------+

替换FILE为要上传到container1容器的本地文件的名称 。

列出container1容器中的文件:

$ openstack object list container1
+------+
| Name |
+------+
| FILE |
+------+

container1容器下载测试文件:

$ openstack object save container1 FILE

替换FILE为上传到container1容器的文件名 。

注意:此命令不提供任何输出。

您的 OpenStack 环境现在包括对象存储。