设为首页 收藏本站
查看: 957|回复: 0

[经验分享] openstack运维实战系列(三)之cinder磁盘挂载

[复制链接]

尚未签到

发表于 2018-6-1 11:05:54 | 显示全部楼层 |阅读模式
  1. 概述
  openstack的cinder项目负责volume的服务,即虚拟机的外挂存储,cinder作为管理存储的工具,可以支持LVM,glusterfs,ceph,sleepdog等开源的存储方案,同时也提供了对HP,IBM,huawei等商业存储的支持,配置完cinder之后,即可对虚拟机分配存储空间,如下给虚拟机分配cinder存储空间为例,讲述cinder的使用方法。
  

  2. 磁盘挂载
[root@controller ~]# nova list |grep 10.16.6.52
| 1809ae2e-7e29-4203-930b-494de426bf8e | Dev_20151201_01      | ACTIVE  | -          | Running     | vmPrivate=10.16.6.52     | ChuangYiYuan_10_16_2_13 |
[root@controller ~]# cinder create --display-name "storage_10.16.6.52" 20    #划分一个20G的磁盘   
+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|       bootable      |                false                 |
|      created_at     |      2016-01-19T08:58:29.819663      |
| display_description |                 None                 |
|     display_name    |          storage_10.16.6.52          |
|      encrypted      |                False                 |
|          id         | e5ef5ad4-ddc4-4675-95bf-726473c4c62d |                #获取cinder-volume的id号码,用于和instance关联
|       metadata      |                  {}                  |
|         size        |                  20                  |
|     snapshot_id     |                 None                 |
|     source_volid    |                 None                 |
|        status       |               creating               |
|     volume_type     |                 None                 |
+---------------------+--------------------------------------+
将cinder和虚拟机关联
[root@controller ~]# nova volume-attach 1809ae2e-7e29-4203-930b-494de426bf8e  e5ef5ad4-ddc4-4675-95bf-726473c4c62d   
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdc                             |        #虚拟机将会识别为vdc设备
| id       | e5ef5ad4-ddc4-4675-95bf-726473c4c62d |
| serverId | 1809ae2e-7e29-4203-930b-494de426bf8e |
| volumeId | e5ef5ad4-ddc4-4675-95bf-726473c4c62d |
+----------+--------------------------------------+
查看cinder的情况
[root@controller ~]# cinder show e5ef5ad4-ddc4-4675-95bf-726473c4c62d
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
|            Property            |                                                                                                    Value                                                                                                     |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
|          attachments           | [{u'device': u'/dev/vdc', u'server_id': u'1809ae2e-7e29-4203-930b-494de426bf8e', u'id': u'e5ef5ad4-ddc4-4675-95bf-726473c4c62d', u'host_name': None, u'volume_id': u'e5ef5ad4-ddc4-4675-95bf-726473c4c62d'}] |
|       availability_zone        |                                                                                                     nova                                                                                                     |
|            bootable            |                                                                                                    false                                                                                                     |
|           created_at           |                                                                                          2016-01-19T08:58:29.000000                                                                                          |
|      display_description       |                                                                                                     None                                                                                                     |
|          display_name          |                                                                                              storage_10.16.6.52                                                                                              |
|           encrypted            |                                                                                                    False                                                                                                     |
|               id               |                                                                                     e5ef5ad4-ddc4-4675-95bf-726473c4c62d                                                                                     |
|            metadata            |                                                                               {u'readonly': u'False', u'attached_mode': u'rw'}                                                                               |
|     os-vol-host-attr:host      |                                                                                            ChuangYiYuan_10_16_2_7                                                                                            |
| os-vol-mig-status-attr:migstat |                                                                                                     None                                                                                                     |
| os-vol-mig-status-attr:name_id |                                                                                                     None                                                                                                     |
|  os-vol-tenant-attr:tenant_id  |                                                                                       842ab3268a2c47e6a4b0d8774de805ae                                                                                       |
|              size              |                                                                                                      20                                                                                                      |
|          snapshot_id           |                                                                                                     None                                                                                                     |
|          source_volid          |                                                                                                     None                                                                                                     |
|             status             |                                                                                                    in-use                                                                                                    |
|          volume_type           |                                                                                                     None                                                                                                     |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+  

  3. 格式化磁盘

  •   查看系统识别的disk
[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether fa:16:3e:d5:e1:4e brd ff:ff:ff:ff:ff:ff
    inet 10.16.6.52/23 brd 10.16.7.255 scope global eth0
[root@localhost ~]# dmesg | tail -10
pci 0000:00:07.0: using default PCI settings
virtio-pci 0000:00:07.0: enabling device (0000 -> 0003)
virtio-pci 0000:00:07.0: PCI INT A -> Link[LNKC] -> GSI 10 (level, high) -> IRQ 10
  alloc irq_desc for 31 on node -1
  alloc kstat_irqs on node -1
virtio-pci 0000:00:07.0: irq 31 for MSI/MSI-X
  alloc irq_desc for 32 on node -1
  alloc kstat_irqs on node -1
virtio-pci 0000:00:07.0: irq 32 for MSI/MSI-X
vdc: unknown partition table            #磁盘识别为vdc  2. 分区与格式化
[root@Dev_10_16_6_52 ~]# fdisk /dev/vdc                 #磁盘分区
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x115a4ff3.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@Dev_10_16_6_52 ~]# partprobe /dev/vdc
[root@Dev_10_16_6_52 ~]# mkfs.ext4 /dev/vdc1             #格式化
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242624 blocks
262131 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.  3. 挂载使用
[root@localhost ~]# mkdir /data2
[root@localhost ~]# mount /dev/vdc1 /data2/
[root@localhost ~]# df -h /data2/
Filesystem            Size  Used Avail Use% Mounted on
/dev/vdc1              20G  172M   19G   1% /data2  

  4. 总结
  cinder作为一种外挂的存储,在openstack中用于数据存储有非常关键的作用,并且在openstack中,使用cinder非常方便,创建和关联,轻松就可以实现任意大小磁盘的分配,实现高效的管理。
  

  5. 附录
[root@controller ~]# cinder -h
usage: cinder [--version] [--debug] [--os-username <auth-user-name>]
              [--os-password <auth-password>]
              [--os-tenant-name <auth-tenant-name>]
              [--os-tenant-id <auth-tenant-id>] [--os-auth-url <auth-url>]
              [--os-region-name <region-name>]
              [--os-auth-system <auth-system>] [--service-type <service-type>]
              [--service-name <service-name>]
              [--volume-service-name <volume-service-name>]
              [--endpoint-type <endpoint-type>]
              [--os-volume-api-version <volume-api-ver>]
              [--os-cacert <ca-certificate>] [--retries <retries>]
              <subcommand> ...
Command-line interface to the OpenStack Cinder API.
Positional arguments:
  <subcommand>
    absolute-limits     Print a list of absolute limits for a user
    availability-zone-list
                        List all the availability zones.
    backup-create       Creates a backup.                                            #备份相关
    backup-delete       Remove a backup.
    backup-list         List all the backups.
    backup-restore      Restore a backup.
    backup-show         Show details about a backup.
    create              Add a new volume.
    credentials         Show user credentials returned from auth.
    delete              Remove volume(s).
    encryption-type-create                                                            #加密盘相关
                        Create a new encryption type for a volume type (Admin
                        Only).
    encryption-type-delete
                        Delete the encryption type for a volume type (Admin
                        Only).
    encryption-type-list
                        List encryption type information for all volume types
                        (Admin Only).
    encryption-type-show
                        Show the encryption type information for a volume type
                        (Admin Only).
    endpoints           Discover endpoints that get returned from the
                        authenticate services.
    extend              Attempt to extend the size of an existing volume.
    extra-specs-list    Print a list of current 'volume types and extra specs'
                        (Admin Only).
    force-delete        Attempt forced removal of volume(s), regardless of the
                        state(s).
    list                List all the volumes.
    metadata            Set or Delete metadata on a volume.
    metadata-show       Show metadata of given volume.
    metadata-update-all
                        Update all metadata of a volume.
    migrate             Migrate the volume to the new host.                        #qos相关
    qos-associate       Associate qos specs with specific volume type.
    qos-create          Create a new qos specs.
    qos-delete          Delete a specific qos specs.
    qos-disassociate    Disassociate qos specs from specific volume type.
    qos-disassociate-all
                        Disassociate qos specs from all of its associations.
    qos-get-association
                        Get all associations of specific qos specs.
    qos-key             Set or unset specifications for a qos spec.
    qos-list            Get full list of qos specs.
    qos-show            Get a specific qos specs.
    quota-class-show    List the quotas for a quota class.                        #磁盘配额相关
    quota-class-update  Update the quotas for a quota class.
    quota-defaults      List the default quotas for a tenant.
    quota-delete        Delete the quotas for a tenant.
    quota-show          List the quotas for a tenant.
    quota-update        Update the quotas for a tenant.
    quota-usage         List the quota usage for a tenant.
    rate-limits         Print a list of rate limits for a user
    readonly-mode-update
                        Update volume read-only access mode read_only.
    rename              Rename a volume.
    reset-state         Explicitly update the state of a volume.                #服务管理相关
    service-disable     Disable the service.
    service-enable      Enable the service.
    service-list        List all the services. Filter by host & service
                        binary.
    show                Show details about a volume.
    snapshot-create     Add a new snapshot.                                    快照相关
    snapshot-delete     Remove one or more snapshots.
    snapshot-list       List all the snapshots.
    snapshot-metadata   Set or Delete metadata of a snapshot.
    snapshot-metadata-show
                        Show metadata of given snapshot.
    snapshot-metadata-update-all
                        Update all metadata of a snapshot.
    snapshot-rename     Rename a snapshot.
    snapshot-reset-state
                        Explicitly update the state of a snapshot.
    snapshot-show       Show details about a snapshot.   
    transfer-accept     Accepts a volume transfer.                           
    transfer-create     Creates a volume transfer.
    transfer-delete     Undo a transfer.
    transfer-list       List all the transfers.
    transfer-show       Show details about a transfer.
    type-create         Create a new volume type.                            cinder type相关
    type-delete         Delete a specific volume type.
    type-key            Set or unset extra_spec for a volume type.
    type-list           Print a list of available 'volume types'.
    upload-to-image     Upload volume to image service as image.
    bash-completion     Print arguments for bash_completion.
    help                Display help about this program or one of its
                        subcommands.
    list-extensions     List all the os-api extensions that are available.  

  

  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-498173-1-1.html 上篇帖子: openstack运维实战系列(二)之instance ERR故障处理 下篇帖子: openstack运维实战系列(四)之删除computes节点
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表