달력

112024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

### 실행중인 VM 리스트 확인 ###
[root@kvmsvr ~]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 10    cluster1                       running
 13    cluster2                       running
 14    cluster3                       running
 15    cluster4                       running
 -     vm1                            shut off


[root@kvmsvr ~]# virsh console 14
exit -> Ctrl + ] or Ctrl + 5     

### 실행 중 VM 종료 및 리부팅 ###
- 실행 중인 VM shutdown
# virsh list
# virsh shutdown <vm_name>
# virsh shutdown desktop_xp1
# virsh shutdown 7

- 실행 중인 VM reboot
# virsh list
# virsh reboot <vm_name>
# virsh reboot desktop_xp4
# virsh reboot 10

- 실행 중인 VM 강제 종료하기
# virsh list
# virsh destroy <vm_name>

### KVM 이미지 백업 ###
qemu-img convert -c -O qcow2 Window_server_2003.qcow2 Window_server_2003.qcow2.20151228

### VM 상태 정보 확인 ###
[root@kvmsvr VM_IMG]# virsh list
 Id    이름                         상태
----------------------------------------------------
 3     DNS                            실행중
 5     CRM                           실행중
 6     server1                        실행중


[root@kvmsvr VM_IMG]# virsh domblklist 24
Target     Source
------------------------------------------------
vda        /home/VM_IMG/semusarang.img
vdb        /home/VM_IMG/semudata.img
hda        /home/iso/ko_windows_7_X86+x64_Ultimate_with_sp1_IE9_Hotfix_2012.iso
hdc        /usr/share/virtio-win/virtio-win-1.iso

[root@kvmsvr VM_IMG]# virsh list --all
 Id    이름                         상태
----------------------------------------------------
 3     DNS                            실행중
 5     CRM                   실행중
 6     server1                        실행중
 -     Window_server_2003             종료
 -     winXP                          종료

[root@kvmsvr VM_IMG]# virsh domblklist Window_server_2003
Target     Source
------------------------------------------------
hda        /home/VM_IMG/Window_server_2003.img
hdb        -

### VM Shutdown ###
[root@kvmsvr VM_IMG]# virsh list
 Id    이름                         상태
----------------------------------------------------
 3     DNS                            실행중
 5     CRM                           실행중
 6     server1                        실행중

[root@kvmsvr VM_IMG]# virsh shutdown 3
[root@kvmsvr VM_IMG]# virsh destroy 3    // 강제종료

### VM 리소스 정보 확인 ###
# virsh list  // 리스트 확인
# virsh list
Id    Name                           State
----------------------------------------------------
82    iscsi-server                   running
101   rhel7-cs2                      running
104   rhel7-cs1                      running

# virsh dominfo

# virsh dominfo 170
Id:             170
Name:           kweb3
UUID:           6afa6e09-b525-403c-9da9-4ca9ecf0c78d
OS Type:        hvm
State:          running
CPU(s):         2                  << CPU 수 확인
CPU time:       16546
Max memory:     2097152 KiB
Used memory:    2097152 KiB   << Memory 확인
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: none
Security DOI:   0


### KVM 환경 Disk 추가 방법 ###
- 파일
# virsh attach-disk nfvd-ff1 --source /VM/add-disk.img --target vdb --persistent

- Block device
# virsh attach-disk nfvd-ff1 --source /dev/NFVO/ff1 --target vdb --persistent

### Disk Type VirtIO / IDE 차이 및 변경 방법 ###
- virtIO는 다른 disk에 비해  I/O가 빠릅니다
- IDE는 I/O는 떨어지지만 다른 시스템과 호환성이 뛰어납니다

< KVM IDE에서 virtIO로 변경하는 방법 >
1) vm OS 종료
2) # systemctl stop libvirtd
3) # vi /etc/libvirt/qemu/rhel7.xml

### 수정 전 < 현재 상태 >
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/DATA/rhel7.cow2'/>
      <target dev='hda' bus='ide'/>  ← 수정
     <address type='drive' controller='0' bus='0' target='0' unit='0' />  ← 삭제
    </disk>

### 수정 후
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/DATA/rhel7.qcow2'/>
      <target dev='hda' bus='virtio'/>
    </disk>

4. # systemctl start libvirtd
5. # systemctl enable libvirtd
5. # virt-manager
6. vm OS 실행

### KVM 이미지 백업(img+xml) ###
1. img 파일 백업(KVM 구성 시 지정한 디렉토리)
2. 각 VM별 xml 파일 백업(/etc/libvirt/qemu)
3. 신규로 사용할 서버의 각각 위치에 img 파일 복구 / xml 파일 복구


### KVM 이미지 클론(복사) ###
virt-clone --original=[원래 있던 VM 이름] --name=[새로 만들 VM 이름] -f [생성할 img 파일 위치] --mac [랜카드 맥주소]
# virt-clone --original=testvm1 --name=newvm -f /var/lib/libvirt/images/skylit_newvm.img --mac 00:12:34:56:78:90

Posted by 짜꾸미의골골몽
|