Tanti Technology

My photo
Bangalore, karnataka, India
Multi-platform UNIX systems consultant and administrator in mutualized and virtualized environments I have 4.5+ years experience in AIX system Administration field. This site will be helpful for system administrator in their day to day activities.Your comments on posts are welcome.This blog is all about IBM AIX Unix flavour. This blog will be used by System admins who will be using AIX in their work life. It can also be used for those newbies who want to get certifications in AIX Administration. This blog will be updated frequently to help the system admins and other new learners. DISCLAIMER: Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility. If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.

Wednesday 13 February 2013

How to configure the DNS in Unix and Linux servers?



How to configure the DNS in Unix and Linux servers?


A) Steps:

First Create the file called /etc/resolv.conf - which includes the primary and secondary DNS server IP address for UNIX system, its your own DNS server.

# touch /etc/resolv.conf
# vi /etc/resolv.conf (Add the following lines to it)
domain test-lob.com  
nameserver ipaddress
nameserver ipaddress
Where, nameserver IP: It is IP of first DNS server and secondary DNS server of test-lob.com.


Search test-lob.com: Default domain name to search.

For example, if you type command nslookup www, it will search it as www.test-lob.com

For AIX Enable the name resolving using DNS as follows:
Edit the file /etc/netsvc.conf so that the “host =” will be pointing to local and dns as in the following
hosts=local,bind

For Solaris and Linux, Enable the name resolving using DNS as follows:
Edit the file /etc/nsswitch.conf so that the “host:” will be pointing to local and dns as in the following
hosts: files dns

B). VALIDATION REQUIREMENTS
Check with nslookup it should be able to resolve the host to IP and IP to host as in the following example
# nslookup
Default Server: change.test-lob.com
Address: 10.14.15.16
> lotus

Server: change.test-lob.com
Address: 10.14.15.16

Name: lotus.test-lob.com
Address: 10.120.12.6

Resolve from IP to host:
nslookup 10.120.12.6

Server: change.test-lob.com
Address: 10.14.15.16


Name: lotus.test-lob.com
Address: 10.120.12.6


C). ROLL BACK
AIX:
Remove the entries you have added in the /etc/netsvc.conf , so that the server will point to local host configuration file ( /etc/hosts ) only.

LINUX & SOLARIS:
Remove the entries you have added in the /etc/nsswitch.conf so that the server will point to local host configuration file ( /etc/hosts ) only.


How to mirror the rootvg in AIX?


How to mirror the rootvg in AIX?

How to mirror the rootvg in AIX?

This procedure is to assume the rootvg having hdisk0 and we need to take a mirror to hdisk1. 

Pre-Work:

                   
Make sure the hdisk0 and the hdisk1 are in the same size. check the size with the #bootinfo -s hdisk1" command

          

Steps:
     
1. Add hdisk1 to rootvg:
         extendvg rootvg hdisk1
2. Mirror rootvg to hdisk1:
         mirrorvg rootvg hdisk1 (or smitty mirrorvg)
3. Create boot images on hdisk1:
         bosboot -ad /dev/hdisk1
4. Add hdisk1 to the bootlist:

                                     bootlist -m normal hdisk0 hdisk1  

Validation:

Validation:

·         Execute the below commands and ensure that the number of PPs is double than number than LPs.
             # lsvg –l rootvg

rootvg:
LV NAME   TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
hd5                 boot       1       2       2    closed/syncd  N/A
hd6                 paging     105     210     2    open/syncd    N/A
hd8                 jfs2log    1       2       2    open/syncd    N/A
hd4                 jfs2       16      32      2    open/syncd    /
hd2                 jfs2       40      80      2    open/syncd    /usr
hd9var              jfs2       40      80      2    open/syncd    /var
hd3                 jfs2       40      80      2    open/syncd    /tmp
hd1                 jfs2       16      32      2    open/syncd    /home
hd10opt             jfs2       40      80      2    open/syncd    /opt




Rollback:
1. Un-Mirror rootvg to hdisk0:
unmirrorvg rootvg hdisk1
2. Reduce the hdisk0 from Rootvg
reducevg rootvg hdisk1
3. delete the bootimage from hdisk1
chpv -c hdisk1
4. Add hdisk0 only to the bootlist:
bootlist -m normal hdisk0

Downtime details:

·        No downtime required.

How to recover a deleted file in aix?



How to recover a deleted file in aix?

It is possible to recover the file using the "fsdb" command (filesystem debugger). when,
No new files have been created on the filesystem.
No files have been extended.
The filesystem is able to be unmounted.

Warning: I have test this in my test server. This is undocumented one. You may facing the critical problem when you follow the below steps on your systems. So try this at your own risk. Please avoid directly try this with your production servers. Here is the output for your reference.


# lsvg -l testvg
testvg:
LV NAME             TYPE       LPs   PPs   PVs  LV STATE      MOUNT POINT
loglv00             jfs2log    1     1     1    closed/syncd  N/A
#
# crfs -a size=256M -v jfs2 -g testvg -m /new            à create a "/new" FS
File system created successfully.
261932 kilobytes total disk space.
New File System size is 524288
#
# lsvg -l testvg
testvg:
LV NAME             TYPE       LPs   PPs   PVs  LV STATE      MOUNT POINT
loglv00             jfs2log    1     1     1    closed/syncd  N/A
fslv00              jfs2       16    16    1    closed/syncd  /new
#
# mount /new         à mount the /new FS
#
# lsvg -l testvg
testvg:
LV NAME             TYPE       LPs   PPs   PVs  LV STATE      MOUNT POINT
loglv00             jfs2log    1     1     1    open/syncd    N/A
fslv00              jfs2       16    16    1    open/syncd    /new
#
# cd /new
#
# ls -l
total 0
drwxr-xr-x   2 root     system          256 Apr 03 16:47 lost+found
#
# cat >> film         à Create a file named “film”
Hi this is the test file. I want to use this file for recovery test
^C#
#
# cat film
Hi this is the test file. I want to use this file for recovery test
#
# ls –il        à check the inode number of the file “film”. That is 4
total 8
    4 -rw-r--r--   1 root     system           68 Apr 03 16:49 film
    3 drwxr-xr-x   2 root     system          256 Apr 03 16:47 lost+found
#
#
# rm film     à remove the file “film”
#
# ls -l
total 0
drwxr-xr-x   2 root     system          256 Apr 03 16:47 lost+found
#
# cd ~
#
# umount /new     à unmount the /new FS
#
# lsvg -l testvg
testvg:
LV NAME             TYPE       LPs   PPs   PVs  LV STATE      MOUNT POINT
loglv00             jfs2log    1     1     1    closed/syncd  N/A
fslv00              jfs2       16    16    1    closed/syncd  /new
#
# fsdb /dev/fslv00       à use the “fsdb ” to recover the deleted  file.

File System:                    /dev/fslv00

File System Size:               523864  (512 byte blocks)
Aggregate Block Size:           4096
Allocation Group Size:          8192    (aggregate blocks)

> dir 2
 idotdot = 2

 3      lost+found
> 
> i 4     à provide the inode number of our deleted file. That is 4
Inode 4 at block 33, offset 0x800:

[1] di_fileset:         16                 [18] di_inostamp:       0x4d98ead4
[2] di_number:          4               [19] di_gen:            3940655789
[3] di_size:    0x0000000000000044      [20] di_ixpxd.len:      4
[4] di_nblocks: 0x0000000000000001      [21] di_ixpxd.addr1:    0x00
[5] di_nlink:           0               [22] di_ixpxd.addr2:    0x00000021
[6] di_mode:            0x000081a4           di_ixpxd.address:  33
                 0100644 -rw-r--r--      [24] di_uid:            0
                                        [25] di_gid:            0
[9] di_atime.tj_nsec:   0x1e8a1025      [26] di_atime.tj_sec:0x000000004d98eb7d
[10] di_ctime.tj_nsec:  0x0ca85614      [27] di_ctime.tj_sec:0x000000004d98ebac
[11] di_mtime.tj_nsec:  0x1af63892      [28] di_mtime.tj_sec:0x000000004d98eb77
[12] di_otime.tj_nsec:  0x03b74a9a      [29] di_otime.tj_sec:0x000000004d98eb24
[13] di_ea.flag:        0x00            [30] di_ea.len:         0
     EAv1                               [31] di_ea.addr1:       0x00
[15] di_ea.nEntry:      0x00            [32] di_ea.addr2:       0x00000000
[16] di_ea.type:        0x0000               di_ea.address:     0
                                        [34] di_ea.nblocks:     0
change_inode: [m]odify, [e]a, [t]ree, or e[x]it > m     à choose “m” to modify
Please enter: field-number value > 5  1   à  put the field number is 5, change the di_nlink value to 1
Inode 4 at block 33, offset 0x800:

[1] di_fileset:         16              [18] di_inostamp:       0x4d98ead4
[2] di_number:          4               [19] di_gen:            3940655789
[3] di_size:    0x0000000000000044      [20] di_ixpxd.len:      4
[4] di_nblocks: 0x0000000000000001      [21] di_ixpxd.addr1:    0x00
[5] di_nlink:           1               [22] di_ixpxd.addr2:    0x00000021
[6] di_mode:            0x000081a4           di_ixpxd.address:  33
                 0100644 -rw-r--r--      [24] di_uid:            0
                                        [25] di_gid:            0
[9] di_atime.tj_nsec:   0x1e8a1025      [26] di_atime.tj_sec:0x000000004d98eb7d
[10] di_ctime.tj_nsec:  0x0ca85614      [27] di_ctime.tj_sec:0x000000004d98ebac
[11] di_mtime.tj_nsec:  0x1af63892      [28] di_mtime.tj_sec:0x000000004d98eb77
[12] di_otime.tj_nsec:  0x03b74a9a      [29] di_otime.tj_sec:0x000000004d98eb24
[13] di_ea.flag:        0x00            [30] di_ea.len:         0
     EAv1                               [31] di_ea.addr1:       0x00
[15] di_ea.nEntry:      0x00            [32] di_ea.addr2:       0x00000000
[16] di_ea.type:        0x0000               di_ea.address:     0
                                        [34] di_ea.nblocks:     0
change_inode: [m]odify, [e]a, [t]ree, or e[x]it > x    à exit
> quit
#
# fsck -yp /dev/fslv00     à run fsck to repaired the  inconsistencies.
The current volume is: /dev/fslv00
Primary superblock is valid.
J2_LOGREDO:log redo processing for /dev/fslv00
logredo start at:  1301867616 sec and end at  1301867616 sec
Primary superblock is valid.
*** Phase 1 - Initial inode scan
*** Phase 2 - Process remaining directories
*** Phase 3 - Process remaining files
*** Phase 4 - Check and repair inode allocation map
File system inode map is corrupt (FIXED)
Superblock marked dirty because repairs are about to be written.
*** Phase 5 - Check and repair block allocation map
Block allocation map is corrupt (FIXED)
Inodes not connected to the root directory
         tree have been detected.  Will reconnect.
File system is clean.
Superblock is marked dirty (FIXED)
All observed inconsistencies have been repaired.
#
# mount /new   à mount the /new FS
# lsvg -l testvg
testvg:
LV NAME             TYPE       LPs   PPs   PVs  LV STATE      MOUNT POINT
loglv00             jfs2log    1     1     1    open/syncd    N/A
fslv00              jfs2       16    16    1    open/syncd    /new
#
# cd /new  à goto the /new FS
#
# ls -l
total 0
drwxr-xr-x   2 root     system          256 Apr 03 16:47 lost+found
#
# cd lost+found   à go to lost+found dir
#
# pwd
/new/lost+found
#
# ls -l
total 8
-rw-r--r--   1 root     system           68 Apr 03 16:49 4     à you can see the deleted file in the name of your inode number
#
# cat 4   à confirm the file content
Hi this is the test file. I want to use this file for recovery test
#
# mv 4 /new/.      à move the file to the exact place where it was before
#
# pwd
/new/lost+found
# cd ..
#
# pwd
/new
# ls -l
total 8
-rw-r--r--   1 root     system           68 Apr 03 16:49 4
drwxr-xr-x   2 root     system          256 Apr 03 16:55 lost+found
#
# cat 4
Hi this is the test file. I want to use this file for recovery test
#
# mv 4 film  à change the name of the recovered file to the old one.
#
# ls -l
total 8
-rw-r--r--   1 root     system           68 Apr 03 16:49 film   à the deleted file has been recovered.
drwxr-xr-x   2 root     system          256 Apr 03 16:55 lost+found