OpenStack组件的基本使用
- Keystone
- 命令行的方式
- 项目
- 用户
- 角色
- 图形化界面方式
- 项目
- 用户
- 角色
- Glance
- 命令行操作
- 镜像上传下载
- 管理镜像
- 开放镜像权限
- 转换镜像格式
- 图形化界面
- Nova和Neutron
- 命令行的方式
- 实例类型
- 密钥对
- 安全组
- 创建网络
- 创建云主机
- 启动关闭云主机
- 图形化界面
- 创建实例类型
- 创建网络
- 创建密钥对
- 添加安全组规则
- 创建云主机
- Cinder
- 命令行操作
- 创建块存储
- 挂载块存储
- 扩展块存储
- 删除块存储
- Swift
- 命令行操作
- 创建容器
- 创建对象
- 下载对象
- 删除对象
- 删除容器
- 分片存储案例
Keystone
用户(user)可以同时属于一个或多个项目,角色(role)定义了用户可以执行的操作类型。
openstack项目中的各个服务组件可以执行的操作可以在/etc/xxxxx/policy.json 文件中进行定义。例如,Nova计算服务组件可执行操作列表在 /etc/nova/policy.json文件中定义。keystone服务则在/etc/keystone/policy.json中定义
在进行删除用户操作时,首先将用户和项目的映射删除。
命令行的方式
项目
(1)展示列表中所有的项目
[root@controller ~]# openstack project list
+----------------------------------+-----------+
| ID | Name |
+----------------------------------+-----------+
| 0769b940829c4078a4aa573e83d6520c | admin |
| 60882db373c2495eb7498a06b9443360 | service |
| 98b082ffdddb4361ab983ea3cfcd6094 | demo |
| a14ec47b15344fbd8247e933d973efcc | myproject |
+----------------------------------+-----------+
(2)创建项目
[root@controller ~]# openstack project create --description 'default project' csq1
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | default project |
| domain_id | default |
| enabled | True |
| id | 378813957fca4a25a74d856bab219e48 |
| is_domain | False |
| name | csq1 |
| options | {} |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
(3)更新项目
①禁用租户
禁用刚刚创建的csq1项目
[root@controller ~]# openstack project set 378813957fca4a25a74d856bab219e48 --disable
②启用被禁用的项目
[root@controller ~]# openstack project set 378813957fca4a25a74d856bab219e48 --enable
③更改项目名称
[root@controller ~]# openstack project set 378813957fca4a25a74d856bab219e48 --name zhw1
[root@controller ~]# openstack project list |grep zhw1 |cut -d '|' -f 3
zhw1
④确认已修改信息
[root@controller ~]# openstack project show 378813957fca4a25a74d856bab219e48
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | default project |
| domain_id | default |
| enabled | True |
| id | 378813957fca4a25a74d856bab219e48 |
| is_domain | False |
| name | zhw1 |
| options | {} |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
(4)删除项目
[root@controller ~]# openstack project delete zhw1
用户
(5)展示列表中的所有用户
[root@controller ~]# openstack user list
+----------------------------------+-------------------+
| ID | Name |
+----------------------------------+-------------------+
| fef5f8c16d3d4b9d849bc1488bf50a21 | admin |
| 5bf6341f28174502abc213ce093d4376 | myuser |
| 28863c4ea60b43a6aa07b4388bf5417b | glance |
| dd0b68b6602a4c2d808d9e876574d12a | placement |
| 003a122553b44827968d8b0f07c91434 | nova |
| 65a61b0b295b428f934b809e73a36cd0 | neutron |
| 604f6fa1e4714c348f7d90f134065757 | cinder |
| d29d82ce57524c9c88c61a60da3d6cae | swift |
| acd845361d32470f888ec98a33bcd176 | heat |
| ddacc6ca064a462690f84a439bfcc06a | heat_domain_admin |
| 941d4f91bf144a358c46bd338eb53ef7 | demo |
| 2d6b2600158e430e8fdaaaab332e6203 | manila |
| 7d982c41976147c6a0b0d8339c408acd | barbican |
| 6372f45b6f074a2490de88dcf3d5f5e0 | cloudkitty |
+----------------------------------+-------------------+
(6)创建用户
在创建用户时,必须指定用户名称。可选项包括租户ID和密码,建议在创建用户时指定可选信息,否则用户无法通过dashboard登录
[root@controller ~]# openstack user create --domain default --password-prompt csq1
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | c4157e5599114d05a0f8460deafd39e1 |
| name | csq1 |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
# 当然你也可以选择 --password <密码> 这种方式
(7)更新用户
①禁用用户
[root@controller ~]# openstack user set c4157e5599114d05a0f8460deafd39e1 --disable
②启用被禁用的用户
[root@controller ~]# openstack user set c4157e5599114d05a0f8460deafd39e1 --enable
③更新用户名称
[root@controller ~]# openstack user set c4157e5599114d05a0f8460deafd39e1 --name zhw1
[root@controller ~]# openstack user list |grep zhw |cut -d "|" -f 3
zhw1
(8)删除用户
[root@controller ~]# openstack user delete zhw1
角色
(9)展示列表中的所有角色
[root@controller ~]# openstack role list
+----------------------------------+------------------+
| ID | Name |
+----------------------------------+------------------+
| 11904104fea14c029d7db85a25ccc8c0 | heat_stack_user |
| 1550dde96f9944eab4d872376a2becae | heat_stack_owner |
| 4255cb58a4eb459e843c408bbd92dee8 | myrole |
| 70c96642c6d74c4ab8847f6b2bd7cb1b | creator |
| 7d1e5d969f7e427ca70ffc4decb0b393 | admin |
| 8487e7321922440793dc4c262f575081 | member |
| b41d4562a3bf43138cbf1d575cfda382 | reader |
+----------------------------------+------------------+
(10)创建角色
[root@controller ~]# openstack role create csq1
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | None |
| domain_id | None |
| id | 1f83b2300bec43029ec9b1270e2da164 |
| name | csq1 |
| options | {} |
+-------------+----------------------------------+
(11)分配角色
①列出所有项目和用户并挑选所需赋予角色的用户
[root@controller ~]# openstack project list
+----------------------------------+-----------+
| ID | Name |
+----------------------------------+-----------+
| 0769b940829c4078a4aa573e83d6520c | admin |
| 60882db373c2495eb7498a06b9443360 | service |
| 98b082ffdddb4361ab983ea3cfcd6094 | demo |
| a14ec47b15344fbd8247e933d973efcc | myproject |
+----------------------------------+-----------+
[root@controller ~]# openstack user list
+----------------------------------+-------------------+
| ID | Name |
+----------------------------------+-------------------+
| fef5f8c16d3d4b9d849bc1488bf50a21 | admin |
| 5bf6341f28174502abc213ce093d4376 | myuser |
| 28863c4ea60b43a6aa07b4388bf5417b | glance |
| dd0b68b6602a4c2d808d9e876574d12a | placement |
| 003a122553b44827968d8b0f07c91434 | nova |
| 65a61b0b295b428f934b809e73a36cd0 | neutron |
| 604f6fa1e4714c348f7d90f134065757 | cinder |
| d29d82ce57524c9c88c61a60da3d6cae | swift |
| acd845361d32470f888ec98a33bcd176 | heat |
| ddacc6ca064a462690f84a439bfcc06a | heat_domain_admin |
| 941d4f91bf144a358c46bd338eb53ef7 | demo |
| 2d6b2600158e430e8fdaaaab332e6203 | manila |
| 7d982c41976147c6a0b0d8339c408acd | barbican |
| 6372f45b6f074a2490de88dcf3d5f5e0 | cloudkitty |
+----------------------------------+-------------------+
②列出所有角色并挑选所需使用的角色
[root@controller ~]# openstack role list
+----------------------------------+------------------+
| ID | Name |
+----------------------------------+------------------+
| 11904104fea14c029d7db85a25ccc8c0 | heat_stack_user |
| 1550dde96f9944eab4d872376a2becae | heat_stack_owner |
| 1f83b2300bec43029ec9b1270e2da164 | csq1 |
| 4255cb58a4eb459e843c408bbd92dee8 | myrole |
| 70c96642c6d74c4ab8847f6b2bd7cb1b | creator |
| 7d1e5d969f7e427ca70ffc4decb0b393 | admin |
| 8487e7321922440793dc4c262f575081 | member |
| b41d4562a3bf43138cbf1d575cfda382 | reader |
+----------------------------------+------------------+
③将角色赋予用户和项目
[root@controller ~]# openstack role add --user admin --project admin csq1
(12)移除赋予角色的用户和项目
[root@controller ~]# openstack role remove --user admin --project admin csq1
(13)删除角色
[root@controller ~]# openstack role delete csq1
图形化界面方式
项目
首先登录OpenStack Web界面
(1)创建项目
(2)管理成员
当你想要修改项目成员或者项目组以及项目名称等等信息,可以在里面设置
(3)删除项目
用户
(1)创建用户
(2)更改用户信息
点编辑即可 更改用户信息
如果想修改密码可点旁边的倒三角
角色
角色是拥有权限的集合,定义用户可以执行的一系列操作
(1)创建角色
(2)编辑角色
①
②
③
(3)删除角色
Glance
命令行操作
在镜像管理之前你需要先准备一个镜像文件
镜像上传下载
上传镜像
上传镜像镜像名字为 cirros
[root@controller ~]# openstack image create --disk-format qcow2 --container-format bare --file image/cirros-0.3.4-x86_64-disk.img cirros
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2023-07-03T05:05:18Z |
| disk_format | qcow2 |
| file | /v2/images/23ba495a-ee86-4570-a7bb-4c1eac9c742b/file |
| id | 23ba495a-ee86-4570-a7bb-4c1eac9c742b |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 0769b940829c4078a4aa573e83d6520c |
| properties | os_hash_algo='sha512', os_hash_value='1b03ca1bc3fafe448b90583c12f367949f8b0e665685979d95b004e48574b953316799e23240f4f739d1b5eb4c4ca24d38fdc6f4f9d8247a2bc64db25d6bbdb2', os_hidden='False' |
| protected | False |
| schema | /v2/schemas/image |
| size | 13287936 |
| status | active |
| tags | |
| updated_at | 2023-07-03T05:05:19Z |
| virtual_size | None |
| visibility | shared |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
–disk-format:镜像格式
–container-format:镜像在其他项目中可见性
–file:选择本地镜像文件
镜像下载
–file 指定下载到哪个目录什么文件名
[root@controller ~]# openstack image save --file /opt/my-image.qcow2 cirros
[root@controller ~]# ls /opt/
my-image.qcow2
管理镜像
(1)查看镜像
[root@controller ~]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 23ba495a-ee86-4570-a7bb-4c1eac9c742b | cirros | active |
+--------------------------------------+--------+--------+
(2)查看镜像详细信息
[root@controller ~]# openstack image show 23ba495a-ee86-4570-a7bb-4c1eac9c742b
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2023-07-03T05:05:18Z |
| disk_format | qcow2 |
| file | /v2/images/23ba495a-ee86-4570-a7bb-4c1eac9c742b/file |
| id | 23ba495a-ee86-4570-a7bb-4c1eac9c742b |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 0769b940829c4078a4aa573e83d6520c |
| properties | os_hash_algo='sha512', os_hash_value='1b03ca1bc3fafe448b90583c12f367949f8b0e665685979d95b004e48574b953316799e23240f4f739d1b5eb4c4ca24d38fdc6f4f9d8247a2bc64db25d6bbdb2', os_hidden='False' |
| protected | False |
| schema | /v2/schemas/image |
| size | 13287936 |
| status | active |
| tags | |
| updated_at | 2023-07-03T05:05:19Z |
| virtual_size | None |
| visibility | shared |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
(3)修改镜像
参数说明:
–min-disk:镜像启动最小硬盘大小
–name:镜像名称
–disk-format:镜像格式。
–min-ram:镜像启动最小内存大小
–container-format:镜像在项目中可见性
[root@controller ~]# openstack image set --min-disk 10 --min-ram 1024 cirros
(4)删除镜像
[root@controller ~]# openstack image delete cirros
[root@controller ~]# openstack image list
开放镜像权限
[root@controller ~]# openstack project create --domain default csqA
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | |
| domain_id | default |
| enabled | True |
| id | 34585d2439934ebd8b1b9c2e6110667e |
| is_domain | False |
| name | csqA |
| options | {} |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
[root@controller ~]# openstack project create --domain default csqB
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | |
| domain_id | default |
| enabled | True |
| id | faa83f0d3d0c42a19773c05fe2043adf |
| is_domain | False |
| name | csqB |
| options | {} |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
[root@controller ~]# openstack user create --domain default --password 000000 csq-userA
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | de01f40d307d41fe9a828a9694fb6c79 |
| name | csq-userA |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[root@controller ~]# openstack user create --domain default --password 000000 csq-userB
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 4c5478b9d7d84dd3879d410acc833f57 |
| name | csq-userB |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[root@controller ~]# openstack role add --project csqA --user csq-userA user
[root@controller ~]# openstack role add --project csqB --user csq-userB user
[root@controller ~]# openstack image create --disk-format qcow2 --container-format bare --file image/cirros-0.3.4-x86_64-disk.img cirros1
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2023-07-03T13:24:22Z |
| disk_format | qcow2 |
| file | /v2/images/b272c8ef-14b8-4d64-9449-84b2f5313cdd/file |
| id | b272c8ef-14b8-4d64-9449-84b2f5313cdd |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros1 |
| owner | 0769b940829c4078a4aa573e83d6520c |
| properties | os_hash_algo='sha512', os_hash_value='1b03ca1bc3fafe448b90583c12f367949f8b0e665685979d95b004e48574b953316799e23240f4f739d1b5eb4c4ca24d38fdc6f4f9d8247a2bc64db25d6bbdb2', os_hidden='False' |
| protected | False |
| schema | /v2/schemas/image |
| size | 13287936 |
| status | active |
| tags | |
| updated_at | 2023-07-03T13:24:23Z |
| virtual_size | None |
| visibility | shared |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@controller ~]# glance member-create b272c8ef-14b8-4d64-9449-84b2f5313cdd 34585d2439934ebd8b1b9c2e6110667e
+--------------------------------------+----------------------------------+---------+
| Image ID | Member ID | Status |
+--------------------------------------+----------------------------------+---------+
| b272c8ef-14b8-4d64-9449-84b2f5313cdd | 34585d2439934ebd8b1b9c2e6110667e | pending |
+--------------------------------------+----------------------------------+---------+
[root@controller ~]# glance member-update b272c8ef-14b8-4d64-9449-84b2f5313cdd 34585d2439934ebd8b1b9c2e6110667e accepted
+--------------------------------------+----------------------------------+----------+
| Image ID | Member ID | Status |
+--------------------------------------+----------------------------------+----------+
| b272c8ef-14b8-4d64-9449-84b2f5313cdd | 34585d2439934ebd8b1b9c2e6110667e | accepted |
+--------------------------------------+----------------------------------+----------+
# 测试 切换到 csqB用户后查看镜像
[root@controller ~]# export OS_PROJECT_NAME=csqB
[root@controller ~]# export OS_USERNAME=csq-userB
[root@controller ~]# export OS_PASSWORD=000000
[root@controller ~]# glance image list
+----+------+
| ID | Name |
+----+------+
+----+------+
# 测试切换到 csqA用户后查看信息
[root@controller ~]# export OS_PROJECT_NAME=csqA
[root@controller ~]# export OS_USERNAME=csq-userA
[root@controller ~]# export OS_PASSWORD=000000
[root@controller ~]# glance image-list
+--------------------------------------+---------+
| ID | Name |
+--------------------------------------+---------+
| b272c8ef-14b8-4d64-9449-84b2f5313cdd | cirros1 |
+--------------------------------------+---------+
转换镜像格式
# 首先准备一个镜像
[root@controller ~]# ls
bionic-server-cloudimg-amd64.vmdk
# 查看镜像文件信息
[root@controller ~]# qemu-img info bionic-server-cloudimg-amd64.vmdk
image: bionic-server-cloudimg-amd64.vmdk
file format: vmdk
virtual size: 10G (10737418240 bytes)
disk size: 370M
cluster_size: 65536
Format specific information:
cid: 2119925927
parent cid: 4294967295
create type: streamOptimized
extents:
[0]:
compressed: true
virtual size: 10737418240
filename: bionic-server-cloudimg-amd64.vmdk
cluster size: 65536
format:
执行以下命令将镜像从vmdk转化为qcow2
[root@controller ~]# qemu-img convert -f vmdk -O qcow2 -c -p bionic-server-cloudimg-amd64.vmdk bionic-server-cloudimg-amd64.qcow2
- -f 指定输入磁盘的镜像格式
- -O 指定输出格式
- -c 目标只能被压缩成QCOW2格式
- -p 显示转换进度
等镜像格式转化呢完成后查看你信息
[root@controller ~]# qemu-img info bionic-server-cloudimg-amd64.qcow2
image: bionic-server-cloudimg-amd64.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 387M
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
创建镜像
[root@controller ~]# openstack image create --disk-format qcow2 --container-format bare \
> --min-disk 10 \
> --min-ram 1024 \
> --file bionic-server-cloudimg-amd64.qcow2 \
> Ubuntu-image
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | 8d2427ce42ef65aaf912475c37026cd5 |
| container_format | bare |
| created_at | 2023-07-03T14:35:47Z |
| disk_format | qcow2 |
| file | /v2/images/58fe3551-b653-4d6c-aa27-db514470b96c/file |
| id | 58fe3551-b653-4d6c-aa27-db514470b96c |
| min_disk | 10 |
| min_ram | 1024 |
| name | Ubuntu-image |
| owner | 05a47fe36758427785540085776c6e36 |
| properties | os_hash_algo='sha512', os_hash_value='49f0f07ff1f4f14257d8080c91f7ca8de1eff359c9be472c3974eefae9d0141bdac48bbf6228c753d96bd1e283b7c9bcef7f5fb4d8d82f987f7147b92d27a4d8', os_hidden='False' |
| protected | False |
| schema | /v2/schemas/image |
| size | 405667840 |
| status | active |
| tags | |
| updated_at | 2023-07-03T14:35:52Z |
| virtual_size | None |
| visibility | shared |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@controller ~]# openstack image list
+--------------------------------------+--------------+--------+
| ID | Name | Status |
+--------------------------------------+--------------+--------+
| 58fe3551-b653-4d6c-aa27-db514470b96c | Ubuntu-image | active |
| 0ee90422-2c4a-4da1-a162-2e315cddbcd1 | cirros | active |
+--------------------------------------+--------------+--------+
图形化界面
创建镜像
Nova和Neutron
命令行的方式
实例类型
(1)创建flavor类型
[root@controller ~]# openstack flavor create --disk 20 --ram 3096 --vcpus 3 --id 777 flavor2
+----------------------------+---------+
| Field | Value |
+----------------------------+---------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 20 |
| id | 777 |
| name | flavor2 |
| os-flavor-access:is_public | True |
| properties | |
| ram | 3096 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 3 |
+----------------------------+---------+
(2)查看flavor类型
[root@controller ~]# openstack flavor list
+-----+---------+------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+-----+---------+------+------+-----------+-------+-----------+
| 0 | m1.nano | 64 | 1 | 0 | 1 | True |
| 777 | flavor2 | 3096 | 20 | 0 | 3 | True |
+-----+---------+------+------+-----------+-------+-----------+
(3)查看flavor具体信息
[root@controller ~]# openstack flavor show flavor2
+----------------------------+---------+
| Field | Value |
+----------------------------+---------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| access_project_ids | None |
| disk | 20 |
| id | 777 |
| name | flavor2 |
| os-flavor-access:is_public | True |
| properties | |
| ram | 3096 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 3 |
+----------------------------+---------+
(4)删除flavor类型
[root@controller ~]# openstack flavor delete <flavor name>
密钥对
创建密钥对mykey2
[root@controller ~]# ssh-keygen -q -N ""
[root@controller ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey2
+-------------+-------------------------------------------------+
| Field | Value |
+-------------+-------------------------------------------------+
| fingerprint | 4e:89:e8:78:70:1e:82:4a:b8:65:87:1e:21:6a:83:25 |
| name | mykey2 |
| user_id | fef5f8c16d3d4b9d849bc1488bf50a21 |
+-------------+-------------------------------------------------+
安全组
(1)查看安全组
[root@controller ~]# openstack security group list
(2)创建安全组
[root@controller ~]# openstack security group create myanquanzu
+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2023-07-03T15:29:20Z |
| description | myanquanzu |
| id | 5b76d5ae-c8b2-4f44-8da2-0dc2a1626b25 |
| location | cloud='', project.domain_id=, project.domain_name='Default', project.id='0769b940829c4078a4aa573e83d6520c', project.name='admin', region_name='', zone= |
| name | myanquanzu |
| project_id | 0769b940829c4078a4aa573e83d6520c |
| revision_number | 1 |
| rules | created_at='2023-07-03T15:29:20Z', direction='egress', ethertype='IPv4', id='c498e8d8-8fda-4739-86da-aad0e03889d9', updated_at='2023-07-03T15:29:20Z' |
| | created_at='2023-07-03T15:29:20Z', direction='egress', ethertype='IPv6', id='cf3f3224-71c7-4831-b5bf-cc56e466e3b2', updated_at='2023-07-03T15:29:20Z' |
| tags | [] |
| updated_at | 2023-07-03T15:29:20Z |
+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
(3)删除安全组
[root@controller ~]# openstack security group delete myanquanzu
(4)添加安全规则
在myanquanzu安全组中添加一条策略,从入口方向放行所有ICMP规则,命令如下
[root@controller ~]# openstack security group rule create --protocol icmp --ingress myanquanzu
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2023-07-03T15:31:10Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | de5748eb-770b-4fe5-86f9-24b34271ac76 |
| location | cloud='', project.domain_id=, project.domain_name='Default', project.id='0769b940829c4078a4aa573e83d6520c', project.name='admin', region_name='', zone= |
| name | None |
| port_range_max | None |
| port_range_min | None |
| project_id | 0769b940829c4078a4aa573e83d6520c |
| protocol | icmp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 849923e9-2eed-42b5-8eee-fa0f1b855026 |
| tags | [] |
| updated_at | 2023-07-03T15:31:10Z |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
在myanquanzu安全组中添加一条策略,从入口方向放行所有TCP规则,命令如下
[root@controller ~]# openstack security group rule create --protocol tcp --ingress myanquanzu
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2023-07-03T15:32:14Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 9dfedfbd-3328-4340-abc0-04f3b64367ec |
| location | cloud='', project.domain_id=, project.domain_name='Default', project.id='0769b940829c4078a4aa573e83d6520c', project.name='admin', region_name='', zone= |
| name | None |
| port_range_max | None |
| port_range_min | None |
| project_id | 0769b940829c4078a4aa573e83d6520c |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 849923e9-2eed-42b5-8eee-fa0f1b855026 |
| tags | [] |
| updated_at | 2023-07-03T15:32:14Z |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
在myanquanzu安全组中添加一条策略,从入口方向放行所有UDP规则,命令如下
[root@controller ~]# openstack security group rule create --protocol udp --ingress myanquanzu
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2023-07-03T15:33:09Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 928c3bca-ea8c-4d50-9919-432f03b90a92 |
| location | cloud='', project.domain_id=, project.domain_name='Default', project.id='0769b940829c4078a4aa573e83d6520c', project.name='admin', region_name='', zone= |
| name | None |
| port_range_max | None |
| port_range_min | None |
| project_id | 0769b940829c4078a4aa573e83d6520c |
| protocol | udp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | 849923e9-2eed-42b5-8eee-fa0f1b855026 |
| tags | [] |
| updated_at | 2023-07-03T15:33:09Z |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
查看myanquanzu安全组中所有的规则列表信息,命令如下
[root@controller ~]# openstack security group rule list myanquanzu
+--------------------------------------+-------------+-----------+-----------+------------+-----------------------+
| ID | IP Protocol | Ethertype | IP Range | Port Range | Remote Security Group |
+--------------------------------------+-------------+-----------+-----------+------------+-----------------------+
| 1435f001-94fa-4d29-ad0f-626cff27feef | None | IPv6 | ::/0 | | None |
| 928c3bca-ea8c-4d50-9919-432f03b90a92 | udp | IPv4 | 0.0.0.0/0 | | None |
| 9b34ccb6-ab3e-4dbf-bc8a-da901066755f | None | IPv4 | 0.0.0.0/0 | | None |
| 9dfedfbd-3328-4340-abc0-04f3b64367ec | tcp | IPv4 | 0.0.0.0/0 | | None |
| de5748eb-770b-4fe5-86f9-24b34271ac76 | icmp | IPv4 | 0.0.0.0/0 | | None |
+--------------------------------------+-------------+-----------+-----------+------------+-----------------------+
创建网络
创建网络
[root@controller ~]# openstack network create --share --external --provider-physical-network provider --provider-network-type flat net-flat
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2023-07-03T15:39:27Z |
| description | |
| dns_domain | None |
| id | cfd04a6d-47c0-4144-b3a1-537179d037c8 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | None |
| is_vlan_transparent | None |
| location | cloud='', project.domain_id=, project.domain_name='Default', project.id='0769b940829c4078a4aa573e83d6520c', project.name='admin', region_name='', zone= |
| mtu | 1500 |
| name | net-flat |
| port_security_enabled | True |
| project_id | 0769b940829c4078a4aa573e83d6520c |
| provider:network_type | flat |
| provider:physical_network | provider |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 1 |
| router:external | External |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2023-07-03T15:39:27Z |
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
--share
:表示这个网络是共享的,其他项目也可以使用该网络--external
:表示这个网络是外部网络,即连接到外部物理网络的网络--provider-physical-network provider
:指定了物理网络的名称为 “provider”,这是为了将该网络连接到特定的物理网络。--provider-network-type flat
:指定了网络类型为 “flat”net-flat
:指定了网络的名称为 “net-flat”
创建子网
[root@controller ~]# openstack subnet create --network net-flat --allocation-pool start=192.168.200.50,end=192.168.200.100 --dns-nameserver 114.114.114.114 --gateway 192.168.200.2 --subnet-range 192.168.200.0/24 net-sub
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| allocation_pools | 192.168.200.50-192.168.200.100 |
| cidr | 192.168.200.0/24 |
| created_at | 2023-07-03T15:40:51Z |
| description | |
| dns_nameservers | 114.114.114.114 |
| enable_dhcp | True |
| gateway_ip | 192.168.200.2 |
| host_routes | |
| id | ea9230c9-128f-42fd-affa-42a53a995622 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| location | cloud='', project.domain_id=, project.domain_name='Default', project.id='0769b940829c4078a4aa573e83d6520c', project.name='admin', region_name='', zone= |
| name | net-sub |
| network_id | cfd04a6d-47c0-4144-b3a1-537179d037c8 |
| prefix_length | None |
| project_id | 0769b940829c4078a4aa573e83d6520c |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2023-07-03T15:40:51Z |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
--network net-flat
:指定了要在名为 net-flat"的网络中创建子网--allocation-pool start=192.168.200.50,end=192.168.200.100
:指定了分配 IP 地址的范围,从 192.168.200.50 到 192.168.200.100--dns-nameserver 114.114.114.114
:指定了 DNS 服务器的 IP 地址为 114.114.114.114--gateway 192.168.200.2
:指定了子网的网关 IP 地址为 192.168.200.2--subnet-range 192.168.200.0/24
:指定了子网的 IP 地址范围为 192.168.200.0 到 192.168.200.255,使用 /24 表示子网掩码是 255.255.255.0net-sub
:指定了子网的名称为 net-sub
创建云主机
# 创建云主机
[root@controller ~]# openstack server create --flavor 777 --image Ubuntu-image --nic net-id=cfd04a6d-47c0-4144-b3a1-537179d037c8 --security-group myanquanzu --key-name mykey2 myserver
+-------------------------------------+-----------------------------------------------------+
| Field | Value |
+-------------------------------------+-----------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-SRV-ATTR:host | None |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None |
| OS-EXT-SRV-ATTR:instance_name | |
| OS-EXT-STS:power_state | NOSTATE |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | None |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | |
| adminPass | RVJeZLYfn4mi |
| config_drive | |
| created | 2023-07-03T15:56:44Z |
| flavor | flavor2 (777) |
| hostId | |
| id | 629268c7-9bda-464b-bd86-e60192b0e02c |
| image | Ubuntu-image (734207ab-6a85-473c-8021-00e7173e6441) |
| key_name | mykey2 |
| name | myserver |
| progress | 0 |
| project_id | 0769b940829c4078a4aa573e83d6520c |
| properties | |
| security_groups | name='849923e9-2eed-42b5-8eee-fa0f1b855026' |
| status | BUILD |
| updated | 2023-07-03T15:56:44Z |
| user_id | fef5f8c16d3d4b9d849bc1488bf50a21 |
| volumes_attached | |
+-------------------------------------+-----------------------------------------------------+
[root@controller ~]# openstack server list
+--------------------------------------+----------+--------+-------------------------+--------------+---------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+----------+--------+-------------------------+--------------+---------+
| 629268c7-9bda-464b-bd86-e60192b0e02c | myserver | ACTIVE | net-flat=192.168.200.72 | Ubuntu-image | flavor2 |
+--------------------------------------+----------+--------+-------------------------+--------------+---------+
# 测试连通性
[root@controller ~]# ping 192.168.200.72
PING 192.168.200.72 (192.168.200.72) 56(84) bytes of data.
64 bytes from 192.168.200.72: icmp_seq=1 ttl=64 time=2.12 ms
# 连接云主机
[root@controller ~]# ssh ubuntu@192.168.200.72
ubuntu@myserver:~$ pwd
/home/ubuntu
# 可以看到使用的是我们创建的规格类型
ubuntu@myserver:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 20G 0 disk
├─vda1 252:1 0 19.9G 0 part /
├─vda14 252:14 0 4M 0 part
└─vda15 252:15 0 106M 0 part /boot/efi
# 也可以ping通百度 能连接到外网
ubuntu@myserver:/$ ping -c4 baidu.com
PING baidu.com (39.156.66.10) 56(84) bytes of data.
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=1 ttl=128 time=18.9 ms
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=2 ttl=128 time=19.0 ms
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=3 ttl=128 time=17.6 ms
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=4 ttl=128 time=17.2 ms
--- baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3009ms
rtt min/avg/max/mdev = 17.246/18.228/19.096/0.791 ms
ubuntu@myserver:/$
启动关闭云主机
[root@controller ~]# openstack server stop myserver
[root@controller ~]# openstack server list
+--------------------------------------+----------+---------+-------------------------+--------------+---------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+----------+---------+-------------------------+--------------+---------+
| 629268c7-9bda-464b-bd86-e60192b0e02c | myserver | SHUTOFF | net-flat=192.168.200.72 | Ubuntu-image | flavor2 |
+--------------------------------------+----------+---------+-------------------------+--------------+---------+
[root@controller ~]# openstack server start myserver
[root@controller ~]# openstack server list
+--------------------------------------+----------+--------+-------------------------+--------------+---------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+----------+--------+-------------------------+--------------+---------+
| 629268c7-9bda-464b-bd86-e60192b0e02c | myserver | ACTIVE | net-flat=192.168.200.72 | Ubuntu-image | flavor2 |
+--------------------------------------+----------+--------+-------------------------+--------------+---------+
图形化界面
创建实例类型
创建网络
创建密钥对
[root@controller ~]# ssh-keygen -q -N ""
# -q:表示以静默模式生成密钥对,不会显示额外的输出信息。
# -N "":表示设置生成的密钥对的密码为空,即不设置密码保护。
# 执行这个命令后,会生成一对 SSH 密钥,包括私钥和公钥。
# 私钥将保存在默认的路径 ~/.ssh/id_rsa,而公钥将保存在 ~/.ssh/id_rsa.pub
# 私钥用于对 SSH 连接进行身份验证,而公钥则用于将其添加到目标服务器上的
# ~/.ssh/authorized_keys 文件中,以允许使用私钥进行身份验证。
添加安全组规则
添加安全组规则
放行所有ICMP TCP UDP 的入口出口
创建云主机
选择刚刚创建的资源
查看主机详细信息
远程连接
Cinder
命令行操作
查看cinder存储服务状态
[root@controller ~]# openstack volume service list
+------------------+-------------+------+---------+-------+----------------------------+
| Binary | Host | Zone | Status | State | Updated At |
+------------------+-------------+------+---------+-------+----------------------------+
| cinder-scheduler | controller | nova | enabled | up | 2023-07-04T07:59:41.000000 |
| cinder-volume | compute@lvm | nova | enabled | up | 2023-07-04T07:59:38.000000 |
+------------------+-------------+------+---------+-------+----------------------------+
创建块存储
创建块存储
[root@controller ~]# openstack volume create --size 3 volume1
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2023-07-04T08:33:09.000000 |
| description | None |
| encrypted | False |
| id | 3f277366-14e4-4ead-bcf1-2fde6ab595f1 |
| migration_status | None |
| multiattach | False |
| name | volume1 |
| properties | |
| replication_status | None |
| size | 3 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| type | __DEFAULT__ |
| updated_at | None |
| user_id | fef5f8c16d3d4b9d849bc1488bf50a21 |
+---------------------+--------------------------------------+
查看块存储
[root@controller ~]# openstack volume list
+--------------------------------------+---------+-----------+------+-------------+
| ID | Name | Status | Size | Attached to |
+--------------------------------------+---------+-----------+------+-------------+
| 3f277366-14e4-4ead-bcf1-2fde6ab595f1 | volume1 | available | 3 | |
+--------------------------------------+---------+-----------+------+-------------+
查看某一块存储的详细信息
[root@controller ~]# openstack volume show volume1
+--------------------------------+--------------------------------------+
| Field | Value |
+--------------------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2023-07-04T08:33:09.000000 |
| description | None |
| encrypted | False |
| id | 3f277366-14e4-4ead-bcf1-2fde6ab595f1 |
| migration_status | None |
| multiattach | False |
| name | volume1 |
| os-vol-host-attr:host | compute@lvm#LVM |
| os-vol-mig-status-attr:migstat | None |
| os-vol-mig-status-attr:name_id | None |
| os-vol-tenant-attr:tenant_id | 0769b940829c4078a4aa573e83d6520c |
| properties | |
| replication_status | None |
| size | 3 |
| snapshot_id | None |
| source_volid | None |
| status | available |
| type | __DEFAULT__ |
| updated_at | 2023-07-04T08:33:10.000000 |
| user_id | fef5f8c16d3d4b9d849bc1488bf50a21 |
+--------------------------------+--------------------------------------+
挂载块存储
首先创建一台云主机
[root@controller ~]# openstack server list
+--------------------------------------+---------+--------+------------------------------+--------+---------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+---------+--------+------------------------------+--------+---------+
| efec3eb5-fa01-4224-bd7a-bd7e2352e186 | server1 | ACTIVE | flat-provider=192.168.200.62 | cirros | m1.nano |
+--------------------------------------+---------+--------+------------------------------+--------+---------+
将创建好的块存储添加到这台云主机上
[root@controller ~]# openstack server add volume efec3eb5-fa01-4224-bd7a-bd7e2352e186 3f277366-14e4-4ead-bcf1-2fde6ab595f1
# openstack server add volume <server name or ID> <volume name or ID>
查看块存储信息
[root@controller ~]# openstack volume list
+--------------------------------------+---------+--------+------+----------------------------------+
| ID | Name | Status | Size | Attached to |
+--------------------------------------+---------+--------+------+----------------------------------+
| 3f277366-14e4-4ead-bcf1-2fde6ab595f1 | volume1 | in-use | 3 | Attached to server1 on /dev/vdb |
+--------------------------------------+---------+--------+------+----------------------------------+
登录云主机查看挂载信息
[root@controller ~]# ssh cirros@192.168.200.62
The authenticity of host '192.168.200.62 (192.168.200.62)' can't be established.
RSA key fingerprint is SHA256:w/aUcwAwx25Ol3MOJd3Yunu18Bif338H9tuFqt1pUOs.
RSA key fingerprint is MD5:9a:18:79:38:31:52:8e:56:a7:cf:6c:f4:9c:91:18:52.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.200.62' (RSA) to the list of known hosts.
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 1G 0 disk
`-vda1 253:1 0 1011.9M 0 part /
vdb 253:16 0 3G 0 disk
$
扩展块存储
创建完卷后可能因为需求的变更,需要对已有的卷进行扩容操作
[root@controller ~]# openstack server remove volume server1 volume1
[root@controller ~]# openstack volume set
[root@controller ~]# openstack volume set volume1 --size 5
[root@controller ~]# openstack server add volume server1 volume1
[root@controller ~]# openstack volume list
+--------------------------------------+---------+--------+------+----------------------------------+
| ID | Name | Status | Size | Attached to |
+--------------------------------------+---------+--------+------+----------------------------------+
| 3f277366-14e4-4ead-bcf1-2fde6ab595f1 | volume1 | in-use | 5 | Attached to server1 on /dev/vdb |
+--------------------------------------+---------+--------+------+----------------------------------+
[root@controller ~]# ssh cirros@192.168.200.62
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 1G 0 disk
`-vda1 253:1 0 1011.9M 0 part /
vdb 253:16 0 5G 0 disk
$
删除块存储
删除很简单,如果你要删除挂载的块存储 首先你要先分离
块存储然后再删除
[root@controller ~]# openstack server remove volume server1 volume1
[root@controller ~]# openstack volume delete volume1
[root@controller ~]# openstack volume list
Swift
命令行操作
查看服务状态
[root@controller ~]# swift stat
Account: AUTH_0769b940829c4078a4aa573e83d6520c
Containers: 0
Objects: 0
Bytes: 0
Containers in policy "policy-0": 0
Objects in policy "policy-0": 0
Bytes in policy "policy-0": 0
X-Account-Project-Domain-Id: default
X-Openstack-Request-Id: txc951de50e3464755a30b3-0064a3e3a7
X-Timestamp: 1688230822.33140
X-Trans-Id: txc951de50e3464755a30b3-0064a3e3a7
Content-Type: application/json; charset=utf-8
Accept-Ranges: bytes
创建容器
[root@controller ~]# openstack container create csq-swift
+---------------------------------------+-----------+------------------------------------+
| account | container | x-trans-id |
+---------------------------------------+-----------+------------------------------------+
| AUTH_0769b940829c4078a4aa573e83d6520c | csq-swift | txf3fe9450eb1444e18d9d3-0064a3e416 |
+---------------------------------------+-----------+------------------------------------+
查看容器
[root@controller ~]# openstack container list
+-----------+
| Name |
+-----------+
| csq-swift |
+-----------+
查看容器详细信息
[root@controller ~]# openstack container show csq-swift
+--------------+---------------------------------------+
| Field | Value |
+--------------+---------------------------------------+
| account | AUTH_0769b940829c4078a4aa573e83d6520c |
| bytes_used | 0 |
| container | csq-swift |
| object_count | 0 |
+--------------+---------------------------------------+
创建对象
在使用命令创建对象前,需要将上传后的目录结构在本地创建。在本地创建名为test的目录/root/test,将/root/anaconda-ks.cfg文件复制至/root/test目录中。
[root@controller ~]# mkdir test
[root@controller ~]# mv anaconda-ks.cfg test/
[root@controller ~]# ls test/
anaconda-ks.cfg
[root@controller ~]# openstack object create csq-swift test/anaconda-ks.cfg
+----------------------+-----------+----------------------------------+
| object | container | etag |
+----------------------+-----------+----------------------------------+
| test/anaconda-ks.cfg | csq-swift | 31d063bfe3e1f5bb6b61b421ba5e21d7 |
+----------------------+-----------+----------------------------------+
查看对象
[root@controller ~]# openstack object list csq-swift
+----------------------+
| Name |
+----------------------+
| test/anaconda-ks.cfg |
+----------------------+
查询详细信息
[root@controller ~]# openstack object show csq-swift test/anaconda-ks.cfg
+----------------+---------------------------------------+
| Field | Value |
+----------------+---------------------------------------+
| account | AUTH_0769b940829c4078a4aa573e83d6520c |
| container | csq-swift |
| content-length | 1698 |
| content-type | application/octet-stream |
| etag | 31d063bfe3e1f5bb6b61b421ba5e21d7 |
| last-modified | Tue, 04 Jul 2023 09:31:50 GMT |
| object | test/anaconda-ks.cfg |
+----------------+---------------------------------------+
下载对象
存储在容器中的对象,可以在需要使用时进行下载,命令如下
[root@controller ~]# cd /opt/
[root@controller opt]# openstack object save csq-swift test/anaconda-ks.cfg
[root@controller opt]# ls test/
anaconda-ks.cfg
删除对象
[root@controller ~]# openstack object delete csq-swift test/anaconda-ks.cfg
[root@controller ~]# openstack object list csq-swift
删除容器
[root@controller ~]# openstack container delete csq-swift
[root@controller ~]# openstack container list
分片存储案例
创建容器
[root@controller ~]# openstack container create swift-csq
+---------------------------------------+-----------+------------------------------------+
| account | container | x-trans-id |
+---------------------------------------+-----------+------------------------------------+
| AUTH_0769b940829c4078a4aa573e83d6520c | swift-csq | txb209ec3e4c2e439896cba-0064a3e96d |
+---------------------------------------+-----------+------------------------------------+
分片存储镜像
[root@controller ~]# swift upload swift-csq -S 10000000 image/cirros-0.3.4-x86_64-disk.img
image/cirros-0.3.4-x86_64-disk.img segment 1
image/cirros-0.3.4-x86_64-disk.img segment 0
image/cirros-0.3.4-x86_64-disk.img
查看存储路径
[root@controller ~]# swift stat swift-csq image/cirros-0.3.4-x86_64-disk.img
Account: AUTH_0769b940829c4078a4aa573e83d6520c
Container: swift-csq
Object: image/cirros-0.3.4-x86_64-disk.img
Content Type: application/octet-stream
Content Length: 13287936
Last Modified: Tue, 04 Jul 2023 09:50:53 GMT
ETag: "cca17a689bfcd70118fabc833af0d033"
Manifest: swift-csq_segments/image/cirros-0.3.4-x86_64-disk.img/1687999427.910558/13287936/10000000/
Meta Mtime: 1687999427.910558
Accept-Ranges: bytes
X-Timestamp: 1688464252.67141
X-Trans-Id: tx4d69e4da9077494189878-0064a3eb95
X-Openstack-Request-Id: tx4d69e4da9077494189878-0064a3eb95
查看路径中的数据片
[root@controller ~]# swift list swift-csq_segments
image/cirros-0.3.4-x86_64-disk.img/1687999427.910558/13287936/10000000/00000000
image/cirros-0.3.4-x86_64-disk.img/1687999427.910558/13287936/10000000/00000001
--------------------------+
| AUTH_0769b940829c4078a4aa573e83d6520c | swift-csq | txb209ec3e4c2e439896cba-0064a3e96d |
±--------------------------------------±----------±-----------------------------------+
分片存储镜像
```shell
[root@controller ~]# swift upload swift-csq -S 10000000 image/cirros-0.3.4-x86_64-disk.img
image/cirros-0.3.4-x86_64-disk.img segment 1
image/cirros-0.3.4-x86_64-disk.img segment 0
image/cirros-0.3.4-x86_64-disk.img
查看存储路径
[root@controller ~]# swift stat swift-csq image/cirros-0.3.4-x86_64-disk.img
Account: AUTH_0769b940829c4078a4aa573e83d6520c
Container: swift-csq
Object: image/cirros-0.3.4-x86_64-disk.img
Content Type: application/octet-stream
Content Length: 13287936
Last Modified: Tue, 04 Jul 2023 09:50:53 GMT
ETag: "cca17a689bfcd70118fabc833af0d033"
Manifest: swift-csq_segments/image/cirros-0.3.4-x86_64-disk.img/1687999427.910558/13287936/10000000/
Meta Mtime: 1687999427.910558
Accept-Ranges: bytes
X-Timestamp: 1688464252.67141
X-Trans-Id: tx4d69e4da9077494189878-0064a3eb95
X-Openstack-Request-Id: tx4d69e4da9077494189878-0064a3eb95
查看路径中的数据片
[root@controller ~]# swift list swift-csq_segments
image/cirros-0.3.4-x86_64-disk.img/1687999427.910558/13287936/10000000/00000000
image/cirros-0.3.4-x86_64-disk.img/1687999427.910558/13287936/10000000/00000001