案例说明:

在KingbaseES Clusterware高可用的架构中,集群节点需要访问共享的存储设备,可以使用FC SAN、iscsi SAN、NAS等存储设备。本案例详细描述了,在Linux系统下构建 iscsi存储服务器及客户端访问的过程,为部署KingbaseES Clusterware做好相应的准备。

如下所示:KingbaseES Clusterware架构

系统架构节点信息:

ISCSI SAN存储架构:

一、iscsi server配置

Tips:

iscsi server提供共享存储,并接受client的访问。

1、系统环境信息

[root@node1 ~]# cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)

2、server端软件包安装及启动服务

#软件包安装
[root@node1 ~]# yum -y install targetd targetcli #启动server端服务
[root@node1 ~]# systemctl start target [root@node1 ~]# systemctl enable target
Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service. [root@node1 ~]# systemctl status target
● target.service - Restore LIO kernel target configuration
Loaded: loaded (/usr/lib/systemd/system/target.service; enabled; vendor preset: disabled)
Active: active (exited) since Wed 2022-11-23 15:46:17 CST; 17s ago
Main PID: 22094 (code=exited, status=0/SUCCESS) Nov 23 15:46:15 node1 systemd[1]: Starting Restore LIO kernel target configuration...
Nov 23 15:46:17 node1 target[22094]: No saved config file at /etc/target/saveconfig.json, ok, exiting
Nov 23 15:46:17 node1 systemd[1]: Started Restore LIO kernel target configuration.

3、iscsi server端配置

Tips:

当执行targetcli出现以下错误时,需要安装python-rtslib软件。

安装python-rtslib软件:

[root@node1 ~]# yum install -y python-rtslib

server端配置工具:

[root@node1 ~]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'. /> help AVAILABLE COMMANDS
==================
The following commands are available in the
current path: - bookmarks action [bookmark]
- cd [path]
- clearconfig [confirm]
- exit
- get [group] [parameter...]
- help [topic]
- ls [path] [depth]
- pwd
- refresh
- restoreconfig [savefile] [clear_existing] [target] [storage_object]
- saveconfig [savefile]
- sessions [action] [sid]
- set [group] [parameter=value...]
- status
- version

4、server端添加共享磁盘

[root@node1 ~]# fdisk -l
.......
Disk /dev/sdb: 21.6 GB, 21579694080 bytes, 42147840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

5、server端iscsi配置

1)创建要发布的磁盘(块设备LUN)

[root@node1 ~]# targetcli
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: 0]
| o- fileio ................................................................................................. [Storage Objects: 0]
| o- pscsi .................................................................................................. [Storage Objects: 0]
| o- ramdisk ................................................................................................ [Storage Objects: 0]
o- iscsi ............................................................................................................ [Targets: 0]
o- loopback ......................................................................................................... [Targets: 0] /> /backstores/block create server0.disk1 /dev/sdb
Created block storage object server0.disk1 using /dev/sdb.
#注:server0.disk1 是给/dev/sdb转化成块的名字。 /> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: 1]
| | o- server0.disk1 ................................................................. [/dev/sdb (20.1GiB) write-thru deactivated]
| | o- alua ................................................................................................... [ALUA Groups: 1]
| | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
| o- fileio ................................................................................................. [Storage Objects: 0]
| o- pscsi .................................................................................................. [Storage Objects: 0]
| o- ramdisk ................................................................................................ [Storage Objects: 0]
o- iscsi ............................................................................................................ [Targets: 0]
o- loopback ......................................................................................................... [Targets: 0]

2)创建iqn名字即创建iscsi对象

iqn:iSCSI Qualified Name(ISCSI 限定名称)

/> /iscsi create iqn.test.com.bqdn:disk1
WWN not valid as: iqn, naa, eui
# 注意:iqn名称格式 /> /iscsi create iqn.2022-11.com.bqdn:disk1
Created target iqn.2022-11.com.bqdn:disk1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260. o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: 1]
| | o- server0.disk1 ................................................................. [/dev/sdb (20.1GiB) write-thru deactivated]
| | o- alua ................................................................................................... [ALUA Groups: 1]
| | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
| o- fileio ................................................................................................. [Storage Objects: 0]
| o- pscsi .................................................................................................. [Storage Objects: 0]
| o- ramdisk ................................................................................................ [Storage Objects: 0]
o- iscsi ............................................................................................................ [Targets: 1]
| o- iqn.2022-11.com.bqdn:disk1 ........................................................................................ [TPGs: 1]
| o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
| o- acls .......................................................................................................... [ACLs: 0]
| o- luns .......................................................................................................... [LUNs: 0]
| o- portals .................................................................................................... [Portals: 1]
| o- 0.0.0.0:3260 ..................................................................................................... [OK]
o- loopback ......................................................................................................... [Targets: 0]

3)设置ACL即将ISCSI对象与客户端IP或主机名绑定

/> /iscsi/iqn.2022-11.com.bqdn:disk1/tpg1/acls create iqn.2022-11.com.bdqn:client1
Created Node ACL for iqn.2022-11.com.bdqn:client1 /> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: 1]
| | o- server0.disk1 ................................................................. [/dev/sdb (20.1GiB) write-thru deactivated]
| | o- alua ................................................................................................... [ALUA Groups: 1]
| | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
| o- fileio ................................................................................................. [Storage Objects: 0]
| o- pscsi .................................................................................................. [Storage Objects: 0]
| o- ramdisk ................................................................................................ [Storage Objects: 0]
o- iscsi ............................................................................................................ [Targets: 1]
| o- iqn.2022-11.com.bqdn:disk1 ........................................................................................ [TPGs: 1]
| o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
| o- acls .......................................................................................................... [ACLs: 1]
| | o- iqn.2022-11.com.bdqn:client1 ......................................................................... [Mapped LUNs: 0]
| o- luns .......................................................................................................... [LUNs: 0]
| o- portals .................................................................................................... [Portals: 1]
| o- 0.0.0.0:3260 ..................................................................................................... [OK]
o- loopback ......................................................................................................... [Targets: 0]
/>
#注:iqn.2022-11.com.bdqn:client1是 initiator 的名字,需要在客户端中设置的。

4)创建LUN并绑定块

/> /iscsi/iqn.2022-11.com.bqdn:disk1/tpg1/luns create /backstores/block/server0.disk1
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2022-11.com.bdqn:client1 /> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: 1]
| | o- server0.disk1 ................................................................... [/dev/sdb (20.1GiB) write-thru activated]
| | o- alua ................................................................................................... [ALUA Groups: 1]
| | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
| o- fileio ................................................................................................. [Storage Objects: 0]
| o- pscsi .................................................................................................. [Storage Objects: 0]
| o- ramdisk ................................................................................................ [Storage Objects: 0]
o- iscsi ............................................................................................................ [Targets: 1]
| o- iqn.2022-11.com.bqdn:disk1 ........................................................................................ [TPGs: 1]
| o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
| o- acls .......................................................................................................... [ACLs: 1]
| | o- iqn.2022-11.com.bdqn:client1 ......................................................................... [Mapped LUNs: 1]
| | o- mapped_lun0 ......................................................................... [lun0 block/server0.disk1 (rw)]
| o- luns .......................................................................................................... [LUNs: 1]
| | o- lun0 .............................................................. [block/server0.disk1 (/dev/sdb) (default_tg_pt_gp)]
| o- portals .................................................................................................... [Portals: 1]
| o- 0.0.0.0:3260 ..................................................................................................... [OK]
o- loopback ......................................................................................................... [Targets: 0]

二、iscsi client访问iscsi server

1、系统环境信息

[root@node1 ~]# cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)

2、客户端软件包安装

[root@node2 ~]# rpm -qa |grep iscsi
libiscsi-1.9.0-6.el7.x86_64
iscsi-initiator-utils-6.2.0.873-32.el7.x86_64
iscsi-initiator-utils-iscsiuio-6.2.0.873-32.el7.x86_64

3、客户端配置

# 配置iscsi client名称
[root@node2 ~]# cat /etc/iscsi/initiatorname.iscsi
#InitiatorName=iqn.1994-05.com.redhat:e43610d8fc4d
InitiatorName=iqn.2022-11.com.bdqn:client1

4、客户端访问iscsi服务器

1)客户端访问工具iscsiadm

[root@node2 ~]# iscsiadm --help
iscsiadm -m discoverydb [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p ip:port -I ifaceN ... [ -Dl ] ] | [ [ -p ip:port -t type] [ -o operation ] [ -n name ] [ -v value ] [ -lD ] ]
iscsiadm -m discovery [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p ip:port -I ifaceN ... [ -l ] ] | [ [ -p ip:port ] [ -l | -D ] ]
iscsiadm -m node [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -L all,manual,automatic ] [ -U all,manual,automatic ] [ -S ] [ [ -T targetname -p ip:port -I ifaceN ] [ -l | -u | -R | -s] ] [ [ -o operation ] [ -n name ] [ -v value ] ]
iscsiadm -m session [ -hV ] [ -d debug_level ] [ -P printlevel] [ -r sessionid | sysfsdir [ -R | -u | -s ] [ -o operation ] [ -n name ] [ -v value ] ]
iscsiadm -m iface [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -I ifacename | -H hostno|MAC ] [ [ -o operation ] [ -n name ] [ -v value ] ] [ -C ping [ -a ip ] [ -b packetsize ] [ -c count ] [ -i interval ] ]
iscsiadm -m fw [ -d debug_level ] [ -l ]
iscsiadm -m host [ -P printlevel ] [ -H hostno|MAC ] [ [ -C chap [ -x chap_tbl_idx ] ] | [ -C flashnode [ -A portal_type ] [ -x flashnode_idx ] ] | [ -C stats ] ] [ [ -o operation ] [ -n name ] [ -v value ] ]
iscsiadm -k priority

2)连接iscsi server

# discovery iscsi server

[root@node2 ~]# iscsiadm -m discovery -t st -p 192.168.8.200 -l
192.168.8.200:3260,1 iqn.2022-11.com.bqdn:disk1
Logging in to [iface: default, target: iqn.2022-11.com.bqdn:disk1, portal: 192.168.8.200,3260] (multiple)
Login to [iface: default, target: iqn.2022-11.com.bqdn:disk1, portal: 192.168.8.200,3260] successful. # 查看共享存储
[root@node2 ~]# lsscsi
[0:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sda
[2:0:0:0] cd/dvd VBOX CD-ROM 1.0 /dev/sr0
[3:0:0:0] disk LIO-ORG server0.disk1 4.0 /dev/sdb
# 如上所示,已经发现共享的存储/dev/sdb。

3)查看磁盘设备

Tips:

如下所示,可以通过fdisk查看到共享的存储,可以像本地磁盘一样去使用共享存储。

[root@node2 ~]# fdisk -l
.......
Disk /dev/sdb: 21.6 GB, 21579694080 bytes, 42147840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes

4)启动客户端iscsi服务

[root@node2 ~]# systemctl start iscsi
[root@node2 ~]# systemctl status iscsi
● iscsi.service - Login and scanning of iSCSI devices
Loaded: loaded (/usr/lib/systemd/system/iscsi.service; enabled; vendor preset: disabled)
Active: active (exited) since Wed 2022-11-23 16:17:53 CST; 1s ago
Docs: man:iscsid(8)
man:iscsiadm(8)
Process: 27430 ExecStart=/sbin/iscsiadm -m node --loginall=automatic (code=exited, status=21)
Process: 27419 ExecStart=/usr/libexec/iscsi-mark-root-nodes (code=exited, status=0/SUCCESS)
Main PID: 27430 (code=exited, status=21) Nov 23 16:17:53 node2 systemd[1]: Starting Login and scanning of iSCSI devices...
Nov 23 16:17:53 node2 iscsiadm[27430]: iscsiadm: No records found
Nov 23 16:17:53 node2 systemd[1]: Started Login and scanning of iSCSI devices.

三、iscsi client使用共享存储

1、创建磁盘分区

[root@node2 ~]# fdisk /dev/sdb

2、mount磁盘分区

[root@node2 ~]# mkdir /sharedsk

[root@node2 ~]# mount /dev/sdb1 /sharedsk
[root@node2 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 39G 23G 16G 61% /
devtmpfs 906M 0 906M 0% /dev
tmpfs 921M 84K 920M 1% /dev/shm
........
/dev/sdb1 21G 33M 21G 1% /sharedsk #如上所示,在node2节点(iscsi client)已经可以像本地磁盘一样访问共享存储。

四、总结

 通过iscsi存储可以构建高性价比的共享存储设备,在基于共享存储的高可用架构中被广泛使用。

KingbaseES Clusterware 高可用案例之---构建iSCSI共享存储的更多相关文章

  1. (转)Heartbeat+DRBD+NFS高可用案例

    原文:http://9861015.blog.51cto.com/9851015/1939521--------------------------------Heartbeat+DRBD+NFS高可 ...

  2. RabbitMQ从零到集群高可用(.NetCore5.0) -高可用集群构建落地

    系列文章: RabbitMQ从零到集群高可用(.NetCore5.0) - RabbitMQ简介和六种工作模式详解 RabbitMQ从零到集群高可用(.NetCore5.0) - 死信队列,延时队列 ...

  3. 学习heartbeat-03t实现web服务的高可用案例及维护要点

    8.Heartbeat实现web服务的高可用案例 8.1部署准备 通过web服务高可用案例来熟悉heatbeat软件的使用,用上面的两台服务器机器名分别为heartbeat-1-130和heartbe ...

  4. Linux下搭建iSCSI共享存储的方法 Linux-IO Target 方式CentOS7-1810下实现

    iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速 ...

  5. Linux下搭建iSCSI共享存储的方法 TGT 方式 CentOS6.9系统下

    iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速 ...

  6. Linux下搭建iSCSI共享存储的方法 Linux-IO Target 方式 Debian9.5下实现

    iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速 ...

  7. Linux下搭建iSCSI共享存储的方法 TGT 方式 Debian9.5系统下

    iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速 ...

  8. 实验:iscsi共享存储

    实验名称: iscsi共享存储 实验环境: 我们需要准备一个磁盘,对于这个磁盘我们需要使用,将这个磁盘空间共享给iscsi客户端: 实验需求: 我们这里使用两台服务器来实现iscsi共享存储: 1.指 ...

  9. Linux下搭建iSCSI共享存储详细步骤(服务器模拟IPSAN存储)

    一.简介 iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够 ...

  10. Linux下搭建iSCSI共享存储

    转至:https://www.linuxidc.com/Linux/2016-09/135655.htm Linux下搭建iSCSI共享存储 拓扑: 实验步骤: ------------------- ...

随机推荐

  1. oracle FGAC(细粒度访问控制)介绍

    在ORACLE中,RLS有时也叫做虚拟私有数据库(VPD)或者细粒度访问控制(FGAC). RLS由8i引进,利用这一特性我们可以对表定义安全策略(并且指明对表的操作类型),实现对用户可以看到或者修改 ...

  2. 如何基于three.js(webgl)引擎架构,实现3D密集架库房,3D档案室(3d机器人取档、机器人盘点、人工查档、设备巡检)

     前言: 这是最好的时代,也是最坏的时代:是充满挑战的时代,也是充满机遇的时代.是科技飞速的时代,也是无限可能的时代. 近年来,人工智能(AI)技术的飞速发展已经席卷了全球,不断突破着技术边界,为各行 ...

  3. 【Android 逆向】【攻防世界】android2.0

    这是一道纯算法还原题 1. apk安装到手机,提示输入flag,看来输入就是flag 2. jadx 打开apk查看 this.button.setOnClickListener(new View.O ...

  4. PostgreSQL中查看版本的几种方式

    PostgreSQL中查看版本的几种方式 1.SQL方式 1 2 3 4 5 6 7 8 9 10 postgres=# show server_version;  server_version -- ...

  5. java日期中YYYY与yyyy的区别

    date==>string string ==>date 总结: 个人觉得:当天所在的周属于的年份,一周从周日开始,周六结束,只要本周跨年,那么这周就算入下一年.这个结论在正向转换的时候是 ...

  6. Java面向对象之内部类的几类使用场景

    介绍 Java内部类是一种特殊的类,它定义在另一个类的内部.内部类提供了许多有用的特性,包括访问外部类的私有成员.隐藏实现细节以及实现回调接口等.以下是Java内部类的一些常用场景及其举例说明: 回调 ...

  7. 【Azure Data Lake Storage】如何才能保留Blob中的文件目录结构(即使文件夹中文件数量为0的情况下)?

    问题描述 在使用Azure Storage Account Blob时候,发现当文件夹中的Blob(文件)被全部输出后,文件夹也会消失? 为什么它不能像Windows系统中的文件夹一样,即使是一个空文 ...

  8. 【Azure Cloud Service(Extended Support)】如何使用外延服务迁移应用?

    问题一:迁移到云服务扩展后,之前经典版的云服务的部署槽会变成单一的部署槽,关于两个云服务扩展版之间的部署交换能否提供一个演示? 对于具有双槽的云服务(Classic),根据文档中的建议,在迁移到云服务 ...

  9. 【Azure Developer】使用Azure Resource Graph的查询语法的示例

    文章"[Azure Developer]在Azure Resource Graph Explorer中查看当前订阅下的所有资源信息列表并导出(如VM的名称,IP地址内网/公网,OS,区域等) ...

  10. 聊聊 HTTP 性能优化

    哈喽大家好,我是咸鱼. 作为用户的我们在 "上网冲浪" 的时候总是希望快一点,尤其是抢演唱会门票的时候,但是现实并非如此,有时候我们会遇到页面加载缓慢.响应延迟的情况. 而 HTT ...