Thursday, July 28, 2011

GPG key error when updating RHEL 5.x system

when running a `yum update -y`, i got:

--
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 897da07a


Public key for nash-5.1.19.6-71.el5.i386.rpm is not installed
--


I had to install:

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta

then run again.


also, check this:

rpm -qa |grep gpg

if you have multiple of the same gpg keys installed use the following:

rpm -e --allmatches gpg-pubkey*
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta

Monday, July 25, 2011

mdadm notes

mdadm --remove /dev/md0 /dev/sdb
#pull disk, replace with new one

# you have to fail a disk before you remove it
# however, if the system wont release the raid partner, you need to slide the offending disks out and boot off a good disk.

#here you can review the layout
[root@host~]# fdisk -l /dev/sda

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          16      128488+  fd  Linux raid autodetect
/dev/sdb2              17        1291    10241437+  fd  Linux raid autodetect
/dev/sdb3            1292        2566    10241437+  83  Linux
/dev/sdb4            2567       30401   223584637+   5  Extended
/dev/sdb5            2567        2827     2096451   fd  Linux raid autodetect
/dev/sdb6            2828        2860      265041   fd  Linux raid autodetect
/dev/sdb7            2861       30401   221223051   fd  Linux raid autodetect

#review the descriptions of the disks



-----------


[root@host ~]# sfdisk -d /dev/sda
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=       63, size=   256977, Id=fd, bootable
/dev/sda2 : start=   257040, size= 20482875, Id=fd
/dev/sda3 : start= 20739915, size= 20482875, Id=83
/dev/sda4 : start= 41222790, size=449113140, Id= 5
/dev/sda5 : start= 41222853, size=  4192902, Id=fd
/dev/sda6 : start= 45415818, size=   530082, Id=fd
/dev/sda7 : start= 45945963, size=444389967, Id=fd
[root@host ~]# sfdisk -d /dev/sdb

sfdisk: ERROR: sector 0 does not have an msdos signature
 /dev/sdb: unrecognized partition table type
No partitions found
-----------


#this command is similar to `sfdisk -l`, but you can use it to copy the layout to the new replacement disk
#its destructive to sdb, be sure you know what you're doing. read man page, right?  :)


-----------

[root@host~]# sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdb: 30522 cylinders, 255 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
 /dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sdb1   *        63    257039     256977  fd  Linux raid autodetect
/dev/sdb2        257040  20739914   20482875  fd  Linux raid autodetect
/dev/sdb3      20739915  41222789   20482875  83  Linux
/dev/sdb4      41222790 490335929  449113140   5  Extended
/dev/sdb5      41222853  45415754    4192902  fd  Linux raid autodetect
/dev/sdb6      45415818  45945899     530082  fd  Linux raid autodetect
/dev/sdb7      45945963 490335929  444389967  fd  Linux raid autodetect
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
[root@host~]# sfdisk -d /dev/sdb
# partition table of /dev/sdb
unit: sectors

/dev/sdb1 : start=       63, size=   256977, Id=fd, bootable
/dev/sdb2 : start=   257040, size= 20482875, Id=fd
/dev/sdb3 : start= 20739915, size= 20482875, Id=83
/dev/sdb4 : start= 41222790, size=449113140, Id= 5
/dev/sdb5 : start= 41222853, size=  4192902, Id=fd
/dev/sdb6 : start= 45415818, size=   530082, Id=fd
/dev/sdb7 : start= 45945963, size=444389967, Id=fd


-----------




#check the status of the set
cat /proc/mdstat

#now, add the partition slices back to the set
mdadm --add /dev/md0 /dev/sdb1
mdadm --add /dev/md1 /dev/sdb5
mdadm --add /dev/md3 /dev/sdb6
mdadm --add /dev/md4 /dev/sdb7
mdadm --add /dev/md2 /dev/sdb2


#review
mdadm --detail /dev/md0

#review progress
cat /proc/mdstat


healthy output:

[root@host ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[0] sdb1[1]
      128384 blocks [2/2] [UU]
   
md1 : active raid1 sda5[0] sdb5[1]
      2096384 blocks [2/2] [UU]
   
md3 : active raid1 sda6[0] sdb6[1]
      264960 blocks [2/2] [UU]
   
md4 : active raid1 sda7[0] sdb7[1]
      221222976 blocks [2/2] [UU]
   
md2 : active raid1 sda2[0] sdb2[1]
      10241344 blocks [2/2] [UU]
   
unused devices:


UNhealthy output:

[root@host ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1]
      128384 blocks [2/2] [_U]
   
md1 : active raid1 sdb5[1]
      2096384 blocks [2/2] [_U]
   
md3 : active raid1 sdb6[1]
      264960 blocks [2/2] [_U]
   
md4 : active raid1 sdb7[1]
      221222976 blocks [2/2] [_U]
   
md2 : active raid1 sdb2[1]
      10241344 blocks [2/2] [_U]
   
unused devices:

#have a nice day



--------------------------------------------------------
[root@somehost ~]# mdadm --detail /dev/md0
/dev/md0:
Version : 00.90.03
Creation Time : Sat Oct 31 03:08:47 2009
Raid Level : raid1
Array Size : 128384 (125.40 MiB 131.47 MB)
Device Size : 128384 (125.40 MiB 131.47 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Mon Jul 25 04:48:26 2011
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

UUID : xxxxxx:xxxxxxxx:xxxxxxx:dd7a13a5
Events : 0.74

Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
--------------------------------------------------------

nagios check: check_by_ssh!"sudo /bin/cat /proc/mdstat | grep _ /proc/mdstat -c | grep 0 -c

Thursday, July 21, 2011

ethtool command

/sbin/ethtool -s eth0 speed 100 duplex full autoneg off

mail alert when script is finished

echo y | ./deploy.sh -s xxxx -f '/root/xxxxx.tgz' && mail -s "deployment complete on `hostname`" me@overthere.com < /dev/null

Monday, July 18, 2011

logrotate script

#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0

create a list of all packages

#!/bin/sh

/bin/rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}.rpm\n' 2>&1 \
| /bin/sort > /var/log/rpmpkgs

The idea would be to take a sha1 hash of this file and then check it periodically to be sure that the package list has not changed.