Use volumes on a Linux ECS instance

更新时间:
复制 MD 格式

This topic describes how to connect to and use the iSCSI volumes of a Cloud Storage Gateway (CSG) agent on a Linux Elastic Compute Service (ECS) instance.

Prerequisites

An iSCSI volume is created. For more information, see Create an iSCSI volume.

Connect to the iSCSI volume

  1. Log on to the ECS instance.

    Note

    If your on-premises host is connected to a virtual private cloud (VPC) over an Express Connect circuit, you can also perform the following steps by using the host.

  2. Connect to your Linux ECS instance. For more information, see Connect to an instance.

  3. Run the following command to install the iscsi-initiator-utils package:

    You need an iSCSI initiator to connect to the iSCSI volume. If you have already installed the iSCSI initiator, skip this step.

    sudo yum install iscsi-initiator-utils

    If you are using Debian or Ubuntu, run the following command to install open-iscsi:

    sudo apt-get install open-iscsi
  4. Run the following command to check whether the iSCSI daemon is running.

    • If you are using RHEL 5 or RHEL 6, run the following command:

      sudo /etc/init.d/iscsi status
    • If you are using RHEL 7 or later, run the following command:

      sudo systemctl status iscsid

    If you run the command above and it does not return a running status, run the following command to start the iSCSI daemon.

    • If you are using RHEL 5 or RHEL 6, run the following command:

      sudo /etc/init.d/iscsi start
    • If you are using RHEL 7 or later, run the following command:

      sudo systemctl start iscsid
  5. (Optional) Configure Challenge-Handshake Authentication Protocol (CHAP) authentication.

    Note

    If you enabled CHAP authentication when you created an iSCSI volume, you must configure the CHAP authentication information in the Advanced Settings dialog box before you can use the iSCSI volume.

    1. Run the following command to open the iscsid.conf configuration file:

      vi /etc/iscsi/iscsid.conf
    2. Find the CHAP Settings section, remove the comment character (#) from the beginning of the relevant configuration lines, and set the username and password.

      • Enter the CHAP username that you set when you created the iSCSI volume.

      • Enter the CHAP password that you set when you created the iSCSI volume.

      设置CHAP认证

  6. Discover the iSCSI volume.

    In the Cloud Storage Gateway console, find your Block Gateway. You can find the gateway's IPv4 address on the Volume List page and its IPv6 address on the second line in the Service IP Address column of the gateway list.

    • IPv4:

      iscsiadm -m discovery -t st -p <IPv4 address>:3260
    • IPv6:

      iscsiadm -m discovery -t st -p <IPv6 address>:3260

    In the preceding commands, 3260 is the port number, and IPv4 address and IPv6 address are the IPv4 address and IPv6 address of an iSCSI gateway, respectively.

    Note
    • CSG version 1.6.0 and later support IPv6.

    • You can mount iSCSI volumes over IPv6 only in the China (Hohhot) region. Make sure that the VPC and vSwitch of the gateway support IPv6.

    • If you mount iSCSI volumes over IPv6, make sure that an IPv6 address is configured for your CSG agent.

    • If the VPC and vSwitch of an existing gateway support IPv6, you can obtain an IPv6 mount target after you enable IPv6 for the gateway. By default, gateways created in this VPC support IPv6.

  7. Run the following command to mount the iSCSI volume:

    • IPv4:

      iscsiadm -m node -T <target name> -p <IPv4 address>:3260 -l
    • IPv6:

      iscsiadm -m node -T <target name> -p <IPv6 address>:3260 -l

    In the preceding commands, target name is the iSCSI volume that you want to mount. You can obtain the target name in Step 6.

    Note

    The iSCSI protocol does not allow you to mount one iSCSI volume to multiple Linux clients.

View the iSCSI volume

  1. Run the fdisk -l or lsblk command to view the iSCSI volume.

  2. If the output of the command is similar to the following output, the iSCSI volume is available as a raw disk. You can read data from and write data to the iSCSI volume from an on-premises host.查看卷

Unmount the iSCSI volume

To unmount the iSCSI volume, run the following command:

  • IPv4:

    iscsiadm -m node -T <target name> -p <IPv4 address>:3260 -u
  • IPv6:

    iscsiadm -m node -T <target name> -p <IPv6 address>:3260 -u