Identify ethN correspondent to physical interface – Red Hat Enterprise Linux

Many times is necessary identify who eth (eth0, eth1, eth2, … , ethN) correspond to physical interface.

For this you can use the ethtool

ethtool -p ethN

example:

ethtool -p eth0

One or more LEDs on the specific physical ethernet port are blinking now.

Using authorized keys on SSH without password – Red Hat Enterprise Linux (works with others Unix)

Remember this is a very intrusive configuration.
Look your security policies with atention.

1. Make de keys using ssh-keygen

On the “Enter passphrase” question leave black and enter.

# ssh-keygen -t dsa -f ~/.ssh/id_dsa
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user1/.ssh/id_dsa.
Your public key has been saved in /home/user1/.ssh/id_dsa.pub.
The key fingerprint is:
87:52:b6:ec:c9:1f:f2:ce:be:d7:33:e9:1b:2b:33:dd user1@myserver1

2. Copy the public key for the server you want to have direct access.

# scp .ssh/id_dsa.pub user1@myserver2:~/.ssh/authorized_keys_temp

On myserver2 increse autorized_keys

# cat ~/.ssh/authorized_keys_temp >> ~/.ssh/authorized_keys

Remove temporary authorized_keys

# rm ~/.ssh/authorized_keys_temp

TIP: On RHEL 5 You can use ssh-copy-id

# ssh-copy-id -i ~user1/.ssh/id_dsa.pub user1@myserver2

Enabling rlogin, rexec and rcp (rsh-server) on Red Hat

On this example I´m using two servers named of myserver1 and myserve2 and the user is user1.

1. Install rsh-server

# yum install rsh-server -y
Loaded plugins: rhnplugin, security
Repository 'RHEL5LocalRepository' is missing name in configuration, using id
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package rsh-server.x86_64 0:0.17-40.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================
Package               Arch              Version                 Repository                       Size
=======================================================================================================
Installing:
rsh-server            x86_64            0.17-40.el5             RHEL5LocalRepository             40 k

Transaction Summary
=======================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 40 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : rsh-server                                                                      1/1

Installed:
rsh-server.x86_64 0:0.17-40.el5

Complete!

2. Enable services

# chkconfig rsh on
# chkconfig rlogin on
# chkconfig rexec on
# chkconfig nscd on
# chkconfig xinetd on

3. Reestart xinetd and  nscd

# /etc/init.d/xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]

# /etc/init.d/nscd restart
Stopping nscd:                                             [  OK  ]
Starting nscd:                                             [  OK  ]

4. Edit /etc/securetty and add rsh, rlogin and rexec

# vi /etc/securetty

Put on end of file:

rsh
rlogin
rexec

5. Create file ~user1/.rhosts (user1 is my user example)

# vi ~user1/.rhosts

Put on end of file:

myserver2 user1

Change the permission of file

# chmod 600 ~user1/.rhost

6. Testing

On myserver2 with user1 create a file testing.file

# touch testing.file

Uses the rcp:

# rcp testing.file myserver1:tested.file

Look if file are created using the rexec

# rsh myserver1 ls -l ~user1

Identify QLogic WWN on Red Hat Enterprise Linux 5 and 4 (RHEL)

How to identify/get QLogic WWN on Red Hat Enterprise Linux 5 (RHEL5).

First identify your installed or recognized

# lspci | grep -i fibre
04:00.0 Fibre Channel: QLogic Corp. ISP2432-based 4Gb Fibre Channel to PCI Express HBA (rev 03)
04:00.1 Fibre Channel: QLogic Corp. ISP2432-based 4Gb Fibre Channel to PCI Express HBA (rev 03)
05:00.0 Fibre Channel: QLogic Corp. ISP2432-based 4Gb Fibre Channel to PCI Express HBA (rev 03)
05:00.1 Fibre Channel: QLogic Corp. ISP2432-based 4Gb Fibre Channel to PCI Express HBA (rev 03)

On Red Hat Enterprise Linux 5 (5.x) is on /sys/class/fc_host/hostX/port_name

(X is your device 1,2,3,…N)

For get use:

cat /sys/class/fc_host/hostX/port_name

Sample with multiple HBA (Fibre) QLogic

# ls /sys/class/fc_host/
host3  host4  host5  host6
# cat /sys/class/fc_host/host[3-6]/port_name
0x2100001b32936e24
0x2101001b32b36e24
0x2100001b32932821
0x2101001b32b32821

On Red Hat Enterprise Linux 4 (AS/ES) is on /proc/scsi/qla2xxx/1 (1,2,3,..N)

Sample:

# egrep [node|port] /proc/scsi/qlx2xxx/0
scsi-qla0-adapter-node=200000e08b1c19f2;
scsi-qla0-adapter-port=210000e08b1c19f2;

Making LVM Mirror on Linux using Red Hat CLuster Suite – CLVM (Cluster LVM) – on RHEL 5

1. The scenario

On my box I’ve two disks from two differents Storage Disk.

Using multipath I’ve this disks
/dev/dm-15 from Storage Disk A (in use)
/dev/dm-28 from Storage Disk B (not in use yet.)

I’ve the Volume Group with name vg_gfs00 on /dev/dm-15
I’ve the Logical Volume with name lv00 on the Volume Group VG_GFS

Looking my outputs pvs, vgs and lvs

PVS output
# pvs
PV         VG          Fmt  Attr PSize   PFree
/dev/dm-15 vg_gfs00    lvm2 a-   278,98G 39,95G
/dev/sda3  rootvg      lvm2 a-   131,47G 86,19G

VGS output
# vgs
VG          #PV #LV #SN Attr   VSize   VFree
rootvg        1  11   0 wz--n- 131,47G 86,19G
vg_gfs00all   8   7   0 wz--n- 278,98G 39,95G

LVS output
# lvs
LV          VG          Attr   LSize
homelv      rootvg      -wi-ao 512,00M
optlv       rootvg      -wi-ao   1,00G
rootlv      rootvg      -wi-ao   1,00G
tmplv       rootvg      -wi-ao   2,00G
usrlv       rootvg      -wi-ao   4,00G
varloglv    rootvg      -wi-ao   8,00G
varlv       rootvg      -wi-ao   4,00G
lv00        vg_gfs00    -wi-ao 239,03G

2. Objective

Implement a mirror on filesystems for high availbility if my Storage Disk A or B crashs.

3. Implementing

a. Make a PV on new disk (/dev/dm-28)

# pvcreate /dev/dm-28

b. Add new volume on the vg_gfs00

# vgextend vg_gfs00 /dev/dm-28

c. Make a mirror on Logical Volume

# lvconvert -m1 vg_gfs00/lv00 /dev/dm-28
vg_gfs00/lv00: Converted: 17,1%
vg_gfs00/lv00: Converted: 34,1%
vg_gfs00/lv00: Converted: 51,0%
vg_gfs00/lv00: Converted: 68,4%
vg_gfs00/lv00: Converted: 85,5%
vg_gfs00/lv00: Converted: 100,0%

Note: If your LV are in more PVs you can specify all PVs
Sample:

# lvs -a -o +devices | grep lv00
lv00          vg_gfs00 -wi-ao  10,00G     /dev/dm-15(0)
lv00          vg_gfs00 -wi-ao  10,00G     /dev/dm-16(123490)

In this case dm-15 and dm-16 are on my Storage Disk A, I need two disks on the Storage Disk B, sample dm-28 and dm-29.
For convert I use this
# lvconvert -m1 vg_gfs00/lv00 /dev/dm-28 /dev/dm-29

d. Checking Mirror with lvs -a -o +devices

# lvs -a -o +devices | grep vl00
lv00            vg_gfs00 mwi-ao  10,00G       lv00_mlog 100,00         lv00_mimage_0(0),lv00_mimage_1(0)
[lv00_mimage_0] vg_gfs00 iwi-ao  10,00G                                /dev/dm-15(10242)
[lv00_mimage_1] vg_gfs00 iwi-ao  10,00G                                /dev/dm-28(14086)

Looking details:

lv00 is a lv00_mlog and have a 100% of sync to lv00_mimage_0 and lv00_image1.
The lv00_mimage_0 is stored on /dev/dm-15
The lv00_mimage_1 is stored on /dev/dm-28

Looking with a simple lvs

# lvs
LV          VG          Attr   LSize  Origin Snap%  Move Log              Copy%  Convert
homelv      rootvg      -wi-ao 512,00M
optlv       rootvg      -wi-ao   1,00G
rootlv      rootvg      -wi-ao   1,00G
tmplv       rootvg      -wi-ao   2,00G
usrlv       rootvg      -wi-ao   4,00G
varloglv    rootvg      -wi-ao   8,00G
varlv       rootvg      -wi-ao   4,00G
lv00        vg_gfs00    -wi-ao 239,03G              lv00_mlog 100,00

If the lv00_mlog is not 100% you have a problem with one of disks.

4. Documentation:

* http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.2/html/Cluster_Logical_Volume_Manager/
- 2.3.3. Mirrored Logical Volumes
- 4.4.1.3. Creating Mirrored Volumes
- 6.3. Recovering from LVM Mirror Failure

Linux: GFS / GFS2 Sharing filesystems multiple servers / nodes

1 – Creating the Volume Group

# pvs
PV         VG     Fmt  Attr PSize  PFree
/dev/sda3  rootvg lvm2 a-   62.75G 38.97G
/dev/dm-10        lvm2 --   70.00G 70.00G
/dev/dm-13        lvm2 --   70.00G 70.00G
/dev/dm-14        lvm2 --   70.00G 70.00G
/dev/dm-9         lvm2 --   70.00G 70.00G

# vgcreate vg_cluster00 /dev/dm-10 /dev/dm-13  /dev/dm-14 /dev/dm-9
Volume group "vg_cluster00" successfully created

# pvs
PV         VG          Fmt  Attr PSize  PFree
/dev/dm-10 vg_cluster00 lvm2 a-   70.00G 70.00G
/dev/dm-13 vg_cluster00 lvm2 a-   70.00G 70.00G
/dev/dm-14 vg_cluster00 lvm2 a-   70.00G 70.00G
/dev/dm-9  vg_cluster00 lvm2 a-   70.00G 70.00G
/dev/sda3  rootvg      lvm2 a-   62.75G 38.97G

# vgs
VG          #PV #LV #SN Attr   VSize   VFree
rootvg        1   9   0 wz--n-  62.75G  38.97G
vg_cluster00   4   0   0 wz--n- 279.98G 279.98G

2 – Creating the Logical Volumes

# vcreate -L180G vg_cluster00 -n lvuserapp

3 – Making the Cluster

Particulary I like system-config-cluster

This is my simple /etc/cluster/cluster.conf

<?xml version="1.0"?>
<cluster alias="CLUSTER00" config_version="23" name="CLUSTER00">
<fence_daemon post_fail_delay="0" post_join_delay="3"/>
<clusternodes>
<clusternode name="node001" nodeid="1" votes="1">
<fence>
<method name="1"/>
</fence>
</clusternode>
<clusternode name="node003" nodeid="3" votes="1">
<fence>
<method name="1"/>
</fence>
</clusternode>
<clusternode name="node004" nodeid="4" votes="1">
<fence>
<method name="1"/>
</fence>
</clusternode>
<clusternode name="node002" nodeid="2" votes="1">
<fence>
<method name="1"/>
</fence>
</clusternode>
</clusternodes>
<fencedevices/>
</cluster>

4 – making gfs2 filesystems

# mkfs -t gfs2 -p lock_dlm -t CLUSTER00:lvuserapp -j 8 /dev/vg_cluster00/lvuserapp

5 – mounting GFS2 filesystems

Put on the /etc/fstab file

/dev/vg_cluster00/lvuserapp      /home/userapp           gfs2    defaults       0 0

6 – Start the cluster services

Note: For complete startup start the service on all nodes.

service cman start
service rgmanager start

7 – Check the nodes

# cman_tool nodes
Node  Sts   Inc   Joined               Name
1   M    196   2009-04-09 11:57:16  node001
2   M    216   2009-04-09 11:57:32  node002
3   M    212   2009-04-09 11:58:02  node003
4   M    214   2009-04-09 11:58:32  node004

8 – mounting the filesystems

Mount filesystems on all nodes

# mount /home/userapp

9 – testing the read/write files on nodes

# touch /home/userapp/teste.txt

Check on all servers if this file exist.

Sources:

Recovering VGDA on LVM1 (restore metadata to disk) Linux

vgscan output this error

ERROR "vg_read_with_pv_and_lv(): current PV" can't get data of volume group "vgappl01" from physicalvolume(s)

1) Check the backups on /etc/lvmconf/

NOTE: I recommend make backup of this dir to tape or external media

2) Check PVS

# pvdisplay /dev/sdxn

If some PV output no informations use that.

3) Recreate PV on partition or disk

# pvcreate /dev/sdb1

4) Make restore of VG on disk

# vgcfgrestore -n vgappl01 /dev/sdb1
vgcfgrestore -- INFO: using backup file "/etc/lvmconf/vgappl01.conf"
vgcfgrestore -- VGDA for "vgappl01" successfully restored to physical volume "/dev/sdb1"

5) Run pvscan

# pvscan
pvscan -- reading all physical volumes (this may take a while...)
pvscan -- inactive PV "/dev/vpatha1"  is associated to unknown VG "vgappl01" (run vgscan)
pvscan -- inactive PV "/dev/vpathb1"  is associated to unknown VG "vgappl01" (run vgscan)
pvscan -- ACTIVE   PV "/dev/sda3"    of VG "rootvg"   [52.49 GB / 37.31 GB free]
pvscan -- inactive PV "/dev/sdb1"     is associated to unknown VG "vgappl01" (run vgscan)
pvscan -- inactive PV "/dev/sdc1"     is associated to unknown VG "vgappl01" (run vgscan)
pvscan -- inactive PV "/dev/sdd1"     is associated to unknown VG "vgappl01" (run vgscan)
pvscan -- inactive PV "/dev/sde1"     is associated to unknown VG "vgappl01" (run vgscan)
pvscan -- inactive PV "/dev/sdf1"     is associated to unknown VG "vgappl01" (run vgscan)
pvscan -- inactive PV "/dev/sdg1"     is associated to unknown VG "vgappl01" (run vgscan)
pvscan -- inactive PV "/dev/sdh1"     is associated to unknown VG "vgappl01" (run vgscan)
pvscan -- inactive PV "/dev/sdi1"     is associated to unknown VG "vgappl01" (run vgscan)
pvscan -- total: 11 [402.42 GB] / in use: 11 [402.42 GB] / in no VG: 0 [0]

6) run vgscan

# vgscan
vgscan -- reading all physical volumes (this may take a while...)
vgscan -- found active volume group "vgappl01"
vgscan -- found active volume group "rootvg"
vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created
vgscan -- WARNING: This program does not do a VGDA backup of your volume groups

7) For your security, make new backup

# vgcfgbackup
vgcfgbackup -- volume groups found: rootvg vgappl01
vgcfgbackup -- successful VGDA backup of volume group "rootvg" to "/etc/lvmconf/rootvg.conf"
vgcfgbackup -- successful VGDA backup of volume group "vgappl01" to "/etc/lvmconf/vgappl01.conf"

Reference: http://kbase.redhat.com/faq/docs/DOC-5537

Installing IBM lin_tape and lin_taped on Linux (Red Hat Enterprise Linux)

Installing IBM lin_tape on Linux (Red Hat Enterprise Linux)

Steps for install lin_tape and lin_taped

1. Download the lin_tape source and lin_taped from ftp://ftp.software.ibm.com/storage/devdrvr/Linux/lin_tape_source-lin_taped/

lin_tape-X.YY.Z-W.src.rpm.bin
lin_taped-X.YY.Z-rhel[V].arch.rpm.bin

Samples for version 1.20.0-1

lin_tape-1.20.0-1.src.rpm.bin
lin_taped-1.20.0-rhel4.x86_64.rpm.bin

2. Rebuild lin_tape rpm source

# rpmbuild --rebuild lin_tape-X.YY.Z-W.src.rpm.bin

(mais…)

Extracting files from rpm

First you need rpm2cpio

Use

# mkdir /tmp/package
# cp package.rpm /tmp/package
# cd /tmp/package
# rpm2cpio package.rpm | cpio -idv

Posted by Wordmobi

Checking the install date of Linux Operation System (Red Hat) – Not official, but usefull

Inglish (português mais abaixo)

The package basesystem contains no files

# rpm -ql basesystem
(contains no files)

But your discription is very clean:
Basesystem defines the components of a basic Red Hat Linux system (for
example, the package installation order to use during bootstrapping).
Basesystem should be the first package installed on a system and it
should never be removed.

You can check Install Date from this package

# rpm -qi basesystem
Name : basesystem Relocations: (not relocatable)
Version : 8.0 Vendor: Red Hat, Inc.
Release : 4 Build Date: Wed 22 Sep 2004 07:01:44 PM BRT
Install Date: Sat 17 Jan 2009 05:28:37 PM BRST Build Host: tweety.build.redhat.com
Group : System Environment/Base Source RPM: basesystem-8.0-4.src.rpm
Size : 0 License: public domain
Signature : DSA/SHA1, Wed 05 Jan 2005 09:03:37 PM BRST, Key ID 219180cddb42a60e
Packager : Red Hat, Inc.
Summary : The skeleton package which defines a simple Red Hat Linux system.
Description :
Basesystem defines the components of a basic Red Hat Linux system (for
example, the package installation order to use during bootstrapping).
Basesystem should be the first package installed on a system and it
should never be removed.

Português

Checando a data de instalação do Sistema Operacional Linux (Red Hat) – Não oficial, mas utilizavel

O pacote basesystem não contem arquivos

# rpm -ql basesystem
(contains no files)

Mas usa descrição é muito simples:
Basesystem defines the components of a basic Red Hat Linux system (for
example, the package installation order to use during bootstrapping).
Basesystem should be the first package installed on a system and it
should never be removed.

Você pode checar a data de instalação a partir deste pacote

# rpm -qi basesystem
Name : basesystem Relocations: (not relocatable)
Version : 8.0 Vendor: Red Hat, Inc.
Release : 4 Build Date: Wed 22 Sep 2004 07:01:44 PM BRT
Install Date: Sat 17 Jan 2009 05:28:37 PM BRST Build Host: tweety.build.redhat.com
Group : System Environment/Base Source RPM: basesystem-8.0-4.src.rpm
Size : 0 License: public domain
Signature : DSA/SHA1, Wed 05 Jan 2005 09:03:37 PM BRST, Key ID 219180cddb42a60e
Packager : Red Hat, Inc.
Summary : The skeleton package which defines a simple Red Hat Linux system.
Description :
Basesystem defines the components of a basic Red Hat Linux system (for
example, the package installation order to use during bootstrapping).
Basesystem should be the first package installed on a system and it
should never be removed.