[Make it clear, to say it! ] Commonly shared storage --iSCSI deploy enterprise-class network storage services

Contents:
(a) to understand what is the need for shared storage and shared storage
(two) iSCSI server configuration
(c) to configure iSCSI client


iSCSI (Internet Small Computer System Interface) , Internet Small Computer System Interface, also known as IP-SAN, is based storage technology in the Internet and SCSI-3 protocol proposed by the IETF, it proposes, and on February 11, 2003 as it becomes an official standard. Compared with the conventional technique SCSI, iSCSI technology has revolutionized the following three: a SCSI protocol originally used only for transmission through the native TCP / IP network, the connection may be made from an unlimited geographical extension; 2. Unlimited number of server connections (the upper limit of the original SCSI-3 is 15); 3. Because it is server architecture, it can also be achieved online expansion as well as dynamic deployment.
(A) understand what is the need for shared storage and shared storage
(1.1) Now we want to build a cluster with nodes node1 and node2 node in our cluster, we set up a high-availability cluster, so if and when node1 when problems nodes will quickly switch to the services provided by the node node2. At this point the problem we encountered was how to ensure that nodes node1 and node2 node data synchronization and consistency. Our solution is to configure shared storage, for example, we configured a NFS server, node node1 and node2 node directory to mount NFS server, the user is normal to use node1 node to access data nfs server, when node1 node goes down when the switching node node2 by a customer service visit again, due to the node node2 is mounted on an NFS server, so in this case the customer can still normal access data they need. At this point we have to ensure that the high availability cluster, synchronization of data between nodes. There are, for example, when doing migrations of virtual machines in a virtualized environment, we also solve the problem by configuring the shared storage.
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(1.2) When it comes to shared storage, the our common shared storage are mainly three types: The first one is the direct attached storage DAS, will be our daily operation of the mobile hard disk connected together by way of the data line and the motherboard is a model DAS such poor storage expansion, is an obsolete technique;. 2 i.e. the second NAS storage area network, is share a folder level, such as a shared file in the Windows folder, the other hosts can access shared directory, our common services such as NFS, SAMBA, FTP belong NAS storage, NAS storage is the main problem, when many nodes, and access to a huge amount of time, it is prone to performance bottlenecks, so in general we will ease while using the distributed file system performance bottlenecks, common distributed file system includes ceph, glusterfs, mfs like; 3. the third storage area network SAN i.e., a shared block level, the more common FC- SAN network and IP-SAN network, which belong iSCSI IP-SAN network.
(1.3) Now we have two nodes, nodes A and B, A and B on the two hosts have their own local disk sda, now we have a back-end storage, hard disk sdx1 and sdy1 top to the bottom sharing out, for example, a hard disk sdx1 mapped to the simultaneously transmitted through the network node a and a node B, and named sdb, sdb case of the partition and other operations on the node a, is the normal implementation of the zoning, and will the division results to the synchronization map sdb on node B. At this time, regardless of node A or node metadata information on B sdb created, in fact, is stored on the back-end storage sdx1, so for example sdb on Node A to create a partition in the partition table is divided, save to take effect , by automatically synchronized to the rear end sdx1 stored on node B, sdb. The traditional approach is to use an optical fiber data transmission switch, all the devices are connected using an optical fiber, and a fiber to be installed on each device hba card, using the data transmission fibers such architectures device environment is very expensive, hundreds million for the average small and medium enterprises is difficult to bear, such a structure is called FC-SAN network environment. Do not worry, we optimized feed using IP-SAN network can be a good alternative, the transmission data is re-encapsulated tcp / ip packets, we will use the normal Ethernet switches of the data can be transferred , such as data storage sdx1 reaches node a after the sdb decapsulates, so that our SAN network Ethernet transmission is called a reality. In our back-end storage, we are unable to directly share in foreign sdx1 or sdy1, we need to create a virtual target device to manage the sdx1 and sdy1, where the target is named for the iqn.2019-09.com .example: disk, we shared storage when the target is in foreign share.
On a target connecting two devices sdx1 and sdy1, all have two interfaces, because the target and interfaces are virtual not real, so the interface named lun (Logical Unit Number) or logical unit number. For example, can only see two lun up when the node A learning target, but does not know is there are a few specific back-end storage hard drive, so in the end on the nodes A and B will have to learn to sdb and sdc
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services


(二)配置iSCSI服务器端
(2.1)服务器的配置主要包括:准备磁盘,创建target,把target和磁盘关联,以及其他设置。我们首先在vms001主机上的扩展分区中创建sda5和sda6用于共享出去。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
我们创建的sda5和sda6是作为iSCSI后端存储的两块硬盘
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(2.2)保存设置后,还要将分区设置同步到磁盘。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(2.3)首先在vms001主机上安装target软件,并将target服务启动起来,还要设置开机自动启动,此时iSCSI服务器端便可以正常的登录了。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(2.4)进入iSCSI服务器端的控制界面后使用# ls /可以当前iSCSI的配置情况。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(2.5)在iSCSI服务器的后端存储backstores中,创建两个块设备block1和block2,并使用创建的后端存储sda5和sda6与其一一对应起来。
注意:如果我们的block1创建错了,可以使用delete命令进行删除
/> /backstores/block delete block1
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(2.6)接着我们在iscsi中创建一个target
注意:如果这个target创建错了,我们可以使用如下的方式进行删除
/> /iscsi delete iqn.2019-09.com.example:disk
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(2.7)此时我们便可以对acl、luns、portals的值进行相关设置,首先进入到/iscsi/iqn.2019-09.com.example:disk/tpg1/路径下并设置acl的值。
注意:如果acl的值我们设置错误了,可以通过如下的方式进行删除
/> acls/ delete iqn.2019-09.com.example:xx
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(2.8)接着我们在luns中创建对应的逻辑单元号,主要是和backstores中的block进行关联。
注意:如果第一个逻辑单元号创建错了,那么我们可以使用如下的方式删除
/> luns/ delete 0
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(2.9)接着我们对portals进行设置,其中portals代表端口的意思,如果我们设置portals监听在192.168.26.101主机的3260端口上不太合适,也可以设置portals监听在所有主机的3260端口上。退出后所有的设置都保存在/etc/target/saveconfig.json文件中了。
# cat /etc/target/saveconfig.json | json_reformat
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(2.10)接着在防火墙设置将3260端口开放,此时我们服务器端便配置完毕了。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services


(三)配置iSCSI客户端
(3.1)接着我们在vms002主机上安装iSCSI的客户端。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.2)首先我们必须要知道服务器vms001这边共享的target是什么,所以需要做“发现”的操作。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.3)接着要在/etc/iscsi/目录下的initiatorname.iscsi文件中设置acl的值为vms001主机acls中设置的iqn.2019-09.com.example:xx即可。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.4)然后将服务重启一下并且设置开机自动启动,再从vms002主机的iSCSI客户端登录到vms001主机上的iSCSI服务中。
注意:①如果是加载某个指定的target的时候是使用
# iscsiadm -m discovery -t st -p 192.168.26.101
# iscsiadm -m node -T iqn.2019-09.com.example:disk -p vms001.example.com -l
②如果是加载所有的target的时候是使用
# iscsiadm -m discovery -t st -p 192.168.26.101 -l
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.5)我们也可以使用lsscsi命令查看当前vms002主机上iSCSI设备的挂载情况。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.6)我们也可以使用如下的命令可以查看vms002主机上的连接iSCSI服务器的属性,而且显示的信息依次变得更详细。
# iscsiadm -m session -P0
# iscsiadm -m session -P1
# iscsiadm -m session -P2
# iscsiadm -m session -P3
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.7)如果我们想在vms002主机上断开当前iSCSI指定的挂载则可以使用如下的命令:
# iscsiadm -m node -T iqn.2019-09.com.example:disk -p vms001.example.com -u
(3.8)但是-u命令只是临时的断开连接的命令,客户端重启之后还是会主动连接过去的,我们如果想彻底的删除iSCSI指定的挂载则可以使用如下的命令:
# iscsiadm -m node -T iqn.2019-09.com.example:disk -p vms001.example.com -o delete
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.9)由于我们已经彻底删除了,如果需要再次加载使用,此时可以使用加载所有target的命令执行即可。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.10)如果我们需要同时断开vms002主机上所有的iSCSI的挂载则可以使用如下的命令:
# iscsiadm -m node -u ALL
如果我们需要同时彻底删除vms002主机上所有的iSCSI的挂载则可以使用如下的命令:
# iscsiadm -m node -o delete
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.11)我们重新将vms002主机挂载在vms001主机的iSCSI服务上,并将sdb分区进行划分,并格式化为xfs格式。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.12)在vms002主机上创建一个/data目录,将/data目录挂载到创建的iSCSI分区/dev/sdb1上,发现此时iSCSI服务提供的分区已经可以正常的挂载使用了。
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.13) after if we want to still be able to restart the mount to take effect, you should go to / etc / fstab file for editing.
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.14) Note that in the / etc / fstab file _netdev need to add the parameter option, if you forget added, unable to log system is normal, remember enter the root password on the command line, and into the / etc / fstab file plus _netdev parameters, so as to continue normal restart.
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
[Make it clear, to say it!  ] Commonly shared storage --iSCSI deploy enterprise-class network storage services
(3.15) practical applications for iSCSI service if we need to achieve, for example after a node A is down, Node B can immediately make use of the same data to provide services, namely real-time synchronization of data, at this time we need to be formatted as a cluster file system file the system can, because our common xfs, ext3, ext4 belong to a single log file system, and can not do real-time synchronization of data. So far, this is what we introduced the IP-SAN network, its performance will be much higher than the NAS network, and no performance bottlenecks, in line with the needs of enterprise-class applications.

Guess you like

Origin blog.51cto.com/13613726/2438377