Configuring iSCSI in RHEL
- Check that related software has been installed in the host system.
After RHEL is installed, run the rpm -qa |grep iscsi command to check whether the iSCSI software is installed.
[root@root ~]# rpm -qa |grep iscsi iscsi-initiator-utils-6.2.0.872-41.el6.x86_64
The output shows that the iSCSI software has been installed. If the iSCSI software is not installed or the installed iSCSI software is of an early version, perform the following steps to install or upgrade the software:
- Obtain the iSCSI software package.
- Upload the downloaded software package to the host.
- Install the iSCSI software on the host. In this example, the software package is stored in the /root directory. Run the following command:
[root@root ~]# rpm -ivh /root/iscsi-initiator-utils-6.2.0.872-41.el6.x86_64.rpm warning: /root/iscsi-initiator-utils-6.2.0.872-41.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:iscsi-initiator-utils ########################################### [100%]
You are advised to restart the host after the software installation.
- Configure the IP address for the storage system.
This section describes how to use the configuration script to configure the IP address. Perform the following steps:
- Check whether the network port of the host is enabled. Port em4 is used as an example.
[root@root ~]# ifconfig em1 Link encap:Ethernet HWaddr D4:AE:52:7F:D9:55 inet addr:129.22.9.64 Bcast:129.22.255.255 Mask:255.255.0.0 inet6 addr: fe80::d6ae:52ff:fe7f:d955/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:17868968 errors:0 dropped:0 overruns:0 frame:0 TX packets:8656 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2904408367 (2.7 GiB) TX bytes:647027 (631.8 KiB) Interrupt:34 Memory:f2000000-f2012800 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:2 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:98 (98.0 b) TX bytes:98 (98.0 b)
- If the network port is not enabled, run the ifconfig command to enable the port and check its IP address.
[root@root ~]# ifconfig em4 up [root@root ~]# ifconfig em4 em4 Link encap:Ethernet HWaddr D4:AE:52:7F:D9:5B inet6 addr: fe80::d6ae:52ff:fe7f:d95b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:46 Memory:f8000000-f8012800
- Run the following command to configure the static IP address:
[root@root ~]# vi /etc/sysconfig/network-scripts/ifcfg-em4 DEVICE="em4" BOOTPROTO="static" HWADDR="D4:AE:52:7F:D9:5B" IPADDR=100.100.100.1 NETMASK=255.255.255.0 NM_CONTROLLED="no" ONBOOT="yes" TYPE="Ethernet" UUID="7acf956e-3b29-4160-9db7-fba863a06147" NM_CONTROLLED="no" ONBOOT="yes" TYPE="Ethernet" UUID="7acf956e-3b29-4160-9db7-fba863a06147"
- Restart the network service.
[root@root ~]# /etc/init.d/network restart Shutting down interface em1: [ OK ] Shutting down interface em4: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface em1: [ OK ] Bringing up interface em4: [ OK ] [root@root ~]# ifconfig em1 Link encap:Ethernet HWaddr D4:AE:52:7F:D9:55 inet addr:129.22.9.64 Bcast:129.22.255.255 Mask:255.255.0.0 inet6 addr: fe80::d6ae:52ff:fe7f:d955/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3619 errors:0 dropped:0 overruns:0 frame:0 TX packets:72 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:614860 (600.4 KiB) TX bytes:9841 (9.6 KiB) Interrupt:34 Memory:f2000000-f2012800 em4 Link encap:Ethernet HWaddr D4:AE:52:7F:D9:5B inet addr:100.100.100.1 Bcast:100.100.100.255 Mask:255.255.255.0 inet6 addr: fe80::d6ae:52ff:fe7f:d95b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:9 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:734 (734.0 b) Interrupt:46 Memory:f8000000-f8012800 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
- After IP addresses are configured for the host and the storage system, run the ping command to check the link connectivity. If the link connectivity is poor, check the physical links and IP address configurations.
[root@root ~]# ping 100.100.100.2 PING 100.100.100.2 (100.100.100.2) 56(84) bytes of data. 64 bytes from 100.100.100.2: icmp_seq=1 ttl=64 time=0.607 ms 64 bytes from 100.100.100.2: icmp_seq=2 ttl=64 time=0.181 ms 64 bytes from 100.100.100.2: icmp_seq=3 ttl=64 time=0.159 ms ^C --- 100.100.100.2 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2399ms rtt min/avg/max/mdev = 0.159/0.315/0.607/0.207 ms
In some RHEL versions, the network service and NetworkManager are both enabled by default, as shown in the following output:
[root@localhost ~]# chkconfig|grep -i network NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@localhost ~]#
In this case, network configurations may conflict and cannot take effect. Run the following command to disable Network Manager:
service NetworkManager stop
To prevent the automatic startup of NetworkManager after the system restart, run the following command:
chkconfig NetworkManager off
- Check whether the network port of the host is enabled. Port em4 is used as an example.
- Configure an initiator on the host.
After an initiator is installed, run the which iscsiadm command to check whether the iscsiadm command is available.
[root@root ~]# which iscsiadm /sbin/iscsiadm [root@root ~]#
If iscsiadm is available, run this command to configure the initiator. Otherwise, use the configuration file to configure the initiator.
- Run the iscsiadm command to configure the host initiator.
- Start the iSCSI service.
[root@root ~]# /etc/init.d/iscsi start
- View the host initiator name.
[root@root ~]#cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.1994-05.com.redhat:d0104b56adc6
The output shows that the name of the host initiator is iqn.1994-05.com.redhat:d0104b56adc6.
Rules for setting an iSCSI initiator name:
Format: iqn.domaindate.reverse.domain.name:optional name
An iSCSI initiator name contains only:
- Special characters: hyphens (-), periods (.), and semicolons (:)
- Lower-case letters (a to z)
- Digits (0 to 9)
An iSCSI initiator name can contain a maximum of 223 characters.
In some OSs, the host initiator name is left blank. You need to configure this parameter using the configuration file.
- Query the target.
For example, if the service IP address of the storage port is 100.100.100.2, run the following command on the host to query the target:
[root@root ~]# iscsiadm -m discovery -t st -p 100.100.100.2 Starting iscsid: [ OK ] 100.100.100.2:3260,257 iqn.2006-08.com.huawei:oceanstor:21000022a10b7bb2::100.100.100.2-20100
- Log in to the target.
[root@root ~]# iscsiadm -m node -p 100.100.100.2 -l Logging in to [iface: default, target: iqn.2006-08.com.huawei:oceanstor:21000022a10b7bb2::100.100.100.2-20100, portal: 100.100.100.2,3260] (multiple) Login to [iface: default, target: iqn.2006-08.com.huawei:oceanstor:21000022a10b7bb2::100.100.100.2-20100, portal: 100.100.100.2,3260] successful.
- Configure the iSCSI service to run upon system startup.
[root@root ~]# chkconfig iscsi on
- If CHAP authentication is not required between the storage system and the host, the host initiator configuration is completed. If CHAP authentication is required, run the iscsiadm command.
[root@root ~]#iscsiadm -m node -o update -p 100.100.100.2 –n node.session.auth.authmethod -v CHAP [root@root ~]# iscsiadm -m node -o update -p 100.100.100.2 -n node.session.auth.username -v root [root@root ~]# iscsiadm -m node -o update -p 100.100.100.2 -n node.session.auth.password -v huawei123456 [root@root ~]# /etc/init.d/iscsi restart Stopping iSCSI daemon: iscsid dead but pid file exists [ OK ] Turning off network shutdown. Starting iSCSI daemon: [ OK ] [ OK ] Setting up iSCSI targets: Logging in to [iface: default, target: iqn.2006-08.com.huawei:oceanstor:21000022a10b7bb2::100.100.100.2-20100, portal: 100.100.100.2,3260] Login to [iface: default, target: iqn.2006-08.com.huawei:oceanstor:21000022a10b7bb2::100.100.100.2-20100, portal: 100.100.100.2,3260]: successful [ OK ]
The user name and password in the commands must be the same as the initiator name and password configured on the storage system; otherwise, the connection cannot be established.
Command formats:
iscsiadm -m node -o update -p targetip -n node.session.auth.authmethod -v CHAP iscsiadm -m node -o update -p targetip -n node.session.auth.username -v username iscsiadm -m node -o update -p targetip -n node.session.auth.password -v password
To modify other parameters, you are advised to run the iscsiadm command instead of modifying the configuration file.
- Modify the iscsi.conf file to configure CHAP authentication.
Some early versions of RHEL do not provide the iscsiadm command and you need to modify the configuration file to configure CHAP authentication.
- Modify the iscsi.conf file to configure CHAP authentication.
- Start the iSCSI service.
[root@localhost ~]# /etc/init.d/iscsi start Checking iscsi config: [FAILED]
- View the host initiator name.
[root@localhost ~]#cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.1994-05.com.redhat:d0104b56adc6
The output shows that the name of the host initiator is iqn.1994-05.com.redhat:d0104b56adc6.
Rules for setting an iSCSI initiator name:
Format: iqn.domaindate.reverse.domain.name:optional name
An iSCSI initiator name contains only:
- Special characters: hyphens (-), periods (.), and semicolons (:)
- Lower-case letters (a to z)
- Digits (0 to 9)
An iSCSI initiator name can contain a maximum of 223 characters.
In some OSs, the host initiator name is left blank. You need to configure this parameter using the configuration file.
- Add the port address of the storage system.
[root@localhost ~]# vi /etc/iscsi.conf
In the configuration file, add the IP address of the storage system port connected to the host in DiscoveryAddress=xx.xx.xx.xx.
- Start the iSCSI service.
[root@localhost ~]# /etc/init.d/iscsi restart Searching for iscsi-based multipath maps Found 0 maps Stopping iscsid: iscsid not running Checking iscsi config: [ OK ] Loading iscsi driver: [ OK ] Starting iscsid: [ OK ]
- Modify the initiator startup configuration.
Run the chkconfig iscsi on command to configure the iSCSI service to run upon system startup.
In the configuration file, make sure that no space is left in front of DiscoveryAddress=xx.xx.xx.xx.
- If CHAP authentication is not required between the storage system and the host, the host initiator configuration is completed.
In the /etc/iscsi.conf file, add the target IP address for CHAP authentication and specify the user name and password of the initiator used for target authentication. Related parameters are as follows:
OutgoingUsername=xxx
OutgoingPassword=xxxx
Remove only number signs (#) in front of OutgoingUsername/OutgoingPassword and keep the space in front of them unchanged.
- Start the iSCSI service.
- Run the iscsiadm command to configure the host initiator.