Cài đặt những hói cần thiết trên host:
1. Copy file
CentOS-Base.repo vào thư mục
/etc/yum.repos.d/ trên host;
2. Chạy lệnh sau để cài gói iscsi-initiator-utils:
Code:
# yum install iscsi-initiator-utils
Cấu hình iSCSI:
Cần thực hiện 3 bước sau để thiết lập 1 hệ thống sử dụng iSCSI storage: iSCSI startup bằng init script hay startup bằng tay. Bạn cần chỉnh sửa và cấu hình iSCSI thông qua file
/etc/iscsi/iscsid.conf:
1. Tìm đia điểm.
2. Đặt tự động login cho lần reboot tiếp theo.
3. Bạn cần phải có
iSCSI username,
password và địa chỉ IP của
storage server
Bước # 1: Cấu hình iSCSI
Mở
/etc/iscsi/iscsid.conf bằng vi:
Code:
# vi /etc/iscsi/iscsid.conf
Thiết lập
username và
password:
Code:
node.session.auth.username = My_ISCSI_USR_NAME
node.session.auth.password = MyPassword
discovery.sendtargets.auth.username = My_ISCSI_USR_NAME
discovery.sendtargets.auth.password = MyPassword
Với
* node.session.* dùng để thiết lập CHAP username và password cho chứng thực lúc khởi động trên host đích.
* discovery.sendtargets.* dùng để tìm phiên CHAP username và password cho chứng thực lúc khởi động trên host đích.
Bạn cũng cần phải chỉnh sửa và thiết lập những lựa chọn khác. Vào man page để biết thêm chi tiết. Bậy giờ thò start iscsi service:
Code:
# /etc/init.d/iscsi start
Bước # 2: Tìm máy đich.
Bậy giòe bạn dùng lệnh
iscsiadm (1 tool dạng command line) cho phép tìm và đăng nhập vào máy đích iSCSI, cũng như truy xuất và quản trị CSDL open-iscsi. Nếu địa chỉ IP của
storage server của bạn là 192.168.1.5, nhập:
Code:
# iscsiadm -m discovery -t sendtargets -p 192.168.1.5
# /etc/init.d/iscsi restart
Bây giờ có lẽ đã xuất hiện 1 block device bên dưới thư mục
/dev. Để lấy tên của thiết bị mới, nhập:
hoặc
Code:
# tail -f /var/log/messages
Xuất:
Code:
Oct 10 12:42:20 ora9is2 kernel: Vendor: EQLOGIC Model: 100E-00 Rev: 3.2
Oct 10 12:42:20 ora9is2 kernel: Type: Direct-Access ANSI SCSI revision: 05
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: 41963520 512-byte hdwr sectors (21485 MB)
Oct 10 12:42:20 ora9is2 kernel: sdd: Write Protect is off
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: drive cache: write through
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: 41963520 512-byte hdwr sectors (21485 MB)
Oct 10 12:42:20 ora9is2 kernel: sdd: Write Protect is off
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: drive cache: write through
Oct 10 12:42:20 ora9is2 kernel: sdd: unknown partition table
Oct 10 12:42:20 ora9is2 kernel: sd 3:0:0:0: Attached scsi disk sdd
Oct 10 12:42:20 ora9is2 kernel: sd 3:0:0:0: Attached scsi generic sg3 type 0
Oct 10 12:42:20 ora9is2 kernel: rtc: lost some interrupts at 2048Hz.
Oct 10 12:42:20 ora9is2 iscsid: connection0:0 is operational now
/dev/sdd là 1 ví dụ về block device.
Bước # 3: Format và Mount iSCSI Volume
Bậy giờ bạn đã có thể tạo partition và định dạng filesystem trên máy đích bằng lệnh
fdisk và
mkfs.ext3:
Code:
# fdisk /dev/sdd
# mke2fs -j -m 0 -O dir_index /dev/sdd1
hoặc
Code:
# mkfs.ext3 /dev/sdd1
Mount partition mới:
Code:
# mkdir /mnt/iscsi
# mount /dev/sdd1 /mnt/iscsi
Bước #4: Mount iSCSI drive tự động lúc khởi động
Đầu tiên kiểm tra
iscsi service turned on khi boot:
Code:
# chkconfig iscsi on
Mở
/etc/fstab file và thêm config directive:
Code:
/dev/sdd1 /mnt/iscsi ext3 _netdev 0 0