Labels

hpunix (63) marathi kavita (52) linux (21) solaris11 (10) AWS (5) numerology (5)

Monday, December 19, 2016

rpm and yum commands are not working+ linux

At the time of patching I encountered a error and I wanted to check the version of yum on TEM server and the server which is going to patched. 

But found that neither the rpm or yum commands are working & session was getting hang.

#yum info yum or # rpm -qa |grep -i yum
session was hanging

 In such case, check whether any lock is created under  /var/lib/rpm/ & if it is there remove it because these locks are creating problem while running rpm commands.

1. # ls -lrt /var/lib/rpm/__db.*
-rw-------  1 root root   753664 Dec  9 07:05 __db.004
-rw-------  1 root root  1318912 Dec  9 07:05 __db.003
-rw-------  1 root root    24576 Dec  9 09:02 __db.001
-rw-------  1 root root   237568 Dec  9 09:05 __db.002

2. # rm /var/lib/rpm/__db.*


3. # ls -lrt /var/lib/rpm/__db.*

4. rpm commands and yum commands will run now.

Thanks,
Kiran Jadhav





Wednesday, September 14, 2016

New FS creation steps - Linux

Let’s take example that, admin wants to create a new FS with new VG.

VG name = vgbackup
LV name = lvbkp
mountpoint name = /backup
New disk added by VM team : /dev/sde

1. Scan new disk added by VM team
#fdisk -l |grep -i disk --> before adding new disk

#cd /sys/class/scsi_host/ --> we are having host0, host1 and host2

#echo ""- - -"" > /sys/class/scsi_host/host0/scan --> scanning new Lun for host0 , host1 & host2
#echo ""- - -"" > /sys/class/scsi_host/host1/scan
#echo ""- - -"" > /sys/class/scsi_host/host2/scan

#fdisk -l |grep -i disk --> after adding new disk

compare both fdisk output

2. create pv on new disk
#pvcreate /dev/sde

3. Create new VG:
#vgcreate vgbackup /dev/sde
#vgs --> to check all VG's details present on server.

4. Create new LV:
#lvcreate -n lvbkp -l 100%FREE vgbackup --> to use 100% disk space from VG
#lvcreate -n lvbkp -L 4G vgbackup --> to create LV of size 4GB

5. Create FS with FS type ext4:
#mkfs.ext4 /dev/mapper/vgbackup-lvbkp

6. Tune the FS
#tune2fs -m 1 /dev/vgbackup/lvbkp

where -m reserved-blocks-percentage

#tune2fs –c 0 –i 0 /dev/vgbackup/lvbkp

where, The Mount Count (-c) and check interval (i) values below are set to "-1" which disables any checking.

(If c=50 & i=1m then following command will modify the Check interval and Mount Count to only check after 100 mounts or a 1 month period.
#tune2fs -c 100 -i 1m /dev/vgbackup/lvbkp)

7. Create mountpoint:

#mkdir -p /backup

8. Edit /etc/fstab & make entry of new FS
#vi /etc/fstab
/dev/mapper/vgbackup-lvbkp       /backup     ext4    defaults        1 2"

9. Mount file-system

mount /dev/vgbackup/lvbkp /backup

Thanks & Regards,
Kiran Jadhav 

Wednesday, September 7, 2016

Small script to move files to & from multiple servers - Linux

Small script to move files to & from multiple servers:

1. Lets take a scenario in which we want to move files from one source server to multiple servers.

Here, we are taking example that the admin wants to move nmon log files to multiple servers.

nmon_servers = file where multiple servers name mentioned
source path : /usr/local/nmon_monthly
destination path : /usr/local/

for i in `cat /home/kiran/nmon_servers`
do
scp -rp /usr/local/nmon_monthly $i:/usr/local/
done

2. Second scenario is that we want to move files from multiple servers to one server:
nmon_servers = file where multiple servers name mentioned

for i in `cat /home/kiran/nmon_servers`
do
scp -rp $i:/var/log/nmon/* /var/log/nmon/
done

Thanks & Regards,

Kiran Jadhav 

Thursday, January 28, 2016

file:///mnt/repodata/repomd.xml - Yum error - RHEL

Yum Error:

[root@hrspwr ~]#  yum repolist

file:///mnt/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/repodata/repomd.xml
Trying other mirror.
repo id                                              repo name                                            status
cd                                                   cd                                                   0
cdha                                                 cd                                                   0
yum                                                  yum                                                  0
yum-update                                           yum-update                                           0
repolist: 0

The repolist shows value 0


Anwer:

In this case we are trying to get the yum repository from the repository server and not from the internet or DVD.


The just to check /edit whether you have proper entry in /etc/auto.master & /etc/auto.yum

[root@hrspwr ~]# cd /etc/yum.repos.d

[root@hrspwr yum.repos.d]# ls -lrt
total 8
-rw-r--r--. 1 root root 529 Oct 30  2013 rhel-source.repo
-rw-r--r--  1 root root 130 Nov 14 09:29 dvd.repo


[root@hrspwr yum.repos.d]# cat dvd.repo
[cd]
name = cd
baseurl = file:///mnt/
enabled = 1
gpgcheck = 0


[cdha]
name = cd
baseurl = file:///mnt/
enabled = 1
gpgcheck = 0

[root@hrspwr yum.repos.d]# vi dvd.repo

The enabled value should be 0, so it will not read the repository coming from DVD.

[root@hrspwr yum.repos.d]#  yum repolist

yum                                                                                      | 4.0 kB     00:00 ...
yum/primary_db                                                                           | 3.1 MB     00:02 ...
yum-update                                                                               | 3.0 kB     00:00 ...
yum-update/primary_db                                                                    |  14 MB     00:07 ...
repo id                                              repo name                                            status
yum                                                  yum                                                   3,585
yum-update                                           yum-update                                           15,533
repolist: 19,118


Now the repolist is showing value 19,118


Regards,
Kiran Jadhav



Monday, January 4, 2016

Linux Commands to scan/rescan Virtual Disk - Linux

Linux Commands to scan/rescan Virtual Disks:

1. If a new disk is added to VM:

#cd /sys/class/scsi_host/

# ls –lrt  It will show host0, host1….

#echo "- - -" > /sys/class/scsi_host/host[0-1-2]/scan


2. To rescan existing disk. If a existing disk is extended by VMWare team. Then rescan the same disk so the extended size of pv will reflect.

Note down the path [2:0:4:0] or disk name [/dev/sde] which is extended by VMWare team.

#echo 1 > /sys/class/scsi_device/*/device/rescan

# echo 1 > /sys/class/scsi_device/2:0:4:0/device/rescan --> fdisk -l will show new size of that lun

or go to #cd /sys/class/scsi_device/2:0:4:0/device/
#echo 1 > rescan

then

#pvresize [particular PV]

#pvresize /dev/sde --> #pvs command will show extended size of that PV