OpenStack安装(五)-Swift模块

一、安装和配置对象存储服务Swift

在控制节点完成

1. 创建Swift的身份认证证书

  1. 加载admin客户端脚本:source admin-openrc.sh
  2. 创建swift用户:openstack user create --password-prompt swift
  3. 将admin角色添加给swift用户:openstack role add --project service --user swift admin

2. 创建Swift的服务实体

  1. 创建swift的服务实体:
    openstack service create --name swift --description "OpenStack Object Storage" object-store

3. 创建Swift的API端点

  1. 创建swift的API endpoint:
    openstack endpoint create --publicurl 'http://controller:8080/v1/AUTH_%(tenant_id)s' --internalurl 'http://controller:8080/v1/AUTH_%(tenant_id)s' --adminurl 'http://controller:8080' --region RegionOne object-store

二、在控制节点上安装和配置Swift

1. 安装Swift

  1. 安装Swift:
    apt-get install swift swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcached

2. 配置Swift

  1. 创建/etc/swift目录:mkdir /etc/swift
  2. 进入该目录:cd /etc/swift
  3. 从对象存储服务源库获取代理服务配置文件:
    curl -o /etc/swift/proxy-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/proxy-server.conf-sample?h=stable/kilo
  4. 编辑文件:/etc/swift/proxy-server.conf
  5. 修改[DEFAULT]部分,配置绑定端口,用户和配置文件存放的路径:
    bind_port = 8080
    user = swift
    swift_dir = /etc/swift
    
  6. 在[pipeline:main]部分,启用相应的模块:
    pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk ratelimit authtoken keystoneauth container-quotas account-quotas slo dlo proxy-logging proxy-server
    
  7. 在[app:proxy-server]部分,启用账户自动创建的功能:
    account_autocreate = true
    
  8. 在[filter:keystoneauth]部分,配置操作的角色
    use = egg:swift#keystoneauth
    operator_roles = admin,user
    
  9. 在[filter:authtoken]部分,配置身份认证服务的访问,注意要注释掉其他的内容:
    paste.filter_factory = keystonemiddleware.auth_token:filter_factory
    auth_uri = http://controller:5000
    auth_url = http://controller:35357
    auth_plugin = password
    project_domain_id = default
    user_domain_id = default
    project_name = service
    username = swift
    password = SWIFT_PASS
    delay_auth_decision = true
    
  10. 在[filter:cache]部分,配置memcached位置:
    memcache_servers = 127.0.0.1:11211
    

三、在对象存储节点上安装和配置Swift

1. 配置对象存储的操作系统环境

  1. 配置管理接口:待补充...........................................

  2. 配置主机名:待补充...........................................

  3. 将两台主机的/etc/hosts内容同步到其他所有节点:

  4. 为两台主机分别添加新的磁盘,并创建分区:fdisk /dev/sdb fdisk /dev/sdc

  5. 在两个节点上分别安装工具包:apt-get install xfsprogs rsync

  6. 格式化/dev/sdb1和/dev/sdc1位XFS:mkfs.xfs /dev/sdb1 mkfs.xfs /dev/sdc1

  7. 创建目录挂载点:mkdir -p /srv/node/sdb1 mkdir -p /srv/node/sdc1

  8. 编辑/etc/fstab,添加这两个内容:
    /dev/sdb1 /srv/node/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
    /dev/sdc1 /srv/node/sdc1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 2

  9. 挂载设备:mount /srv/node/sdb1 mount /srv/node/sdc1

  10. 编辑/etc/rsyncd.conf,添加如下内容:

    uid = swift
    gid = swift
    log file = /var/log/rsyncd.log
    pid file = /var/run/rsyncd.pid
    address = MANAGEMENT_INTERFACE_IP_ADDRESS
    
    [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
    
  11. 编辑/etc/default/rsync文件,,添加下面内容,启用rsync服务:

    RSYNC_ENABLE=true
    
  12. 启动rsync服务:service rsync start

2. 安装Swift(在两个对象存储节点上安装)

  1. 安装Swift:apt-get install swift swift-account swift-container swift-object

3. 获取Swift的配置文件

  1. 获取accounting, container, object, container-reconciler和object-expirer service服务的配置文件
    curl -o /etc/swift/account-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/kilo
    curl -o /etc/swift/container-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=stable/kilo
    curl -o /etc/swift/object-expirer.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-expirer.conf-sample?h=stable/kilo
    curl -o /etc/swift/object-expirer.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-expirer.conf-sample?h=stable/kilo
    curl -o /etc/swift/object-expirer.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-expirer.conf-sample?h=stable/kilo

  2. 编辑配置文件/etc/swift/account-server.conf:
    在[DEFAULT]部分,配置绑定ip地址,端口,用户,配置文件路径,和挂载点的路径:

    bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
    bind_port = 6002
    user = swift
    swift_dir = /etc/swift
    devices = /srv/node
    

    在[pipeline:main]部分,启用appropriate模块:

    pipeline = healthcheck recon account-server
    

    在[filter:recon]部分,配置缓存目录:

    recon_cache_path = /var/cache/swift
    
  3. 编辑配置文件/etc/swift/container-server.conf:
    在[DEFAULT]部分,配置绑定ip地址,端口,用户,配置文件路径,和挂载点的路径:

    bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
    bind_port = 6001
    user = swift
    swift_dir = /etc/swift
    devices = /srv/node
    

    在[pipeline:main]部分,启用appropriate模块:

    pipeline = healthcheck recon container-server
    

    在[filter:recon]部分,配置缓存目录:

    recon_cache_path = /var/cache/swift
    
  4. 编辑配置文件/etc/swift/object-server.conf:
    在[DEFAULT]部分,配置绑定ip地址,端口,用户,配置文件路径,和挂载点的路径:

    bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
    bind_port = 6001
    user = swift
    swift_dir = /etc/swift
    devices = /srv/node
    

    在[pipeline:main]部分,启用appropriate模块:

    pipeline = healthcheck recon object-server
    

    在[filter:recon]部分,配置缓存目录和lock目录:

    recon_cache_path = /var/cache/swift
    recon_lock_path = /var/lock
    
  5. 修改挂载点的权限:chown -R swift:swift /srv/node

  6. 创建recon目录,并修改目录权限:mkdir -p /var/cache/swift chown -R swift:swift /var/cache/swift

四、创建初始的rings

1. 创建Account ring(在控制节点上)

  1. 进入/etc/swift目录:cd /etc/swift
  2. 创建基本的account.builder文件:swift-ring-builder account.builder create 10 3 1
  3. 添加所有的存储节点到ring中:
    swift-ring-builder account.builder add r1z1-10.0.0.51:6002/sdb1 100
    swift-ring-builder account.builder add r1z2-10.0.0.51:6002/sdc1 100
    swift-ring-builder account.builder add r1z3-10.0.0.52:6002/sdb1 100
    swift-ring-builder account.builder add r1z4-10.0.0.52:6002/sdc1 100

2. 校验Account ring

  1. 校验Account ring的内容:swift-ring-builder account.builder
  2. 重新分布ring:swift-ring-builder account.builder rebalance

3. 创建Container ring(在控制节点上)

  1. 进入/etc/swift目录:cd /etc/swift
  2. 创建基本的container.builder文件:swift-ring-builder container.builder create 10 3 1
  3. 添加所有的存储节点到ring中:
    swift-ring-builder container.builder add r1z1-10.0.0.51:6001/sdb1 100
    swift-ring-builder container.builder add r1z2-10.0.0.51:6001/sdc1 100
    swift-ring-builder container.builder add r1z3-10.0.0.52:6001/sdb1 100
    swift-ring-builder container.builder add r1z4-10.0.0.52:6001/sdc1 100

4. 校验Container ring

  1. 校验Container ring的内容:swift-ring-builder container.builder
  2. 重新分布ring:swift-ring-builder container.builder rebalance

5. 创建Object ring(在控制节点上)

  1. 进入/etc/swift目录:cd /etc/swift
  2. 创建基本的object.builder文件:swift-ring-builder object.builder create 10 3 1
  3. 添加所有的存储节点到ring中:
    swift-ring-builder object.builder add r1z1-10.0.0.51:6000/sdb1 100
    swift-ring-builder object.builder add r1z2-10.0.0.51:6000/sdc1 100
    swift-ring-builder object.builder add r1z3-10.0.0.52:6000/sdb1 100
    swift-ring-builder object.builder add r1z4-10.0.0.52:6000/sdc1 100

6. 校验Object ring

  1. 校验Object ring的内容:swift-ring-builder object.builder
  2. 重新分布ring:swift-ring-builder object.builder rebalance

7. 分发配置文件

如果有其他的对象存储节点,请将account.ring.gz, container.ring.gz和object.ring.gz三个文件拷贝到其他节点的/etc/swift目录

8. 完成安装

  1. 从对象存储资源库中获取/etc/swift/swift.conf文件:
    curl -o /etc/swift/swift.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample?h=stable/kilo

  2. 编辑/etc/swift/swift.conf文件:
    在[swift-hash]部分,为环境配置哈希路径的前缀和后缀:

    swift_hash_path_suffix = HASH_PATH_PREFIX(改成唯一值)
    swift_hash_path_prefix = HASH_PATH_SUFFIX(改成唯一值)
    

    在[storage-policy:0] 部分,配置默认存储策略:

    name = Policy-0
    default = yes
    
  3. 复制文件swift.conf到每个存储节点响应的/etc/swift目录下:

    scp swift.conf  [email protected]:~/
    scp swift.conf  [email protected]:~/
    
    sudo cp swift.conf /etc/swift
    
  4. 在所有的存储节点上,设置目录的权限:chown -R swift:swift /etc/swift

  5. 在控制节点和其他存储节点上重启服务:service memcached restart service swift-proxy restart

  6. 在所有的存储节点上重启服务:swift-init all start

五、校验Swift的安装(在控制节点上)

  1. 检查对象存储服务启动的服务组件:swift -V 3 stat
  2. 上传一个测试文件:swift -V 3 upload demo-container1 FILE
  3. 查看容器:swift -V 3 list
  4. 下载测试文件:swift -V 3 download demo-container1 FILE

你可能感兴趣的:(OpenStack安装(五)-Swift模块)