Monday, November 3, 2014

How to troubleshoot openstack neutron?

neutron net-list
neutron router-list
neutron subnet-list
neutron port-list
ovs-vsctl show ip netns list
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)]#

How to list ports on Openstack neutron?

from os neutron run:
#neutron port-list | awk '{print $2}' | xargs --verbose -i neutron port-show {} | grep -i device
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]#
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

How to copy file using rsync?


#the P will continue from where it stopped if it brakes
rsync -aP --progress -e 'ssh -p 22000' root@194.50.6.245:/home/versions/[name of file] [target dir]
How to forward ports on SSH?

ssh -D 9999 root@192.168.33.10 -p 22000

ssh -D 9999 root@109.23.22.10


#on windows run in putty directory
putty -ssh -D 9999 -P 22 -i private.ppk ihoffen@80.12.23.31