《云计算》-集群:配置iscsi服务

1 案例1:配置iSCSI服务
1.1 问题

本案例要求先搭建好一台iSCSI服务器,并将整个磁盘共享给客户端:

服务器上要额外配置一块硬盘
服务端安装target,并将新加的硬盘配置为iSCSI 的共享磁盘
在客户端上安装initiator,挂在服务器iSCSI,要求实现开机自动挂载

    
    
  • 1
  • 2
  • 3

1.2 方案

使用2台RHEL7虚拟机,其中一台作为iSCSI服务器(192.168.4.5)、另外一台作为测试用的Linux客户机(192.168.4.100),如图-1所示。
在这里插入图片描述
图-1

在RHEL7系统中,默认通过targetcli软件包提供iSCSI服务,因此需要在服务端安装targetcli包并配置对应的服务,iSCSI服务主要配置选项如表-1所示。
在这里插入图片描述
表-1 iSCSI配置选项列表

客户端挂载iSCSI服务器:

客户端需要安装iscsi-initiator-utils软件包
客户端使用命令挂载后需要分区、格式化并进行挂载测试

    
    
  • 1
  • 2

1.3 步骤

实现此案例需要按照如下步骤进行。

步骤一:安装iSCSI服务器软件

1)使用yum安装targetcli软件包

[root@proxy ~]# yum  -y  install  targetcli
.. ..
[root@proxy ~]# yum info targetcli
.. ..

    
    
  • 1
  • 2
  • 3
  • 4

步骤二:通过命令行配置iSCSI服务

1)真实主机准备底层存储磁盘

真实主机使用virt-manager工具为proxy虚拟机添加磁盘,如图-2所示。
在这里插入图片描述
图-2

双击打开虚拟机后添加磁盘设备,如图-3和图-4所示。
在这里插入图片描述
图-3
在这里插入图片描述
图-4

登陆到192.168.4.5主机,为新添加的磁盘准备分区:

[root@proxy ~]# parted /dev/vdb mklabel gpt
[root@proxy ~]# parted /dev/vdb mkpart primary 1 100%

    
    
  • 1
  • 2

2)使用targetcli定义后端存储

[root@proxy ~]# targetcli
/> ls
/> backstores/block create /dev/vdb1

    
    
  • 1
  • 2
  • 3

3)创建iqn对象

/> /iscsi create iqn.2018-01.cn.tedu:server1

    
    
  • 1
  1. 授权客户机访问

    /> iscsi/iqn.2018-01.cn.tedu:server1/tpg1/acls create iqn.2018-01.cn.tedu:client1

  2. 绑定存储

    />iscsi/iqn.2018-01.cn.tedu:server1/tpg1/luns create /backstores/block/iscsi_store

  3. 存储绑定服务监听的地址,并保存配置

    /> iscsi/iqn.2018-01.cn.tedu:server1/tpg1/portals/ create 0.0.0.0
    /> saveconfig
    /> exit

步骤三:服务管理

1)启动服务

[root@proxy ~]# systemctl  {start|restart|stop|status} target
[root@proxy ~]# systemctl enable target

    
    
  • 1
  • 2

2)查看端口信息

[root@proxy ~]# ss -tlnp | grep :3260

    
    
  • 1

3)关闭防火墙与SELinux

[root@proxy ~]# systemctl stop firewalld
[root@proxy ~]# setenforce 0

    
    
  • 1
  • 2

步骤四:客户端访问

1)客户端安装软件并启动服务

[root@client ~]# yum -y install iscsi-initiator-utils
[root@client ~]# systemctl restrt iscsi

    
    
  • 1
  • 2

2)设置本机的iqn名称

[root@client ~]# vim /etc/iscsi/initiatorname.iscsi 
InitiatorName=iqn.2018-01.cn.tedu:client1
注意:必须跟服务器上配置的ACL一致!

    
    
  • 1
  • 2
  • 3

3)发现远程target存储

提示:参考man iscsiadm!

[root@client ~]# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.4.5 –discover
[root@client ~]# iscsiadm --mode node --targetname iqn.2018-01.cn.tedu:server1 --portal 192.168.4.5:3260 --login

    
    
  • 1
  • 2

3)客户端挂载iSCSI共享

[root@client ~]# systemctl restart iscsi 
[root@client ~]# lsblk

    
    
  • 1
  • 2

4)分区、格式化、挂载

[root@client ~]# parted /dev/sdb mklabel gpt
[root@client ~]# parted /dev/sdb mkpart primary 1 800
[root@client ~]# mount /dev/sdb1  /mnt

    
    
  • 1
  • 2
  • 3
                                </div>
            <link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-b6c3c6d139.css" rel="stylesheet">
                                            <div class="more-toolbox">
            <div class="left-toolbox">
                <ul class="toolbox-list">
                    
                    <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                        <use xlink:href="#csdnc-thumbsup"></use>
                    </svg><span class="name">点赞</span>
                    <span class="count">1</span>
                    </a></li>
                    <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-csdnc-Collection-G"></use>
                    </svg><span class="name">收藏</span></a></li>
                    <li class="tool-item tool-active is-share"><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;1582594662_002&quot;}"><svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-csdnc-fenxiang"></use>
                    </svg>分享</a></li>
                    <!--打赏开始-->
                                            <!--打赏结束-->
                                            <li class="tool-item tool-more">
                        <a>
                        <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                        </a>
                        <ul class="more-box">
                            <li class="item"><a class="article-report">文章举报</a></li>
                        </ul>
                    </li>
                                        </ul>
            </div>
                        </div>
        <div class="person-messagebox">
            <div class="left-message"><a href="https://blog.csdn.net/xie_qi_chao">
                <img src="https://profile.csdnimg.cn/B/F/6/3_xie_qi_chao" class="avatar_pic" username="xie_qi_chao">
                                        <img src="https://g.csdnimg.cn/static/user-reg-year/1x/2.png" class="user-years">
                                </a></div>
            <div class="middle-message">
                                    <div class="title"><span class="tit"><a href="https://blog.csdn.net/xie_qi_chao" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">解启超</a></span>
                                        </div>
                <div class="text"><span>发布了355 篇原创文章</span> · <span>获赞 52</span> · <span>访问量 3万+</span></div>
            </div>
                            <div class="right-message">
                                        <a href="https://im.csdn.net/im/main.html?userName=xie_qi_chao" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
                    </a>
                                                        <a class="btn btn-sm attented bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">已关注</a>
                                </div>
                        </div>
                </div>
</article>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

尹汇川

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值