wtorek, 8 września 2015

Clustering using sharing of vmdks between virtual machines

https://communities.vmware.com/blogs/Abhilash_hb/2013/08/25/clustering-using-sharing-of-vmdks-between-virtual-machines



This blog post explains how to share a VMDK between two virtual machines so they can be clustered or any application that needs two machines to share their disks.
  
    Assume there are two VMs that participate in the clustering
    Node-01 and Node-02

    Create a Virtual disk on Node-01 that has to be shared with Node-02
1.jpg


    Add a hard disk by clicking on Add a hardware and select Hard disk and click Next
2.jpg



   Select Create a new virtual disk
3.jpg


Must be type Thick Provision Eager Zeroed !!!!!!!!!!!!!!!!!!


    Choose SCSI (1:0) which creates a fresh SCSI controller apart from the default one created during virtual machine creation and click Next
4.jpg



    Click on Finish
5.jpg



    Click on the newly created SCSI controller and change the SCSI Bus sharing option to “Physical”
6.jpg
   Click on OK and power ON the machine

    Now the newly added disk shows up on the Node-01 machine as /dev/sdb.
7.jpg

     We need to add the Virtual disk created on Node-01 to Node-02

   
     Click on Edit Setting of Node-02 machine and select Add hardware and click on hard disk
     And click Next
8.jpg

    Click on “use an existing virtual disk” and click Next
9.jpg

 
    Browse to the location where Node-01’s VMDK file is present and select it
10.jpg


     Confirm the path and click Next
11.jpg


  

    Select SCSI (1:0) which creates a new SCSI controller on Node-02
12.jpg


     Review the changes and click Finish
13.jpg


    Select the newly created SCSI controller and select Physical under SCSI bus sharing option and click OK
14.jpg

    Power on Node-02 and confirm that Node-01’s shared disk is showing up on Node-02
15.jpg

   You might want to turn the Multi-writer flag in the advanced options of VM so you can let the machines write to the disk. Follow the below link for the same

   Note: This might cause some problems while doing vMotion of the machines involved in clustering. So do some research before you do it.

piątek, 4 września 2015

Cluster HAProxy

Configuring HAProxy and Keepalived - HTTP

Install HAProxy and Keepalived on both ubuntu nodes.
Load balancing in HAProxy also requires the ability to bind to an IP address that are nonlocal, meaning that it is not assigned to a device on the local system. Below configuration is added so that floating/shared IP can be assigned to one of the load balancers. Below line get it done.
Now you know what’s happening with above lines let’s edit the sysctl.conf.
Add the below lines.
To enable the changes made in sysctl.conf you will need to run the command.

Now let’s create keepalived.conf file on each instances. All the below Keepalived configurations are explained in the User guide provided by Keepalived and refer this guide as well.
Add the below configuration on the master node

Add the below configuration on the slave node.
Restart Keepalived.
Now let’s configure HAProxy on both instances. You will have do the below steps on master node as well as slave node.
set the property ENABLED to 1.
Note that below configurations are as per my requirement.
If above configurations are not clear please refer this guide from HAProxy.

Testing

Let’s check whether our configuration has been done correctly. Try executing ip addr on master node. As you can see on the master node 192.168.6.164 IP is assigned.
Try executing ip addr on slave node.
Let stop the HAProxy on the master node. Now you can see that IP address 192.168.6.164 will be assigned to the salve node. If you start HAproxy instance on the master node IP address 192.168.6.164 will be assigned back to master node. See the O/P below.
Try http://192.168.6.169:8989/stats or http://192.168.6.170:8989/stats URL to login into statistics report for HAProxy.
Statistics Report for HAProxy
Statistics Report for HAProxy
If you have any questions let me know in the comments below. Your feedback is highly appreciated(happy-face). 

piątek, 14 sierpnia 2015

LVM

Create


This example creates an LVM logical volume called new_logical_volume that consists of the disks at /dev/sda1, /dev/sdb1, and /dev/sdc1.

5.1.1. Creating the Physical Volumes



[root@tng3-1 ~]# pvcreate /dev/sda1 /dev/sdb1 /dev/sdc1
  Physical volume "/dev/sda1" successfully created
  Physical volume "/dev/sdb1" successfully created
  Physical volume "/dev/sdc1" successfully created

5.1.2. Creating the Volume Group

The following command creates the volume group new_vol_group.
[root@tng3-1 ~]# vgcreate new_vol_group /dev/sda1 /dev/sdb1 /dev/sdc1
  Volume group "new_vol_group" successfully created
You can use the vgs command to display the attributes of the new volume group.
[root@tng3-1 ~]# vgs
  VG            #PV #LV #SN Attr   VSize  VFree
  new_vol_group   3   0   0 wz--n- 51.45G 51.45G

5.1.3. Creating the Logical Volume

The following command creates the logical volume new_logical_volume from the volume group new_vol_group. This example creates a logical volume that uses 2GB of the volume group.
[root@tng3-1 ~]# lvcreate -L2G -n new_logical_volume new_vol_group
  Logical volume "new_logical_volume" created

5.1.4. Creating the File System

The following command creates a GFS file system on the logical volume. np:
[root@tng3-1 ~]# gfs_mkfs -plock_nolock -j 1 /dev/new_vol_group/new_logical_volume
This will destroy any data on /dev/new_vol_group/new_logical_volume.

Are you sure you want to proceed? [y/n] y

Device:                    /dev/new_vol_group/new_logical_volume
Blocksize:                 4096
Filesystem Size:           491460
Journals:                  1
Resource Groups:           8
Locking Protocol:          lock_nolock
Lock Table:

Syncing...
All Done
The following commands mount the logical volume and report the file system disk space usage.
[root@tng3-1 ~]# mount /dev/new_vol_group/new_logical_volume /mnt
[root@tng3-1 ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/new_vol_group/new_logical_volume
                       1965840        20   1965820   1% /mnt 
 
 
 
Rozszerzenie Phisical volume  
 
echo 1 > /sys/block/sdX/device/rescan
  
 
[root@centos7 ~]# pvs
  PV         VG           Fmt  Attr PSize   PFree
  /dev/sda2  centos       lvm2 a--   59.51g 64.00m
  /dev/sdb   vol_group_sk lvm2 a--  160.00g 10.00g
[root@centos7 ~]# pvresize /dev/sdb
  Physical volume "/dev/sdb" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
[root@centos7 ~]# pvs
  PV         VG           Fmt  Attr PSize   PFree
  /dev/sda2  centos       lvm2 a--   59.51g 64.00m
  /dev/sdb   vol_group_sk lvm2 a--  210.00g 60.00g
[root@centos7 ~]#
 
  
 
 
Rozszerz LVM logical volume

# lvextend -L12G /dev/myvg/homevol
 
 
Najpierw zrób:
e2fsck -f /dev/myvg/homevol/dev/myvg/homevol 
 
 
ext2/ext3
          
umount /dev/myvg/homevol/dev/myvg/homevol
   # resize2fs /dev/myvg/homevol         # wykonuj na zamontowanym zasobie 
   # mount /dev/myvg/homevol /home
 umount /dev/myvg/homevol/dev/myvg/homevol
   # ext2resize /dev/myvg/homevol       # wykonuj na zamontowanym zasobie 
   # mount /dev/myvg/homevol /home
 
xfs
mount /dev/myvg/homevol /home
xfs_growfs /home        # wykonuj na zamontowanym zasobie 
 
df -h  
 
 
Rozszerz LVM volume group
 
vgextend new_vol_group /dev/sdd
 
 
 Usuń uszkodzony dysk z volume group
 
 
# pvs -o+pv_used
Sprawdz zajętość dysków

# pvmove /dev/sdb1

przenieść dane z dysku do wymiany
/dev/sdb1: Moved: 2.0% ...
/dev/sdb1: Moved: 79.2% ...
/dev/sdb1: Moved: 100.0%

# pvs -o+pv_used
 Sprawdz zajętość dysków
 
# vgreduce myvg /dev/sdb1
Wypnij dysk z grupy

czwartek, 13 sierpnia 2015

Red Hat & Ubuntu reset root password

REDHAT
 
- init.d
W Grub Press "e"
linia kernel... Press "e" na końcu space i 1
Enter
Pres "b"
passwd

- system.d
W Grub Press "e"

linia linux16....znajdz
rhgb quite LANG
i zmien na
rhgb quite rd.break LANG
Ctrl + x

Jak wyskoczy Promt #
mount -o remount,rw /sysroot/
chroot /sysroot/
passwd


UBUNTU 14

Albo tryb recovery i potem
mount -o remount,rw /
chroot /

Albo:
  1. Select (highlight) the GRUB boot menu entry you wish to use.
  2. Press e to edit the GRUB boot commands for the selected boot menu entry.
  3. Look near the bottom of the list of commands for lines similar to

    linux /boot/vmlinuz-3.2.0-24-generic root=UUID=bc6f8146-1523-46a6-8b\
    6a-64b819ccf2b7 ro quiet splash
    initrd /boot/initrd.img-3.2.0-24-generic
  4. Change the middle line in (3) by adding the kernel boot parameter single to the end of the line (i.e. after ro quiet splash).

    For this example you would change
    6a-64b819ccf2b7 ro quiet splash
    to
    6a-64b819ccf2b7 ro quiet splash single
  5. Press either Ctrl+X or F10 to boot using these kernel options.