2021년 10월 15일 금요일

OpenStack backend 스토리지로 Ceph 사용하기

전제 조건

  • 오픈스택이 이미 구성되어 있음
  • Ceph 클러스터도 이미 구성되어 있음

ceph 노드 수정

  • ceph node 들의 hosts 파일에 openstack 노드 정보 입력
# vi /etc/hosts 10.10.10.74 cont30.mytec.com cont30 10.10.10.77 comp1.mytec.com comp1 10.10.10.78 comp2.mytec.com comp2

openstack 을 위한 pool 생성

  • cinder, glance 를 위한 pool 생성
    • ceph admin node 에서 실행
ceph osd pool create volumes ceph osd pool create images ceph osd pool create backups ceph osd pool create vms
  • rbd tool 을 사용해서 pool 들을 initialize 함
    • 새로 생성된 pool 들은 사용하기 전에 initialize 되어야 함
rbd pool init volumes rbd pool init images rbd pool init backups rbd pool init vms

openstack ceph clients 환경 설정

  • glance-api, cinder-volume, nova-compute, cinder-backup 를 실행하는 노드들은 Ceph client 로 동작해야 함
  • 따라서 ceph.conf 파일이 필요함
    • 각 노드에서 아래 실행
for NODE in comp1 comp2 cont30 do scp /etc/ceph/ceph.conf $NODE:/etc/ceph/ done
  • ceph client 패키지 설치

    • glance-api 노드에서 python-rbd 설치
    sudo yum install python-rbd
    • nova-compute, cinder-backup, cinder-volume node 에서 ceph-common 설치
    sudo yum install ceph-common

Setup Ceph Client Authentication

ceph auth get-or-create client.glance mon 'profile rbd' osd 'profile rbd pool=images' mgr 'profile rbd pool=images' ceph auth get-or-create client.cinder mon 'profile rbd' osd 'profile rbd pool=volumes, profile rbd pool=vms, profile rbd-read-only pool=images' mgr 'profile rbd pool=volumes, profile rbd pool=vms' ceph auth get-or-create client.cinder-backup mon 'profile rbd' osd 'profile rbd pool=backups' mgr 'profile rbd pool=backups'
  • client.cinder, client.glance, client.cinder-backup 용 keyring 를 필요로 하는 오픈스택 노드에 추가하고 owernership 변경함
    • ceph admin 노드에서 실행
# cont30 is openstack controller node ceph auth get-or-create client.glance | ssh cont30 sudo tee /etc/ceph/ceph.client.glance.keyring ssh cont30 sudo chown glance:glance /etc/ceph/ceph.client.glance.keyring ceph auth get-or-create client.cinder | ssh cont30 sudo tee /etc/ceph/ceph.client.cinder.keyring ssh cont30 sudo chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring ceph auth get-or-create client.cinder-backup | ssh cont30 sudo tee /etc/ceph/ceph.client.cinder-backup.keyring ssh cont30 sudo chown cinder:cinder /etc/ceph/ceph.client.cinder-backup.keyring
  • nova-compute 노드에서 필요로 하는 keyring 파일 전달
ceph auth get-or-create client.cinder | ssh comp1 sudo tee /etc/ceph/ceph.client.cinder.keyring ceph auth get-or-create client.cinder | ssh comp2 sudo tee /etc/ceph/ceph.client.cinder.keyring
  • 오픈스택 노드에 대해 secret key 에 대한 임시 카피본 생성
# cont30: controller node, comp1, 2: compute node ceph auth get-key client.cinder | ssh cont30 tee client.cinder.key ceph auth get-key client.cinder | ssh comp1 tee client.cinder.key ceph auth get-key client.cinder | ssh comp2 tee client.cinder.key
  • compute 노드에서 secret 키를 libvirt 에 추가하고 임시 카피본 삭제함
    • 각 compute 노드에서 실행함
    • uuidgen 으로 나온 값은 하나만 가지고 계속 사용해야 하므로 잘 기록해둘 것
# uuidgen 66263415-483a-4450-bd89-a0c036fb8f8c cat > secret.xml <<EOF <secret ephemeral='no' private='no'> <uuid>66263415-483a-4450-bd89-a0c036fb8f8c</uuid> <usage type='ceph'> <name>client.cinder secret</name> </usage> </secret> EOF # sudo virsh secret-define --file secret.xml Secret 457eb676-33da-42ec-9a8c-9293d545c337 created # sudo virsh secret-set-value --secret 66263415-483a-4450-bd89-a0c036fb8f8c --base64 $(cat client.cinder.key) && rm client.cinder.key secret.xml

Ceph 을 사용하기 위해 오픈스택 구성하기

  • Glance 환경 설정
    • Glance 는 이미지들을 저정하기 위해 멀티 backend 를 사용할 수 있음
    • Ceph block 디바이스를 디폴트로 사용하기 위해 glance 를 아래와 같이 수정함
# 컨트롤러 노드의 ceph.conf 를 수정해야 함 # vi /etc/ceph/ceph.conf [client.glance] keyring = /etc/ceph/ceph.client.glance.keyring
  • /etc/glance/glance-api.conf 열어서 아래와 같이 [glance_store] section 추가
[glance_store] stores = rbd default_store = rbd rbd_store_pool = images rbd_store_user = glance rbd_store_ceph_conf = /etc/ceph/ceph.conf rbd_store_chunk_size = 8
  • glance 에 있는 image 들의 copy-on-write cloning 을 사용고자 한다면, glance-api.conf 의 [DEFAULT] section 에서 아래 항목 추가
show_image_direct_url = True
  • Cache management 비활성화
    • Disable the Glance cache management to avoid images getting cached under /var/lib/glance/image-cache/
      • flavor = keystone+cachemanagement 로 되어있다면 아래와 같이 변경함
[paste_deploy] flavor = keystone
  • cinder 노드 환경 설정
    • openstack 이 Ceph block device 를 사용하기 위해서는 driver 가 필요함
    • 또한 이 block device 를 위한 pool name 도 지정해야 함
    • 따라서 오픈스택 cinder 노드에서 아래와 같이 /etc/cinder/cinder.conf 를 수정해야 함
[DEFAULT] ... enabled_backends = ceph glance_api_version = 2 ... [ceph] volume_driver = cinder.volume.drivers.rbd.RBDDriver volume_backend_name = ceph rbd_pool = volumes rbd_ceph_conf = /etc/ceph/ceph.conf rbd_flatten_volume_from_snapshot = false rbd_max_clone_depth = 5 rbd_store_chunk_size = 4 rados_connect_timeout = -1 rbd_user = cinder rbd_secret_uuid = 66263415-483a-4450-bd89-a0c036fb8f8c
  • cinder backup 노드 환경 설정
    • cinder backup 노드에서 /etc/cinder/cinder.conf 를 아래와 같이 수정
backup_driver = cinder.backup.drivers.ceph.CephBackupDriver backup_ceph_conf = /etc/ceph/ceph.conf backup_ceph_user = cinder-backup backup_ceph_chunk_size = 134217728 backup_ceph_pool = backups backup_ceph_stripe_unit = 0 backup_ceph_stripe_count = 0 restore_discard_excess_bytes = true
  • ceph rbd block device 를 attach 하기 위한 nova 노드 환경 설정
    • cinder 디바이스를 붙이기 위해 nova 하고 libvirt 에게 user, uuid 정보를 알려주어야 함
    • 이 정보를 이용해서 ceph cluster 와 통신함
      • /etc/nova/nova.conf 수정
[libvirt] ... rbd_user = cinder rbd_secret_uuid = 66263415-483a-4450-bd89-a0c036fb8f8c
  • nova 환경 설정

    • To enable RBD cache and admin sockets, ensure that on each hypervisor’s ceph.conf contains:
    • RBD cache 와 admin socket 활성화를 위해 ceph.conf 수정 (모든 compute node)
    [client] rbd cache = true rbd cache writethrough until flush = true admin socket = /var/run/ceph/guests/$cluster-$type.$id.$pid.$cctid.asok log file = /var/log/qemu/qemu-guest-$pid.log rbd concurrent management ops = 20
    • 디렉토리 권한 설정
mkdir -p /var/run/ceph/guests/ /var/log/qemu/ chown qemu:libvirtd /var/run/ceph/guests /var/log/qemu/ 위 명령 에러나면 아래로 변경 chown qemu:libvirt /var/run/ceph/guests /var/log/qemu/
  • 오픈스택 재시작
    • Ceph block 디바이스 드라이버를 활성화시키고 block device pool 을 사용하기 위해 관련된 오픈스택 데몬들을 재시작 해야 함

(모든 노드, 없는 서비스는 알아서 에러 날 것이나 무시하면 됨)

sudo service openstack-glance-api restart sudo service openstack-nova-compute restart sudo service openstack-cinder-volume restart sudo service openstack-cinder-backup restart

openstack 으로 ceph 테스트 하기

  • ceph 테스트로 사용할 이미지 생성
    • cirros 이미지는 검색하면 다 나옴
cirros-0.5.2-x86_64-disk.img 다운로드 아래 명령어 실행하기 전에 source keystonerc_admin 식의 명령어 실행으로 openstack 환경 sourcing 해야 함 # openstack image create --disk-format qcow2 --container-format bare --public --file cirros-0.5.2-x86_64-disk.img cirros2
  • 오픈스택 접속해서 위에서 만든 이미지 가지고 VM 생성 시도

    • 에러 나는 경우, cinder.conf 의 default_volume_type 을 ceph 으로 변경하고 cinder 서비스 재시작 하고 아래 명령어 실행
    sudo service openstack-cinder-api restart # openstack volume type create ceph # openstack volume type set --property volume_backend_name=ceph ceph # 아래 명령어 결과에서 ceph 정보가 있는지 확인 # cinder type-default # cinder type-list # cinder extra-specs-list
    • 위와 같이 해도 인스턴스 생성 에러 발생할 경우, 볼륨 생성만 따로 해보던지 해서 문제를 좁힘
    • nova log 나 cinder log 보고 인증 쪽 오류이면 위의 key 생성을 관련 호스트들에 대해서 제대로 했는지 확인

댓글 없음:

댓글 쓰기