배경

배경

(CentOS 7, Ceph Incunabulus, 모두 최신으로 패치되었습니다)

배경

인증을 위해 cephx가 활성화되어 작동하는 통합 Ceph/qemu/kvm 클러스터가 있습니다. 저는 이것을 qemu/kvm 가상 머신용 블록 장치를 저장하는 데 사용하려고 합니다. 이는 드문 구성이 아닙니다. ceph에서 가상 디스크용 풀을 설정하고 libvirt에서 풀을 정의하고 인증한 다음 풀을 사용하여 가상 머신을 생성하고 싶습니다. 모든 튜토리얼과 예제는 각 디스크 파일에서 직접 cephx 인증을 설정하는 것을 보여줍니다. 이제 나는 그 이유를 이해하기 시작했습니다!

질문

다음을 시도하면 qemu-kvm이 구성된 대로 통과하는 것 같지만 file=rbd:vmlive/testguest-vda:auth_supported=none어떤 auth_supported=cephx이유로든 발생하지 않습니다.

필요에 따라 모든 인증을 풀에 넣을 수 있나요? 아니면 인증 부분을 각 가상 디스크의 XML에 넣어야 하나요? 이렇게 할 수 있다면 아래 오류는 어디에 있습니까?

내가 지금 뭘하려고 하는 거지?

문맥

test1과 test2라는 두 개의 노드가 있습니다. 각각에는 2개의 OSD가 있고 각각은 모니터이기도 합니다(예, 짝수 개의 모니터로 실행하는 것은 좋지 않은 생각입니다). 각각에는 libvirt가 설치되어 있으므로 qemu/kvm이 있습니다. test1에서 루트로 다음 명령을 실행했습니다. UUID가 변경되었으며 아래에 키가 표시되지 않은 것을 볼 수 있습니다!

Ceph 풀 및 client.kvm 사용자 생성

SENSIBLE_PGS=512 # Calculate as OSDs * 100 / number of replicas, rounded up to next power of 2
ID=kvm
POOL=vmlive
ceph osd pool create $POOL $SENSIBLE_PGS $SENSIBLE_PGS
KEY=`ceph auth get-or-create client.$ID | grep -v '^\[' | awk '{print $3}'`
ceph auth caps client.$ID mon "allow r" osd "allow rwx pool=$POOL"

Ceph 사용자 키가 포함된 libvirt 키 생성

SECRET_DEFINITION_FILE=~/secret-$ID.xml
SECRET_UUID=12345678-1234-1234-1234-123456789abc
cat > $SECRET_DEFINITION_FILE << EOF
<secret ephemeral='no' private='no'>
  <uuid>$SECRET_UUID</uuid>
  <usage type='ceph'>
    <name>ceph client.$ID key</name>
  </usage>
</secret>
EOF
virsh secret-define --file $SECRET_DEFINITION_FILE
rm -f $SECRET_DEFINITION_FILE
virsh secret-set-value "$SECRET_UUID" "$KEY"

libvirt 스토리지 풀을 생성하고 cephx 인증을 사용해 보십시오.

POOL_DEFINITION_FILE=~/pool-$POOL.xml
cat > $POOL_DEFINITION_FILE << EOF
<pool type="rbd">
  <name>$POOL</name>
  <source>
    <name>$POOL</name>
    <host name="test1" port="6789" />
    <host name="test2" port="6789" />
    <auth username='$ID' type='ceph'>
      <secret uuid='$SECRET_UUID'/>
    </auth>
  </source>
</pool>
EOF
virsh pool-define $POOL_DEFINITION_FILE
rm -f $POOL_DEFINITION_FILE
virsh pool-autostart $POOL
virsh pool-start $POOL

virt-install을 사용하여 게스트 생성

NAME=testguest
DEV=vda
SIZE=8G
IMAGE=CentOS-7-x86_64-Minimal-1503-01.iso
VCPUS=1
RAM=512
MACLAST_HEX=10
IPLAST_DECIMAL=16

FILE=$NAME-$DEV
qemu-img create -f rbd rbd:$POOL/$FILE $SIZE
sudo virsh net-update default add-last ip-dhcp-host \
  --xml "<host mac='52:54:00:00:00:$MACLAST_HEX' ip='192.168.122.$IPLAST_DECIMAL' name='$NAME'/>" --live --config
sudo virt-install \
  --connect qemu:///system \
  --virt-type kvm \
  --name $NAME \
  --ram $RAM \
  --vcpus=$VCPUS \
  --disk vol=$POOL/$FILE \
  --location /var/lib/libvirt/images/$IMAGE \
  --vnc \
  --noautoconsole \
  --os-type linux \
  --os-variant rhel7 \
  --network=bridge:virbr0,model=virtio,mac=52:54:00:00:00:$MACLAST_HEX \
  --autostart

결과

WARNING  vmlive/testguest-vda may not be accessible by the hypervisor. You will need to grant the 'qemu' user search permissions for the following directories: ['vmlive', '']

Starting install...
Retrieving file .treeinfo...
Retrieving file vmlinuz...
Retrieving file initrd.img...
ERROR    internal error: process exited while connecting to monitor: 2016-01-06T15:16:54.639890Z qemu-kvm: -drive file=rbd:vmlive/testguest-vda:auth_supported=none:mon_host=test1\:6789,if=none,id=drive-virtio-disk0,format=raw: error connecting
2016-01-06T15:16:54.640574Z qemu-kvm: -drive file=rbd:vmlive/testguest-vda:auth_supported=none:mon_host=test1\:6789,if=none,id=drive-virtio-disk0,format=raw: could not open disk image rbd:vmlive/testguest-vda:auth_supported=none:mon_host=test1\:6789: Could not open 'rbd:vmlive/testguest-vda:auth_supported=none:mon_host=test1\:6789': Operation not supported

Domain installation does not appear to have been successful.

여기까지 읽으셨다면...감사합니다, 축하드립니다. 그리고 여러분이 받은 모든 도움에 감사드립니다!

업데이트 1

업데이트: 이는 virt-install이 풀을 부분적으로(완전히는 아님) 해결하는 문제인 것 같습니다. --print-xml디스크에 대해 생성된 부분 XML을 사용하는 경우 다음과 같습니다.

<disk type="network" device="disk">
  <driver name="qemu"/>
  <source protocol="rbd" name="vmlive/testguest-vda">
    <host name="test1" port="6789"/>
  </source>
  <target dev="vda" bus="virtio"/>
</disk>

...대부분의 풀 정의가 포함되어 있지만아니요축제 auth.

계속 조사하겠습니다.

답변1

말씀하신 대로 XML에는 auth섹션이 포함되어 있지 않기 때문에 도메인 설치가 실패하지만 auth섹션을 수동으로 추가할 수 있습니다 . 다음과 같이
편집하세요 ./usr/share/virt-manager/virtinst/guest.py

#vim /usr/share/virt-manager/virtinst/guest.py
import re
...
#define the auth 
auth_secret = '''
      <auth username='libvirt'>
        <secret type='ceph' uuid='e63e4b32-280e-4b00-982a-9d3xxxxxxx'/>
      </auth>
'''
ceph_monitors = '''
        <host name='172.16.200.104' port='6789'/>
        <host name='172.16.200.105' port='6789'/>
        <host name='172.16.200.106' port='6789'/>
'''

#change func: _build_xml 
    def _build_xml(self, is_initial):
        log_label = is_initial and "install" or "continue"
        disk_boot = not is_initial

        start_xml = self._get_install_xml(install=True, disk_boot=disk_boot)
        final_xml = self._get_install_xml(install=False)

#add------------start
        rgx_qemu = re.compile('(<driver name="qemu"[^>]*?>)')
        rgx_auth = re.compile('(?<=<source protocol="rbd" name=")([^>]*?">).*?(?= *?</source>)',re.S)

        start_xml = rgx_qemu.sub('\\1' + auth_secret,start_xml)
        start_xml = rgx_auth.sub('\\1' + ceph_monitors,start_xml)

        final_xml = rgx_qemu.sub('\\1' + auth_secret,final_xml)
        final_xml = rgx_auth.sub('\\1' + ceph_monitors,final_xml)
#add------------end

        logging.debug("Generated %s XML: %s",
                      log_label,
                      (start_xml and ("\n" + start_xml) or "None required"))
        logging.debug("Generated boot XML: \n%s", final_xml)

        return start_xml, final_xml

그런 다음 virt-install다시 실행하세요.

sudo virt-install \
  --connect qemu:///system \
  --virt-type kvm \
  --name $NAME \
  --ram $RAM \
  --vcpus=$VCPUS \
  --disk vol=$POOL/$FILE \
  --location /var/lib/libvirt/images/$IMAGE \
  --vnc \
  --noautoconsole \
  --os-type linux \
  --os-variant rhel7 \
  --network=bridge:virbr0,model=virtio,mac=52:54:00:00:00:$MACLAST_HEX \
  --autostart

추가 정보http://www.isjian.com/ceph/virt-install-create-vm-use-rbd-pool/

답변2

현재 접근 방식(virt-inst 3.1부터 여전히 손상됨):

  1. 다른 방법과 마찬가지로 비밀을 설정하세요.
  2. rbd를 사용하여 스토리지 풀을 만듭니다. XML은 다음과 같습니다.
 <pool type='rbd'>
 <name>volumes</name> <!-- libvirt pool name -->
 <source>
  <host name='10.1.1.1' port='6789'/>
  <host name='10.1.1.2' port='6789'/>
  <host name='10.1.1.3' port='6789'/>
  <name>volumes</name><!-- ceph pool name -->
  <auth type='ceph' username='hypervisor'>
    <secret uuid='ff831b04-65a6-4b1b-ae53-9318e65158e6'/>
  </auth>
</source>
</pool>

단순화를 위해 libvirt 및 ceph 풀 이름을 동일하게 유지하는 것이 좋습니다.

  1. 추가하세요(자동화하려면 XML을 복사 /etc/libvirt/storage하고 디렉터리에 링크를 만드는 것도 가능합니다. libvirtd를 다시 시작하면 됩니다)./autostart
virsh pool-define volumes.xml 
virsh pool-start volumes
  1. 그 시점부터는 옵션을 vol=poolname/volumename에 전달하여 간단히 지정할 수 있습니다 .--diskvirt-install

답변3

이는 현재 virt-manager의 알려진 버그입니다. 이메일 스레드를 참조하세요.https://www.redhat.com/archives/virt-tools-list/2016-January/msg00007.html.

그동안 저는 이 문제를 해결할 수 있는 다른 방법을 찾아보겠습니다.

관련 정보