How to use Rsh/Tar to quickly clone a Linux server

Source: Internet
Author: User
Tags reverse dns
I. Overview The purpose of this article is to quickly clone all the content of another running Linux server, and then change the corresponding configuration file to quickly set another server with identical configurations. Environment 2 This article uses the latest RedhatLinux7.1CDROM to start the first installation disk, the cloned service

I. Overview

This article aims to quickly clone all the content of another running Linux server, and then change the corresponding configuration file to quickly set another server with identical configurations.

2. environment

This article uses the latest Redhat Linux 7.1 CDROM, the first installation disk to start, the cloned server is any Linux system, this article is also Redhat 7.1.

Step 3

1. on the cloned linux server A (192.168.0.1) that is already running, the IP address of server B (the tentative IP address is 192.168.0.2) can be rsh first.

A. run/usr/bin/ntsysv on the server and select rexec, rlogin, and rsh.

B. run #/sbin/service xinetd restart to start the three services.

C. run # echo "rexec">/etc/securetty; echo "rlogin">/etc/securetty; echo "rsh">/etc/securetty allow rsh in (only required by redhat 7.1)

D. run # echo "192.168.0.2">/root/. rhosts on the server to allow the IP address to enter rsh without a password.

2. set/etc/hosts on server A and add A record. you can obtain any host name, for example:


# Echo "192.168.0.2 test">/etc/hosts

In this way, address mismatch is avoided during forward/reverse DNS resolution. otherwise, when you change from B rsh to A, B will prompt you with the "host address mismatch" problem.

3. use the first CDROM in Redhat Linux 7.1 to start Machine B. We can enter "text" to quickly enter the text installation interface. since it is not a real installation, no graphic interface is required, we only use the first CDROM to start and use rsh/tar to copy machine A. press enter until the automaticpartitioning part appears, select "Continue" or "Manual Partition" and press Alt + F2 to go to the character page.

4. set the IP address of the NIC to ensure that the IP address can be pinged to 192.168.0.1.

Use the default Nic supported by Linux, such as 3com and Intel:


# Ping 192.168.0.1 after ifconifg eth0 192.168.0.2 up

 
Now Test rsh. for Redhat 7.1, you must do the following:


# Cd/etc # echo "login 513/tcp"> services # echo "shell 514/tcp"> services

 
Then you can # rsh 192.168.0.1 without a password.

 

Note: If you use VA Linux 6.2.3, you do not need to do the above. you have not tried other versions yet. I believe RedhatLinux 6.2 does not need it.

5. set the/dev/hda device so that you can manually perform fdisk/mke2fs

For Redhat Linux 7.1 to the character interface, you still cannot perform fdisk/dev/hda. the system prompts "cannot open the device". now you can run rsh to 192.168.0.1 and do the following:


# (Rsh 192.168.0.1 cd/dev; tar cf-hda * sda *) | tar xvfp-

Now you can do # fdisk/dev/hda, and then use mke2fs to format all partitions into the ext2 file system. If a partition already exists in the hard disk and you want to delete it all quickly, you can do it # dd if =/dev/zero of =/dev/hda, and press ctrl + C to interrupt immediately, then, the partition table is cleared.
 
Note: If you use VA Linux 6.2.3, you do not need to do the above rsh part. you have not tried other versions yet. I believe Redhat Linux 6.2 is not required.
 
6. preparations before replication
 
Assume that your partition is/boot 25 M (/dev/hda1), SWAP 1G (/dev/hda2),/4G (/dev/hda3) after mke2fs for each partition and mkswap for the swap partition, do the following mount work.
 
# Cd/# mkdir hda3 # mount/dev/hda3 hda3 # cd hda3 # mkdir boot; mount/dev/hda1 boot

 
Note: If you cannot create A directory in the root directory, restart the directory and then run it again. you do not need to copy the/dev/hda */dev/sda * file on A after the restart *, because you have already done fdisk/mke2fs.
 
7. copy another machine
 
Run the following command:
 
# Cd/hda3 # (rsh 192.168.0.1 cd/; tar cf--- exclude proc.) | tar xvf-

  
Note: it is used to ensure that-it is not interpreted by bash shell as another character. If you have a directory other than proc that does not need to be copied, such as the data directory, the command is:
 
# (Rsh 192.168.0.1 cd/; tar cf--- exclude proc -- exclude data.) | tar xvf-

  
8. end work
 
# Cd/hda3 # mkdir proc # chroot. (chroot is used as the root directory to facilitate/sbin/lilo)

  
Change the corresponding file such as/etc/hosts,/etc/fstab,/etc/sysconfig/network,/etc/sysconfig/network-scripts/ifcfg-eth * to change/etc/lilo. conf, run/sbin/lilo, and restart.
 
9. FAQ
 
A. If your CDROM cannot be mounted after cloning, check whether the/dev/cdrom symbolic link is copied to the wrong device and use dmesg to check whether the CDROM device name on Machine B is relinked.
B. If your source server uses an IDE hard disk and the cloned server uses a SCSI hard disk, you need to set it.
/Etc/modules. alias scsi_hostadapter aic7xxx in conf (if your SCSI chip class is), run mkinitrd to create an image file and update/etc/lilo. add initrd = to the conf file. Otherwise, you cannot boot from the SCSI disk.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.