Tải bản đầy đủ (.pdf) (17 trang)

Thiết lập mô hình ATA Over Ethernet (AoE) trên Ubuntu 10.04 (Initiator và Target) doc

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (170.72 KB, 17 trang )

Thiết lập mô hình ATA Over Ethernet (AoE) trên
Ubuntu 10.04 (Initiator và Target)


Trong bài viết sau đây, Quản Trị sẽ giới thiệu với các bạn
cách cài đặt và thiết lập hệ thống AoE target và AoE initiator
(client), cả 2 đều hoạt động dưới nền tảng Ubuntu 10.04. AoE
- ATA over Ethernet, hay hiểu nôm na là giao thức hệ thống
mạng lưu trữ - storage area network (SAN), cho phép các thành
phần khởi tạo AoE trực tiếp sử dụng các thiết bị lưu trữ trên mô
hình AoE target được remote qua cable nối mạng thông thường.
Từ remote ở đây có thể hiểu theo nghĩa trong cùng 1 mạng LAN,
bởi vì AoE không thể tự định tuyến bên ngoài mạng LAN (đây là
điểm khác biệt chính khi so sánh với mô hình iSCSI).

Lưu ý sơ bộ

Tại đây, chúng ta sẽ sử dụng 2 hệ thống Ubuntu 10.04 server:
- Initiator: server1.example.com với địa chỉ IP: 192.168.0.100
- Target: server2.example.com với địa chỉ IP: 192.168.0.101

Tải Module aoe Kernel trên cả 2 hệ thống

Trước tiên, chúng ta phải bảo đảm rằng hệ thống kernel hiện tại
có hỗ trợ AoE:
grep ATA_OVER /boot/config-`uname -r`
Kết quả hiển thị sẽ có trông giống như sau đây:
root@server1:~# grep ATA_OVER /boot/config-`uname -r`
CONFIG_ATA_OVER_ETH=m
root@server1:~#
Điều này có nghĩa rằng AoE được xây dựng nh


ư 1 module kernel.
Kiểm tra lại xem module đã được nạp vào hệ thống hay chưa:
lsmod | grep aoe
Nếu hệ thống không trả lại kết quả gì thì có nghĩa là module chưa
được nạp. Trong trường hợp này, chúng ta sẽ cần dùng lệnh sau:
modprobe aoe
Kiểm tra lại 1 lần nữa:
lsmod | grep aoe

root@server1:~# lsmod | grep aoe
aoe 26960 0
root@server1:~#
Và để cho hệ thống tự động nạp các module này khi khởi động,
chúng ta cần ghép module aoe vào/etc/modules:
vi /etc/modules

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be
loaded
# at boot time, one per line. Lines beginning with "#" are ignored.


loop
lp
rtc
aoe
Thiết lập hệ thống Target (server2)

Với server2, chúng ta áp dụng câu lệnh sau:

aptitude install vblade
Tại đây, chúng ta có thể sử dụng các phân vùng logic không thực
sự cần thiết, file ảnh, ổ cứng (ví dụ /dev/sdb), các phân vùng ổ
cứng (ví dụ /dev/sdb1) hoặc các thiết bị RAID (ví dụ /dev/md0)
để lưu trữ. Trong bài thử nghiệm này, chúng ta sẽ tạo ra 1 phân
vùng logical riêng với dung lượng 20GB và đặt tên là storage1
trong nhóm vg0:
lvcreate -L20G -n storage1 vg0
Nếu bạn muốn tạo và sử dụng file image, thì tạo ra theo cách sau:

mkdir /storage
dd if=/dev/zero of=/storage/storage1.img bs=1024k
count=20000
Câu lệnh trên sẽ tạo ra file /storage/storage1.img với dung lượng
20GB.

Tiếp theo, chúng ta thiết lập và xác định các thiết bị lưu trữ như
sau:
vbladed 0 1 eth0 /dev/vg0/storage1
Số đầu tiên (0) là số các giá kệ (số chính), tiếp theo (1) là số các
khe, rãnh (số phụ), thay đổi những số này theo ý muốn của bạn.
Mỗi thiết bị AoE được nhận định bởi cặp thông số chính / phụ
này và chúng phải đồng nhất theo chuẩn (nếu áp dụng quá trình
này với nhiều thiết bị), số chính nằm trong khoảng từ 0-65535, s

phụ từ 0-255. Đư
ờng dẫn eth0 thống báo với vbladed rằng thiết bị
mạng nào được sử dụng (nếu thiết bị mạng của bạn là eth1 thì
khai báo là eth1, thông số này được tìm ra bởi lệnh ifconfig).


Để thiết lập tính năng tự động cho quá trình này mỗi khi hệ thống
kích hoạt, mở /etc/rc.local…:
vi /etc/rc.local
và thêm dòng sau (vào trước dòng exit 0):
[ ]
vbladed 0 1 eth0 /dev/vg0/storage1
[ ]
Thiết lập hệ thống Initiator (server1):

Trên hệ thống server1, chúng ta tiến hành cài đặt và khởi tạo các
initiator:
aptitude install aoetools
Và kiểm tra xem thiết bị AoE nào đã sẵn sàng:
aoe-discover
Lệnh aoe-stat sẽ hiển thị kết quả trả về như sau:
root@server1:~# aoe-stat
e0.1 21.474GB eth0 up
root@server1:~#
Tại thời điểm này, chúng ta có 1 thiết bị đã sẵn sàng sử dụng với
tên gọi /dev/etherd/e0.1. Nếu nhìn vào cây hiển thị /dev bạn sẽ
thấy 1 node mới xuất hiện:
ls -la /dev/etherd/

root@server1:~# ls -la /dev/etherd/
total 0
drwxr-xr-x 2 root root 160 2010-08-13 16:24 .
drwxr-xr-x 16 root root 3800 2010-08-13 16:21
c-w w 1 root disk 152, 3 2010-08-13 16:21 discover
brw-rw 1 root disk 152, 16 2010-08-13 16:24 e0.1
cr r 1 root disk 152, 2 2010-08-13 16:21 err

c-w w 1 root disk 152, 6 2010-08-13 16:21 flush
c-w w 1 root disk 152, 4 2010-08-13 16:21 interfaces
c-w w 1 root disk 152, 5 2010-08-13 16:21 revalidate
root@server1:~#
Và kết quả của fdisk -l sẽ hiển thị thêm thiết bị ổ cứng mới:
root@server1:~# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00016be9

Device Boot Start End Blocks Id System
/dev/sda1 * 1 32 248832 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 32 3917 31205377 5 Extended
/dev/sda5 32 3917 31205376 8e Linux LVM

Disk /dev/etherd/e0.1: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/etherd/e0.1 doesn't contain a valid partition table
root@server1:~#
Để sử dụng được thiết bị này, chúng ta phải định dạng nó

trước tiên:
fdisk /dev/etherd/e0.1

root@server1:~# fdisk /dev/etherd/e0.1
Device contains neither a valid DOS partition table, nor
Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier
0x3093ae28.
Changes will remain in memory only, until you decide to
write them.
After that, of course, the previous content won't be
recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be
corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's
strongly recommended to
switch off the mode (command 'c') and change display units
to
sectors (command 'u').

Command (m for help): < gõ n
Command action
e extended
p primary partition (1-4)
< gõ p
Partition number (1-4): < gõ 1
First cylinder (1-2610, default 1): < nhấn ENTER
Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-2610, default
2610): < nhấn ENTER
Using default value 2610

Command (m for help): < gõ t
Selected partition 1
Hex code (type L to list codes): < gõ 83

Command (m for help): < gõ w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
root@server1:~#

Sau đó, kết quả của fdisk -l sẽ trông giống như sau:

root@server1:~# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00016be9

Device Boot Start End Blocks Id System
/dev/sda1 * 1 32 248832 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 32 3917 31205377 5 Extended

/dev/sda5 32 3917 31205376 8e Linux LVM

Disk /dev/etherd/e0.1: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3093ae28

Device Boot Start End Blocks Id System
/dev/etherd/e0.1p1 1 2610 20964793+ 83 Linux
root@server1:~#
Tiếp theo, tạo file hệ thống trên /dev/etherd/e0.1p1…:
mkfs.ext4 /dev/etherd/e0.1p1
và ghép vào hệ thống để thử nghiệm:
mount /dev/etherd/e0.1p1 /mnt
Sau đó, bạn sẽ thấy thiết bị mới hiển thị trong danh sách
của mount:
root@server1:~# mount
/dev/mapper/server1-root on / type ext4
(rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts
(rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)

none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
none on /var/lib/ureadahead/debugfs type debugfs
(rw,relatime)
/dev/sda1 on /boot type ext2 (rw)
/dev/etherd/e0.1p1 on /mnt type ext4 (rw)
root@server1:~#
và của df -h là:
root@server1:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/server1-root
18G 838M 16G 5% /
none 243M 180K 242M 1% /dev
none 247M 0 247M 0% /dev/shm
none 247M 32K 247M 1% /var/run
none 247M 0 247M 0% /var/lock
none 247M 0 247M 0% /lib/init/rw
none 18G 838M 16G 5% /var/lib/ureadahead/debugfs
/dev/sda1 228M 17M 199M 8% /boot
/dev/etherd/e0.1p1 20G 172M 19G 1% /mnt
root@server1:~#
Nếu không muốn tiếp tục sử dụng, bạn có thể bỏ đi như
sau:
umount /mnt
Để thiết bị từ ghép vào hệ thống khi hệ điều hành khởi
động, ví dụ tại thư mục /storage, chúng ta sẽ tạo thư mục
đó:
mkdir /storage
và thêm dòng sau vào /etc/fstab:

vi /etc/fstab

[ ]
/dev/etherd/e0.1p1 /storage ext4 defaults,auto,_netdev 0 0
Thực chất, chỉ như trên thì vẫn chưa đủ vì các thành phần
liên quan đến AoE sẽ tự tải sau khi /etc/fstab được đọc dữ
liệu. Do vậy, hãy mở /etc/rc.local…:
vi /etc/rc.local
và thêm dòng mã sau vào (vào trước dòng exit 0):
[ ]
aoe-discover
sleep 5
mount -a
[ ]
Khởi động lại hệ thống:
reboot
Kiểm tra lại sau khi hệ thống vừa khởi động lên:
mount

root@server1:~# mount
/dev/mapper/server1-root on / type ext4
(rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts
(rw,noexec,nosuid,gid=5,mode=0620)

none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
none on /var/lib/ureadahead/debugfs type debugfs
(rw,relatime)
/dev/sda1 on /boot type ext2 (rw)
/dev/etherd/e0.1p1 on /storage type ext4 (rw,_netdev)
root@server1:~#

df -h

root@server1:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/server1-root
18G 838M 16G 5% /
none 243M 180K 242M 1% /dev
none 247M 0 247M 0% /dev/shm
none 247M 32K 247M 1% /var/run
none 247M 0 247M 0% /var/lock
none 247M 0 247M 0% /lib/init/rw
none 18G 838M 16G 5% /var/lib/ureadahead/debugfs
/dev/sda1 228M 17M 199M 8% /boot
/dev/etherd/e0.1p1 20G 172M 19G 1% /storage
root@server1:~#
Trên đây là 1 số bước để thiết lập và sử dụng hệ thống
ATA Over Ethernet (AoE) trên Ubuntu 10.04 (Initiator và
Target). Chúc các bạn thành công!


×