下文主要参考:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/dm_multipath/index
多路径就是用来解决上述问题的,其原理就是基于每个物理设备的wwid(全球唯一id),方法如下:
访问端口组有如下状态,在相应访问状态下,阵列控制器只能回应相应的命令标准(命令标准由ISO/IEC SPC-3制定),这就决定了在某一时刻是否可以通过某个目标端口访问逻辑单元。
不同的多路径模式就是根据上面不同的路径状态组合而成。下文主要参考如下文章并总结:
https://www.360blogs.top/alua/
https://blog.csdn.net/Pipcie/article/details/105038262
https://blog.51cto.com/u_15127636/2770220
下文参考代码:
https://github.com/ceph/ceph-iscsi
https://github.com/open-iscsi/rtslib-fb
参考下面代码可知,每个添加到target中的lun有一个owner portal,此portal的路径状态为active/optimal,其他路径在implicit模式时为active/non-optimal,在explicit模式时为active/standby。
def alua_format_group_name(tpg, failover_type, is_owner):
if is_owner:
return "ao"
if failover_type == "explicit":
return "standby{}".format(tpg.tag)
else:
return "ano{}".format(tpg.tag)
def alua_create_ao_group(so, tpg, group_name):
alua_tpg = ALUATargetPortGroup(so, group_name, tpg.tag)
alua_tpg.alua_support_active_optimized = 1
alua_tpg.alua_access_state = 0 # 设置active/optimal
return alua_tpg
def alua_create_implicit_group(tpg, so, group_name, is_owner):
if is_owner:
alua_tpg = alua_create_ao_group(so, tpg, group_name)
else:
alua_tpg = ALUATargetPortGroup(so, group_name, tpg.tag)
alua_tpg.alua_access_state = 1 # 设置active/non-optimal
alua_tpg.alua_support_active_nonoptimized = 1
alua_tpg.alua_access_type = 1
# Just make sure we get to at least attempt one op for the failover
# process.
alua_tpg.implicit_trans_secs = settings.config.osd_op_timeout + 15
return alua_tpg
def alua_create_explicit_group(tpg, so, group_name, is_owner):
if is_owner:
alua_tpg = alua_create_ao_group(so, tpg, group_name)
alua_tpg.preferred = 1
else:
alua_tpg = ALUATargetPortGroup(so, group_name, tpg.tag)
alua_tpg.alua_support_standby = 1
# Use Explicit but also set the Implicit bit so we can
# update the kernel from configfs.
alua_tpg.alua_access_type = 3
# start ports in Standby, and let the initiator drive the initial
# transition to AO.
alua_tpg.alua_access_state = 2 # 设置active/standby
return alua_tpg
def alua_create_group(failover_type, tpg, so, is_owner):
group_name = alua_format_group_name(tpg, failover_type, is_owner)
if failover_type == "explicit":
alua_tpg = alua_create_explicit_group(tpg, so, group_name, is_owner)
elif failover_type == "implicit":
# tmp drop down to implicit. Next patch will check for "implicit"
# and add error handling up the stack if the failover_type is invalid.
alua_tpg = alua_create_implicit_group(tpg, so, group_name, is_owner)
else:
raise CephiSCSIInval("Invalid failover type {}".format(failover_type))
alua_tpg.alua_support_active_optimized = 1
alua_tpg.alua_support_offline = 0
alua_tpg.alua_support_unavailable = 0
alua_tpg.alua_support_transitioning = 1
alua_tpg.nonop_delay_msecs = 0
return alua_tpg
上文alua_access_state状态参考如下rtslib代码:
alua_access_state = property(_get_alua_access_state, _set_alua_access_state,
doc="Get or set ALUA state. "
"0 = Active/optimized, "
"1 = Active/non-optimized, "
"2 = Standby, "
"3 = Unavailable, "
"4 = LBA Dependent, "
"14 = Offline, "
"15 = Transitioning")
根据上面的路径状态可知,ceph-iscsi只能支持ALUA模式。
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/dm_multipath/index
https://www.360blogs.top/alua/
https://blog.csdn.net/Pipcie/article/details/105038262
https://blog.51cto.com/u_15127636/2770220