Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Wednesday, 6 May 2020

Checking physical & Logical volumes or LPARS in AIX 7.1

To check Physical Volumes run below commands
lspv

To obtain a list of all the physical volumes known to a node and to find out the volume groups to which they belong, use the lspv command. If you do not specify the name of a volume group as an argument, the lspv command displays every known
physical volume in the system.

lspv hdisk2


To check Logical Volumes run below commands
 
To check the state of logical volumes defined on the physical volumes, use the lspv -l command and specify the logical name of the disk to be checked.

As shown in the following example, you can use this command to determine the names of the logical volumes defined on a physical volume.

lspv -l hdisk2




Thanks

for more details https://www.ibm.com/support/knowledgecenter/en/SSPHQG_7.2/trouble/ha_trgd_check_log.html

Monday, 23 July 2018

Failover - Host two will be added in hosts file If Host one is Down | Linux

This bash script we used for our of our client.
to use simple create a file e.g failover.sh and paste the below mentioned script into it.
now configure a cronjob to run this script every after 5 minutes or whatever you like.

#!/bin/bash
HOST1="10.2.4.115"
HOST2="10.2.4.116"
COUNT=4
for myHost in $HOST1
do
  count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }' 2>/dev/null)
  #count=$count"skj"
#  echo $count" ccc"
  if [ $count -gt 0 ]; then
    # 100% failed
    g_count=`grep -c $HOST1 /etc/hosts`
    if [ $g_count -eq 0 ]; then
      echo "change host1 ip"
     `cat /etc/hosts | sed 's/10.2.4.116/10.2.4.115/' > /etc/hosts_tmp`
     `cp /etc/hosts_tmp /etc/hosts --reply=yes`
    fi
    echo "Host : $myHost is UP"
  else
    g_count=`grep -c $HOST2 /etc/hosts`
    echo $g_count
    if [ $g_count -eq 0 ]; then
      echo "change  host2 ip"
     `cat /etc/hosts | sed 's/10.2.4.115/10.2.4.116/' > /etc/hosts_tmp`
     `cp /etc/hosts_tmp /etc/hosts --reply=yes`
    fi
    echo "Host : $myHost is down"
  fi
done

Monday, 16 October 2017

Anonymize or Replace text within a File using SED | Linux

Stream Editor aka 'sed' is a *nix utility to transform and parse text.

for example.
if a file testing.txt contains some text like ' helloworld.zip ',  it will be replace with any text or we can use $RANDOM function also.
sed s/hello.*zip/"hello://$RANDOM.zip"/g testing.txt
the final result will be like this:
hello12345.zip (any random number)
/g means all occurrence of this text


Friday, 13 October 2017

Find and Delete All Files Older than 10 Days using mtime | Linux

#to file files older than 10 days:
find /home/folder/ -mtime +10;

#now append it with -exec switch +  rm {} loop to delete all found files:
find /home/folder/ -mtime +10 -exec rm {} \;

----------------------
#and to find only in specific directory ignore sub directories

find /home/folder/ -maxdepth 1 -mtime +10

Wednesday, 9 August 2017

What is inode in Linux and IF You are Out of It (solution) | Linux

inode is basically a count of total number of files in directories of a user account in *nix systems.

similar to a unique identification of individuals in a country.

inode is data structure , it contains:
size,
user id,
group id
device id,
mode and access
protection
timestamps
links
points
etc.
except file name, and contents.