Клонирование жестких дисков - удаленно

2417
soulSurfer2010

У меня есть два сервера, A и B. Я хотел бы клонировать сервер A в B. A работает под управлением Linux, и оба они являются удаленными, у меня нет физического доступа к ним

Каков наилучший способ приблизиться к этому?

1
Какой компьютер OS B работает? jet 13 лет назад 0

4 ответа на вопрос

0
xciter

Я считаю, что rsync - это решение здесь. Я не уверен, что все файлы будут доступны для записи во время сеанса rsync, хотя ...

Вы решили создать клон dd для разделов на сервере A и перенести его на сервер B? Это звучит немного дико, но, возможно, в крайнем случае?

0
SethG

Для создания образа диска мне нравится clonezilla, но вам нужен физический доступ для загрузки с диска, чтобы он работал. Честно говоря, я не думаю, что вы можете сделать полностью отключенную полную системную копию. rsync покажет вам только это. Если на обеих системах уже установлены полные системы, и в остальном они идентичны, то на хосте B можно установить те же приложения, что и на хосте A. Тогда достаточно просто скопировать необходимые файлы конфигурации из A в B. Т обязательно нужно копировать все .

0
karel

Cloning remote Linux machines

The bash script backup-images-1.0.sh automates the process of cloning disks of remote Linux machines. It uses the dd command together with ssh and gzip commands to copy and compress remote disks and send them on the fly to a local disk over an SSH connection.

Examples of cloning a remote disk to a local disk using backup-images-1.0.sh written by Radovan Brezula, who wrote backup-images-1.0.sh.

Example of cloning a local disk to a remote disk using dd

dd if=/path/to/disk/image ibs=4096 conv=notrunc,noerror | (ssh 132.183.12.128 dd of=/remote-archive/test/remote-archive-test.img obs=4096) 
  • ibs=4096 read up to 4096 bytes at a time

  • conv=notrunc,noerror do not truncate the output file and continue after read errors

  • obs=4096 write 4096 bytes at a time

0
Hennes

There are al least three different ways to do this.

1 scripted setups.

This option is mostly useful in large corporations with proper documentation and likely expands into setups with PXE booting and puppet or similar setups.

Basically you repeat the same steps which you used to configure server A on server B.

This works very well if your setup is big enough (e.g. you are running 100 servers and want to spin up server 101. PXE boot, tell your puppet config that it needs to be a server of $type and come back an hour later. Done!).

A lot of work to set up, but perfect afterwards. And with all the setup work probably not worth it for copying a setup once.

2 filesystem copy.

You can copy all files from server A to server B, preserving their rights and users. rsync is probably the best tool for this.

For this you want to prepare the target server with a similar setup (e.g. copy the partition setup) and then rsync most files over. The tricky part here is that you do not want to rsync some files (e.g. skip /proc and /dev) and that you need to have something to receive the rsync files on server B.

For the last you probably want to boot server B from a different disk, or use the ILO/DRAC/.. to boot from an liveCD iso image on your desktop, leaving its disk bare and ready to receive the rsync files.

3 Copy disk.

This is diffent from copying the filesystem. It is much easier and probably a lot faster, but raw disk access (e.g. with dd) ignores all filesystem changes. This means that you really do not want to copy a running filesystem.

To help you understand this easier, imaging a book. This book has an index and four stories. The rest of the book is blank and this is also nicely indicated in the books index.

Now we start copying. We copy the index. We copy story 1, we copy...
** hold briefly, let me add a new story here and change the index**
We copy stopry 2, 3, 4 and 5...

We now have aq book with an index showing four stories (not five, since we copied that before writing story 5, and five stories)... a corrupt book.

Something similar can (and will) happen if you use raw disk access to copy a running system. So before using a raw disk copy make sure that the OS is off-line. Either boot something different (e.g. from a second disk, from a local CD, or via the network (PXE, DRAC, ...) and then copy.

Details on how to do this are already in plenty posts here on [su].

Похожие вопросы