Wednesday, 30 November 2011

How to get cpu / processor / core info in Linux?

To get processor info we need to run below commands in Linux

1. #cat /proc/cpuinfo

or

2. #dmidecode

To get the core info in linux use the below commands. If the processor is dual core or quad core or single core processor means we will get the "core id"value in the below commands. If no core (single core) processor means we wont get the core id . so from the word "core id" we can get the processor is core processor or physical processor.

For examble here i took 2 servers ..

server1 - has 4 physical - single cored processors

server 2 - has 2 physical - dual core processors

4 Physical processor with no core (single core) means we will get o/p like below


root:server1# egrep "^processor|^cpu cores|^core id" /proc/cpuinfo
processor : 0
processor : 1
processor : 2
processor : 3
root:server1#

To get core info (whether core is there or not)

root:server1# grep core\ id /proc/cpuinfo |uniq -d |wc -l
0

To get total no of physical processor

root:server1# grep core\ id /proc/cpuinfo | grep -c \ 0$ | grep ^0$ >> /dev/null && grep -c processor /proc/cpuinfo || grep core\ id /proc/cpuinfo | grep -c \ 0$
4


Two dual core processor means (2- physical processor) we will get o/p like below


root:server2# egrep "^processor|^cpu cores|^core id" /proc/cpuinfo
processor : 0
core id : 0 ----------------- processor 1
cpu cores : 2
processor : 1
core id : 0 ----------------- processor 1
cpu cores : 2

processor : 2
core id : 1 ----------------- processor 2
cpu cores : 2
processor : 3
core id : 1 ----------------- processor 2
cpu cores : 2

root:server2#

To get core info run the below command

root:server2# grep core\ id /proc/cpuinfo |uniq -d |wc -l -------> this will give how many cores are there / if no core means it will give out put as 0.
2


To get how many physical processor is there on server ,then run below command

root:server2# grep core\ id /proc/cpuinfo | grep -c \ 0$ | grep ^0$ >> /dev/null && grep -c processor /proc/cpuinfo || grep core\ id /proc/cpuinfo | grep -c \ 0$
2


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

Friday, 25 November 2011

Mount DVD in unix ?

Use the following procedure to mount a DVD-ROM on HP-UX 11i v2 (B.11.23):

1. Log in as root
2. Insert the DVD into the DVD-ROM drive and wait for the drive's busy light to stop blinking.
3. Find the DVD-ROM device file name using the following command:

ioscan -fn -C disk | more
/dev/dsk/c1t2d0 is a typical device name.

4. Create the mount point under root(/):

mkdir /dvdrom

5. Mount the DVD onto the new directory as a file system. For example, the following command mounts the /dev/dsk/c1t2d0 device as the /dvdrom directory:

mount /dev/dsk/c1t2d0 /dvdrom

Route add in HP Unix

Let us assume your router address is 192.168.1.254 and network ID is 192.168.1.0/24, then you can type route command as follows:
# route add net 192.168.1.0 netmask 255.255.255.0 192.168.1.254
OR
To add a default route:
# route add default 192.168.1.254
Verify that (display) routing table is updated (display routing table):
# netstat -nr
Test it i.e. try to ping or send nslookup request:
# ping mycorp.com
To flush all routing entries use command [quite handy to clean your gordian knot ;)] :
# route -f
However if I reboot HPUX box then above routing entries gets removed. To pick up your setting upon each reboot your need to configure Routes in HPUX networking configuration file - /etc/rc.config.d/netconf. To add default router/gateway 192.168.1.254:

# vi /etc/rc.config.d/netconf
Add or modify following entries
ROUTE_DESTINATION[0]="default"
ROUTE_MASK[0]=""
ROUTE_GATEWAY[0]="192.168.1.254"
ROUTE_COUNT[0]="1"
ROUTE_ARGS[0]=""
Reboot HP-UX system/server to take effect

# shutdown -ry 0

Bundle All Patches in One Big Bundle - HP Unix

Creating one big bundle with all the extra patches you need to install will save your time during the upgrade/patching process and also prevent multiple reboots of your servers.

Create folder '/var/patches' with 'depot' and 'add' subfolders and copy the Quality Pack into '/var/patches/depot' and additional patches into '/var/patches/add' folder. Next you need to unpack the Golden Pack:

# swcopy -s /var/patches/depot/GOLDQPK11i_B.11.11.0612.459.depot \* @ /var/patches/depot/QPK

With swcopy copy all additional patches into this unpacked depot.


# for patch in /var/depot/app/*; do
echo ${patch}
swcopy -x enforce_dependencies=FALSE \
-x mount_all_filesystems=FALSE \
-x reinstall=TRUE -s ${patch} \* @ \
/var/patches/depot/QPK >> swcopy_patchs.log 2>&1 Verify that all the packages in the new bundle we create are OK.

# swverify -d -x mount_all_filesystems=FALSE \
-x enforce_dependencies=FALSE \* @ /var/patches/depot/QPK

Now, we have to revert the bundle into the original format for easier distribution.

# swpackage -x media_type=tape -s /var/patches/depot/QPK @ \
/var/patches/depot/GOLDQPK11i_B.11.11.0612.459.NEW.depot

You can use this file as any other regular depot file.

# swinstall -i -x patch_match_target=true -x autoreboot=true -s \
/var/patches/depot/GOLDQPK11i_B.11.11.0612.459.NEW.depot

Thursday, 24 November 2011

Recover OS using Ignite Backup

HP-UX have a software to backup the OS called "Ignite". It bundled with OS installed. The easy way to make a OS backup is using tape data cartridge. Just plug the tape to tape library, and run command "make_tape_recovery -AI".

To restore OS using recovery tape, go to MP (management processor) and boot to tape (Sequential media) and follow the intructions.

To simplify manage the archive of OS backup, we can utilize "Ignite Server". We can make OS backup to disk (via network) in another server (Ignite Server).The command is "make_net_recovery -s ignite_server -x inc_entire=vg00″.

To recovery OS using ignite server (Client and Ignite server in same IP subnet):

1. Boot the failed system to Ignite server (boot lan install or boot lan.ip_ignite_server install)
2. Do not interact with ISL
3. Select "Install HP-UX" and follow the instructions to fill about server configurations (network, hostname, etc)

4. Select recovery configurations to use
If clients to use is different subnet, we must use a boot helper server. the boot helper server have same subnet with client server. to setting up boot helper:

* for example: IP Ignite server is 10.2.2.1 & GW 10.2.2.254, OS to be restored is restore01 and target client is client01 (10.2.3.1 & GW 10.2.3.254)

1. Make sure the boot helper server have Ignite software with same version with client & Ignite server
2. Point the installation to Ignite server
# instl_adm -t 10.2.2.1
3. To verify the correct configuration in boot helper, run command instl_adm -d
4. Specify the temporary ip address at boot helper that client can use to boot. Edit /etc/opt/ignite/instl_boottab

5. Copy the CINDEX & recovery directory from source (OS to be restored) to target client (server use to restore).
at Ignite Server:
# cd /var/opt/ignite/clients/restore01
# find CINDEX recovery | cpio -pvdma ../client01
# edit CINDEX file at target client (/var/opt/ignite/clients/client01/CINDEX)
- make a full path for system_cfg, control_cfg & archive_cfg. (/var/opt/ignite/clients/client01/../…..)

6. Boot to boot helper or direct to ignite server

Add SWAP in HP Unix : How to ?

How to add SWAP in hp Unix

To create swap, you need a contiguous space on a disk/LUN.
Create vg01:

pvcreate /dev/rdsk/c25t0d0
pvcreate /dev/rdsk/c25t2d0
vgcreate -s 8 -p 128 /dev/vg01 /dev/dsk/c25t0d0 /dev/dsk/c25t2d0
vgchange -a y /dev/vg01

lvcreate -C y -L 16384 -n lvswap /dev/vg01

/usr/sbin/swapon -f -p 3 /dev/vg01/lvswap

add to /etc/fstab:

/dev/vg01/lvswap … swap pri=3 0 0

Unix- LVM commonly asked Interview questions..

Regular tasks
I) How to create a Volume Group (VG).
II) How to create a Logical Volume (LV) and mount the file system.

III) How to add a disk to a Volume Group
IV) How to increase the size of a logical volume without OnlineJFS
V) How to remove a Logical Volume
VI) How to reduce the size of a logical volume without OnlineJFS (advanced JFS)
VII) How to remove a disk from a volume group
VIII) How to remove a volume group
IX) How to increase the primary swap
X) How to create a secondary boot disk LVM Mirroring
XI) How to mirror a logical volume