Tuesday, December 12, 2017

Cluster 1. HP DL380p Gen8 initial setup using Intelligent Provisioning: iLO4 & other firmware upgrade, host system (CentOS7) installation.

Minimum requirements concerning hardware servers:
  • Two servers with the following;
  • Two network switches - also you can interconnect network cables between both servers.
Technologies We Will Use while setting cluster up:
  • Red Hat Enterprise Linux 7
  • Red Hat Cluster Services:
    • Cluster Manager (corosync); Manages the starting, stopping and managing of the cluster.
    • Resource Manager (pacemaker); Manages cluster resources and services. Handles service recovery during failures.
    • Clustered Logical Volume Manager (clvm); Cluster-aware (disk) volume manager (backs GFS2 filesystems and KVM virtual machines).
    • Global File System version 2 (gfs2); Cluster-aware, concurrently mountable file system.
  • Distributed Redundant Block Device (DRBD); Keeps shared data synchronized across cluster nodes.
  • KVM; Hypervisor that controls and supports virtual machines.

Upgrading iLO4 & other firmware

Insert cable to the desired NIC port of the server. After powering server on, wait until this appears:

Press F10. 
Choose "Perform Maintenance", then "Intelligent Provisioning Preferences" here you can verify an IP address assigned via DHCP (if DHCP is used) or assign an IP manually (cable connected port is shown as tick in a green circle). This IP must have privilege to access the Internet. After verifying/assigning an IP  go back and choose "Firmware update" (If you want to view verified packets and download status during firmware updates availability testing - click "More"). All available packets will be shown and then you can choose needed updates and install them.
By default only IP address is assigned to the iLO via DHCP and no DNS or Default Gateway. To fix that access "iLO Configuration" ("Intelligent Provisioning" -> "Perform Maintenance"),  and check those below:

also disable IPv6 if you don't need it:

 Accessing iLO4

Insert network cable to the servers iLO port.
On the picture above you can see IPv4 which is assigned to the iLO via DHCP server. If you have firewall - give that IP permission to access the Internet (Internet access is needed in order to register your server). Access iLO via https://iLO_IPv4. Default User-name and Password are on the bottom of the tag on the front of the server:

Verify that "Administration" -> "Access Settings" -> "IPMI/DCMI over LAN Access" is "Enabled.
I don't exactly know why we need to assign iLO4 DNS Name, but I've assigned it (iLO DNS Name can be found on the same tag).
If you done some changes in a iLO4 Web GUI - you must to "Reset" iLO. This can be done either in the tab where you done changes, or via "Information" -> "Diagnostics" -> "Reset iLO"

Host system (CentOS7) installation

After upgrading firmware and verifying access to the iLO4, go to "Configure and Install" of the "Intelligent Provisioning":
  
 
Insert CentOS7 installation DVD into server's optical drive. 
Then:
Manual is selected because CentOS7 is not distinctly RHEL and  CentOS7 installation  media is not recognized by HP Intelligent Provisioning.

After hitting "Continue" HP Drivers related Warning message is shown, ignore this message and accept. After reboot CentOS7 installation will start and you'll see all HP RAID Logical Disks.

PS
On one of my servers IP (Intelligent Provisioning) is not working and I installed OS using USB Flash:

  1. Download CentOS 7
  2. lsblk -a #find a proper USB Flash i.e. /dev/sdb
  3. fdisk /dev/sdb #create partition if no one exists
  4. lsblk -a # find created partition label i.e. /dev/sdb1
  5. mkfs.fat /dev/sdb1 or mkfs.vfat /dev/sdb1
  6. Write downloaded CentOS 7 iso to the USB Flash (use only disk label, not partition label):
    1. dd if=CentOS-7-x86_64-Minimal-1708.iso of=/dev/sdb #NOT /dev/sdb1
  7. Install
  8. Set amount of space needed for VM's on both servers (i.e. you assume to have 100GB space for VM's on one server and 150GB on the other, sum=100+150=250) as raw device/partition, this will save you much time when setting up clustered storage


Thursday, December 7, 2017

Java Bubble sort

Example:
we have array of 5 numbers: [5,3,4,1,2]
To sort this array with Bubble sort we must compare each pair of adjacent items - if the order is wrong - swap them:
At step 3.2 our array will be sorted but algorithm doesn't know that so the algorithm will:
  1.  make external loop (array.length) times, one time for each index of the array,
  2.  and internal loop pairs_in_an_array times, one time for each adjacent pair  
  3. (let's count pairs in [5,3,4,1,2] :  
  4. 1) [5,3] ; 2) [3,4] ; 3) [4,1] ; 4) [1,2] - it's equal to (array.length - 1))
  1. loop 1:
    1. [5,3,4,1,2] -> [3,5,4,1,2]
    2. [3,5,4,1,2] -> [3,4,5,1,2]
    3. [3,4,5,1,2] -> [3,4,1,5,2]
    4. [3,4,1,5,2] -> [3,4,1,2,5]
  2. loop 2: 
    1. [3,4,1,2,5] -> [3,4,1,2,5]
    2. [3,4,1,2,5] -> [3,1,4,2,5]
    3. [3,1,4,2,5] -> [3,1,2,4,5]
    4. [3,1,2,4,5] -> [3,1,2,4,5]
  3. loop 3:
    1. [3,1,2,4,5] -> [1,3,2,4,5]
    2. [1,3,2,4,5] -> [1,2,3,4,5]
    3. [1,2,3,4,5] -> [1,2,3,4,5]
    4. [1,2,3,4,5] -> [1,2,3,4,5] 
  4. loop 4:
    1. [1,2,3,4,5] -> [1,2,3,4,5]
    2. [1,2,3,4,5] -> [1,2,3,4,5]
    3. [1,2,3,4,5] -> [1,2,3,4,5]
    4. [1,2,3,4,5] -> [1,2,3,4,5]
  5. loop 5: 
    1. [1,2,3,4,5] -> [1,2,3,4,5]
    2. [1,2,3,4,5] -> [1,2,3,4,5]
    3. [1,2,3,4,5] -> [1,2,3,4,5]
    4. [1,2,3,4,5] -> [1,2,3,4,5]
The algorithm called bubble sort because each high element goes to the top of the array as bubble goes to the top of the water reservoir.
Algorithm itself is too slow and impractical to be used in production environment. 

public class BubbleSort 
{
    public static void main(String[] args) throws Exception 

    {
    }

    public static void sort(int[] array) 

    {
        // extI - external loop iterator
        // intI - internal loop iterator
        for (int extI = 0; extI < array.length; extI++)

        {
            for (int intI = 0; intI < array.length-1; intI++)

            {
                if (array[intI + 1] < array[intI])

                {
                    int temp = array[intI + 1];
                    array[intI + 1] = array[intI];
                    array[intI] = temp;
                }
            }
        }
    }
}

Wednesday, December 6, 2017

Python string slicing (substringing) in Java 

we have a string "I don't want to learn programming, I want to earn money"

Python slicing:
>>> line[0:10]
"I don't wa"
>>> line[0:-1]
"I don't want to learn programming, I want to earn mone"
>>> line[2:]
"don't want to learn programming, I want to earn money"
>>> line[:]
"I don't want to learn programming, I want to earn money"
>>> line[10:-3]
'nt to learn programming, I want to earn mo'

Python slicing Java implementation:
public class Solution 
{
    public static void main(String[] args) 

    {
        String s = "I don't want to learn programming, I want to earn money";
        slicer(s, 0, 10);
        slicer(s, 0, -1);
        slicer(s, 2);
        slicer(s);
        slicer(s, 10, -3);
    }

    // using VarArgs to allow using no index, only one ore both
    // indexes without method overloading
    public static void slicer(String str, int... index) 

    {
            int startIndex;
            int endIndex;

            if (index.length > 1)

            {
                startIndex = index[0];
                endIndex = index[1];
            } else if (index.length == 1) 

            {
                startIndex = index[0];
                endIndex = str.length();
            } else 

            {
                startIndex = 0;
                endIndex = str.length();
            }

            if (endIndex < 0) 

            {
                endIndex = str.length() + endIndex;
            }

            char[] sentence = str.toCharArray();
            for (int n = startIndex; n < endIndex; n++) 

            {
                System.out.print(sentence[n]);
            }
            System.out.print("\n");
    }

}





Wednesday, November 29, 2017

Error Description: 13801: IKE authentication credentials are unacceptable

Tried to connect Windows 7 client to the pfSense® with IKEv2 and native Windows IPSec VPN client. Everything was setup using IKEv2_with_EAP-MSCHAPv2 and every-time trying to connect I got "Error Description: 13801: IKE authentication credentials are unacceptable". After searching and troubleshooting it turned out that importing CA cert to the Windows 7 client PC must be done only via mmc console otherwise certificate is shown as installed but nothing works as expected.
PS to install CA certificates use this link: Import_Root_Cert_mmc

Friday, November 24, 2017

MySQL OUTFILE & INFILE

To write dump into file (by default this file will go to the /var/lib/mysql/DBNAME/test.sql). I use NULL for id column's values because it's AUTOINCREMENT and will be generated automatically (otherwise if I dump actual value duplicate values will be created):
SELECT
 NULL,time,callid,queuename,agent,event,data1,data2,data3,data4,data5
INTO OUTFILE 'test.sql'
FIELDS TERMINATED BY ','
OPTIONALLY
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM
queue_log;

Files content is something like:
cat test.sql
\N,"2014-10-28 17:45:19.924148","NONE","NONE","NONE","QUEUESTART","","","","",""

To merge this file into an existent table:
LOAD DATA INFILE 'test.sql'
INTO TABLE queue_log
FIELDS TERMINATED BY ','
OPTIONALLY
ENCLOSED BY '"'
LINES TERMINATED BY '\n';

Monday, November 20, 2017

Accessing CentOS 7 via RDP 

Install needed packages:
$ yum install epel-release
$ yum install xrdp tigervnc-server tigervnc-server-module

Change SELinux context for xrdp:
$ chcon -t bin_t /usr/sbin/xrdp
$ chcon -t bin_t /usr/sbin/xrdp-sesman

Open rdp port in firewall:
$ firewall-cmd --zone=public --add-port=3389/tcp --permanent
$ firewall-cmd --zone=public --add-port=3389/udp --permanent
$ firewall-cmd --reload

Enable and start xrdp service:
$ systemctl enable xrdp
$ systemctl start xrdp

Modify GNOME Display Manager custom:
$ vi /etc/gdm/custom.conf
[security]
AllowRemoteRoot=true
DisallowTCP=false
[xdmcp]
Enable=true

Wednesday, November 8, 2017

Can't remove final physical volume  from volume group (Linux)

I have:
[root@localhost ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree 
  VolGroup   1   0   0 wz--n- 279.36g 279.36g
  centos     1   3   0 wz--n-  <3.64t   3.04t
[root@localhost ~]# pvs
  PV         VG       Fmt  Attr PSize   PFree 
  /dev/sda3  centos   lvm2 a--   <3.64t   3.04t
  /dev/sdb1  VolGroup lvm2 a--  279.36g 279.36g
 and want to remove VolGroup and add /dev/sdb1 into centos VG:
[root@localhost ~]# pvremove /dev/sdb1
  PV /dev/sdb1 is used by VG VolGroup so please use vgreduce first.
  (If you are certain you need pvremove, then confirm by using --force twice.)
  /dev/sdb1: physical volume label not removed.
[root@localhost ~]# vgreduce VolGroup /dev/sdb1
  Can't remove final physical volume "/dev/sdb1" from volume group "VolGroup"

To overcome that issue we'll first inactivate "VolGroup" and then remove that VG:
[root@localhost ~]# vgchange -an VolGroup
  0 logical volume(s) in volume group "VolGroup" now active
[root@localhost ~]# vgremove VolGroup
  Volume group "VolGroup" successfully removed 

Verifying and adding PV to a VG:
[root@localhost ~]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   1   3   0 wz--n- <3.64t 3.04t
[root@localhost ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree 
  /dev/sda3  centos lvm2 a--   <3.64t   3.04t
  /dev/sdb1         lvm2 ---  279.36g 279.36g
[root@localhost ~]# vgextend centos /dev/sdb1
  Volume group "centos" successfully extended
[root@localhost ~]# vgs
  VG     #PV #LV #SN Attr   VSize VFree
  centos   2   3   0 wz--n- 3.91t 3.31t
[root@localhost ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree 
  /dev/sda3  centos lvm2 a--   <3.64t   3.04t
  /dev/sdb1  centos lvm2 a--  279.36g 279.36g