- 将ceph volume type的volume attach到instance c1上。
|
|
- 我们重点关注nova-compute 如何将vol-1 attach 到c1。查看cinder-volume日志:
- cinder-volume查看monitor的映射信息,初始化volume的连接,查看要连接的volume信息
|
|
Jun 27 15:34:08 controller cinder-volume[9796]: DEBUG oslo_concurrency.processutils
[req-c9184b0e-2cb3-4549-bb6b-cf0482f682bf req-27aba675-b7ad-4ca0-bc5e-2678211ebe8c admin None] Running cmd (subprocess): ceph mon dump --format=json --id cinder --cluster ceph --conf /etc/ceph/ceph.conf
{{(pid=9947) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:372
|
|
Jun 27 15:34:08 controller cinder-volume[9796]: DEBUG oslo_concurrency.processutils
[req-c9184b0e-2cb3-4549-bb6b-cf0482f682bf req-27aba675-b7ad-4ca0-bc5e-2678211ebe8c admin None] CMD "ceph mon dump --format=json --id cinder --cluster ceph --conf /etc/ceph/ceph.conf" returned: 0 in 0.340s
{{(pid=9947) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:409
|
|
Jun 27 15:34:08 controller cinder-volume[9796]: DEBUG cinder.volume.drivers.rbd
[req-c9184b0e-2cb3-4549-bb6b-cf0482f682bf req-27aba675-b7ad-4ca0-bc5e-2678211ebe8c admin None] connection data: {'driver_volume_type': 'rbd', 'data': {'secret_uuid': 'df0d0b60-047a-45f5-b5be-f7d2b4beadee',
'volume_id': u'823dfaa9-a41c-4df7-a165-30db20b5b1c7', 'auth_username': 'cinder', 'secret_type': 'ceph',
'name': u'volumes/volume-823dfaa9-a41c-4df7-a165-30db20b5b1c7', 'discard': True, 'keyring': None,
'cluster_name': 'ceph', 'hosts': [u'172.16.1.17'], 'auth_enabled': True, 'ports': [u'6789']
{{(pid=9947) initialize_connection /opt/stack/cinder/cinder/volume/drivers/rbd.py:1252
|
|
Jun 27 15:34:09 controller cinder-volume[9796]: INFO cinder.volume.manager
[req-c9184b0e-2cb3-4549-bb6b-cf0482f682bf req-27aba675-b7ad-4ca0-bc5e-2678211ebe8c admin None] attachment_update completed successfully.
|
连接信息更新完毕
|
- 查看nova-compute日志:
- 通过curl请求获得volume。REQ是request,RESP是response。
|
|
Jun 27 15:34:06 controller nova-compute[7060]: INFO nova.compute.manager
[None req-c9184b0e-2cb3-4549-bb6b-cf0482f682bf admin admin]
[instance: f092dfe4-365b-4dd6-8867-76a311399782] Attaching volume 823dfaa9-a41c-4df7-a165-30db20b5b1c7 to /dev/vdb
|
|
Jun 27 15:34:06 controller nova-compute[7060]: DEBUG cinderclient.v3.client
[None req-c9184b0e-2cb3-4549-bb6b-cf0482f682bf admin admin] REQ: curl -g -i -X GET http://172.16.1.17/volume/v3/c1e57b427f934cadbe32750b1b8ccfd8/ volumes/823dfaa9-a41c-4df7-a165-30db20b5b1c7 -H "OpenStack-API-Version: volume 3.48" -H "User-Agent: python-cinderclient" -H "X-OpenStack-Request-ID: req-c9184b0e-2cb3-4549-bb6b-cf0482f682bf" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}7b8f6c716bfad9dcabf83a44913184ec49384e88"
{{(pid=7060) _http_log_request /usr/local/lib/python2.7/dist-packages/keystoneauth1/session.py:372
|
-g:--globoff Disable URL sequences and ranges using {} and []
-i:--include Include protocol headers in the output
-X:--request COMMAND Specify request command to use
-H:--header LINE Pass custom header LINE to server
1
2
3
4
5
6
7
8
9
10
11
12
13
|
Jun 27 15:34:06 controller nova-compute[7060]: RESP BODY: {"volume": {"migration_status": null, "provider_id": null, "attachments": [],
"links": [{"href": "http://172.16.1.17/volume/v3/c1e57b427f934cadbe32750b1b8ccfd8/ volumes/823dfaa9-a41c-4df7-a165-30db20b5b1c7", "rel": "self"}, {"href": "http://172.16.1.17/
volume/c1e57b427f934cadbe32750b1b8ccfd8/volumes/823dfaa9-a41c-4df7-a165-30db20b5b1c7", "rel": "bookmark"}]
, "availability_zone": "nova", "os-vol-host-attr:host": "controller@ceph#ceph", "encrypted": false, "updated_at":
"2019-06-27T07:34:06.000000", "replication_status": null, "snapshot_id": null, "id":
"823dfaa9-a41c-4df7-a165-30db20b5b1c7", "size": 1, "user_id": "7a2243af10174653931f76c748209551",
"os-vol-tenant-attr:tenant_id": "c1e57b427f934cadbe32750b1b8ccfd8", "os-vol-mig-status-attr:migstat": null,
"metadata": {}, "status": "reserved", "description": "", "multiattach": false,
"service_uuid": "a01f1424-3912-4b36-88e0-7fd8e1d5310a", "source_volid": null, "consistencygroup_id": null,
"os-vol-mig-status-attr:name_id": null, "name": "vol-1", "bootable": "false",
"created_at": "2019-06-27T07:31:09.000000", "volume_type": "ceph", "group_id": null, "shared_targets": false
|
|
- 通过curl请求建立attachment。REQ是request,RESP是response。
|
1
2
3
4
5
6
7
8
9
10
11
12
|
Jun 27 15:34:08 controller nova-compute[7060]: DEBUG cinderclient.v3.client
[None req-c9184b0e-2cb3-4549-bb6b-cf0482f682bf admin admin] REQ: curl -g -i -X PUT http://172.16.1.17/volume/v3/c1e57b427f934cadbe32750b1b8ccfd8/attachments/ b030252b-a04d-4cc7-b682-b3a38c1e8937 -H "Accept: application/json" -H "User-Agent: python-cinderclient" -H "OpenStack-API-Version: volume 3.44" -H "X-Auth-Token: {SHA1}7b8f6c716bfad9dcabf83a44913184ec49384e88" -H "Content-Type: application/json" -H "X-OpenStack-Request-ID: req-c9184b0e-2cb3-4549-bb6b-cf0482f682bf" -d '{"attachment": {"connector": {"initiator": "iqn.1993-08.org.debian:01:f3f9353d3735", "ip": "172.16.1.17", "platform": "x86_64", "host": "controller", "do_local_attach": false, "mountpoint": "/dev/vdb", "os_type": "linux2", "multipath": false}'
{{(pid=7060) _http_log_request /usr/local/lib/python2.7/dist-packages/keystoneauth1/session.py:372
|
|
Jun 27 15:34:09 controller nova-compute[7060]: RESP BODY: {"attachment": {"status": "reserved", "detached_at": "", "connection_info":
{"attachment_id": "b030252b-a04d-4cc7-b682-b3a38c1e8937", "encrypted": false, "driver_volume_type":
"rbd", "secret_uuid": "df0d0b60-047a-45f5-b5be-f7d2b4beadee", "qos_specs": null,
"volume_id": "823dfaa9-a41c-4df7-a165-30db20b5b1c7", "auth_username": "cinder", "secret_type": "ceph",
"name": "volumes/volume-823dfaa9-a41c-4df7-a165-30db20b5b1c7", "discard": true, "keyring": null,
"cluster_name": "ceph", "auth_enabled": true, "hosts": ["172.16.1.17"], "access_mode": "rw",
"ports": ["6789"]}, "attached_at": "", "attach_mode": null, "instance": "f092dfe4-365b-4dd6-8867-76a311399782",
"volume_id": "823dfaa9-a41c-4df7-a165-30db20b5b1c7", "id": "b030252b-a04d-4cc7-b682-b3a38c1e8937"
|
|
- 更新 instance 的 XML 配置文件,将 volume 文件映射给 instance。
- 新增的磁盘格式为network,因为在volumes存储池中可以查到对应对象文件
- 启动盘对应的也是network,因为在vms存储池可以查到对应的镜像对象文件
- 对象文件包含三部分:标识符,二进制数据,名字/值
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
Jun 27 15:34:09 controller nova-compute[7060]: DEBUG nova.virt.libvirt.guest
[None req-c9184b0e-2cb3-4549-bb6b-cf0482f682bf admin admin] attach device xml: <disk type="network" device="disk"> <driver name="qemu" type="raw" cache="writeback" discard="unmap"/> <source protocol="rbd" name="volumes/volume-823dfaa9-a41c-4df7-a165-30db20b5b1c7"> <host name="172.16.1.17" port="6789"/> </source> <auth username="cinder"> <secret type="ceph" uuid="df0d0b60-047a-45f5-b5be-f7d2b4beadee"/> </auth> <target bus="virtio" dev="vdb"/> <serial>823dfaa9-a41c-4df7-a165-30db20b5b1c7</serial> </disk> {{(pid=7060) attach_device /opt/stack/nova/nova/virt/libvirt/guest.py:305
|
root@controller:~# vim /etc/libvirt/qemu/instance-00000001.xml
|
|
|