Tuesday, February 25, 2025

Linux migration

In running environment migration of Linux  Like we need to migrate A-Server to B-Server

A-server & B-server filesystem have same size  & same structure if there is database then it's good to install new database in new server & then restore that database because the starting sector & end sector  of a disk may create problem. 

A-server is running server in a production environment 

B-server is now ready take ownership of A-server

For safer side we have added a 100Gb Lun in Server-B & make filesystem & mount in directory call /TEMP
now first we will take the backup of the A-server through sync command which will put all stuff in /TEMP {Like /,opt,/var etc"

this will take backup from server-B & transfer it to Server-B:/TEMP mount point
10.32.2.103 is the Server-A.
rsync -e ssh -avz -n -X  -- exclude-from=/home/exclude.txt  root@10.32.2.103:/usr /TEMP/
rsync -e ssh -avz -n -X root@10.100.2.103:/opt /TEMP/
rsync -e ssh -avz -n -X root@10.100.2.103:/var /TEMP/
rsync -e ssh -avz -n -X root@10.100.2.103:/crs/oracle /TEMP/

dry-run
rsync -avz -n -X  source file system     to  destination 

when sync required
rsync -avz  -X  source file system     to  destination 

-X  = one-file-system
-n = dry-run


Then We can rsync from server-B:/TEMP to Server-B "/" /var /opt etc

exciude.txt
/boot
/proc
/sys
/tmp
/dev
/var/lock
/etc/fstab
/etc/resolv.conf
/etc/sysconfig/network*
/etc/sysconfig/hwconf
/etc/sysconfig/ip6tables-config
/etc/sysconfig/kernel
/etc/hostname
/etc/HOSTNAME
/etc/hosts
/etc/modprobe*
/etc/modules
/net
/lib/modules
/etc/rc.conf
/etc/multipath*
/etc/binding*

sudo rsync -e 'ssh -p 30000' -azPx --delete-after --exclude-from="/mnt/origin/home/demo/

exclude.txt" /mnt/origin/ root@1.2.3.4:/mnt/destination/



RHEL 5 DNS_SERVER
###########################################################################################

# vi /var/named/chroot/etc/named.conf

copy the 11 line from the & put them into the starting of the
[root@localhost ~]# vi  /var/named/chroot/etc/named.caching-nameserver.conf


[root@localhost ~]# vi  /var/named/chroot/etc/named.conf

//

 options {
   listen-on port 53 { 192.168.0.30; };
   listen-on-v6 port 53 { ::1; };
   directory       "/var/named";
   dump-file       "/var/named/data/cache_dump.db";
   statistics-file "/var/named/data/named_stats.txt";
   memstatistics-file "/var/named/data/named_mem_stats.txt";

  // Those options should be used carefully because they disable port
  // randomization
  // query-source    port 53;
 // query-source-v6 port 53;

    allow-query     { any; };
    allow-query-cache { localhost; };
  };

At the bottom put these entry

zone "delhi.com" IN {
        type master;
        file "dk.delhi.zone";

};

zone "0.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.0.zone";
};


[root@localhost ~]# cd /var/named/chroot/var/named/
[root@localhost named]# ls
data  localdomain.zone  localhost.zone  named.broadcast  named.ca  named.ip6.l
[root@localhost named]# cp localhost.zone dk.delhi.zone
[root@localhost named]# vi dk.delhi.zone
[root@localhost named]# ls
data  dk.delhi.com.zone  localdomain.zone  localhost.zone  named.broadcast  named
[root@localhost named]# cp named.local 192.168.0.zone
[root@localhost named]# vi 192.168.0.zone
[root@localhost named]# vi /var/named/chroot/etc/named.conf
[root@localhost named]# pwd
/var/named/chroot/var/named
[root@localhost named]# ls -ltr
total 44
drwxrwx--- 2 named named 4096 Jul 27  2004 slaves
drwxrwx--- 2 named named 4096 Aug 26  2004 data
-rw-r----- 1 root  named  427 Jan 18  2010 named.zero
-rw-r----- 1 root  named  426 Jan 18  2010 named.local
-rw-r----- 1 root  named  424 Jan 18  2010 named.ip6.local
-rw-r----- 1 root  named 1892 Jan 18  2010 named.ca
-rw-r----- 1 root  named  427 Jan 18  2010 named.broadcast
-rw-r----- 1 root  named  195 Jan 18  2010 localhost.zone
-rw-r----- 1 root  named  198 Jan 18  2010 localdomain.zone
-rw-r----- 1 root  root   247 Nov 12 07:47 dk.delhi.zone
-rw-r----- 1 root  root   465 Nov 12 07:49 192.168.0.zone

[root@localhost named]# bind-chroot-admin -d
[root@localhost named]# bind-chroot-admin -e

[root@localhost named]# service named restart
Stopping named:                                            [  OK  ]
Starting named:                                            [  OK  ]

for logs for client query

[root@localhost ~]# rndc -query log

[root@localhost named]# dig dk.delhi.com

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_4.2 <<>> dk.delhi.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2743
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;dk.delhi.com.                  IN      A

;; ANSWER SECTION:
dk.delhi.com.           86400   IN      A       192.168.0.30

;; AUTHORITY SECTION:
delhi.com.              86400   IN      NS      dk.delhi.com.

;; Query time: 2 msec
;; SERVER: 192.168.0.30#53(192.168.0.30)
;; WHEN: Sat Nov 12 07:54:06 2011
;; MSG SIZE  rcvd: 60

[root@localhost named]# dig 192.168.0.30
[root@localhost named]# dig -x 192.168.0.30

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_4.2 <<>> -x 192.168.0.30
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19008
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;30.0.168.192.in-addr.arpa.     IN      PTR

;; ANSWER SECTION:
30.0.168.192.in-addr.arpa. 86400 IN     PTR     dk.delhi.com.

;; AUTHORITY SECTION:
0.168.192.in-addr.arpa. 86400   IN      NS      dk.delhi.com.

;; ADDITIONAL SECTION:
dk.delhi.com.           86400   IN      A       192.168.0.30

;; Query time: 4 msec
;; SERVER: 192.168.0.30#53(192.168.0.30)
;; WHEN: Sat Nov 12 07:54:42 2011
;; MSG SIZE  rcvd: 99


#dig +trace @4.2.2.1 google.com