[原]一些KVM测试过程中的命令笔记(2)分配实例
一.为其他组分配instances:
1.进入192.168.77.51
2.如下操作:
查看images:
euca-describe-images
查看类型;
sudo nova-manage flavor list
选择类型并启动instances:
euca-run-instances ami-00000014 -t m1.hcType
获取地址:
euca-allocate-address
分配地址:
euca-associate-address -i i-000000c8 192.168.77.241
查看instance:
euca-describe-instances | grep 192.168.77.241
进入所在computer,查看VNC端口
ps -ef|grep instances | grep c8
VNC进入,修改防火墙和远程链接,重启instances:
euca-reboot-instances i-000000c8
------------------------------------------------
上传模板:
glance add name="foranybackup" is_public=true < /home/testcloud/win-2003-x86_64.img --host=192.168.77.109
------------------------------------------------
卷相关:
sudo pvs
sudo vgs
sudo lvs
euca-describe-volumes
euca-attach-volume -i i-00000081 -d /dev/vdc vol-00000017
------------------------------------------------
自定义instance类型:
sudo nova-manage flavor create --name=m1.Hao500G --memory=8192 --cpu=8 --local_gb=500 --flavor=16 --swap=0 --rxtx_quota=0 --rxtx_cap=0
sudo nova-manage flavor create --name=m1.hcXCF --memory=4096 --cpu=2 --local_gb=50 --flavor=20 --swap=0 --rxtx_quota=0 --rxtx_cap=0
------------------------------------------------
直接使用img启动虚拟机:
创建镜像:sudo kvm-img create -f qcow2 RHEL6_x86_64.img 20G
sudo kvm -m 2048 -cdrom rhel-server-6.0-x86_64-dvd.iso -drive file=RHEL6_x86_64.img,if=virtio,index=0,boot=on -boot d -net nic -net user -nographic -vnc :25
sudo kvm -m 2048 -drive file=***.img -boot c -usbdevice tablet -nographic -vnc :*
------------------------------------------------
指定compute节点所在机器
nova-manange service disable dev-compute* nova-compute
------------------------------------------------
多节点出现问题时候解决办法:(重装nova-computer服务)
sudo apt-get autoremove nova-compute
sudo apt-get install -y nova-compute
virsh list
sudo service nova-compute restart
sudo service nova-compute start
sudo service nova-compute restart
virsh list
sudo apt-get autoremove nova-compute
sudo apt-get install -y nova-compute
euca-describe-availability-zones verbose
virsh list
----------------------------------------------
sudo kvm -m 2048 -drive file=win-2003-x86_64.img -boot c -usbdevice tablet -nographic -vnc :65
euca-attach-volume -i i-000000f0 -d /dev/vdc vol-00000025
----------------------------------------------
配置网桥
brctl addbr br0
brctl addif br0 eth0
增加网桥:
ifconfig eth0 0.0.0.0 up
ifconfig eth1 0.0.0.0 up
ifconfig eth0 0.0.0.0 promisc
ifconfig eth1 0.0.0.0 promisc
brctl addif br0 eth0 eth1
brctl show
ifconfig br0 10.10.1.1 netmask 255.255.0.0 up
删除网桥接口:
brctl delif br0 eth0 eth1
删除网桥:
brctl delbr br0
关闭生成树:
brctl stp br0 off
----------------------------------------------
1、创建网桥设备 br0: brctl addbr br0
2、向br0中添加网卡 eth0 eth1
brctl addif eth0
brctl addif eth1
3、从网桥中删除网卡 eth0 eth1
brctl delif eth0
brctl delif eth1
4、删除网桥 br0 :
brctl delbr br0
在网桥上设置ip地址的命令:
ifconfig br0 xxx.xxx.xx.xxx netmask 255.255.xxx.xxx broadcast xxx.xxx.xx.xx
----------------------------------------------
添加磁盘:
1. 硬件
2. sudo fdisk -l
3. fdisk /dev/sdb (对新添加的硬盘(裸盘)做格式化:)
3. pvcreate /dev/sdc1 ( 建PV 前一步fdisk -l的设备名)
4. vgcreate vg_compute7RHEL6 /dev/sdb4 (建vg,前者为vg名,后者为设备名)
vgextend vg_compute3rhel6 /dev/sdc1 (建vg vg名 卷名)
5. 创建lv:
[root@compute7RHEL6 testcloud]# vgdisplay vg_compute7RHEL6 | grep "Total PE"
Total PE 119102
[root@compute7RHEL6 testcloud]# lvcreate -l 119102 vg_compute7RHEL6 -n lv1_hc
Logical volume "lv1_hc" created
6. lvextend /dev/mapper/vg_compute3rhel6-LogVol01 /dev/sdc1 (分区名[由df-lh得出] 卷名)
附:帮助信息:
[root@compute7RHEL6 testcloud]# vgcreate --help
vgcreate: Create a volume group
vgcreate
[-A|--autobackup {y|n}]
[--addtag Tag]
[--alloc AllocationPolicy]
[-c|--clustered {y|n}]
[-d|--debug]
[-h|--help]
[-l|--maxlogicalvolumes MaxLogicalVolumes]
[-M|--metadatatype 1|2]
[--[vg]metadatacopies #copies]
[-p|--maxphysicalvolumes MaxPhysicalVolumes]
[-s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE]]
[-t|--test]
[-v|--verbose]
[--version]
[ PHYSICAL DEVICE OPTIONS ]
VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]
kvm --version
uname -a
cat /etc/lsb-release
euca-describe-instances | grep computer4
euca-describe-instances | grep compute4
euca-describe-instances | grep 10.0.2.149
ll
source creds/novarc
sudo pvs
euca-create-volume
euca-create-volume --help
euca-create-volume -z nova -s 500g
euca-create-volume -z nova -s 500
euca-describe-volumes vol-00000026
su
euca-describe-volumes
source kvm/novarc
euca-create-volume -z nova -s 500
euca-describe-volumes vol-00000027
euca-create-volume -z nova -s 500g
euca-create-volume -z nova -s 500
euca-describe-volumes
su
sudo service nova-volume restart
euca-describe-volumes
euca-create-volume -z nova -s 50
euca-describe-volumes
euca-create-volume -z nova -s 50
euca-describe-volumes
euca-create-volume -z nova -s 500
euca-describe-volumes
euca-describe-images
euca-describe-volumes
sudo nova-manage flavor list
euca-run-instances ami-00000014 -t m1.Hao500G
euca-describe-instances | grep i-00000107
euca-reboot-instances i-00000107
euca-describe-instances | grep i-00000107
euca-describe-addresses | grep None
euca-allocate-address -i i-00000107 192.168.77.221
euca-associate-address -i i-00000107 192.168.77.221
euca-describe-instances | grep i-00000107
euca-describe-instances | grep 242
exit
history
内存:
cat /proc/meminfo
dmesg|grep -i ^mem
free -m
启动实例:euca-run-instances ami-00000017 -t m1.hcXCF
启动nova-compute服务
sudo nova-manage service enable dev-compute1 nova-compute
停止指定机器的nova-compute
sudo nova-manage service disable dev-compute4 nova-compute
euca-describe-availability-zones verbose
sudo apt-get autoremove nova-compute
sudo apt-get install -y nova-compute
virsh list
euca-describe-availability-zones verbose
sudo service nova-compute restart
---------------调整kvm 扩大quota--------------
sudo nova-manage project quota --project=kvm
sudo nova-manage project quota --project=kvm --key=instances --value=640
sudo nova-manage project quota --project=kvm --key=gigabytes --value=32768
sudo nova-manage project quota --project=kvm --key=cores --value=2560
sudo nova-manage project quota --project=kvm --key=floating_ips --value=640
sudo nova-manage project quota --project=kvm --key=metadata_items --value=1024
sudo nova-manage project quota --project=kvm --key=injected_file_content_bytes --value=40960
sudo nova-manage project quota --project=kvm --key=injected_files --value=30
sudo nova-manage project quota --project=kvm --key=volume --value=80
sudo nova-manage project quota --project=kvm --key=injected_files --value=100
![](http://files.cnblogs.com/files/haochuang/alipay-RedEnvelopes.bmp)
赠人玫瑰
手留余香
我们曾如此渴望命运的波澜,到最后才发现:人生最曼妙的风景,竟是内心的淡定与从容……我们曾如此期盼外界的认可,到最后才知道:世界是自己的,与他人毫无关系!-杨绛先生
如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的