Sunday, 26 January 2020

GIT Autocomplete Command on Linux Machine

Similar like Linux bash commands, git can also provide auto completion feature for GIT command completion. Definitely tab completion will be faster and easier to operate.


This approach is available for Linux/Windows/Mac OS, in this article it's focused on Linux OS.i.e Centos,RHEL,OL,Ubuntu

1. First step is download the script on to your Linux machine, so execute following command to download the script from github and it will place the script in user home directory.

#curl https://github.com/git/git/blob/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash 
2. Add this line to your ‘~/.bash_profile’. This will allow the execution  of the git autocomplete script if it present
if [ -f ~/.git-completion.bash ]; then
  . ~/.git-completion.bash
fi
3. Open new terminal window, now 'git' 'sub-commands' 'tab' should report all the possibilities matching the sub command string.

Saturday, 25 January 2020

Installing GIT on Linux Machine

The process of installing GIT on a Linux Machine is simple as like other packages, provided the Linux machine is configured with yum(CENTOS, RHEL, OL latest repositories), apt(UBUNTU) or other package manager, else local copy of the binary package. If already installed make sure the package is up to date.

CENTOS, RHEL, OL
#yum install git or dnf install git
UBUNTU
#apt install git
Verify the installation by typing the following command which will print the Git version:
#git --version
With Git successfully installed, you can now move on to the setting up GIT local repository.




Tuesday, 29 May 2018

PCSD - "Error: Unable to communicate with"

PCSD daemon is running on all the nodes which are supposed to be part of cluster, but an attempt to generate a token fails with following error.

[root@pcs1 ~]# pcs cluster auth cs1.internal cs2.internal cs3.internal -u hacluster
Password:
Error: Unable to communicate with cs1.internal
Error: Unable to communicate with cs3.internal
Error: Unable to communicate with cs2.internal

Why to authenticate? 

Well pcs daemon is responsible for keeping corosync configuration files synchronized across all the nodes and starting/stopping cluster services. Each node in the cluster must be authorized to each other. This enables nodes to perform actions on other nodes.


Debug


root@pcs1 ~]# pcs cluster auth cs1.internal cs2.internal cs3.internal -u hacluster --debug

 XDG_SESSION_ID=54
  _=/usr/sbin/pcs
  http_proxy=http://proxy.test:80
  https_proxy=http://proxy.test:80

--Debug Input Start--
{"username": "hacluster", "local": false, "nodes": {"cs1.internal": null, "cs3.internal": null, "cs2.internal": null}, "password": "hapassword", "force": false}
--Debug Input End--

Finished running: /usr/bin/ruby -I/usr/lib/pcsd/ /usr/lib/pcsd/pcsd-cli.rb auth

Return value: 0

--Debug Stdout Start--
{
  "status": "ok",
  "data": {
    "auth_responses": {
      "cs3.internal": {
        "status": "noresponse"
      },
      "cs2.internal": {
        "status": "noresponse"
      },
      "cs1.internal": {
        "status": "noresponse"
      }
    },
    "sync_successful": true,
    "sync_nodes_err": [

    ],
    "sync_responses": {
    }

  },
.....

"I, [2018-05-29T16:54:06.303538 #13362]  INFO -- : SRWT Node: cs1.internal Request: check_auth\n",
    "E, [2018-05-29T16:54:06.303538 #13362] ERROR -- : Unable to connect to node cs1.internal, no token available\n",
    "I, [2018-05-29T16:54:06.303538 #13362]  INFO -- : SRWT Node: cs3.internal Request: check_auth\n",
    "E, [2018-05-29T16:54:06.303538 #13362] ERROR -- : Unable to connect to node cs3.internal, no token available\n",
    "I, [2018-05-29T16:54:06.303579 #13362]  INFO -- : SRWT Node: cs2.internal Request: check_auth\n",

    "E, [2018-05-29T16:54:06.303628 #13362] ERROR -- : Unable to connect to node cs2.internal, no token available\n"

The error message indicates a connection failure to cluster nodes,let's see the common blocking factor's.


  • Firewall is running, but High availability is allowed.(include Corosync/Pacemaker ports)

[root@pcs1 ~]# firewall-cmd --state
running
[root@pcs1 ~]#

[root@pcs1 ~]# firewall-cmd --zone=public --list-services
dhcpv6-client ssh high-availability

  • PCSD daemon status on all the nodes.
root@pcs1 ~]# systemctl status pcsd
● pcsd.service - PCS GUI and remote configuration interface
   Loaded: loaded (/usr/lib/systemd/system/pcsd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2018-05-27 08:53:25 IST; 2 days ago
     Docs: man:pcsd(8)
           man:pcs(8)
 Main PID: 612 (pcsd)
   CGroup: /system.slice/pcsd.service
           └─612 /usr/bin/ruby /usr/lib/pcsd/pcsd > /dev/null &

May 27 08:53:05 pcs1.tux systemd[1]: Starting PCS GUI and remote configuration interface...
May 27 08:53:25 pcs1.tux systemd[1]: Started PCS GUI and remote configuration interface.


  • PCSD listening on port 224

[root@pcs1 ~]# lsof -Pi :2224
COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
pcsd    612 root    7u  IPv4  16876      0t0  TCP *:2224 (LISTEN)


Note: IPv6 is disabled and by default it bind to IPv4, else it will show IPv6. 

What else, most of the blocking factors are set correct? This puzzled me to think on other network factor's, then noticed a proxy line in the debug logs.

Yes, I have exported proxy in bashrc profile and pcsd didn't like that!!

[root@pcs1 ~]# echo $http_proxy
http_proxy=http://proxy.test:80

[root@pcs1 ~]# echo $https_proxy
https_proxy=http://proxy.test:80

Further research on it, revealed a bug and it seems like regression.
Let's leave that to OS vendor (Redhat/Oracle?!)
https://bugzilla.redhat.com/show_bug.cgi?id=1315627

Workaround

Unset the Environmental variable

[root@pcs1 ~]# unset http_proxy;unset https_proxy

What next?  
Try to authenticate.

[root@pcs1 ~]# pcs cluster auth cs1.internal cs2.internal cs3.internal -u hacluster

Above dissertation applies to Oracle Linux 7 and Redhat Linux 7.

Saturday, 13 August 2016

How to create sosreport in alternate location RHEL/OL/CENTOS?

Following steps are applicable to RHEL/OL/CENTOS, widely other distros too have similar option.


  • Older release of sosreport i.e "sos-1.7-9.49.0.2.el5.src.rpm or earlier" doesn't have a inbuilt command line option to define a alternate location, so environmental variables were used.

           # env TMP=<alternate-path> sosreport        

  • sos-1.7-9.54.0.1.el5.src.rpm or later  versions has "--tmpdir" command line option to specify the alternate location.

           --Change log--
           2011-04-08 Bryn M. Reeves <bmr@redhat.com> - 1.7-9.52
          - Add support for --tmp-dir command line option Resolves: bz562283
           ---

          # sosreport --tmp-dir <alternate-path>
       
     

RHEL5/OL5/Centos5 - vi not working for non root user "vim: error while loading shared libraries: libgpm.so.1"

SYMPTOMS

 For non-root user "vi" editor will report errors with the shared library
 $vi test
 vim: error while loading shared libraries: libgpm.so.1: cannot open shared object file: No such file or directory

CAUSE

Shared library "libgpm.so.1" is required for the vim editor and the same is not found as per the ldd command:

#  ldd /usr/bin/vim
linux-vdso.so.1 => (0x00007fffd5ffd000)
libncurses.so.5 => /usr/lib64/libncurses.so.5 (0x0000003a71600000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x0000003a60400000)
libacl.so.1 => /lib64/libacl.so.1 (0x0000003a5f000000)
libgpm.so.1 => not found                            <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
libperl.so => /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so (0x0000003a60800000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x0000003a67000000)
libutil.so.1 => /lib64/libutil.so.1 (0x0000003a6c600000)
libc.so.6 => /lib64/libc.so.6 (0x0000003a5e800000)
libm.so.6 => /lib64/libm.so.6 (0x0000003a5ec00000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003a5f400000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003a5f800000)
libsepol.so.1 => /lib64/libsepol.so.1 (0x0000003a60000000)
/lib64/ld-linux-x86-64.so.2 (0x0000003a5e400000)
libattr.so.1 => /lib64/libattr.so.1 (0x0000003a63000000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003a62c00000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x0000003a71200000)

Thursday, 22 October 2015

How to disable Transparent HugePages or THP on Ol7/RHEL7/CENTOS 7?

Verify the THP mode

# uname -r
3.10.0-229.el7.x86_64
# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<THP is enabled 

Disable it on throughput-performance active profile

 Take a backup of "/usr/lib/tuned/throughput-performance/tuned.conf", then proceed for changes. 
 # cp /usr/lib/tuned/throughput-performance/tuned.conf /usr/lib/tuned/throughput-performance/tuned.conf.bkp_original
 # vi /usr/lib/tuned/throughput-performance/tuned.conf
  [vm]
   transparent_hugepages=always

   to 

  [vm]
  transparent_hugepages=never
  :wq 
  Reboot the server and verify the outcome.    
#uname -r
3.10.0-229.el7.x86_64
#cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<THP Disabled

Disable it on other active tuned profile

 First Identify which profile is active.     
# tuned-adm active
 Current active profile: virtual-guest <<<<<<<<virtual-guest is the active profile
  
Virtual-guest profile use this file "/usr/lib/tuned/virtual-guest/tuned.conf" and it includes "throughput-performance" in the main section which actually takes the configuration from "/usr/lib/tuned/throughput-performance/tuned.conf ". 

Now edit "/usr/lib/tuned/virtual-guest/tuned.conf" file and append "transparent_hugepages=never"  to disable THP.   
#cp /usr/lib/tuned/virtual-guest/tuned.conf /usr/lib/tuned/virtual-guest/tuned.conf.bkp_original
#vi /usr/lib/tuned/virtual-guest/tuned.conf
[main]
include=throughput-performance
[vm]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Append this two lines to disable the THP on the virtual-guest profile.
transparent_hugepages=never
:wq
  Reboot the server and verify the outcome.

#uname -r
3.10.0-229.el7.x86_64
#cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<THP Disabled