1. mount /dev/cdrom /mnt/cdrom color:#555555">2. [root@looklo ~]# vim /etc/yum.repos.d/rhel-source.repo [rhel-source] name=Red Hat Enterprise Linux $releasever - $basea"/> 1. mount /dev/cdrom /mnt/cdrom color:#555555">2. [root@looklo ~]# vim /etc/yum.repos.d/rhel-source.repo [rhel-source] name=Red Hat Enterprise Linux $releasever - $basea"/>
歡迎您光臨本站 註冊首頁

Linux Iscsi 安裝和配置

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

color:#555555">1. mount /dev/cdrom /mnt/cdrom

color:#555555">2.

[root@looklo ~]# vim /etc/yum.repos.d/rhel-source.repo

[rhel-source]

name=Red Hat Enterprise Linux $releasever - $basearch - Source

baseurl=file:///mnt/cdrom

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

color:#555555">3.

安裝方法一:

查找包

[root@looklo ~]# yum search iscsi

iscsi-initiator-utils.x86_64 : iSCSI daemon and utility programs

安裝包

[root@looklo ~]# yum install iscsi-initiator-utils.x86_64 –y

安裝方法二:

find -name iscsi*
rpm -ivh ./Server/iscsi-initiator-utils-6.2.0.868-0.18.el5.i386.rpm

安裝成功后,會產生下面目錄

運行此命令后,會生成一個目錄/etc/iscsi,該目錄下有兩個文件:


Initiatorname.iscsi和iscsid.conf

color:red">4. service iscsi start

/etc/init.d/iscsi start

5.搜索盤陣:
運行以下命令搜尋target,即目標端:存儲設備
命令格式:[root@linux ~]#
iscsiadm --mode discovery --type sendtargets --portal ipaddress
iscsiadm -m discovery -t sendtargets -p 192.168.0.230

6.顯示盤陣:
顯示存儲端target name
eg:
[root@localhost cdrom]#
iscsiadm -m node


192.168.0.230:3260,1 iqn.2001-05.com.equallogic:0-290c06-cb5684bd1-00a4abe3c9d4e5ca-pillar
192.168.0.135:3260,1 iqn.2001-05.com.equallogic:0-290c06-d068419ca-00d000000244f040-volume1

[root@localhost cdrom]#

7.登錄盤陣
命令格式:target登陸
[root@linux ~]#
iscsiadm --mode node --targetname targetname --portal 192.168.0.230:3260 --login
eg:
[root@localhost cdrom]#
iscsiadm -m node -T iqn.2001-05.com.equallogic:0-290c06-cb5684bd1-00a4abe3c9d4e5ca-pillar -p 192.168.0.230:3260 -l
Logging in to [iface: default, target: iqn.2006-01.com.openfiler:tsn.959c083bcac2, portal: 100.1.1.5,3260]
Login to [iface: default, target: iqn.2006-01.com.openfiler:tsn.959c083bcac2, portal: 100.1.1.5,3260]: successful
[root@localhost cdrom]#

經過以上幾步,fdiskl就可以看到所掛接分區了!!!
(
為確保重啟后也能看到,再修改一下

/etc/iscsi/iscsid.conf
[root@linux ~]#
vi /etc/iscsi/iscsid.conf

iscsiadm -m node -T iqn.2001-05.com.equallogic:0-290c06-cb5684bd1-00a4abe3c9d4e5ca-pillar -p 192.168.0.230:3260 –l

添加到該文件中的開始部分.
設置服務啟動
chkconfig --level 35 iscsid .)
其實這個文件大多數內容處於被註釋狀態,該命令添加位置應該影響不大.然後重啟電腦後直接fdisk l 依然可以看到所掛接的分區.至此iscsi所有操作完成,但掛載的分區不是linux所識別,必須使用FDISK進行磁碟分區.

8.設置分區
使用fdisk命令進行磁碟分區
fdisk
是各種Linux

發行版本中最常用的分區工具,是被定義為Expert級別的分區工具.我們可以通過fdisk來分區使用iscsi設備.它還包括一個二級選單,輸入命令,然後出現問答式界面,用戶通過在這個界面中輸入命令參數來操作fdisk.
fdisk /dev/sdb
運行后出現fdiak的命令提示符:
Command (m for help):
使用
n命令創建一個分區,會出現選擇主分區(p primary partition)還是擴展分區(llogical)的提示,通常選用主分區.然後按照提示輸入分區號(Partion number(14):)、新分區起始的磁碟塊數(FirstCylinder)和分區的大小,可以是以MB為單位的數字(Last cylindet or siza or sizeM or sizeK:).例如:


[root@localhost ~]#
fdisk /dev/sdb 查看磁碟信息
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel


Building a new DOS disklabel. 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)

Command (m for help): n 創建新分區
Command action
e extended
擴展分區
p primary partition (1-4)
邏輯分區
p
Partition number (1-4):
1
First cylinder (1-1011, default 1):
Using default value 1
Last cylinder or size or sizeM or sizeK (1-1011, default 1011):
Using default value 1011

Command (m for help): w 保存分區信息
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#


9.
檢驗新分區

[root@localhost ~]# fdisk /dev/sdb

Command (m for help): p

Disk /dev/sda: 1073 MB, 1073741824 bytes
34 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 2074 * 512 = 1061888 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 1011 1048376 83 Linux

10.格式化分區
[root@localhost ~]#
mkfs -t ext3 /dev/sdb1


mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
131072 inodes, 262094 blocks
13104 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

11.設定載入點
文件系統必須有一個掛載點,它只是一個空的目錄,新文件系統在這裡與系統目錄樹“相連”.
經過以上的操作,Linux伺服器已經連接到 iSCSI 儲存設備, 並且如同Linux 本機上面的一個 SCSI 硬碟一樣. 使用的方式幾乎一模一樣.

假設iSCSI 主機掛載到 /mnt/cluster目錄下:
[root@localhost mnt]#
mkdir /mnt/cluster
[root@localhost mnt]#
mount /dev/sdb1 /mnt/cluster
[root@localhost mnt]# df -h
[root@looklo ~]# df –h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-lvroot
9.9G 5.3G 4.2G 57% /
tmpfs 1004M 272K 1004M 1% /dev/shm
/dev/sda1 291M 78M 199M 28% /boot
/dev/mapper/vg0-lvhome
4.0G 202M 3.6G 6% /home
/dev/mapper/vg0-lviso
4.0G 3.5G 255M 94% /iso
/dev/mapper/vg1-lv_oracle
9.9G 8.0G 1.4G 86% /opt
/dev/sdb1 389M 11M 359M 3%
/mnt/cluster

[root@localhost mnt]#


12.
設定自動掛載
在機器重新啟動后自動載入分區,必須在

/etc/fstab中加入相應分區,但分區類型必須市"_netdev".例如載入的分區sda1:
[root@linux ~]#
vi /etc/fstab
/dev/sdb1 /mnt/cluster ext3 ­_netdev 0 0

本文出自 「IT-愛好者」 博客,請務必保留此出處http://pillarmanocean.blog.51cto.com/2349508/795623


[火星人 ] Linux Iscsi 安裝和配置已經有737次圍觀

http://coctec.com/docs/linux/show-post-47504.html