Ceph block storage system to automatically mount the disk in a virtual application, boot

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/ck784101777/article/details/102755291

1.Ceph Cluster Setup

Ceph first need to build a clustered environment

https://blog.csdn.net/ck784101777/article/details/102744203

2. Create a disk image

  1. [root@node1 ~]# rbd create vm1-image --image-feature layering --size 10G
  2. [root@node1 ~]# rbd list
  3. vm1-image

3.Ceph authentication account (you can view only)

Ceph enabled by default user authentication, the client needs an account before they can access the default account name is client.admin, key is the key accounts.

Ceph auth can be used to add a new account (case we use the default account).

All content key behind all keys (also ==)

  1. [Root @ node1 ~] # cat /etc/ceph/ceph.client.admin.keyring // account file
  2. [client.admin]
  3.     key = AQBTsdRapUxBKRAANXtteNUyoEmQHveb75bISg==

4. Configure KVM virtual keys

Written account information file, let KVM know ceph account name.

According to to operate, you do not need to know the inside of principle

  1. [Root @ room9pc01 ~] # vim secret.xml # Create a temporary file, as follows
  2. <secret ephemeral='no' private='no'>
  3. <usage type='ceph'>
  4. <name>client.admin secret</name>
  5. </usage>
  6. </secret>
  7. [Root @ room9pc01 ~] # virsh secret-define secret.xml # XML configuration file to create secret
  8. # Command generates a random UUID, there is the UUID corresponding account information
  9. [Root @ room9pc01 ~] # virsh secret-list # View Secret Information
  10.  UUID                                            用量
    --------------------------------------------------------------------------------
     b0271913-79f9-4c73-be41-884dcc2383d1  ceph client.admin secret
  11. # Bind admin account to secret password, refer ceph.client.admin.keyring file.
  12. [root@room9pc01] virsh secret-set-value --secret 733f0fd1-e3d6-4c25-a69f-6681fc19802b \
  13. --base64 AQBTsdRapUxBKRAANXtteNUyoEmQHveb75bISg
  14. # Here is the secret behind the secret-fine step before UUID created
  15. # Base64 is behind the account password client.admin

 

5. modify the configuration file, the boot automatically mount

Profile marked red to make adjustments where needed

  1. [student @ room9pc01 ~] $ virsh list --all # View Virtual Machine
     Id Name Status
    ------------------------------- ---------------------
     . 1 ceph1 running
     2 ceph2 running
     . 3 ceph3 running
     . 4 Client running
     . 9 ansible running
     - Close Win2008
  2. [Root @ room9pc01] virsh destroy client # need to stop the virtual machine
  3. [Root @ room9pc01] virsh edit client #client virtual machine name, copy <disk> tag to the next content on a <disk> tag
  4. <disk type='network' device='disk'>
  5. <driver name='qemu' type='raw'/>
  6. <auth username='admin'>
  7. # View by virsh secret-list
  8. <secret type='ceph' uuid='b0271913-79f9-4c73-be41-884dcc2383d1'/>  
  9. </auth>
  10. #Ip address ip ceph node, any of which may, vm1-Image is the name I created a mirrored pool, by looking at the ceph, command rbd list
  11. <source protocol='rbd' name='rbd/vm1-image'> <host name='192.168.4.11' port='6789'/> </source> 
  12. # Here we must pay special attention to more than one disk disk configuration file, you must ensure that the name is not repeated here before
  13. <target dev='vdb' bus='virtio'/>
  14. </disk>

 

6. Power View

  1. [root@room9pc01] virsh start client
  2. [root@room9pc01] virsh console client
  3. [root@client] lsblk      
  4. NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  5. vda    253:0    0  30G  0 disk 
  6. └─vda1 253:1    0  30G  0 part /
  7. rbd0   252:0    0  15G  0 disk /mnt

Guess you like

Origin blog.csdn.net/ck784101777/article/details/102755291