How to troubleshoot openstack neutron?
neutron net-list
neutron router-list
neutron subnet-list
neutron port-list
ovs-vsctl show ip netns list
Monday, November 3, 2014
How to disable server on OpenStack-nova
[root@os-controller ~(keystone_admin)]# nova service-disable compute-0-3.local nova-compute
+-------------------+--------------+----------+
| Host | Binary | Status |
+-------------------+--------------+----------+
| compute-0-3.local | nova-compute | disabled |
+-------------------+--------------+----------+
[root@os-controller ~(keystone_admin)]# nova-manage service list
Binary Host Zone Status State Updated_At
nova-consoleauth os-controller.local internal enabled :-) 2014-07-21 09:45:47
nova-scheduler os-controller.local internal enabled :-) 2014-07-21 09:45:48
nova-conductor os-controller.local internal enabled :-) 2014-07-21 09:45:48
nova-cert os-controller.local internal enabled :-) 2014-07-21 09:45:51
nova-compute compute-0-3.local nova disabled XXX 2014-07-21 09:42:36
nova-compute compute-0-2.local nova enabled :-) 2014-07-21 09:45:47
nova-compute compute-0-1.local nova enabled :-) 2014-07-21 09:45:48
nova-compute compute-0-0.local nova enabled :-) 2014-07-21 09:45:47
nova-console os-controller.local internal enabled :-) 2014-07-21 09:45:55
[root@os-controller ~(keystone_admin)]#
[root@os-controller ~(keystone_admin)]# nova service-disable compute-0-3.local nova-compute
+-------------------+--------------+----------+
| Host | Binary | Status |
+-------------------+--------------+----------+
| compute-0-3.local | nova-compute | disabled |
+-------------------+--------------+----------+
[root@os-controller ~(keystone_admin)]# nova-manage service list
Binary Host Zone Status State Updated_At
nova-consoleauth os-controller.local internal enabled :-) 2014-07-21 09:45:47
nova-scheduler os-controller.local internal enabled :-) 2014-07-21 09:45:48
nova-conductor os-controller.local internal enabled :-) 2014-07-21 09:45:48
nova-cert os-controller.local internal enabled :-) 2014-07-21 09:45:51
nova-compute compute-0-3.local nova disabled XXX 2014-07-21 09:42:36
nova-compute compute-0-2.local nova enabled :-) 2014-07-21 09:45:47
nova-compute compute-0-1.local nova enabled :-) 2014-07-21 09:45:48
nova-compute compute-0-0.local nova enabled :-) 2014-07-21 09:45:47
nova-console os-controller.local internal enabled :-) 2014-07-21 09:45:55
[root@os-controller ~(keystone_admin)]#
How to re-size qcow2 image using guest-fish?
#######################################################################################################################################################################################################################
resize Image using virt-resize i.e. guestfish
#######################################################################################################################################################################################################################
1.copy the original image twice not to harm the original
# cp tinyCentos.qcow2 tinyCentosTmp.qcow2
# cp tinyCentos.qcow2 tinyCentos30.qcow2
2.view all file systems:
[root@s4-5 templates]# virt-filesystems --long -h --all -a tinyCentos30.qcow2
Name Type VFS Label MBR Size Parent
/dev/sda1 filesystem ext4 - - 500M -
/dev/VolGroup/lv_root filesystem ext4 - - 3.5G -
/dev/VolGroup/lv_swap filesystem swap - - 1.0G -
/dev/VolGroup/lv_root lv - - - 3.5G /dev/VolGroup
/dev/VolGroup/lv_swap lv - - - 1.0G /dev/VolGroup
/dev/VolGroup vg - - - 4.5G /dev/sda2
/dev/sda2 pv - - - 4.5G -
/dev/sda1 partition - - 83 500M /dev/sda
/dev/sda2 partition - - 8e 4.5G /dev/sda
/dev/sda device - - - 5.0G -
3.enlarge the image by 30Gb:
[root@s4-5 templates]# qemu-img resize tinyCentos30.qcow2 +30G
Image resized.
4.View the filesystems after enlargement:
[root@s4-5 templates]# virt-filesystems --long -h --all -a tinyCentos30.qcow2
Name Type VFS Label MBR Size Parent
/dev/sda1 filesystem ext4 - - 500M -
/dev/VolGroup/lv_root filesystem ext4 - - 3.5G -
/dev/VolGroup/lv_swap filesystem swap - - 1.0G -
/dev/VolGroup/lv_root lv - - - 3.5G /dev/VolGroup
/dev/VolGroup/lv_swap lv - - - 1.0G /dev/VolGroup
/dev/VolGroup vg - - - 4.5G /dev/sda2
/dev/sda2 pv - - - 4.5G -
/dev/sda1 partition - - 83 500M /dev/sda
/dev/sda2 partition - - 8e 4.5G /dev/sda
/dev/sda device - - - 35G -
5.resize the lvm partitions:
[root@s4-5 templates]# virt-resize --expand /dev/sda2 --LV-expand /dev/VolGroup/lv_root tinyCentosTmp.qcow2 tinyCentos30.qcow2
Examining tinyCentosTmp.qcow2 ...
**********
Summary of changes:
/dev/sda1: This partition will be left alone.
/dev/sda2: This partition will be resized from 4.5G to 34.5G. The LVM
PV on /dev/sda2 will be expanded using the 'pvresize' method.
/dev/VolGroup/lv_root: This logical volume will be expanded to maximum
size. The filesystem ext4 on /dev/VolGroup/lv_root will be
expanded using the 'resize2fs' method.
**********
Setting up initial partition table on tinyCentos30.qcow2 ...
Copying /dev/sda1 ...
100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
Copying /dev/sda2 ...
100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
Expanding /dev/sda2 using the 'pvresize' method ...
Expanding /dev/VolGroup/lv_root using the 'resize2fs' method ...
Resize operation completed with no errors. Before deleting the old
disk, carefully check that the resized disk boots and works correctly.
[root@s4-5 templates]#
6.Optional if you want to compress it run:
[root@s4-5 ready_for]# qemu-img convert -c -f qcow2 -O qcow2 tinyCentos30.qcow2 tinyCentos30diet.qcow2
[root@s4-5 ready_for]# ll
-rw-r--r-- 1 root root 307429376 Sep 3 02:08 tinyCentos30diet.qcow2
-rw-r--r-- 1 root root 5854593024 Sep 3 01:15 tinyCentos30.qcow2
-rw-r--r-- 1 root root 943587328 Jun 22 06:02 tinyCentos.qcow2
-rw-r--r-- 1 root root 943587328 Sep 3 01:08 tinyCentosTmp.qcow2
[root@s4-5 ready_for]#
#######################################################################################################################################################################################################################
resize Image using virt-resize i.e. guestfish
#######################################################################################################################################################################################################################
1.copy the original image twice not to harm the original
# cp tinyCentos.qcow2 tinyCentosTmp.qcow2
# cp tinyCentos.qcow2 tinyCentos30.qcow2
2.view all file systems:
[root@s4-5 templates]# virt-filesystems --long -h --all -a tinyCentos30.qcow2
Name Type VFS Label MBR Size Parent
/dev/sda1 filesystem ext4 - - 500M -
/dev/VolGroup/lv_root filesystem ext4 - - 3.5G -
/dev/VolGroup/lv_swap filesystem swap - - 1.0G -
/dev/VolGroup/lv_root lv - - - 3.5G /dev/VolGroup
/dev/VolGroup/lv_swap lv - - - 1.0G /dev/VolGroup
/dev/VolGroup vg - - - 4.5G /dev/sda2
/dev/sda2 pv - - - 4.5G -
/dev/sda1 partition - - 83 500M /dev/sda
/dev/sda2 partition - - 8e 4.5G /dev/sda
/dev/sda device - - - 5.0G -
3.enlarge the image by 30Gb:
[root@s4-5 templates]# qemu-img resize tinyCentos30.qcow2 +30G
Image resized.
4.View the filesystems after enlargement:
[root@s4-5 templates]# virt-filesystems --long -h --all -a tinyCentos30.qcow2
Name Type VFS Label MBR Size Parent
/dev/sda1 filesystem ext4 - - 500M -
/dev/VolGroup/lv_root filesystem ext4 - - 3.5G -
/dev/VolGroup/lv_swap filesystem swap - - 1.0G -
/dev/VolGroup/lv_root lv - - - 3.5G /dev/VolGroup
/dev/VolGroup/lv_swap lv - - - 1.0G /dev/VolGroup
/dev/VolGroup vg - - - 4.5G /dev/sda2
/dev/sda2 pv - - - 4.5G -
/dev/sda1 partition - - 83 500M /dev/sda
/dev/sda2 partition - - 8e 4.5G /dev/sda
/dev/sda device - - - 35G -
5.resize the lvm partitions:
[root@s4-5 templates]# virt-resize --expand /dev/sda2 --LV-expand /dev/VolGroup/lv_root tinyCentosTmp.qcow2 tinyCentos30.qcow2
Examining tinyCentosTmp.qcow2 ...
**********
Summary of changes:
/dev/sda1: This partition will be left alone.
/dev/sda2: This partition will be resized from 4.5G to 34.5G. The LVM
PV on /dev/sda2 will be expanded using the 'pvresize' method.
/dev/VolGroup/lv_root: This logical volume will be expanded to maximum
size. The filesystem ext4 on /dev/VolGroup/lv_root will be
expanded using the 'resize2fs' method.
**********
Setting up initial partition table on tinyCentos30.qcow2 ...
Copying /dev/sda1 ...
100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
Copying /dev/sda2 ...
100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
Expanding /dev/sda2 using the 'pvresize' method ...
Expanding /dev/VolGroup/lv_root using the 'resize2fs' method ...
Resize operation completed with no errors. Before deleting the old
disk, carefully check that the resized disk boots and works correctly.
[root@s4-5 templates]#
6.Optional if you want to compress it run:
[root@s4-5 ready_for]# qemu-img convert -c -f qcow2 -O qcow2 tinyCentos30.qcow2 tinyCentos30diet.qcow2
[root@s4-5 ready_for]# ll
-rw-r--r-- 1 root root 307429376 Sep 3 02:08 tinyCentos30diet.qcow2
-rw-r--r-- 1 root root 5854593024 Sep 3 01:15 tinyCentos30.qcow2
-rw-r--r-- 1 root root 943587328 Jun 22 06:02 tinyCentos.qcow2
-rw-r--r-- 1 root root 943587328 Sep 3 01:08 tinyCentosTmp.qcow2
[root@s4-5 ready_for]#
How to re-size a qcow2 image?
#stop VM and from the hypervisor resize its disk
[root@compute-0-0 ~]# qemu-img resize /zone01/image.qcow2 +35G
Image resized.
-----------------------------------------------------------------------------------------------
#start the VM and login to it
#run fdisk -l
[root@dev ~]# fdisk -l
Disk /dev/vda: 69.8 GB, 69793218560 bytes
16 heads, 63 sectors/track, 135233 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00043b46
Device Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 62416 30944256 8e Linux LVM
Partition 2 does not end on cylinder boundary.
Disk /dev/mapper/vg_dev-lv_root: 25.4 GB, 25375539200 bytes
255 heads, 63 sectors/track, 3085 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_dev-lv_root doesn't contain a valid partition table
Disk /dev/mapper/vg_dev-lv_swap: 6308 MB, 6308233216 bytes
255 heads, 63 sectors/track, 766 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_dev-lv_swap doesn't contain a valid partition table
[root@dev ~]#
-----------------------------------------------------------------------------------------------
#run fdisk on the extended dev
[root@dev ~]# fdisk /dev/vda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1-135233, default 1): 62417
Last cylinder, +cylinders or +size{K,M,G} (62417-135233, default 135233):
Using default value 135233
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/vda: 69.8 GB, 69793218560 bytes
16 heads, 63 sectors/track, 135233 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00043b46
Device Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 62416 30944256 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3 62417 135233 36699768 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
-----------------------------------------------------------------------------------------------
#reboot the vm
#when the VM goes up:
[root@dev ~]# pvscan
PV /dev/vda2 VG vg_dev lvm2 [29.51 GiB / 0 free]
Total: 1 [29.51 GiB] / in use: 1 [29.51 GiB] / in no VG: 0 [0 ]
[root@dev ~]#
-----------------------------------------------------------------------------------------------
#create Physical volume
[root@dev ~]# pvcreate /dev/vda3
Writing physical volume data to disk "/dev/vda3"
Physical volume "/dev/vda3" successfully created
[root@dev ~]#
-----------------------------------------------------------------------------------------------
#extend Volume group
[root@dev ~]# vgextend vg_dev /dev/vda3
Volume group "vg_dev" successfully extended
[root@dev ~]# pvscan
PV /dev/vda2 VG vg_dev lvm2 [29.51 GiB / 0 free]
PV /dev/vda3 VG vg_dev lvm2 [35.00 GiB / 35.00 GiB free]
Total: 2 [64.50 GiB] / in use: 2 [64.50 GiB] / in no VG: 0 [0 ]
[root@dev ~]#
-----------------------------------------------------------------------------------------------
#Extending logical volume
[root@dev ~]# lvextend -L+34G /dev/vg_dev/lv_root
Extending logical volume lv_root to 57.63 GiB
Logical volume lv_root successfully resized
[root@dev ~]#
-----------------------------------------------------------------------------------------------
#resizing the file system
[root@dev ~]# resize2fs /dev/vg_dev/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_dev/lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 4
Performing an on-line resize of /dev/vg_dev/lv_root to 15108096 (4k) blocks.
The filesystem on /dev/vg_dev/lv_root is now 15108096 blocks long.
[root@dev ~]#
[root@dev ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_dev-lv_root
57G 3.5G 51G 7% /
tmpfs 1.9G 88K 1.9G 1% /dev/shm
/dev/vda1 485M 36M 424M 8% /boot
[root@dev ~]#
more commands:
#Extend to all free size
lvextend -l+100%FREE /dev/VolGroup/lv_home
#show vol groups
vgdisplay
#stop VM and from the hypervisor resize its disk
[root@compute-0-0 ~]# qemu-img resize /zone01/image.qcow2 +35G
Image resized.
-----------------------------------------------------------------------------------------------
#start the VM and login to it
#run fdisk -l
[root@dev ~]# fdisk -l
Disk /dev/vda: 69.8 GB, 69793218560 bytes
16 heads, 63 sectors/track, 135233 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00043b46
Device Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 62416 30944256 8e Linux LVM
Partition 2 does not end on cylinder boundary.
Disk /dev/mapper/vg_dev-lv_root: 25.4 GB, 25375539200 bytes
255 heads, 63 sectors/track, 3085 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_dev-lv_root doesn't contain a valid partition table
Disk /dev/mapper/vg_dev-lv_swap: 6308 MB, 6308233216 bytes
255 heads, 63 sectors/track, 766 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_dev-lv_swap doesn't contain a valid partition table
[root@dev ~]#
-----------------------------------------------------------------------------------------------
#run fdisk on the extended dev
[root@dev ~]# fdisk /dev/vda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1-135233, default 1): 62417
Last cylinder, +cylinders or +size{K,M,G} (62417-135233, default 135233):
Using default value 135233
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/vda: 69.8 GB, 69793218560 bytes
16 heads, 63 sectors/track, 135233 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00043b46
Device Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 62416 30944256 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3 62417 135233 36699768 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
-----------------------------------------------------------------------------------------------
#reboot the vm
#when the VM goes up:
[root@dev ~]# pvscan
PV /dev/vda2 VG vg_dev lvm2 [29.51 GiB / 0 free]
Total: 1 [29.51 GiB] / in use: 1 [29.51 GiB] / in no VG: 0 [0 ]
[root@dev ~]#
-----------------------------------------------------------------------------------------------
#create Physical volume
[root@dev ~]# pvcreate /dev/vda3
Writing physical volume data to disk "/dev/vda3"
Physical volume "/dev/vda3" successfully created
[root@dev ~]#
-----------------------------------------------------------------------------------------------
#extend Volume group
[root@dev ~]# vgextend vg_dev /dev/vda3
Volume group "vg_dev" successfully extended
[root@dev ~]# pvscan
PV /dev/vda2 VG vg_dev lvm2 [29.51 GiB / 0 free]
PV /dev/vda3 VG vg_dev lvm2 [35.00 GiB / 35.00 GiB free]
Total: 2 [64.50 GiB] / in use: 2 [64.50 GiB] / in no VG: 0 [0 ]
[root@dev ~]#
-----------------------------------------------------------------------------------------------
#Extending logical volume
[root@dev ~]# lvextend -L+34G /dev/vg_dev/lv_root
Extending logical volume lv_root to 57.63 GiB
Logical volume lv_root successfully resized
[root@dev ~]#
-----------------------------------------------------------------------------------------------
#resizing the file system
[root@dev ~]# resize2fs /dev/vg_dev/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_dev/lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 4
Performing an on-line resize of /dev/vg_dev/lv_root to 15108096 (4k) blocks.
The filesystem on /dev/vg_dev/lv_root is now 15108096 blocks long.
[root@dev ~]#
[root@dev ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_dev-lv_root
57G 3.5G 51G 7% /
tmpfs 1.9G 88K 1.9G 1% /dev/shm
/dev/vda1 485M 36M 424M 8% /boot
[root@dev ~]#
more commands:
#Extend to all free size
lvextend -l+100%FREE /dev/VolGroup/lv_home
#show vol groups
vgdisplay
How to change root password in a qcow2 image using guestfish?
[root@templates]# guestfish --rw -a LoadBalancer-MN.qcow2
Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.
Type: 'help' for help on commands
'man' to read the manual
'quit' to quit the shell
><fs> run
><fs> mount /dev/sda1 /
><fs> cp /etc/passwd /etc/passwd-bkup
><fs> vi /etc/passwd
#in the file change the root line second parameter from x to blank "":
#from: root:x:0:0:root:/root:/bin/bash to root::0:0:root:/root:/bin/bash
><fs>
><fs>
><fs> umount /
><fs> exit
[root@templates]# guestfish --rw -a LoadBalancer-MN.qcow2
Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.
Type: 'help' for help on commands
'man' to read the manual
'quit' to quit the shell
><fs> run
><fs> mount /dev/sda1 /
><fs> cp /etc/passwd /etc/passwd-bkup
><fs> vi /etc/passwd
#in the file change the root line second parameter from x to blank "":
#from: root:x:0:0:root:/root:/bin/bash to root::0:0:root:/root:/bin/bash
><fs>
><fs>
><fs> umount /
><fs> exit
How to run IPv4 over IPv6 on linux VMs?
here is what you need to do:
on VM 1:
1. modprobe ip6_tunnel
2. ip -6 tunnel show mode any
3. ip -6 tunnel add ip6tnl1 mode ip4ip6 remote 2003:1b39:110:1::133d/64 local 2003:1b39:110:1::133e/64
4. ip -6 tunnel show mode any
5. ip link set dev ip6tnl1 up
6. ifconfig
7. ip addr add 10.0.0.1/24 dev ip6tnl1
on VM 2:
1. modprobe ip6_tunnel
2. ip -6 tunnel show mode any
3. ip -6 tunnel add ip6tnl1 mode ip4ip6 remote 2003:1b39:110:1::133e/64 local 2003:1b39:110:1::133d/64
4. ip -6 tunnel show mode any
5. ip link set dev ip6tnl1 up
6. ifconfig
7. ip addr add 10.0.0.2/24 dev ip6tnl1
9. now from VM2 run: ping 10.0.0.1
##############################################################
Dont forget the "modprobe ip6_tunnel" which start up things!
Make sure your distro is with kernel version 2.6.22 or above!
##############################################################
p.s - if its already configured on the 2 VMs(you can see it if you run ifconfig or #ip a):
#################################################
VM1(13.1.1.62 62.225.0.59):
9: ip6tnl1: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1460 qdisc noqueue state UNKNOWN
link/tunnel6 2003:1b39:110:1::133d peer 2003:1b39:110:1::133e
inet 10.0.0.1/24 scope global ip6tnl1
inet6 fe80::463:ccff:fe00:5169/64 scope link
valid_lft forever preferred_lft forever
VM2(13.1.1.63, 62.225.0.60):
7: ip6tnl1: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1460 qdisc noqueue state UNKNOWN
link/tunnel6 2003:1b39:110:1::133e peer 2003:1b39:110:1::133d
inet 10.0.0.2/24 scope global ip6tnl1
inet6 fe80::47b:a8ff:fe00:516a/64 scope link
valid_lft forever preferred_lft forever
here is what you need to do:
on VM 1:
1. modprobe ip6_tunnel
2. ip -6 tunnel show mode any
3. ip -6 tunnel add ip6tnl1 mode ip4ip6 remote 2003:1b39:110:1::133d/64 local 2003:1b39:110:1::133e/64
4. ip -6 tunnel show mode any
5. ip link set dev ip6tnl1 up
6. ifconfig
7. ip addr add 10.0.0.1/24 dev ip6tnl1
on VM 2:
1. modprobe ip6_tunnel
2. ip -6 tunnel show mode any
3. ip -6 tunnel add ip6tnl1 mode ip4ip6 remote 2003:1b39:110:1::133e/64 local 2003:1b39:110:1::133d/64
4. ip -6 tunnel show mode any
5. ip link set dev ip6tnl1 up
6. ifconfig
7. ip addr add 10.0.0.2/24 dev ip6tnl1
9. now from VM2 run: ping 10.0.0.1
##############################################################
Dont forget the "modprobe ip6_tunnel" which start up things!
Make sure your distro is with kernel version 2.6.22 or above!
##############################################################
p.s - if its already configured on the 2 VMs(you can see it if you run ifconfig or #ip a):
#################################################
VM1(13.1.1.62 62.225.0.59):
9: ip6tnl1: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1460 qdisc noqueue state UNKNOWN
link/tunnel6 2003:1b39:110:1::133d peer 2003:1b39:110:1::133e
inet 10.0.0.1/24 scope global ip6tnl1
inet6 fe80::463:ccff:fe00:5169/64 scope link
valid_lft forever preferred_lft forever
VM2(13.1.1.63, 62.225.0.60):
7: ip6tnl1: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1460 qdisc noqueue state UNKNOWN
link/tunnel6 2003:1b39:110:1::133e peer 2003:1b39:110:1::133d
inet 10.0.0.2/24 scope global ip6tnl1
inet6 fe80::47b:a8ff:fe00:516a/64 scope link
valid_lft forever preferred_lft forever
How to prepare/clean a qcow2 image?
#install guestfish if you dont have it
yum install -y libguestfs-tools
#prepare an image
#virt-sysprep -a [imageName.qcow2]
[root@ittai export]# virt-sysprep -a redhat6-4.qcow2
Examining the guest ...
Performing "yum-uuid" ...
Performing "utmp" ...
Performing "udev-persistent-net" ...
Performing "sssd-db-log" ...
Performing "ssh-userdir" ...
Performing "ssh-hostkeys" ...
Performing "smolt-uuid" ...
Performing "script" ...
Performing "samba-db-log" ...
Performing "rpm-db" ...
Performing "rhn-systemid" ...
Performing "random-seed" ...
Performing "puppet-data-log" ...
Performing "pam-data" ...
Performing "package-manager-cache" ...
Performing "pacct-log" ...
Performing "net-hwaddr" ...
Performing "net-hostname" ...
Performing "mail-spool" ...
Performing "machine-id" ...
Performing "logfiles" ...
Performing "hostname" ...
Performing "firstboot" ...
Performing "dovecot-data" ...
Performing "dhcp-server-state" ...
Performing "dhcp-client-state" ...
Performing "cron-spool" ...
Performing "crash-data" ...
Performing "blkid-tab" ...
Performing "bash-history" ...
Performing "abrt-data" ...
Performing "lvm-uuids" ...
#install guestfish if you dont have it
yum install -y libguestfs-tools
#prepare an image
#virt-sysprep -a [imageName.qcow2]
[root@ittai export]# virt-sysprep -a redhat6-4.qcow2
Examining the guest ...
Performing "yum-uuid" ...
Performing "utmp" ...
Performing "udev-persistent-net" ...
Performing "sssd-db-log" ...
Performing "ssh-userdir" ...
Performing "ssh-hostkeys" ...
Performing "smolt-uuid" ...
Performing "script" ...
Performing "samba-db-log" ...
Performing "rpm-db" ...
Performing "rhn-systemid" ...
Performing "random-seed" ...
Performing "puppet-data-log" ...
Performing "pam-data" ...
Performing "package-manager-cache" ...
Performing "pacct-log" ...
Performing "net-hwaddr" ...
Performing "net-hostname" ...
Performing "mail-spool" ...
Performing "machine-id" ...
Performing "logfiles" ...
Performing "hostname" ...
Performing "firstboot" ...
Performing "dovecot-data" ...
Performing "dhcp-server-state" ...
Performing "dhcp-client-state" ...
Performing "cron-spool" ...
Performing "crash-data" ...
Performing "blkid-tab" ...
Performing "bash-history" ...
Performing "abrt-data" ...
Performing "lvm-uuids" ...
How to edit an Image using guestfish?
[root@s4-50 ready_for]# guestfish --rw -a tinyCentosRouter.qcow2
Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.
Type: 'help' for help on commands
'man' to read the manual
'quit' to quit the shell
><fs> run
><fs> list-filesystems
/dev/sda1: ext4
/dev/VolGroup/lv_root: ext4
/dev/VolGroup/lv_swap: swap
><fs> mount /dev/VolGroup/lv_root /
><fs> ls /
.autofsck
.autorelabel
bin
boot
dev
etc
home
lib
lib64
lost+found
media
mnt
opt
proc
root
sbin
selinux
srv
sys
tmp
usr
var
><fs> vi /etc/sysctl.conf
><fs> umount /
><fs> exit
another option is to ru this command:
# guestmount -a template_a.qcow2 -w -m /dev/sda1 /mnt/image/
[root@s4-50 ready_for]# guestfish --rw -a tinyCentosRouter.qcow2
Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.
Type: 'help' for help on commands
'man' to read the manual
'quit' to quit the shell
><fs> run
><fs> list-filesystems
/dev/sda1: ext4
/dev/VolGroup/lv_root: ext4
/dev/VolGroup/lv_swap: swap
><fs> mount /dev/VolGroup/lv_root /
><fs> ls /
.autofsck
.autorelabel
bin
boot
dev
etc
home
lib
lib64
lost+found
media
mnt
opt
proc
root
sbin
selinux
srv
sys
tmp
usr
var
><fs> vi /etc/sysctl.conf
><fs> umount /
><fs> exit
another option is to ru this command:
# guestmount -a template_a.qcow2 -w -m /dev/sda1 /mnt/image/
How to upload a file using CURL command
#curl -T src-file server address
curl -T ODL1.xml http://10.4.4.121/Installs/Templates/KVM/
#curl -T src-file server address
curl -T ODL1.xml http://10.4.4.121/Installs/Templates/KVM/
How to create a Centos VM from command line, with one liner
#create centos6:
virt-install --name acid-1.6 --ram 4096 --vcpus 4 --location http://mirror.centos.org/centos-6/6/os/x86_64/ --disk=/home/templates/acid-1.6.img,size=100 --network=bridge:virbr0,model=virtio --nographics --extra-args="text console=tty0 console=ttyS0,115200"
#create centos5.9:
virt-install --name DS --ram 4096 --vcpus 4 --location http://mirror.nsc.liu.se/centos-store/5.9/os/x86_64/ --disk=/home/cb_templates/ds-base.qcow2,size=10,format=qcow2,bus=virtio,cache=none --network=bridge:virbr0,model=virtio --nographics --extra-args="text console=tty0 console=ttyS0,115200"
or
[root@openvpn ~]# virt-install --name DS --ram 4096 --vcpus 4 --location http://mirror.nsc.liu.se/centos-store/5.9/os/x86_64/ --disk=/home/cb_templates/ds-600base.qcow2,format=qcow2,bus=virtio,cache=none --network=bridge:virbr0,model=virtio --nographics --extra-args="text console=tty0 console=ttyS0,115200"
#create a thin qcow2
[root@openvpn ~]# qemu-img create -f qcow2 -o preallocation=metadata /home/cb_templates/ds-600base.qcow2 600G
Formatting '/home/cb_templates/ds.qcow2', fmt=qcow2 size=644245094400 encryption=off cluster_size=65536 preallocation='metadata'
How to create a Linux bridge:
[root@epi templates]# brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.5254007ce67f yes virbr0-nic
[root@epi templates]# brctl addbr br1
[root@epi templates]# brctl addif br1 eth1
[root@epi templates]# brctl show
bridge name bridge id STP enabled interfaces
br1 8000.3cd92bf6f11c no eth1
virbr0 8000.5254007ce67f yes virbr0-nic
[root@epi templates]#
[root@epi templates]# brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.5254007ce67f yes virbr0-nic
[root@epi templates]# brctl addbr br1
[root@epi templates]# brctl addif br1 eth1
[root@epi templates]# brctl show
bridge name bridge id STP enabled interfaces
br1 8000.3cd92bf6f11c no eth1
virbr0 8000.5254007ce67f yes virbr0-nic
[root@epi templates]#
Subscribe to:
Posts (Atom)