Swift分片存储

在搭建OpenStack安装完成swift服务下进行的
一、查看Swift的状态

使用命令之前要生效一下环境变量
[root@controller ~]# source /etc/keystone/admin-openrc.sh 
查看状态
[root@controller ~]# swift stat
        Account: AUTH_f9d44679d8da4276b113fe99fe3b26c6
     Containers: 0
        Objects: 0
          Bytes: 0
X-Put-Timestamp: 1626366859.74591
    X-Timestamp: 1626366859.74591
     X-Trans-Id: txac55d12295584e56b1f35-0060f0638b
   Content-Type: text/plain; charset=utf-8
[root@controller ~]# source /etc/xiandian/openrc.sh 
[root@controller ~]# swift stat
        Account: AUTH_f9d44679d8da4276b113fe99fe3b26c6
     Containers: 0
        Objects: 0
          Bytes: 0
X-Put-Timestamp: 1626366908.94273
    X-Timestamp: 1626366908.94273
     X-Trans-Id: tx9a0dbd72eb8c47e685ecb-0060f063bc
   Content-Type: text/plain; charset=utf-8

进入/etc/swift目录,使用命令查看

[root@controller ~]# cd /etc/swift
[root@controller swift]# swift-ring-builder object.builder
object.builder, build version 2
1024 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file object.ring.gz is up-to-date
Devices:    id  region  zone      ip address  port  replication ip  replication port      name weight partitions balance flags meta
             0       1     1    10.30.59.217  6000    10.30.59.217              6000      sda5 100.00       1024    0.00  

在这里可以看到Swift的存储区域是10.30.59.217 就是我们搭建OpenStack的计算节点,使用的使用的盘符是sda5 大小为100G

二、创建一个容器
创建容器并查看容器的状态

[root@controller swift]# swift post test
[root@controller swift]# swift stat test 
         Account: AUTH_f9d44679d8da4276b113fe99fe3b26c6
       Container: test
         Objects: 0
           Bytes: 0
        Read ACL:
       Write ACL:
         Sync To:
        Sync Key:
   Accept-Ranges: bytes
X-Storage-Policy: Policy-0
     X-Timestamp: 1626367245.91528
      X-Trans-Id: tx3e3bb647eef04749b82b9-0060f06521
    Content-Type: text/plain; charset=utf-8

三、上传镜像并分片存储
使用终端连接工具上传一个小镜像

[root@controller ~]# ls
anaconda-ks.cfg             CentOS-7-x86_64-DVD-1511.iso  XianDian-IaaS-v2.2.iso
CentOS_7.2_x86_64_XD.qcow2  cirros-0.3.4-x86_64-disk.img

上传镜像到容器并进行分片

[root@controller ~]# swift upload test -S 10000000 cirros-0.3.4-x86_64-disk.img 
cirros-0.3.4-x86_64-disk.img segment 0
cirros-0.3.4-x86_64-disk.img segment 1
cirros-0.3.4-x86_64-disk.img

查看刚刚上传的镜像的存储路径

[root@controller ~]# swift stat test cirros-0.3.4-x86_64-disk.img 
       Account: AUTH_f9d44679d8da4276b113fe99fe3b26c6
     Container: test
        Object: cirros-0.3.4-x86_64-disk.img
  Content Type: application/octet-stream
Content Length: 13287936
 Last Modified: Thu, 15 Jul 2021 17:13:54 GMT
          ETag: "cca17a689bfcd70118fabc833af0d033"
      Manifest: test_segments/cirros-0.3.4-x86_64-disk.img/1605862680.000000/13287936/10000000/
    Meta Mtime: 1605862680.000000
 Accept-Ranges: bytes
   X-Timestamp: 1626369233.33628
    X-Trans-Id: tx86e10ec38fa243a49b865-0060f06cfd

查看存储路径中的数据片

[root@controller ~]# swift list test_segments
cirros-0.3.4-x86_64-disk.img/1605862680.000000/13287936/10000000/00000000
cirros-0.3.4-x86_64-disk.img/1605862680.000000/13287936/10000000/00000001

cirros镜像在上传至swfit对象存储中被分片存储了,单个存储片的大小为10M,因为该镜像大小为13M左右,所有分成了两个存储片。
在这里插入图片描述

你可能感兴趣的:(笔记)