实战Fibre Channel之六: 发起端和目的端常用命令

Fibre Channel作为一种专用高速网络iSCSI相比提供了更高的数据传输带宽速度和可靠性熟练掌握一些常用Fibre channel的一些命令可以方便我们进行原型验证调试和开发下面总结了笔者常用到的一些命令就当抛砖迎玉吧

 

A. FC 发起端

1. 看主机FC HBA wwpn:

cat /sys/class/fc_host/host*/port_name | sed -e s/0x// -e 's/../&:/g' -e s/:$//

 

2. 看对端机器FC相关设置

wwpn:

[root@localhost rport-12:0-0]# cat /sys/class/fc_remote_ports/rport-12\:0-0/port_name

0x21000024ff684921

[root@localhost rport-12:0-0]# cat /sys/class/fc_remote_ports/rport-12\:0-0/scsi_target_id

-1

看角色

[root@localhost rport-12:0-0]# cat /sys/class/fc_remote_ports/rport-12\:0-0/roles

FCP Initiator

24位的port ID:

[root@localhost rport-12:0-0]# cat /sys/class/fc_remote_ports/rport-12\:0-0/port_id

0x0000e8

看发起端的IO超时设置

[root@localhost rport-12:0-0]# cat /sys/class/fc_remote_ports/rport-12\:0-0/dev_loss_tmo

30

[root@localhost rport-12:0-0]# cat /sys/class/fc_remote_ports/rport-12\:0-0/fast_io_fail_tmo

off

 

3. rescan devices after FC fail-over:

[root@localhost var]# cd /sys/class/scsi_host/

[root@localhost scsi_host]# for i in `ls `; do echo "- - -" > $i/scan ; done

[root@localhost scsi_host]# lsscsi -si

[0:0:0:10]   disk    Leadstor swtich_vol       1.0   /dev/sdc   360014055e652dee8e232d50cbd3665c2  1.07GB

[0:0:0:20]   disk    Leadstor fc_failover      1.0   /dev/sdd   36001405d3b6e11ace2a8f7f6b00ba7cc  2.19TB

[1:0:0:0]    disk    ATA      SanDisk SD7SB6S1 X355  /dev/sda   SanDisk_SD7SB6S128G1001_162609801097   128GB

[2:0:0:0]    disk    ATA      ST2000DM001-1ER1 CC62  /dev/sdb   -  2.00TB

[7:0:0:3]    disk    Leadstor fc_vol           1.0   /dev/sde   36001405c410df1475de9e08ab3f8b9ef  1.07GB

[7:0:0:4]    disk    Leadstor fc_all_vol       1.0   /dev/sdf   36001405f4807a693420c2c7b98ad996b  1.07GB

[7:0:0:15]   disk    Leadstor fc_0801vol2      1.0   /dev/sdg   3600140546e63e0728bb357aad6a3d91a  2.14GB

[7:0:0:20]   disk    Leadstor fc_failover      1.0   /dev/sdh   36001405d3b6e11ace2a8f7f6b00ba7cc  2.19TB

 

4.  如何发起枚举FC target上的盘

initiator 上运行下面的命令

## step 1: extend the time-out setting for initiator

for i in `ls /sys/class/fc_host`

do

        echo "Extend time out for $i"

        echo 90 > /sys/class/fc_host/$i/dev_loss_tmo

done

 

## step 2: Trigger to discorvery and login to target

for i in `ls /sys/class/fc_host`

do

        echo "Trigger $i to discovery target"

        echo 1 > /sys/class/fc_host/$i/issue_lip

done

B. FC Target

 

1. target 相关设置

[root@localhost qla2xxx]# pwd

/sys/kernel/config/target/qla2xxx

[root@localhost qla2xxx]# cat 21\:00\:00\:0e\:1e\:c2\:3e\:a0/

fabric_statistics/ tpgt_1/

[root@localhost qla2xxx]# cat 21\:00\:00\:0e\:1e\:c2\:3e\:a0/fabric_statistics/

cat: 21:00:00:0e:1e:c2:3e:a0/fabric_statistics/: Is a directory

[root@localhost qla2xxx]# cat 21\:00\:00\:0e\:1e\:c2\:3e\:a0/tpgt_1/

acls/   attrib/ auth/   enable  lun/    np/     param/

[root@localhost qla2xxx]# cat 21\:00\:00\:0e\:1e\:c2\:3e\:a0/tpgt_1/enable

1

 

2. 解决target端默认不是target 模式的问题

基于qlogic HBA ,CentOS中当期默认按照initiator模式加载驱动但在存储服务器端它必须每次都以target模式加载为此需要做下面的修改

edit : /etc/grub2.cfg

 linux16 /vmlinuz-3.10.0-229.el7.x86_64+ root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet LANG=en_US.UTF-8 systemd.debug  qla2xxx.qlini_mode="disabled"

 

然后运行grub2-mkconfig,最后重启机器后默认就按照target模式加载qla2xxx驱动