kvm 虚拟机 实用工具笔记(方便查看ip 磁盘复制和修改文件等)
kvm 實用工具總結(jié):
1. libguestfs-tools
直接宿主機安裝:
yum -y install libguestfs-tools
virt-df xxx 相當(dāng)于df命令
virt-cat xxx 相當(dāng)遠cat命令
virt-edit xxx 相當(dāng)于vi命令
virt-ls xxx ?相當(dāng)于ls命令
參考:http://www.361way.com/kvm-libguestfs-tools/3175.html
2. qemu-guest-agent centos7.1
如果虛擬機可以關(guān)閉:
?virsh shutdown rhel7
?virsh edit rhel7
?在device段增加:
?<channel type='unix'>
? ?<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
保存退出
virsh start rhel7
?
在虛擬機中安裝:
yum install qemu-guest-agent
systemctl start qemu-guest-agent
在運行的虛擬機中:
vi agent.xml
<channel type='unix'>
? ? ? ? <source mode='bind' path='/tmp/centos7-1.0'/>
? ? ? ? <target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
將配置粘貼到虛擬機文件
virsh attach-device rhel7 agent.xml
若出現(xiàn)如下錯誤:
[root@liulianex2 qemu]# virsh attach-device centos7rediscache agent.xml?
錯誤:從 agent.xml 獲得設(shè)備失敗
錯誤:internal error: no virtio-serial controllers are available
原因:virtio-serial設(shè)備每天添加
解決:
? ? 注意:
? ? <channel type='spicevmc'>
? ? ? ? ? <target type='virtio' name='com.redhat.spice.0'/>
? ? ? ? ? <address type='virtio-serial' controller='0' bus='0' port='1'/>
? ? ? ? </channel>
? ? ? ? 在input之前增加上面的內(nèi)容
? ? ? ? ###<input type='mouse' bus='ps2'/>
? ? ? ??
? ? ?<controller type='virtio-serial' index='0'>
? ? ? ? ? <address type='pci' domain='0x0000' bus='0x01' slot='0x05' function='0x0'/>
? ? ? ? </controller>
? ? ? ? 在bridge之前增加上面的內(nèi)容:
? ? ? ?## <interface type='bridge'>
在虛擬機中安裝:
yum install qemu-guest-agent
systemctl start qemu-guest-agent
執(zhí)行命令檢測:
修改虛擬機密碼:
virsh set-user-password ?LL_WEBccc3294b02 --user root --password 123
查看網(wǎng)卡信息:
virsh domifaddr LL_WEBccc3294b02 --source agent
####
?Name ? ? ? MAC address ? ? ? ? ?Protocol ? ? Address
-------------------------------------------------------------------------------
?lo ? ? ? ? 00:00:00:00:00:00 ? ?ipv4 ? ? ? ? 127.0.0.1/8
?- ? ? ? ? ?- ? ? ? ? ? ? ? ? ? ?ipv6 ? ? ? ? ::1/128
?ens3 ? ? ? 22:66:0f:56:f2:3f ? ?ipv4 ? ? ? ? 172.16.88.192/24
?- ? ? ? ? ?- ? ? ? ? ? ? ? ? ? ?ipv6 ? ? ? ? fe80::2066:fff:fe56:f23f/64
參考文件:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Deployment_and_Administration_Guide/chap-QEMU_Guest_Agent.html
本文轉(zhuǎn)自 ?674591788 ?51CTO博客,原文鏈接:http://blog.51cto.com/mrdeng/1919600
總結(jié)
以上是生活随笔為你收集整理的kvm 虚拟机 实用工具笔记(方便查看ip 磁盘复制和修改文件等)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 优化语句
- 下一篇: tcpwrapper的使用方法