在RHEL 5上安装并配置iSCSI Initiator软件
2012-08-12 16:18
295 查看
服务器到存储的连接
在RHEL 5上安装并配置iSCSIInitiator软件
RHEL 5已开始在内核中加入了对iSCSI的支持,使用的 iSCSI Initiator软件是Open-iSCSI
Initiator,其配置方式与RHEL 4及更早的RedHatLinux发行版中的iSCSI Initiator有很大的区别。比如设置自动挂载的时候,我们现在编辑/etc/fstab文件就可以了,在iSCSI磁盘设备上创建的LV不用再做一些其他的设置就能随系统的启动自动激活了。而且iSCSI
Initiator支持万兆网卡,从Open-iSCSI网站(http://www.open-iscsi.org)上了解到,他们曾测试过2个iSCSI
session的性能达到810MB/s的写速度。
1.安装iSCSI Initiator
把RHEL5第一张安装光盘挂载到/mnt目录下,
用chkconfig检查iscsi和iscsid服务在运行级别3和5中随系统的启动而自动启动
如果iscsid和iscsi没有随系统的启动而启动,则用setup进入system
service,设置这两个服务随系统启动而启动
2.设置InitiatorName
用vi编辑/etc/iscsi/initiatorname.iscsi文件,文件内容如下
本例中InitiatorName为iqn.2005-03.com.max:pe03
3.启动iscsi服务
用service iscsi start启动iSCSI服务。
用service iscsi status及service iscsid status查看iscsi相关服务的运行状态
4.执行target的发现
RHEL 5上当前的iSCSI Initiator版本只支持sendtargets
的发现方式,不支持SLP和iSNS
iSCSI业务IP地址为200.200.10.200,则使用下面的命令执行target的发现:
如果之前没有在存储设备上创建改initiator并分配卷,则这个命令执行成功后没有任何输出,但是此时到存储设备上会查看到有新的initiator生成。
在存储设备上把卷分配给initiator后再次执行target的发现:
此时发现了一个新的target,target名称为iqn.2007-04.acme.com:h3c:200realm.rhel5
5.登录target
这里-T后面跟target名字,最后的l是L的小写,不是数字1
用iscsiadm -m session –i查看iscsi session信息
6.对新发现的磁盘进行分区并创建文件系统
先用fdisk –l查看新的磁盘名称,这里我们发现了一个100GB的磁盘,设备名为/dev/sdb
用fdisk /dev/sdb进行分区,本例中我们把整个磁盘分成一个主分区/dev/sdb1
用mkfs命令在/dev/sdb1上创建ext3文件系统
用tune2fs修改文件系统的属性,去掉自动检查的属性:
7.设定文件系统的自动挂载
本例中我们将要把/dev/sdb1挂载到/data目录下
手动创建一个目录/data
用tune2fs查找文件系统的UUID:
用vi编辑/etc/fstab文件,设置自动挂载:
在/etc/fstab文件中增加下面蓝色的一行文字:
注意,挂载的选项使用的是“_netdev”
用mount –a挂载文件系统
用df查看文件系统已经挂载成功
8.重新启动系统并用df命令确认文件系统自动挂载成功。
附:
Open-iSCSI modules
README文件
1. In ThisRelease
==================
This file describes the Linux* Open-iSCSIInitiator.
1.1. Features
-highly optimized and very small-footprint data path;
-persistent configuration database;
-SendTargets discovery;
-CHAP;
-PDU header Digest;
-multiple sessions;
For the most recent list of features please refer to:
http://www.open-iscsi.org
2. Introduction
===============
Open-iSCSI project is a high-performance,transport independent,
multi-platform implementation of RFC3720iSCSI.
Open-iSCSI is partitioned into user and kernel parts.
Thekernel portion
of Open-iSCSI is a from-scratch codelicensed under GPL. The kernel part implements iSCSI data path (that is, iSCSIRead and iSCSI Write), and consists of three loadable modules:scsi_transport_iscsi.ko, libiscsi.ko and iscsi_tcp.ko.
Userspace contains the entire control plane:configuration manager, iSCSI Discovery, Login and Logoutprocessing,connection-level error processing, Nop-In and Nop-Out handling, and(in
the future:) Text processing, iSNS, SLP, Radius, etc.
Theuser space Open-iSCSI consists of a daemon process called iscsid, and amanagement utility iscsiadm.
3. Installation
===============
To install the iSCSI tools run:
rpm-ivh iscsi-initiator-utils-<your version>.rpm
This willinstall iscsid and iscsiadm to /sbin. It will also install
defaultconfig files to /etc/iscsi:
/etc/iscsi/iscsid.conf- All new session will inherit settings from
this file when they are first discovered.To override a value for a specific
target see the iscsiadm op command belowand in the iscsiadm man page.
See Configuration section below.
/etc/iscsi/initiatorname.iscsi- The default initaitor name for software
iSCSI initiator.
4. Open-iSCSI daemon
====================
The daemon implements control path of iSCSIprotocol, plus some management facilities. For example, the daemon could beconfigured to automatically re-start discovery at startup, based on thecontents
of persistent iSCSI database (see next section).
For help, run:
./iscsid --help
Usage: iscsid[OPTION]
-c,--config=[path] Execute in the configfile (/etc/iscsi/iscsid.conf).
-f,--foreground run iscsid in theforeground
-d,--debug debuglevel print debugginginformation
-u,--uid=uid run as uid, defaultis current user
-g,--gid=gid run as gid, defaultis current user group
-h,--help display this help andexit
-v,--version display version andexit
5. Open-iSCSI Configuration Utility
===================================
Open-iSCSIpersistent configuration is implemented as a set of iSCSI database files.
-Discovery (/var/lib/iscsi/send_targets);
- Node (/var/lib/iscsi/nodes).
The iscsiadm utility is a command-line toolto manage (update, delete, insert, query) the persistent database.
The utility presents a set of operationsthat a user can perform on iSCSI nodes, sessions, connections, and discoveryrecords.
Note that some of the iSCSI Node and iSCSIDiscovery operations do not require iSCSI daemon (iscsid) loaded.
For help, run:
./iscsiadm --help
Usage: iscsiadm[OPTION]
-m,--mode <op> specifyoperational mode op = <discovery|node>
-mdiscovery --type=[type] --portal=[ip:port] --login
perform [type]discovery for target portal with
ip-address [ip] andport [port]. Initiate Login for
each discoveredtarget if --login is specified
-mdiscovery display alldiscovery records from internal
persistent discovery database
-mdiscovery --portal=[ip:port] --login
perform discoverybased on portal in database
-mdiscovery --portal=[ip:port] --op=[op] [--name=[name] --value=[value]]
perform specific DBoperation [op] for specific
discovery portal. Itcould be one of:
[new], [delete],[update] or [show]. In case of
[update], you have toprovide [name] and [value]
you wish to update
-mnode display alldiscovered nodes from internal
persistent discoverydatabase
-mnode --targetname=[name] --portal=[ip:port] [--login|--logout]
-mnode --targetname=[name] --portal=[ip:port] --op=[op] [--name=[name] \
--value=[value]]
perform specific DBoperation [op] for specific
portal on target. Itcould be one of:
[new], [delete],[update] or [show]. In case of
[update], you have toprovide [name] and [value]
you wish to update
-mnode --logoutall=[all,manual,automatic]
Logout "all" therunning sessions or just the ones
with a node or connstartup value manual or automatic.
Nodes marked asONBOOT are skipped.
-mnode --loginall=[all,manual,automatic]
Login "all"the running sessions or just the ones
with a node or connstartup value manual or automatic.
Nodes marked asONBOOT are skipped.
-msession display all activesessions and connections
-msession --sid=[sid] [--info | --rescan | --logout ]
--op=[op][--name=[name] --value=[value]]
perform operation forspecific session with
session id sid. If no sid is given theoperation
will be performed onall running sessions if possible.
--logout, --rescan,--op only work on single session.
--logout and --opwork like they do in node mode,
but in session modetargetname and portal info is
is not passed in.
If no sid and nooperation is given print out the
running sessions.
-d,--debug debuglevel print debugginginformation
-V,--version display version andexit
-h,--help display this help andexit
Usage examples (using the one-letteroptions):
1)SendTargets iSCSI Discovery:
iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260
2)iSCSI Login:
login to a specific target:
iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 -l
login to all targets:
iscsiadm -m node --loginall=all
3) iSCSI Logout:
logout of a specific target:
iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 -u
logout of all targets:
iscsiadm -m node --logoutall=all
4)Changing iSCSI parameter:
iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 \
-o update -nnode.cnx[0].iscsi.MaxRecvDataSegmentLength -v 65536
5)Adding custom iSCSI Node:
iscsiadm -m node -o new -p 192.168.0.1:3260
6)Removing iSCSI Node:
iscsiadm -m node -o delete -Tiqn.2005-03.com.max -p 192.168.0.4:3260
7)Display iSCSI Node configuration:
iscsiadm -m node -Tiqn.2005-03.com.max -p 192.168.0.4:3260
or
iscsiadm -m node -o show -Tiqn.2005-03.com.max -p 192.168.0.4:3260
8) Show all node records:
iscsiadm -m node
9) Show all records in discovery database:
iscsiadm -m discovery
10) Display discovery record setting:
iscsiadm -m discovery -p 192.168.0.4:3260
11) Display session statistics:
iscsiadm -m session -r 1 --stats
12) Display sessionand device info:
iscsiadm -m session –i
6.Configuration
================
The default configuration file is
/etc/iscsi/iscsid.conf. This filecontains only configuration that could be overwritten by iSCSI Discovery, ormanualy updated via iscsiadm utility. It's OK if this file does not exist inwhich case compiled-in default configuration will take
place for newerdiscovered Target nodes. See the example file for the current syntax.
7. Getting Started
==================
There are three steps needed to set up a system to useiSCSI storage:
1. automate iSCSIstartup using the init script.
2. discover targets.
3. automate targetlogins for future system reboots.
1.automate iSCSI startup using the init script
-----------------------------------------------
To start the iSCSI daemon and log intotargets with the node.startup value "automatic"you can do:
service iscsi start
By default, when the system starts up thiswill be run for you once you have installed the iscsi-initiator-utils package.
Toautomatically mount a file system during startup
you must have the partition entry in
/etc/fstab marked with the"_netdev"
option. For example this would mount aiscsi disk sdb:
/dev/sdb/mnt/iscsi ext3 _netdev 0 0
2. discover targets
-------------------
Once the iSCSI service is up, you can perform discovery to targets
using:
iscsiadm -m discovery -tsendtargets -p 192.168.1.1:3260
While discovery targets are kept in thediscovery db, they are usefull only for re-discovery. The discovered targets(a.k.a. nodes) are stored as records in the node db.
The discovered targets are not logged intoyet like in past RHEL iscsi-initiator-utils packages.
Ifyou want to access the newly discovered target manually, run the iscsiadm logincommand
in section 5. In this example if iscsiadm-m discovery -t sendtargets -p 192.168.1.1:3260 found a targe with two portals:
10.15.85.19:3260,3iqn.1992-08.com.netapp:sn.33615311
10.15.84.19:3260,2iqn.1992-08.com.netapp:sn.33615311
You could run:
iscsiadm -m node -Tiqn.1992-08.com.netapp:sn.33615311 -p 10.15.85.19:3260 -l
to log into the first one listed.
(这里的-l是login的意思)
3. automate target logins for future system reboots
---------------------------------------------------
To automate login to a node, use thefollowing with the record ID of the node discovered in the discovery above:
iscsiadm -m node -T targetname -p ip:port --op update -n node.startup -vautomatic
Or to set the "node.statup"attribute to "startup" as default for all sessions that will bediscovered add the following to the /etc/iscsi/iscsid.conf:
node.conn[0].startup = automatic
The next time the iSCSI service is startedup, the target will be logged into automatically.
Thedefault setting is to automatically create a session to every portal on thetarget. If you would like to disable automaticstartup, set the startup value to "manual".
查看有那些target记录在了数据库中
iscsiadm -m node
手动从数据库中删除一个target
iscsiadm -mnode -o delete -T iqn.2005-03.com.max -p 192.168.0.4:3260
在RHEL 5上安装并配置iSCSIInitiator软件
RHEL 5已开始在内核中加入了对iSCSI的支持,使用的 iSCSI Initiator软件是Open-iSCSI
Initiator,其配置方式与RHEL 4及更早的RedHatLinux发行版中的iSCSI Initiator有很大的区别。比如设置自动挂载的时候,我们现在编辑/etc/fstab文件就可以了,在iSCSI磁盘设备上创建的LV不用再做一些其他的设置就能随系统的启动自动激活了。而且iSCSI
Initiator支持万兆网卡,从Open-iSCSI网站(http://www.open-iscsi.org)上了解到,他们曾测试过2个iSCSI
session的性能达到810MB/s的写速度。
1.安装iSCSI Initiator
把RHEL5第一张安装光盘挂载到/mnt目录下,
[root@pe03 Server]# cd /mnt/Server/ [root@pe03 Server]# rpm -ivh iscsi-initiator-utils-6.2.0.742-0.5.el5.i386.rpm |
用chkconfig检查iscsi和iscsid服务在运行级别3和5中随系统的启动而自动启动
[root@pe03 Server]# chkconfig --list |grep iscsi iscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:off iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off |
如果iscsid和iscsi没有随系统的启动而启动,则用setup进入system
service,设置这两个服务随系统启动而启动
2.设置InitiatorName
用vi编辑/etc/iscsi/initiatorname.iscsi文件,文件内容如下
InitiatorName=iqn.2005-03.com.max:pe03 |
3.启动iscsi服务
用service iscsi start启动iSCSI服务。
root@pe03 Server]# service iscsid start Turning off network shutdown. Starting iSCSI daemon: [ OK ] [ OK ] |
[root@pe03 Server]# service iscsi status iscsid (pid 3697 3696) is running... [root@pe03 Server]# service iscsid status iscsid (pid 3697 3696) is running... |
4.执行target的发现
RHEL 5上当前的iSCSI Initiator版本只支持sendtargets
的发现方式,不支持SLP和iSNS
iSCSI业务IP地址为200.200.10.200,则使用下面的命令执行target的发现:
[root@pe03 Server]# iscsiadm -m discovery -t sendtargets -p 192.168.3.2:3260 |
在存储设备上把卷分配给initiator后再次执行target的发现:
[root@pe03 Server]# iscsiadm -m discovery -t sendtargets -p 192.168.3.2:3260 iscsiadm: unexpected SendTargets data: 192.168.10.9:3260,1 iqn.2007-04.acme.com:h3c:200realm.rhel5 |
5.登录target
[root@pe03 Server]# iscsiadm -m node -T iqn.1987-05.com.cisco:01.ca13b3a8fb3 -p 192.168.3.2:3260 –l |
用iscsiadm -m session –i查看iscsi session信息
[root@pe03 ~]# iscsiadm -m session -i iscsiadm version 2.0-742 ************************************ Session (sid 0) using module tcp: ************************************ TargetName: iqn.2007-04.acme.com:h3c:200realm.rhel5 Portal Group Tag: 1 Network Portal: 192.168.10.9:3260 iSCSI Connection State: LOGGED IN Internal iscsid Session State: NO CHANGE ************************ Negotiated iSCSI params: ************************ HeaderDigest: None DataDigest: None MaxRecvDataSegmentLength: 65536 MaxXmitDataSegmentLength: 65536 FirstBurstLength: 65536 MaxBurstLength: 262144 ImmediateData: No InitialR2T: Yes MaxOutstandingR2T: 1 ************************ Attached SCSI devices: ************************ Host Number: 3 State: running scsi3 Channel 00 Id 0 Lun: 0 Attached scsi disk sdb State: running |
6.对新发现的磁盘进行分区并创建文件系统
先用fdisk –l查看新的磁盘名称,这里我们发现了一个100GB的磁盘,设备名为/dev/sdb
[root@pe03 Server]# fdisk -l .............................. Disk /dev/sdb: 107.3 GB, 107373133824 bytes 255 heads, 63 sectors/track, 13054 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table |
用fdisk /dev/sdb进行分区,本例中我们把整个磁盘分成一个主分区/dev/sdb1
[root@pe03 Server]# 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. The number of cylinders for this disk is set to 13054. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) 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-13054, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-13054, default 13054): Using default value 13054 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. |
用mkfs命令在/dev/sdb1上创建ext3文件系统
[root@pe03 Server]# 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) 13107200 inodes, 26214055 blocks 1310702 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=0 800 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 35 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. |
用tune2fs修改文件系统的属性,去掉自动检查的属性:
[root@pe03 Server]# tune2fs -c -1 -i 0 /dev/sdb1 tune2fs 1.39 (29-May-2006) Setting maximal mount count to -1 Setting interval between checks to 0 seconds |
7.设定文件系统的自动挂载
本例中我们将要把/dev/sdb1挂载到/data目录下
手动创建一个目录/data
[root@pe03 Server]# mkdir /data |
用tune2fs查找文件系统的UUID:
[root@pe03 Server]# tune2fs -l /dev/sdb1 tune2fs 1.39 (29-May-2006) Filesystem volume name: <none> Last mounted on: <not available> Filesystem UUID: 3f0a00b7-4939-4ad2-a592-0821bb79f7c6 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal resize_inode dir_index filetype sparse_super large_file .................... |
用vi编辑/etc/fstab文件,设置自动挂载:
[root@pe03 Server]# vi /etc/fstab |
在/etc/fstab文件中增加下面蓝色的一行文字:
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1 LABEL=/boot /boot ext3 defaults 1 2 devpts /dev/pts devpts gid=5,mode=620 0 0 tmpfs /dev/shm tmpfs defaults 0 0 proc /proc proc defaults 0 0 sysfs /sys sysfs defaults 0 0 /dev/VolGroup00/LogVol01 swap swap defaults 0 0 UUID=3f0a00b7-4939-4ad2-a592-0821bb79f7c6 /data ext3 _netdev 0 0 |
用mount –a挂载文件系统
[root@pe03 Server]# mount –a |
[root@pe03 /]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 ext3 65G 2.4G 59G 4% / /dev/sda1 ext3 99M 12M 82M 13% /boot tmpfs tmpfs 471M 0 471M 0% /dev/shm /dev/sdb1 ext3 99G 188M 94G 1% /data |
8.重新启动系统并用df命令确认文件系统自动挂载成功。
附:
Open-iSCSI modules
README文件
1. In ThisRelease
==================
This file describes the Linux* Open-iSCSIInitiator.
1.1. Features
-highly optimized and very small-footprint data path;
-persistent configuration database;
-SendTargets discovery;
-CHAP;
-PDU header Digest;
-multiple sessions;
For the most recent list of features please refer to:
http://www.open-iscsi.org
2. Introduction
===============
Open-iSCSI project is a high-performance,transport independent,
multi-platform implementation of RFC3720iSCSI.
Open-iSCSI is partitioned into user and kernel parts.
Thekernel portion
of Open-iSCSI is a from-scratch codelicensed under GPL. The kernel part implements iSCSI data path (that is, iSCSIRead and iSCSI Write), and consists of three loadable modules:scsi_transport_iscsi.ko, libiscsi.ko and iscsi_tcp.ko.
Userspace contains the entire control plane:configuration manager, iSCSI Discovery, Login and Logoutprocessing,connection-level error processing, Nop-In and Nop-Out handling, and(in
the future:) Text processing, iSNS, SLP, Radius, etc.
Theuser space Open-iSCSI consists of a daemon process called iscsid, and amanagement utility iscsiadm.
3. Installation
===============
To install the iSCSI tools run:
rpm-ivh iscsi-initiator-utils-<your version>.rpm
This willinstall iscsid and iscsiadm to /sbin. It will also install
defaultconfig files to /etc/iscsi:
/etc/iscsi/iscsid.conf- All new session will inherit settings from
this file when they are first discovered.To override a value for a specific
target see the iscsiadm op command belowand in the iscsiadm man page.
See Configuration section below.
/etc/iscsi/initiatorname.iscsi- The default initaitor name for software
iSCSI initiator.
4. Open-iSCSI daemon
====================
The daemon implements control path of iSCSIprotocol, plus some management facilities. For example, the daemon could beconfigured to automatically re-start discovery at startup, based on thecontents
of persistent iSCSI database (see next section).
For help, run:
./iscsid --help
Usage: iscsid[OPTION]
-c,--config=[path] Execute in the configfile (/etc/iscsi/iscsid.conf).
-f,--foreground run iscsid in theforeground
-d,--debug debuglevel print debugginginformation
-u,--uid=uid run as uid, defaultis current user
-g,--gid=gid run as gid, defaultis current user group
-h,--help display this help andexit
-v,--version display version andexit
5. Open-iSCSI Configuration Utility
===================================
Open-iSCSIpersistent configuration is implemented as a set of iSCSI database files.
-Discovery (/var/lib/iscsi/send_targets);
- Node (/var/lib/iscsi/nodes).
The iscsiadm utility is a command-line toolto manage (update, delete, insert, query) the persistent database.
The utility presents a set of operationsthat a user can perform on iSCSI nodes, sessions, connections, and discoveryrecords.
Note that some of the iSCSI Node and iSCSIDiscovery operations do not require iSCSI daemon (iscsid) loaded.
For help, run:
./iscsiadm --help
Usage: iscsiadm[OPTION]
-m,--mode <op> specifyoperational mode op = <discovery|node>
-mdiscovery --type=[type] --portal=[ip:port] --login
perform [type]discovery for target portal with
ip-address [ip] andport [port]. Initiate Login for
each discoveredtarget if --login is specified
-mdiscovery display alldiscovery records from internal
persistent discovery database
-mdiscovery --portal=[ip:port] --login
perform discoverybased on portal in database
-mdiscovery --portal=[ip:port] --op=[op] [--name=[name] --value=[value]]
perform specific DBoperation [op] for specific
discovery portal. Itcould be one of:
[new], [delete],[update] or [show]. In case of
[update], you have toprovide [name] and [value]
you wish to update
-mnode display alldiscovered nodes from internal
persistent discoverydatabase
-mnode --targetname=[name] --portal=[ip:port] [--login|--logout]
-mnode --targetname=[name] --portal=[ip:port] --op=[op] [--name=[name] \
--value=[value]]
perform specific DBoperation [op] for specific
portal on target. Itcould be one of:
[new], [delete],[update] or [show]. In case of
[update], you have toprovide [name] and [value]
you wish to update
-mnode --logoutall=[all,manual,automatic]
Logout "all" therunning sessions or just the ones
with a node or connstartup value manual or automatic.
Nodes marked asONBOOT are skipped.
-mnode --loginall=[all,manual,automatic]
Login "all"the running sessions or just the ones
with a node or connstartup value manual or automatic.
Nodes marked asONBOOT are skipped.
-msession display all activesessions and connections
-msession --sid=[sid] [--info | --rescan | --logout ]
--op=[op][--name=[name] --value=[value]]
perform operation forspecific session with
session id sid. If no sid is given theoperation
will be performed onall running sessions if possible.
--logout, --rescan,--op only work on single session.
--logout and --opwork like they do in node mode,
but in session modetargetname and portal info is
is not passed in.
If no sid and nooperation is given print out the
running sessions.
-d,--debug debuglevel print debugginginformation
-V,--version display version andexit
-h,--help display this help andexit
Usage examples (using the one-letteroptions):
1)SendTargets iSCSI Discovery:
iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260
2)iSCSI Login:
login to a specific target:
iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 -l
login to all targets:
iscsiadm -m node --loginall=all
3) iSCSI Logout:
logout of a specific target:
iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 -u
logout of all targets:
iscsiadm -m node --logoutall=all
4)Changing iSCSI parameter:
iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 \
-o update -nnode.cnx[0].iscsi.MaxRecvDataSegmentLength -v 65536
5)Adding custom iSCSI Node:
iscsiadm -m node -o new -p 192.168.0.1:3260
6)Removing iSCSI Node:
iscsiadm -m node -o delete -Tiqn.2005-03.com.max -p 192.168.0.4:3260
7)Display iSCSI Node configuration:
iscsiadm -m node -Tiqn.2005-03.com.max -p 192.168.0.4:3260
or
iscsiadm -m node -o show -Tiqn.2005-03.com.max -p 192.168.0.4:3260
8) Show all node records:
iscsiadm -m node
9) Show all records in discovery database:
iscsiadm -m discovery
10) Display discovery record setting:
iscsiadm -m discovery -p 192.168.0.4:3260
11) Display session statistics:
iscsiadm -m session -r 1 --stats
12) Display sessionand device info:
iscsiadm -m session –i
6.Configuration
================
The default configuration file is
/etc/iscsi/iscsid.conf. This filecontains only configuration that could be overwritten by iSCSI Discovery, ormanualy updated via iscsiadm utility. It's OK if this file does not exist inwhich case compiled-in default configuration will take
place for newerdiscovered Target nodes. See the example file for the current syntax.
7. Getting Started
==================
There are three steps needed to set up a system to useiSCSI storage:
1. automate iSCSIstartup using the init script.
2. discover targets.
3. automate targetlogins for future system reboots.
1.automate iSCSI startup using the init script
-----------------------------------------------
To start the iSCSI daemon and log intotargets with the node.startup value "automatic"you can do:
service iscsi start
By default, when the system starts up thiswill be run for you once you have installed the iscsi-initiator-utils package.
Toautomatically mount a file system during startup
you must have the partition entry in
/etc/fstab marked with the"_netdev"
option. For example this would mount aiscsi disk sdb:
/dev/sdb/mnt/iscsi ext3 _netdev 0 0
2. discover targets
-------------------
Once the iSCSI service is up, you can perform discovery to targets
using:
iscsiadm -m discovery -tsendtargets -p 192.168.1.1:3260
While discovery targets are kept in thediscovery db, they are usefull only for re-discovery. The discovered targets(a.k.a. nodes) are stored as records in the node db.
The discovered targets are not logged intoyet like in past RHEL iscsi-initiator-utils packages.
Ifyou want to access the newly discovered target manually, run the iscsiadm logincommand
in section 5. In this example if iscsiadm-m discovery -t sendtargets -p 192.168.1.1:3260 found a targe with two portals:
10.15.85.19:3260,3iqn.1992-08.com.netapp:sn.33615311
10.15.84.19:3260,2iqn.1992-08.com.netapp:sn.33615311
You could run:
iscsiadm -m node -Tiqn.1992-08.com.netapp:sn.33615311 -p 10.15.85.19:3260 -l
to log into the first one listed.
(这里的-l是login的意思)
3. automate target logins for future system reboots
---------------------------------------------------
To automate login to a node, use thefollowing with the record ID of the node discovered in the discovery above:
iscsiadm -m node -T targetname -p ip:port --op update -n node.startup -vautomatic
Or to set the "node.statup"attribute to "startup" as default for all sessions that will bediscovered add the following to the /etc/iscsi/iscsid.conf:
node.conn[0].startup = automatic
The next time the iSCSI service is startedup, the target will be logged into automatically.
Thedefault setting is to automatically create a session to every portal on thetarget. If you would like to disable automaticstartup, set the startup value to "manual".
查看有那些target记录在了数据库中
iscsiadm -m node
手动从数据库中删除一个target
iscsiadm -mnode -o delete -T iqn.2005-03.com.max -p 192.168.0.4:3260
相关文章推荐
- RHEL 5下iSCSI Initiator软件安装配置指导
- 详解 RHEL7.1 yum源配置与软件安装
- linux iscsi initiator 安装配置
- rhel7.2软件安装及yum源配置
- rhel7.2软件安装及yum源配置
- RHEL6基础四十之RHEL图形化操作软件VNC安装、配置与使用
- rhel7.2软件安装及yum源配置
- linux iscsi-initiator-utils下的安装配置
- rhel7.2软件安装及yum源配置
- 在RHEL6.4下配置YUM服务器并在安装软件包时验证软件的完整性
- rhel7.2软件安装及yum源配置
- RHEL6下安装配置ISCSI服务器
- linux iscsi initiator 安装配置
- rhel6安装配置iscsi并实现自动挂载
- Linux-->基础知识--> linux iscsi initiator 安装配置
- linux之Rhel7的软件包管理及nginx服务的安装配置
- linux iscsi initiator 安装配置 推荐
- 详解 RHEL7.1 yum源配置与软件安装
- linux iscsi initiator 安装配置
- Linux运维笔记----RHEL7.1之yum源配置与软件安装