ORF反垃圾邮件系统

邮件服务器-邮件系统-邮件技术论坛(BBS)

 找回密码
 会员注册
查看: 5617|回复: 0

[转帖]复制REDHAT系统

[复制链接]
发表于 2006-2-17 11:34:11 | 显示全部楼层 |阅读模式
本文讲述一种实践方法:将REDHAT LINUX系统(包括操作系统,应用程序,数据)从一个物理的系统复制到另一个兼容的物理的系统. 此方法可应用于系统迁移(Server Migration), 系统硬件升级(Server H/W Upgrade), 系统灾难恢复(O.S. Disaster Recovery)等.<br>
<br>
假定被复制的系统(源系统)为A系统,将要建立的系统(目标系统)为B系统.两者都采用固定IP.<br>
<br>
步骤如下:<br>
<br>
1. 在目标系统上安装小的操作系统<br>
<br>
在B系统上安装一个小的Linux,并配制其网络.在安装过程中选择"Server",且去除X Window, Web, Samba, FTP等.只需建2个分区, /(够用就行)和swap(亦将在最终系统上被使用).<br>
<br>
安装光盘的版本须与源系统的版本一致.<br>
<br>
2. 在目标系统上创建文件系统<br>
<br>
按照A系统上的文件系统层次和大小,在B系统上创建相应的相同大小的文件系统.文件系统的大小可根据实际情况作相应调整.<br>
<br>
譬如,A系统上有 /, /boot, /tmp, /usr, /var, /var/www, /home, 那么,在B系统上就创建/x, /x/boot, /x/tmp, /x/usr, /x/var, /x/var/www, /x/home.<br>
<br>
此步骤亦可在安装操作系统时进行.<br>
<br>
3. 将数据从源系统复制到目标系统<br>
<br>
把操作系统,应用程序及其数据从A系统复制到B系统的新建的相应的文件系统上,并修改/x/etc/fstab.<br>
<br>
A:/boot --> B:/x/boot<br>
A:/ --> B:/x<br>
A:/usr --> B:/x/usr<br>
A:/var --> B:/x/var<br>
A:/var/www --> B:/x/var/www<br>
A:/home --> B:/x/home<br>
<br>
根文件系统的复制须包括所有在A系统根文件系统上,除了/proc, /tmp, /dev的数据.<br>
<br>
将数据从A:/复制到B:/x的命令行大致为(须根据实际情况):<br>
[ B # ] ssh A "cd /; tar -czf - bin etc initrd misc lib sbin root" | (cd /x; tar -xzf -)<br>
<br>
将数据从A:/boot复制到B:/x/boot的命令行为:<br>
[ B # ] ssh A "cd /; tar -czf - boot" | (cd /x; tar -xzf -)<br>
<br>
将数据从A:/var/www复制到B:/x/var/www的命令行为:<br>
[ B # ] ssh A "cd /var; tar -czf - www" | (cd /x/var; tar -xzf -)<br>
<br>
若A:/var上一些大的日志文件或临时文件无需复制,可用在tar命令行中加--exclude-from: <br>
[ B # ] ssh A "cd /;tar --exclude-from=/home/chinaux/var.exclude -czf" | (cd /x; tar -xzf -)<br>
然后在B:/x/var上根据实际需要"touch"这些文件.<br>
<br>
4. 复制新装系统的设备文件<br>
<br>
在目标系统上将新装系统的设备文件复制到新建文件系统/x上:<br>
[ B # ] (cd /; tar -czf - dev) | (cd /x; tar xzf -)<br>
<br>
5. 创建/proc, /tmp等<br>
<br>
[ B # ] mkdir -m 755 /x/proc<br>
<br>
[ B # ] mkdir -m 755 /x/mnt<br>
[ B # ] mkdir -m 755 /x/mnt/floppy /x/mnt/cdrom<br>
<br>
[ B # ] mkdir -m 1777 /x/tmp ## 若/tmp将在根文件系统上<br>
或,<br>
[ B # ] chmod 1777 /x/tmp ## 若/tmp将为一独立的文件系统<br>
<br>
6. 置换设备驱动程序<br>
<br>
比较/etc/modules.conf, /x/etc/modules.conf; 比较"lsmod"在系统A和系统B上的输出. 若两者使用不同的设备驱动,在系统B上安装所需设备驱动程序(若有此需要; 安装的根目录为/x),修改/etc/modules.conf, 重建RAMDISK(# chroot /x; mkinitrd ...).<br>
<br>
通常需要置换设备驱动程序是SCSI,NIC设备驱动.<br>
<br>
此步骤可省略若源系统和目标系统的硬件相同或相似.<br>
<br>
7. 修改引导菜单,网络配置<br>
<br>
添加复制的操作系统到/boot/grub/grub.conf上(保留其原有行,以防复制的系统不可引导); 修改/x/etc/hosts, /x/etc/sysconfig/network和/x/etc/sysconfig/network-scripts/ifcfg-eth0.<br>
<br>
8. 重启目标系统<br>
<br>
重启B系统,并引导复制的操作系统.若引导失败,引导至所安装的小系统,并解决问题.<br>
<br>
<br>
How to duplicate RedHat to another system<br>
<br>
The following describes a workaround to copy a Redhat Linux(inculding applications & data) from one system to another, even they have different models of HDs and different H/W.<br>
<br>
Assuming the box to be modelled after is system A, and the system to be built is system B, the prodedure is as follows:<br>
<br>
1. create a minimum O.S. on the target system<br>
<br>
install mininum Linux on system B with networking enabled(a small / and desired swap, e.g. hda1 & hda2)<br>
<br>
2. create file systems on the target system<br>
<br>
follow the file system layout on system A to create partions on system B, and mount them, e.g. /mnt/boot, /mnt, /mnt/usr, /mnt/var. /mnt/tmp. re-use the swap, so no need to create a new swap.<br>
<br>
note: mount /mnt at first, then create the directories /mnt/boot, /mnt/usr, etc., and mount the file systems.<br>
<br>
3. copy the data from the source system to the target system<br>
<br>
copy the O.S. and other data on system A to system B<br>
<br>
A: /boot --> B: /mnt/boot<br>
A: /usr --> B: /mnt/usr<br>
A: / (including /sbin, /etc, /bin, /etc, and the other stuff whatever on / file system, except for /proc, /tmp, /dev) --> B: /mnt<br>
A: /var --> B: /mnt/var<br>
<br>
the command to copy A:/boot to B:/mnt/boot is<br>
[ system B # ] ssh systemA "cd /; tar czf - boot" | (cd /mnt/; tar xzf -)<br>
<br>
the command to copy A:/sbin to B:/mnt/sbin is<br>
[ system B # ] ssh systemA "cd /; tar czf - boot" | (cd /mnt/; tar xzf -)<br>
<br>
4. fix /tmp, /proc, /dev on the target system<br>
<br>
[ system B # ] mkdir -m 755 /mnt/proc<br>
[ system B # ] (cd /; tar czf - dev) | (cd /mnt/; tar xzf -)<br>
[ system B # ] mkdir -m 1777 /mnt/tmp ## if /tmp will be on / file system<br>
or,<br>
[ system B # ] chmod 1777 /mnt/tmp ## if /tmp will be a seperate file system<br>
5. fix driver issues (scsi driver, NIC drivers, etc)<br>
compare /etc/module.conf & /mnt/etc/module.conf; compare the outputs of "lsmod" on the 2 systems<br>
<br>
if a driver is required, install it (the root directory should be changed to /mnt), modify /mnt/etc/modules.conf, rebuild ramdisk image if neccessary(# chroot /mnt; mkinitrd ....)<br>
<br>
6. fix bootup, networking & file system table<br>
<br>
modify /boot/grub/grub.conf (don't remove the orignial entry in case the duplicated O.S. cannot be booted up), /mnt/etc/fstab, /mnt/etc/hosts, /mnt/etc/sysconfig/network and /mnt/etc/sysconfig/network-scripts/ifcfg-eth0.<br>
<br>
7. reboot system B, boot from the duplicated O.S. - done<br>
<br>
if the bootup fails, boot it from original minimum O.S., and fix the problems.<br>
您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

小黑屋|手机版|Archiver|邮件技术资讯网

GMT+8, 2024-3-29 18:01

Powered by Discuz! X3.2

© 2001-2016 Comsenz Inc.

本论坛为非盈利中立机构,所有言论属发表者个人意见,不代表本论坛立场。内容所涉及版权和法律相关事宜请参考各自所有者的条款。
如认定侵犯了您权利,请联系我们。本论坛原创内容请联系后再行转载并务必保留我站信息。此声明修改不另行通知,保留最终解释权。
*本论坛会员专属QQ群:邮件技术资讯网会员QQ群
*本论坛会员备用QQ群:邮件技术资讯网备用群

快速回复 返回顶部 返回列表