Это старая версия документа.
Содержание
DRBD
Распределенное копируемое блочное устройство (Distributed Replicated Block Device - DRBD) создает зеркало между блочными устройствами нескольких систем. Копирование незаметно (прозрачно) для других приложений на этих системах. Любые блочные устройства: жесткие диски, разделы, RAID устройства, логические тома и т.п. могут зеркалироваться.
Перед началом использования drbd установим необходимые пакеты. Введите в терминале:
sudo apt-get install drbd8-utils
В этом разделе рассматривается установка drbd для репликации отдельных /srv разделов с файловой системой ext3 между двумя системами. Размер разделов не имеет особого значения, но оба раздела должны иметь одинаковый размер.
Настройка
The two hosts in this example will be called drbd01 and drbd02. They will need to have name resolution configured either through DNS or the /etc/hosts file. See Domain Name Service (DNS) for details.
To configure drbd, on the first host edit /etc/drbd.conf:
global { usage-count no; } common { syncer { rate 100M; } } resource r0 { protocol C; startup { wfc-timeout 15; degr-wfc-timeout 60; } net { cram-hmac-alg sha1; shared-secret "secret"; } on drbd01 { device /dev/drbd0; disk /dev/sdb1; address 192.168.0.1:7788; meta-disk internal; } on drbd02 { device /dev/drbd0; disk /dev/sdb1; address 192.168.0.2:7788; meta-disk internal; } }
There are many other options in /etc/drbd.conf, but for this example their default values are fine.
Now copy /etc/drbd.conf to the second host:
scp /etc/drbd.conf drbd02:~
And, on drbd02 move the file to /etc:
sudo mv drbd.conf /etc/
Now using the drbdadm utility initialize the meta data storage. On each server execute:
sudo drbdadm create-md r0
Next, on both hosts, start the drbd daemon:
sudo /etc/init.d/drbd start
On the drbd01, or whichever host you wish to be the primary, enter the following:
sudo drbdadm -- --overwrite-data-of-peer primary all
After executing the above command, the data will start syncing with the secondary host. To watch the progress, on drbd02 enter the following:
watch -n1 cat /proc/drbd
To stop watching the output press Ctrl+c.
Finally, add a filesystem to /dev/drbd0 and mount it:
sudo mkfs.ext3 /dev/drbd0 sudo mount /dev/drbd0 /srv
Тестирование
To test that the data is actually syncing between the hosts copy some files on the drbd01, the primary, to /srv:
sudo cp -r /etc/default /srv
Next, unmount /srv:
sudo umount /srv
Demote the primary server to the secondary role:
sudo drbdadm secondary r0
Now on the secondary server promote it to the primary role:
sudo drbdadm primary r0
Lastly, mount the partition:
sudo mount /dev/drbd0 /srv
Using ls you should see /srv/default copied from the former primary host drbd01.