Wednesday, October 22, 2014

setting up autofs



1. Create a dir to be shared
# mkdir /homedirs

2. Add entry to /etc/exportfs
# vi /etc/exports
/homedir *(rw,sync)

wq!

3. restart nfs service
# service autofs restart stop/start

# verify the share
# exportfs


go to client and test if nfs works

# mount 192.168.10.160:/homedirs /mnt

took long time to mount.

# showmount -e 192.168.10.12
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to


disable the firewall
# service iptables stop

Check what is shared for this host

# showmount -e 192.168.10.160
Export list for 192.168.10.160:
/homedirs *


try to moun again

# mount 192.168.10.160:/homedirs /mnt

it works

Note:  if some reason you have problem mounting, please stop nfs and rpcbind and restart rpcbind first and then start nfs.

Now, setup autofs on client
Add entry to /etc/auto.master to set up autofs
# vi /etc/auto.master
/ram    /etc/auto.rhome

# vi /etc/auto.rhome
*       -rw     192.168.10.160:/homedirs/&

Tuesday, October 21, 2014

Some file system info

# more gather_vfstab_zone_xml.sh
#!/bin/ksh
cd /etc
grep FS /etc/vfstab | awk '{ print $3","$1","$2 }' | egrep -v mount > /var/tmp/servername_FS_list
#
Create zfs fs
# zfs create -o mountpoint=/opt/app -o quota=100g MyPool01/FS_OPT_APP

To remove disk from vxvm,
# vxdg -g datadg rmdisk emcdsk03 emcdsk04

To find the particular port on Solaris server  -- copied, forgot the source, big credit to the owner...

#! /bin/sh

if [ $# -ne 1 ]; then
  echo "Usage: $0 "
  exit 1
fi
listen=$1

# PATH=$PATH:/usr/bin:/bin
# export PATH

#
# skip process 0
#
cd /proc
for i in [1-9][0-9]*
do
  pfiles $i | nawk -v listen=$listen '
    BEGIN {
      found=0
    }
    NR==1 {
      process=$0
    }
    /sockname/ && $NF == listen {
      getline
      if ( ! /peername/ ) {
        found=1
        exit
      }
    }
    END {
      if ( found == 1 ) {
        printf("%s\n",process)
      }
    }'
done

===================================

# cat port_proc.sh
#!/bin/bash
 # is the port we are looking for

if [ $# -lt 1 ]
 then
 echo "Please provide a port number parameter for this script"
 echo "e.g. %content 2051"
 exit
 fi

echo "Greping for your port, please be patient (CTRL+C breaks) . "

for i in `ls /proc`
 do
 pfiles $i | grep AF_INET | grep $1
 if [ $? -eq 0 ]
 then
 echo Is owned by pid $i
 echo "-----------------"
 fi
 done

# sh port_proc.sh 2051
Greping for your port, please be patient (CTRL+C breaks) .
pfiles: cannot examine 1291: no such process

Is owned by pid 6692


============================

SAN HBA wwn info

#!/bin/ksh
for i in `ls -ld /sys/class/scsi_host/host* | awk '{print $9}' | cut -d"/" -f5`
do
echo "----------------------------------------"
echo "SAN (HBA) Card $i information"; echo "----------------------------------------"
systool -c fc_host $i -v | egrep "node_name|port_name|port_state|speed "; echo ""
done

#

=====================================

#!/bin/ksh
echo | format >/tmp/format.disks
cd /tmp
for i in `grep c1t2 /tmp/format.disks | awk '{print $2}' | sed '/^$/d'`
# for i in `grep emcp /tmp/format.emc | awk '{print $2}' | sed '/^$/d'`
do
    SIZE=`echo ver | format $i | grep '2    backup'    | awk '{print $7'}`
echo "$i =$SIZE"
done


Friday, October 17, 2014

From list of content , grep the

# for i in $(cat slist.txt | awk '{print $1}') ; do echo ; echo checking $i ; nexec $i cat /etc/redhat-release  ; done ; echo
checking host13
Red Hat Enterprise Linux Server release 6.3 (Santiago)
checking host14
Red Hat Enterprise Linux Server release 6.3 (Santiago)
checking host22
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
checking host57
Red Hat Enterprise Linux Server release 5.9 (Tikanga)

============firewall check===========
Testing from mylxserv05 to backup_serv01
$ nc -z -v -w 1 172.25.10.10 1500
nc: connect to 172.25.50.10 port 1500 (tcp) failed: Connection refused
Testing from backup_serv01 to mylxserv05
$ nc -z -v -w 1 172.26.10.25 1500
Connection to 172.26.10.25 1500 port [tcp/vlsi-lm] succeeded!

#!/bin/ksh
/usr/bin/rsync -logtprz --exclude-from=/var/tmp/rsync.exclude --progress --rsync-path="sudo rsync" --rsh='ssh -l dev' /opt/ dev@sunsrv445:/opt/

# cat >/var/tmp/rsync.exclude
# user relative path to the source rsync dir
# for eg, /opt/ and want to exclude /opt/users just use /users
/users

Thursday, October 16, 2014

Creating zfs filesystem on Solaris servers



#!/bin/bash
rm /tmp/list.fs
echo > /tmp/list.fs
echo " Please enter the "mount point" and space and the "size""
sleep 5
vi /tmp/list.fs
for i in `cat  /tmp/list.fs`
do
Mpoint=`echo $i | awk -F, '{print $1}`
FSSize=`echo $i | awk -F, '{print $2}'`
LvName=`echo $i | awk -F, '{print $1}' |sed 's,^/,,' |sed 's,/,_,g'`
poolName=`zpool list |grep poolv |awk '{print $1}'`
zfs create   -o mountpoint=$Mpoint -o quota=$FSSize  $poolName/FS_$LvName

done

Find the application running on particular port.

This script helps you to find the application running on particular port.
To execure the script, make the script executable and supply the port as a command line parameter.
# netstat -an | grep 2051 ( to see if port is used)
# sh port_proc.sh <port_num>
# sh port_proc.sh 2051 (To check the process of the PID)

root@sunserv01:/var/tmp > cat port_proc.sh
#!/bin/bash
 # is the port we are looking for
if [ $# -lt 1 ]
 then
 echo "Please provide a port number parameter for this script"
 echo "e.g. %content 2051"
 exit
 fi
echo "Greping for your port, please be patient (CTRL+C breaks) . "
for i in `ls /proc`
 do
 pfiles $i | grep AF_INET | grep $1
 if [ $? -eq 0 ]
 then
 echo Is owned by pid $i
 echo "-----------------"
 fi
 done
root@sunserv01:/var/tmp >

root@sunserv01:/var/tmp > sh port_proc.sh 2051
Greping for your port, please be patient (CTRL+C breaks) .
pfiles: cannot examine 1291: no such process
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
        sockname: AF_INET 192.168.10.184  port: 2051
Is owned by pid 6692
---------------
root@sunserv01:/var/tmp > root@sunserv01:/var/tmp > ptree 6692
6692  /opt/sybase1253/ASE-12_5/bin/backupserver -e/opt/sybase1253/ASE-12_5/install/er
root@sunserv01:/var/tmp > ptree 6692
6692  /opt/sybase1253/ASE-12_5/bin/backupserver -e/opt/sybase1253/ASE-12_5/install/er
root@sunserv01:/var/tmp >

source: http://onlineappsdba.com/index.php/2008/06/10/how-to-find-pid-listening-particular-port-on-linuxsolaris-10/

Changing ipaddress and gateway of a host on Redhat 6.5

Changing ipaddress and gateway of a host on Redhat 6.5
# cat ipdata.txt
lxserv01:172.20.0.5:255.255.255.0:172.20.0.1:192.168.210.50:255.255.255.192:192.168.210.65
lxserv02:172.20.0.2:255.255.255.0:172.20.0.1:192.168.210.51:255.255.255.192:192.168.210.65
lxserv03:172.20.0.3:255.255.255.0:172.20.0.1:192.168.210.52:255.255.255.192:192.168.210.65
lxserv04:172.20.0.4:255.255.255.0:172.20.0.1:192.168.210.53:255.255.255.192:192.168.210.65


# cat iphosts.sh
#!/bin/sh
hname=`hostname`
#############################################
# hname=`cat ipdata.txt | awk -F: '{print $1}'`
# oldip=`grep $hname "ipdata.txt"|cut -d":" -f2`
oldip=`cat ipdata.txt | grep $hname | cut -d":" -f2`
oldsubnet=`grep $hname "ipdata.txt"|cut -d":" -f3`
#oldgateway=`grep $hname "ipdata.txt"|cut -d":" -f4`
oldgateway=`cat ipdata.txt | grep $hname | cut -d":" -f4`
newip=`grep $hname "ipdata.txt"|cut -d":" -f5`
newsubnet=`grep $hname "ipdata.txt"|cut -d":" -f6`
newgateway=`grep $hname "ipdata.txt"|cut -d":" -f7`
####
sed -i "s/$oldip/$newip/g" /etc/sysconfig/network-scripts/ifcfg-bond0
sed -i "s/$oldsubnet/newsubnet/g" /etc/sysconfig/network-scripts/ifcfg-bond0
sed -i "s/$oldgateway/newgateway/g" /etc/sysconfig/network-scripts/ifcfg-bond0
sed -i "s/$oldgateway/newgateway/g" /etc/sysconfig/network
echo
echo "Old ip info listed below, please verify \n"
echo "$hname   :::  $oldip   :::  $oldsubnet   :::  $oldgateway"
echo
echo "New ip info is listed below, please verify"
echo "$newip   ::: $newsubnet   ::: $newgateway"

Device is unable to respond to the ping request.


Possible Causes
1. Hardware device might failed. (either network or server).
2. Cable between the network device and the hardware is broken.
3. Incorrect Network Address address assigned to the server.
4. Might be on wrong network.
5. Power Failure.
6. Issue with Device Firmware (Failure).
                        
Possible Solution.
1. Try to ping the gateway.
2. Try to ping the other server on the network. (trace route)
3. If possible check power to device.
4. Find out if its a single isuse or issue on multiple server (global issue)
5. Verify status lights on device if possible.
6. Try to connect through the console.
7. Verify network address in device.
8. Check the logs.
9. Power cycle the device and recheck if everything comes clean.
                        

Tuesday, October 14, 2014

Package Management

Package Management

rpm -i  -> Install Package
rpm -U  -> Update Package
use -i for new kernel so they are installed
rpm -i kernel
rpm -i –-oldpackage  downgrade
rpm -i -–replacefiles  forced install
rpm -i -–nodeps  ignore dependencies
rpm -F  update package in required, or installs if no older version
rpm -e   removes package
rpm -i –-replacepkgs  reinstall overtop

rpm -qa --last   -->  lists all installed packages sorted by install date
rpm -qi package  --> package info
rpm -ql package  --> list of all files in package
rpm -q -f /file/name  --> list package a file belongs to
rpm -q –changelog package  --> display changelog for package
"rpm -qa –-queryformat “%{NAME}\n”
     NAME,DISTRIBUTION or RELEASE"  limit out to name, distribution or release
rpm -qa gpg-pubkey  lists pub keys for package signatures
rpm -–import /key/file  import pub key for signed packages
rpm -V package  Verifies the install of a package and lists inconsistencies
$ rpm -qa --last dstat
dstat-0.7.0-1.el6.noarch                      Sat 08 Nov 2014 07:54:42 PM EST

yum update  update package
yum localinstall ./mypkg
yum clean all
yum repolist
yum list    -->> list all packages, installed and available
yum install  pkgname --> installs the package
yum remove pkgname --> removes package
yum list installed  -->> lists all installed packages
yum groupinstall  "group name" ->> groupinstall like desktop packages
yum search keyword  -->> keyword search
yum info package  --> displays info on package
yum grouplist  -->> list installed and available package groups
yum provides /file/name  filename search
yum list*fire*”  -->> list packages named fire, installed and available

SAN Migration - using veritas volume manager


Plan,
Work with storage team to present the new luns on both hosts. Mirror the luns (volume) on source server and break the mirror. Export the diskgroup and import the disk group to the new host. Star the volume on new host, everything should be fine.
Make sure proper backup is on place.
Work with network team to Push new DNS updates and remove the entry for old host on the dns.
Work with database/application folks to bring the database and application up.
Validate the database(s) are operational and ready to use
wait for at least 1 month to make sure everything is operational.
Issue retirement request to retirement team to retire the old server.

root@samserv02:/dev/vx/dsk/samserv02dg > df -h
/dev/vx/dsk/samserv02dg/FS_opt_dts
                       3.8G   2.8G   556M    84%    /opt/dts
/dev/vx/dsk/samserv02dg/FS_opt_sybase12.5
                       375M   236M   102M    70%    /opt/sybase12.5
/dev/vx/dsk/samserv02dg/FS_FSS_oracle
                        60G   5.5G    48G    11%    /FSS/oracle
/dev/vx/dsk/samserv02dg/FS_opt_sybase
                       750M   175M   500M    26%    /opt/sybase
/dev/vx/dsk/samserv02dg/FS_opt_sybase12.0
                       375M   235M   103M    70%    /opt/sybase12.0
/dev/vx/dsk/samserv02dg/FS_opt_oracle
                        79G    22G    49G    31%    /opt/oracle
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_log
                       5.6G   628M   4.4G    13%    /FSS/oracle/fsdata2/log
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_rollback
                        15G   6.6G   6.9G    50%    /FSS/oracle/fsdata2/rollback
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_system
                        15G   7.8G   5.5G    59%    /FSS/oracle/fsdata2/system
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_index
                        49G    33G    11G    76%    /FSS/oracle/fsdata2/index
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_archive
                        84G    64M    76G     1%    /FSS/oracle/fsdata2/archive
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_dump
                       372G   178G   157G    54%    /FSS/oracle/fsdata2/dump
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_data
                       536G   220G   263G    46%    /FSS/oracle/fsdata2/data
rpool                   96G    98K    32G     1%    /rpool
rpool/ROOT              96G    21K    32G     1%    /rpool/ROOT

root@samserv02:/dev/vx/dsk/samserv02dg >
---------------------------------------------------------------
root@samserv02:/dev/vx/dsk/samserv02dg > ls -l
total 0
brw-------   1 root     root     282, 123000 Nov  4  2012 FS_FSS_oracle
brw-------   1 root     root     282, 123034 Nov  4  2012 FS_FSS_oracle_fsdata2_archive
brw-------   1 root     root     282, 123030 Nov  4  2012 FS_FSS_oracle_fsdata2_data
brw-------   1 root     root     282, 123032 Nov  4  2012 FS_FSS_oracle_fsdata2_dump
brw-------   1 root     root     282, 123031 Nov  4  2012 FS_FSS_oracle_fsdata2_index
brw-------   1 root     root     282, 123038 Nov  4  2012 FS_FSS_oracle_fsdata2_log
brw-------   1 root     root     282, 123033 Nov  4  2012 FS_FSS_oracle_fsdata2_rollback
brw-------   1 root     root     282, 123039 Nov  4  2012 FS_FSS_oracle_fsdata2_system

---------------------------------------------------------------
root@samserv02:/ > df -h | grep vx | grep -v swap |awk '{print $1 "\t\t\t" $6}'

/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_log                /FSS/oracle/fsdata2/log
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_rollback           /FSS/oracle/fsdata2/rollback
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_system             /FSS/oracle/fsdata2/system
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_index              /FSS/oracle/fsdata2/index
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_archive            /FSS/oracle/fsdata2/archive
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_dump               /FSS/oracle/fsdata2/dump
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_data               /FSS/oracle/fsdata2/data
---------------------------------------------------------------
root@samserv02:/ > df -h | grep vx | grep -v swap |awk '{print $1}' | awk -F/ '{print $6}'
FS_FSS_oracle_fsdata2_log
FS_FSS_oracle_fsdata2_rollback
FS_FSS_oracle_fsdata2_system
FS_FSS_oracle_fsdata2_index
FS_FSS_oracle_fsdata2_archive
FS_FSS_oracle_fsdata2_dump
FS_FSS_oracle_fsdata2_data
---------------------------------------------------------------
root@samserv02:/ > vxprint -ht | grep "^v" | awk '{print $2}'
FS_FSS_oracle
FS_FSS_oracle_fsdata2_archive
FS_FSS_oracle_fsdata2_data
FS_FSS_oracle_fsdata2_dump
FS_FSS_oracle_fsdata2_index
FS_FSS_oracle_fsdata2_log
FS_FSS_oracle_fsdata2_rollback
FS_FSS_oracle_fsdata2_system
root@samserv02:/ >
root@samserv02:/dev/vx/dsk/samserv02dg > ls -l | awk '{print $10}'
FS_FSS_oracle
FS_FSS_oracle_fsdata2_archive
FS_FSS_oracle_fsdata2_data
FS_FSS_oracle_fsdata2_dump
FS_FSS_oracle_fsdata2_index
FS_FSS_oracle_fsdata2_log
FS_FSS_oracle_fsdata2_rollback
FS_FSS_oracle_fsdata2_system

---------------------------------------------------------------
root@samserv02:/dev/vx/dsk/samserv02dg > df -h | grep vx | awk '{print $1 "\t\t\t" $2 "\t\t\t" $6}' | grep -v swap
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_log                5.6G                    /FSS/oracle/fsdata2/log    Done - disk1
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_rollback           15G                     /FSS/oracle/fsdata2/rollback  Done - disk3
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_system             15G                     /FSS/oracle/fsdata2/system progress Done - disk3
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_index              49G                     /FSS/oracle/fsdata2/index  Done - disk4
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_archive            84G                     /FSS/oracle/fsdata2/archive   Done - disk3
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_dump               372G                    /FSS/oracle/fsdata2/dump
/dev/vx/dsk/samserv02dg/FS_FSS_oracle_fsdata2_data               536G                    /FSS/oracle/fsdata2/data   Done - disk5/6
---------------------------------------------------------------
# cat oldunxserv02.xml | grep vx | awk -F= '{print $2 "\t\t" $4}' | awk '{print $1 "\t" $3}' | sed 's/"//g' | awk '{print $1}'
/dev/vx/dsk/dataadg/FS_FSS_oracle_cfprod_archive
/dev/vx/dsk/dataadg/FS_FSS_oracle_cfprod_data1
/dev/vx/dsk/dataadg/FS_FSS_oracle_cfprod_data2
/dev/vx/dsk/dataadg/FS_FSS_oracle_cfprod_data3
/dev/vx/dsk/dataadg/FS_FSS_oracle_cfprod_data4
/dev/vx/dsk/dataadg/FS_FSS_oracle_cfprod_data5
/dev/vx/dsk/dataadg/FS_FSS_oracle_cfprod_data6

root@samserv02:/dev/vx/dsk/samserv02dg > vxassist -b -g samserv02dg mirror FS_opt_sybase  EMCDSK01
root@samserv02:/dev/vx/dsk/samserv02dg > vxtask list
TASKID  PTID TYPE/STATE    PCT   PROGRESS
   175           ATCOPY/R 07.62% 0/1638400/124928 PLXATT FS_opt_sybase FS_opt_sybase-02 samserv02dg

=======================================================================

root@samserv02:/ > vxprint -ht | grep "^v" | awk '{print $2}'
FS_FSS_oracle
FS_FSS_oracle_fsdata2_archive
FS_FSS_oracle_fsdata2_data
FS_FSS_oracle_fsdata2_dump
FS_FSS_oracle_fsdata2_index
FS_FSS_oracle_fsdata2_log
FS_FSS_oracle_fsdata2_rollback
FS_FSS_oracle_fsdata2_system


Create a volume with a plex called plex2
# vxmake -g baddg vol vol2 plex=plex2

Start a volume
Next, we must start the new volume
# vxvol -g SAMSUN09dg start vol2

Then use vxplex ‘att’ to attach the plex to the original volume. The plex will be synchronised with the plex(es) already

attached to
the volume.
# vxplex -g diskgroup att plex_name
==============================

mirror a volume

root@SAMSUNP09:/ > vxassist -b -g SAMSUN09dg mirror FS_DATA_oracle_hprd8_index
root@SAMSUNP09:/ > vxprint -ht | grep FS_DATA_oracle_hprd8_index
root@SAMSUNP09:/ > vxtask list
TASKID  PTID TYPE/STATE    PCT   PROGRESS
   275           ATCOPY/R 04.53% 0/109051904/4939776 PLXATT FS_DATA_oracle_hprd8_index FS_DATA_oracle_hprd8_index SAMSUN09dg

veot@SAMSUNP09:/ > vxassist -b -g SAMSUN09dg mirror FS_DATA_oracle_hprd8_archi
root@SAMSUNP09:/ > vxprint -ht | grep FS_DATA_oracle_hprd8_archive
v  FS_DATA_oracle_hprd8_archive - ENABLED ACTIVE 188743680 SELECT -        fsgen
pl FS_DATA_oracle_hprd8_archive-02 FS_DATA_oracle_hprd8_archive ENABLED ACTIVE 188753992 CONCAT - RW
sd emcdsk03-01  FS_DATA_oracle_hprd8_archive-02 emcdsk03 0 188753992 0 EMC_CLARiiON0_9 ENA


root@SAMSUNP09:/ >  vxassist -b -g SAMSUN09dg mirror FS_DATA_oracle_hprd8_index

root@SAMSUNP09:/ > vxassist -b -g SAMSUN09dg mirror FS_DATA_oracle_hprd8_dump EMCDSK01 EMCDSK02 EMCDSK03 EMCDSK04 EMCDSK05
EMCDSK06
root@SAMSUNP09:/ > vxtask list
TASKID  PTID TYPE/STATE    PCT   PROGRESS
   351           ATCOPY/R 00.03% 0/832569344/215040 PLXATT FS_DATA_oracle_hprd8_dump FS_DATA_oracle_hprd8_dump-0 SAMSUN09dg
root@SAMSUNP09:/ > vxprint -ht | grep FS_DATA_oracle_hprd8_dump
v  FS_DATA_oracle_hprd8_dump - ENABLED ACTIVE  832569344 SELECT   -        fsgen
pl FS_DATA_oracle_hprd8_dump-01 FS_DATA_oracle_hprd8_dump ENABLED TEMPRMSD 832569696 CONCAT - WO
sd EMCDSK06-02  FS_DATA_oracle_hprd8_dump-01 EMCDSK06 138923456 832569696 0 EMC_CLARiiON1_5 ENA
pl FS_DATA_oracle_hprd8_dump-02 FS_DATA_oracle_hprd8_dump ENABLED ACTIVE 832569696 CONCAT - RW
sd emcdsk02-04  FS_DATA_oracle_hprd8_dump-02 emcdsk02 169430296 832569696 0 EMC_CLARiiON0_7 ENA


Break a mirror

In the following steps we are going to disassociate the plexes from the parent volume using vxplex ‘dis’. VxVM also has a vxplex
‘det’ which is to detatch a plex. Confusingly, detatching a plex with vxplex ‘det’, stops writes to the plex, but the plex stays
associated with the parent volume

The first step is to detach one of the plexes and break its link to the remaining plex(es) (i.e. dissociate). We’ll

dissociate
‘plex2′

# vxplex -g baddg dis plex2

========================
 Disassociate the mirror plex:

# vxplex -g oradg dis oravol-02


attach back mirror plex to the volumedisk:

# vxplex -g oradg att oravol oravol-02


vxplex command to remove all the plexes of the volumes
# vxplex -o rm dis oravol-02 FS_VOL_vol-02 Next_VOL-02

formatting disks under linux (redhat flavor)


for host in `ls /sys/class/scsi_host`; do echo ""- - -" >/sys/class/scsi_host/$host/scan"; done

#!/bin/bash

for i in b c d e f; do
  if [ -b /dev/sd${i} ]; then
    echo "/dev/sd${i} is present.  Continuing....
  else
    exit 1
  fi
done
echo "Continuing with fdisk to create LVM Partitions"
echo "Press Ctrl+c to break out of the script"
sleep 5
for o in b c d e f; do
  fdisk /dev/sd$o << EOF
n
p
1

t
8e
w
EOF
done
fdisk -l /dev/sd$o
fdisk /dev/sdg << EOF
n
p
1

t
8e
w
EOF
fdisk -l /dev/sdg
partprobe /dev/sd$o


=================


#!/bin/bash
for i in b c d e f; do
  if [ -b /dev/sd${i} ]; then
    echo "/dev/sd${i} is present.  Continuing...."
    sleep 2
    (echo n; echo p; echo 1; echo 1;echo ;echo t; echo 8e;echo w) | fdisk /dev/sd${i}
  else
    exit 1
  fi
done

echo "Please enter a disk that you want to format"

#!/bin/ksh
#Create a single primary partiton with whole disk size and create LVM PV on it
disk=$1
partno=1
if [[ -z $disk ]]; then
   echo "Usage: $0 disk device name: e.g $0 /dev/sdb"
   exit
fi 
if [[ -e ${disk}${partno} ]]; then
   echo "==> ${disk}${partno} already exist"
   exit
fi

(echo n; echo p; echo 1; echo 1;echo ;echo t; echo 8e;echo w) | fdisk $disk

echo "==> create primary parition  $partno with $ncyl cylinders"
parted -a optimal $disk mkpart primary 0cyl ${ncyl}cyl
echo "==> set partition $partno to type: lvm "
parted $disk set $partno lvm on
partprobe > /dev/null 2>&1
echo "==> create PV ${disk}${partno} "
pvcreate ${disk}${partno}


#!/bin/sh
echo " Please enter the disk you like to partition"
read disk1 disk2 disk3 disk4 disk5 disk6 disk7
isslice=1
if [[ -z $disk


#!/bin/sh

echo "Please enter disk partition followed by space to create physical volume. eg: sdb1 sdb1 sdc1"
read a b c d d e f g h
pvcreate /dev/$a /dev/$b /dev/$c /dev/$d /dev/$e /dev/$f /dev/$g /dev/$h
echo "following confirms the pv is created"
pvs

echo "enter the size followed by the LV and VG name to create the  logical volume "
read a b c
lvcreate -L $a -n $b /dev/$c
echo "following confirms the logical volume is created"
lvs


echo "Please ensure the associated filesystem is unmounted before resize "
echo "enter the new size for lv followed by the vg and lv name and new size for filesystem for the resize operation "
echo "please be informed that during the resize operation filesystem consistency will be checked"
read a b c d
lvresize -L $a /dev/$b/$c ; e2fsck -f /dev/$b/$c ; resize2fs /dev/$b/$c $d
echo "following confirms the logical volume is resized"
lvs

#!/bin/ksh
# Create a single primary partiton with whole disk size and create LVM PV on it
disk=$1
partno=1
if [[ -z $disk ]]; then
echo "Usage: $0 disk device name: e.g $0 /dev/sdb"
exit
fi 
if [[ -e ${disk}${partno} ]]; then
echo "==> ${disk}${partno} already exist"
exit
fi

lsattr and chattr file attributes

Some Extended Attributes:-

lsattr and chattr

chattr - changes the file attributes on a Linux file system.
The format of a symbolic mode is +-=[acdeijstuADST].


Linux file systems support three permission attributes: Read, write and execute for three different levels: Owner, owning group, and everyone else. Extended attributes, abbreviated xattr, add some more permissions or restrictions to the original three attributes. chattr can be used to keep important system files secure.

The operator '+' causes the selected attributes to be added to the existing attributes of the files; '-' causes them to be removed; and '=' causes them to be the only attributes that the files have.

The letters 'acdeijstuACDST' select the new attributes for the files:


a :- append only
c :- compressed
d :- no dump
e :- extent format
i :- immutable
j :- data journalling
s :- secure deletion
t :- no tail-merging
u :- undeletable
A :- no atime updates
C :- no copy on write
D :- synchronous directory updates
S :- synchronous updates
T :- top of directory hierarchy



The following attributes are read-only, and may be listed by lsattr but not modified by chattr:

h :- huge file
E :- compression error
I :- indexed directory
X :- compression raw access
Z :- compressed dirty file

Options

R :- Recursively change attributes of directories and their contents.
V :- Be verbose with chattr's output and print the program version.
f :- Suppress most error messages.
v :- version, Set the file's version/generation number.


Detail,


When
'A' attribute is set, its atime record is not modified.
'a' attribute is set, only be open in append mode for writing.
'c' attribute is set, it automatically compressed on the disk by the kernel.
Note:
A read from this file returns uncompressed data.
A write to this file compresses data before storing them on the disk.

'D' attribute is set, the changes are written synchronously on the disk; this is equivalent to the 'dirsync' mount option applied to a subset of the files.

'd' attribute is set, there is no backup when the dump program is run.
'e' attribute indicates that the file is using extents for mapping the blocks on disk. It may not be removed using chattr.
'I' attribute is used by the htree code to indicate that a directory is being indexed using hashed trees.
'h' attribute indicates the file is storing its blocks in units of the filesystem blocksize instead of in units of sectors.
'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file.
'j' attribute has all of its data written to the ext3 journal before being written to the file itself, if the filesystem is mounted with the "data=ordered" or "data=writeback" options. When the filesystem is mounted with the "data=journal" option all file data is already journalled and this attribute has no effect.
a file with the 's' attribute set is deleted, its blocks are zeroed and written back to the disk.

When a file with the 'u' attribute set is deleted, its contents are saved. This allows the user to ask for its undeletion.

Changing attributes can be done with:

+ – set attribute
- – remove attribute
= – force these attributes
Thus to add the append attribute to test.txt:

# chattr +a test.txt

Using the = to set attributes will force only those attributes to be applied. If there are already attributes that are applied to the file those will be removed if not specified by in the chattr command.
Trying to set or remove the h attribute will fail as this can only be set by the file system not with chattr.

A file or directories attributes can be viewed with the lsattr command.



There are four extended attribute classes: security, system, trusted and user.
Note: extended attributes are not preserved by cp, rsync, and probably others.

$ setfattr -n user.checksum -v "3baf9ebce4c664ca8d9e5f6314fb47fb" foo.bar

$ getfattr -d file1
# file: file1
user.checksum="3baf9ebce4c664ca8d9e5f6314fb47fb3"


$ lsattr file1
-------------e- file1




Who Permission Numbers
------ ----------- ---------
u - owning user r - read 4 - read
g - group w - write 2 - write
o - others x - execute/search 1 - execute
a - all

Note:
The 'j', 'a' and 'i' options are only available to the superuser.
Please make sure to read the bugs and limitations section at the end of this document.
Even root can't delete a file that is immutable or append-only without first explicitly removing that attribute.
Using this flag on /etc/passwd or /etc/shadow files keeps them safe from an accidental rm -f and also ensures no new accounts can be added in the event of an exploit.
Keeping other files append-only means once they are written, that data can't be changed. Logs are a good candidate for this to keep them from being tampered with.


$ cd /var/tmp; $ mkdir test
$ cd test
$ touch file1 file2
$ lsattr
-------------e- ./file2
-------------e- ./file1
$ ls
file1  file2
$ setfattr -n user.checksum -v "3baf9ebce4c664ca8d9e5f6314fb47fb3" file1
$ lsattr
-------------e- ./file2
-------------e- ./file1
$ getfattr -d file1
# file: file1
user.checksum="3baf9ebce4c664ca8d9e5f6314fb47fb3"

$  getfattr -d file2
$ man chattr
$ lsattr file1
-------------e- file1
$ ls
file1  file2
$ cat >file2
This is a test file
cool !!!
$ ls -l file2
-rw-rw-r--. 1 dev dev 29 Oct 14 21:19 file2
$ lsattr file2
-------------e- file2
$ chmod 777 file2
$ lsattr file2
-------------e- file2
$ ls -l file2
-rwxrwxrwx. 1 dev dev 29 Oct 14 21:19 file2
$ chattr +i file2
chattr: Operation not permitted while setting flags on file2
$ su -
Password:
# cd /var/tmp/test
# ls
file1  file2
# chattr +i file2
# lsattr
----i--------e- ./file2
-------------e- ./file1
# cat file2
This is a test file
cool !!!
# cat >test2
This is cool too
# cat test2
This is cool too
# cat >>test2
I am just testing it
# rm test2
rm: remove regular file `test2'? y
# ls -l
total 8
-rw-rw-r--. 1 dev dev  0 Oct 14 19:14 file1
-rwxrwxrwx. 1 dev dev 29 Oct 14 21:19 file2
# mv file2 file3
mv: cannot move `file2' to `file3': Operation not permitted
# chattr -i file2
# lsattr file2
-------------e- file2
# rm file2
rm: remove regular file `file2'? y
# ls -l
total 4
-rw-rw-r--. 1 dev dev 0 Oct 14 19:14 file1
# cp file1 file2
# cat >>test2
I am just testing file again
# cat test2
I am just testing file again
# chattr +a test2
# rm test2
rm: remove regular file `test2'? y
rm: cannot remove `test2': Operation not permitted
# ls -l
total 8
-rw-rw-r--. 1 dev dev  0 Oct 14 19:14 file1
-rw-r--r--. 1 root  root   0 Oct 14 21:23 file2
-rw-r--r--. 1 root  root  29 Oct 14 21:23 test2
# cat >test2
-bash: test2: Operation not permitted
# cat >>test2
THis is added content
# cat test2
I am just testing file again
THis is added content
#
# chattr -i test
# lsattr test
-----a-------e- test/test2
-------------e- test/file2
-------------e- test/file1
# chattr -R -i test
# lsattr test
-----a-------e- test/test2
-------------e- test/file2
-------------e- test/file1
# rm -rf test
rm: cannot remove `test/test2': Operation not permitted

http://www.linuxintheshell.org/2013/04/23/episode-028-extended-attributes-lsattr-and-chattr/
http://en.wikipedia.org/wiki/Extended_file_attributes
http://linux.die.net/man/1/chattr - linux man page.
http://www.linuxhowtos.org/Tips%20and%20Tricks/chattr.htm

Friday, October 10, 2014

Booting into Rescue Mode and fsck the volumes


Booting into Rescue Mode and fsck the volumes

When you boot from cd, you will get an option to go to rescue mode. Please boot off the cd1 of the OS disk. It can be cd/DVD or ISO image. (x86 system).

You will be on prompt and just type linux rescue and press enter.
Follow some information and finally you will be on rescue mode with the shell prompt.
sh-2.05b#

A. Check the mounted filesystem with df -h

1. Get the volume to fsck
# df -h | awk '{print $i} >/tmp/zzz

2. Remove unwanted content and do the fsck.
# vi /tmp/zzz

3. If you get complain that mounted fs can not be fsck, unmount sysimage.
# mount | grep sysimage | awk '{print $3}' |sort -r | awk '{print "umount " $0}' |sh

4. Run fsck on volume.
# for i in `cat /tmp/zzz`; do fsck -y $i; done
or
# for i in `cat /tmp/zzz`; do e2fsck -y $i; done

B. Logging to the system disk.

1. Now mount the OS with chroot command
# chroot /mnt/sysimage

2. List the mounted fs. You will see all mounted from /etc/fstab
# df -h
3. If needed do the fsck.

Thursday, October 9, 2014

Linux chroot command

chroot - command
The chroot command creates a shell with an alternate root directory. It hides the content anything outside of this directory. To rescure the system, or for maintenance, you boot off the cd/DVD or ISO image. Your filesystem will be on cdrom's root filesystem not the system disks partition.

You can check with following commands.

# df -h | grep root
# mount | grep root
# ls

Mount your disk based root filesystem.
# mount /dev/mapper/system--ROOT /mnt
# cd /mnt

chroot to the disk mounted mountpoint.
# chroot /mnt
# ls /

review the content before chroot and after chroot. You will not be able to see the content from cd before you chrooted contents.

Note: If you are on rescue mode on redhat based systems using cd/dvd/iso image, your disk based root disk is mounted at /mnt/sysimage. You can simply run # chroot /mnt/sysimage to get into the disk based root fs.