среда, 12 августа 2009 г.

Метки GPT для ZFS

Нужно создать ZFS пул с зеркалом из носителей, смонтированных по меткам GPT, чтобы не зависеть от имён устройств и номеров портов контроллёров.

Исходное состояние


Зеркало как таковое отсутствует:

% zpool status
pool: amd64rio
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
amd64rio ONLINE 0 0 0
ad6p3 ONLINE 0 0 0

errors: No known data errors

Включим в пул ещё один носитель (GPT-раздел устройства ad10) — разметка разделов второго винчестера аналогична первому, так что здесь последовательность команд не приводится.

Создание зеркала в пуле


% zpool attach amd64rio /dev/ad6p3 /dev/ad10p3
% zpool scrub amd64rio
% zpool status
pool: amd64rio
state: ONLINE
scrub: scrub in progress for 0h0m, 0,00% done, 131h10m to go
config:

NAME STATE READ WRITE CKSUM
amd64rio ONLINE 0 0 0
mirror ONLINE 0 0 0
ad6p3 ONLINE 0 0 0
ad10p3 ONLINE 0 0 0

errors: No known data errors

Состояние разметки устройств


Подготовительные операции для перехода на новую схему:

% echo 'geom_label_load="YES"' >> /boot/loader.conf
% shutdown -r now
% glabel list
Geom name: ad6p1
Providers:
1. Name: gpt/rio_boot
Mediasize: 131072 (128K)
Sectorsize: 512
Mode: r0w0e0
secoffset: 0
offset: 0
seclength: 256
length: 131072
index: 0
Consumers:
1. Name: ad6p1
Mediasize: 131072 (128K)
Sectorsize: 512
Mode: r0w0e0

Geom name: ad6p1
Providers:
1. Name: gptid/6e56389f-81a6-11de-8aa6-02508d92a2eb
Mediasize: 131072 (128K)
Sectorsize: 512
Mode: r0w0e0
secoffset: 0
offset: 0
seclength: 256
length: 131072
index: 0
Consumers:
1. Name: ad6p1
Mediasize: 131072 (128K)
Sectorsize: 512
Mode: r0w0e0

Geom name: ad6p2
Providers:
1. Name: gpt/rio_swap
Mediasize: 2147483648 (2.0G)
Sectorsize: 512
Mode: r0w0e0
secoffset: 0
offset: 0
seclength: 4194304
length: 2147483648
index: 0
Consumers:
1. Name: ad6p2
Mediasize: 2147483648 (2.0G)
Sectorsize: 512
Mode: r0w0e0

Geom name: ad6p2
Providers:
1. Name: gptid/e0fa02b3-81a6-11de-8aa6-02508d92a2eb
Mediasize: 2147483648 (2.0G)
Sectorsize: 512
Mode: r0w0e0
secoffset: 0
offset: 0
seclength: 4194304
length: 2147483648
index: 0
Consumers:
1. Name: ad6p2
Mediasize: 2147483648 (2.0G)
Sectorsize: 512
Mode: r0w0e0

Geom name: ad6p3
Providers:
1. Name: gpt/rio_zfs
Mediasize: 317921280000 (296G)
Sectorsize: 512
Mode: r0w0e0
secoffset: 0
offset: 0
seclength: 620940000
length: 317921280000
index: 0
Consumers:
1. Name: ad6p3
Mediasize: 317921280000 (296G)
Sectorsize: 512
Mode: r0w0e0

Geom name: ad6p3
Providers:
1. Name: gptid/1f26a2d6-81a7-11de-8aa6-02508d92a2eb
Mediasize: 317921280000 (296G)
Sectorsize: 512
Mode: r0w0e0
secoffset: 0
offset: 0
seclength: 620940000
length: 317921280000
index: 0
Consumers:
1. Name: ad6p3
Mediasize: 317921280000 (296G)
Sectorsize: 512
Mode: r0w0e0

Geom name: ad10p1
Providers:
1. Name: gptid/a01d172c-81a6-11de-8aa6-02508d92a2eb
Mediasize: 131072 (128K)
Sectorsize: 512
Mode: r0w0e0
secoffset: 0
offset: 0
seclength: 256
length: 131072
index: 0
Consumers:
1. Name: ad10p1
Mediasize: 131072 (128K)
Sectorsize: 512
Mode: r0w0e0

Geom name: ad10p2
Providers:
1. Name: gptid/e2aef92e-81a6-11de-8aa6-02508d92a2eb
Mediasize: 2147483648 (2.0G)
Sectorsize: 512
Mode: r0w0e0
secoffset: 0
offset: 0
seclength: 4194304
length: 2147483648
index: 0
Consumers:
1. Name: ad10p2
Mediasize: 2147483648 (2.0G)
Sectorsize: 512
Mode: r0w0e0

Geom name: ad10p3
Providers:
1. Name: gptid/20db981e-81a7-11de-8aa6-02508d92a2eb
Mediasize: 317921280000 (296G)
Sectorsize: 512
Mode: r0w0e0
secoffset: 0
offset: 0
seclength: 620940000
length: 317921280000
index: 0
Consumers:
1. Name: ad10p3
Mediasize: 317921280000 (296G)
Sectorsize: 512
Mode: r0w0e0

Процесс отвязки носителей от "устройств"


1. Вывод из зеркала одного носителя и его полная очистка "для чистоты эксперимента"

% zpool detach amd64rio ad10p3
% zpool status
pool: amd64rio
state: ONLINE
scrub: scrub in progress for 0h0m, 0,00% done, 69h45m to go
config:

NAME STATE READ WRITE CKSUM
amd64rio ONLINE 0 0 0
ad6p3 ONLINE 0 0 0

errors: No known data errors
% dd if=/dev/zero of=/dev/ad10p3 bs=100m
dd: /dev/ad10p3: short write on character device
dd: /dev/ad10p3: end of device
3032+0 records in
3031+1 records out
317921280000 bytes transferred in 5836.782166 secs (54468587 bytes/sec)

2. Задание метки

% gpart modify -i 3 -l rio_zfs2 ad10
ad10p3 modified
% shutdown -r now

3. Внесение носителя в зеркало

% zpool attach amd64rio ad6p3 gpt/rio_zfs2
% zpool status
pool: amd64rio
state: ONLINE
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scrub: resilver in progress for 0h3m, 17,22% done, 0h17m to go
config:

NAME STATE READ WRITE CKSUM
amd64rio ONLINE 0 0 0
mirror ONLINE 0 0 0
ad6p3 ONLINE 0 0 0 7,80M resilvered
gpt/rio_zfs2 ONLINE 0 0 0 9,08G resilvered

errors: No known data errors

4. После окончания репликации проделываем аналогичную операцию с другим носителем

% zpool detach amd64rio ad6p3
% zpool status
pool: amd64rio
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
amd64rio ONLINE 0 0 0
gpt/rio_zfs2 ONLINE 0 0 0

errors: No known data errors
% gpart modify -i 3 -l rio_zfs1 ad6
ad6p3 modified
% dd if=/dev/zero of=/dev/ad6p3 bs=100m
dd: /dev/ad6p3: short write on character device
dd: /dev/ad6p3: end of device
3032+0 records in
3031+1 records out
317921280000 bytes transferred in 5950.955982 secs (53423564 bytes/sec)
% shutdown -r now
% zpool attach amd64rio gpt/rio_zfs2 gpt/rio_zfs1
% zpool status
pool: amd64rio
state: ONLINE
scrub: resilver completed after 0h21m with 0 errors on Wed Aug 12 17:44:06 2009
config:

NAME STATE READ WRITE CKSUM
amd64rio ONLINE 0 0 0
mirror ONLINE 0 0 0
gpt/rio_zfs2 ONLINE 0 0 0 123M resilvered
gpt/rio_zfs1 ONLINE 0 0 0 52,7G resilvered

errors: No known data errors


Это всё.

Комментариев нет: