修改: README.md 新文件: storage-server-targetcli.md Signed-off-by: Li,Juejie <jjli@linx-info.com>
359 lines
12 KiB
Markdown
359 lines
12 KiB
Markdown
# 一、配置存储服务器 #
|
||
|
||
## 1、安装:targetcli ##
|
||
|
||
```
|
||
sudo apt-get install targetcli
|
||
```
|
||
|
||
## 2、加载模块 ##
|
||
|
||
```
|
||
root@rocky:/mnt# lsmod |grep configfs
|
||
configfs 36864 4 iscsi_target_mod,libcomposite,target_core_mod
|
||
root@rocky:/mnt# modprobe configfs
|
||
|
||
#如果加载模块后没有自动挂载上,执行以下命令手动挂载:
|
||
mount -t configfs configfs /sys/kernel/config
|
||
```
|
||
|
||
## 3、配置configfs开机自动挂载 ##
|
||
|
||
```
|
||
vi /etc/fstab
|
||
configfs /sys/kernel/config configfs defaults 1 1
|
||
```
|
||
|
||
## 4、配置hba驱动 ##
|
||
|
||
```
|
||
root@rocky:~# vi /etc/modprobe.d/qla2xxx.conf
|
||
options qla2xxx qlini_mode="disabled"
|
||
root@rocky:~# modprobe qla2xxx
|
||
root@rocky:~# sudo update-initramfs -u -k all
|
||
update-initramfs: Generating /boot/initrd.img-4.4.0-21-generic
|
||
root@rocky:~# sudo reboot
|
||
```
|
||
|
||
## 5、查看每台服务器的wwn号 ##
|
||
|
||
```
|
||
cat /sys/class/fc_host/host*/port_name | sed -e s/0x// -e 's/../&:/g' -e s/:$//
|
||
```
|
||
|
||
## 6、运行targetcli ##
|
||
|
||
```
|
||
#使用root用户执行
|
||
root@rocky:~# targetcli
|
||
targetcli 3.0.pre4.1~ga55d018 (rtslib 3.0.pre4.1~g1b33ceb)
|
||
Copyright (c) 2011-2014 by Datera, Inc.
|
||
All rights reserved.
|
||
#执行targetcli,ls后显示qla2xxx即为正常
|
||
/> ls
|
||
o- / ......................................................................................................................... [...]
|
||
o- backstores .............................................................................................................. [...]
|
||
| o- fileio ................................................................................................... [0 Storage Object]
|
||
| o- iblock ................................................................................................... [0 Storage Object]
|
||
| o- pscsi .................................................................................................... [0 Storage Object]
|
||
| o- rd_mcp ................................................................................................... [0 Storage Object]
|
||
o- ib_srpt ........................................................................................................... [0 Targets]
|
||
o- iscsi ............................................................................................................. [0 Targets]
|
||
o- loopback .......................................................................................................... [0 Targets]
|
||
o- qla2xxx ........................................................................................................... [0 Targets]
|
||
o- tcm_fc ............................................................................................................ [0 Targets]
|
||
o- usb_gadget ........................................................................................................ [0 Targets]
|
||
o- vhost ............................................................................................................. [0 Targets]
|
||
|
||
```
|
||
|
||
## 7、创建iblock ##
|
||
|
||
```
|
||
/> cd backstores
|
||
/backstores> iblock/ create name=linx_disk1 dev=/dev/sda6
|
||
Created iblock storage object linx_disk1 using /dev/sda6.
|
||
/backstores> ls
|
||
o- backstores ................................................................................................................ [...]
|
||
o- fileio ..................................................................................................... [0 Storage Object]
|
||
o- iblock ..................................................................................................... [1 Storage Object]
|
||
| o- linx_disk1 .......................................................................................... [/dev/sda6, not in use]
|
||
o- pscsi ...................................................................................................... [0 Storage Object]
|
||
o- rd_mcp ..................................................................................................... [0 Storage Object]
|
||
```
|
||
|
||
## 8、创建wwn ##
|
||
|
||
```
|
||
/backstores> cd ..
|
||
/> qla2xxx/ create 50:01:43:80:03:af:dd:d8
|
||
/> cd qla2xxx/50:01:43:80:03:af:dd:d8/
|
||
/qla2xxx/50:0...0:03:af:dd:d8> ls
|
||
o- 50:01:43:80:03:af:dd:d8 ............................................................................................... [enabled]
|
||
o- acls ................................................................................................................. [0 ACLs]
|
||
o- luns ................................................................................................................. [0 LUNs]
|
||
```
|
||
|
||
## 9、创建luns ##
|
||
|
||
```
|
||
qla2xxx/50:0...0:03:af:dd:d8> luns/ create /backstores/iblock/linx_disk1
|
||
Selected LUN 0.
|
||
Created LUN 0.
|
||
/qla2xxx/50:0...0:03:af:dd:d8> ls
|
||
o- 50:01:43:80:03:af:dd:d8 ............................................................................................... [enabled]
|
||
o- acls ................................................................................................................. [0 ACLs]
|
||
o- luns .................................................................................................................. [1 LUN]
|
||
o- lun0 ........................................................................................ [iblock/linx_disk1 (/dev/sda6)]
|
||
```
|
||
|
||
|
||
## 10、创建acls ##
|
||
|
||
```
|
||
/qla2xxx/50:0...0:03:af:dd:d8> acls/ create 50:01:43:80:01:34:9a:8c
|
||
Created Node ACL for 50:01:43:80:01:34:9a:8c
|
||
Created mapped LUN 0.
|
||
/qla2xxx/50:0...0:03:af:dd:d8> ls
|
||
o- 50:01:43:80:03:af:dd:d8 ............................................................................................... [enabled]
|
||
o- acls ................................................................................................................. [2 ACLs]
|
||
| o- 50:01:43:80:01:34:9a:8c ...................................................................................... [1 Mapped LUN]
|
||
| o- mapped_lun0 ................................................................................................... [lun0 (rw)]
|
||
o- luns .................................................................................................................. [1 LUN]
|
||
o- lun0 ........................................................................................ [iblock/linx_disk1 (/dev/sda6)]
|
||
```
|
||
|
||
## 11、保存配置 ##
|
||
|
||
保存完配置后,需重启服务器生效。
|
||
|
||
```
|
||
/qla2xxx/50:0...0:03:af:dd:d8> saveconfig
|
||
Save configuration? [Y/n]: y
|
||
Performing backup of startup configuration: /var/target/backup-2017-06-08_14:08:36.lio
|
||
Saving new startup configuration
|
||
```
|
||
|
||
## 12、保存配置时可能出现的报错 ##
|
||
|
||
### 报错信息 ###
|
||
|
||
```
|
||
/qla2xxx/50:0...0:03:af:dd:d8> saveconfig
|
||
Save configuration? [Y/n]: y
|
||
Performing backup of startup configuration: /var/target/backup-2017-06-08_14:08:36.lio
|
||
Saving new startup configuration
|
||
Traceback (most recent call last):
|
||
File "/usr/lib/python2.7/dist-packages/configshell/shell.py", line 990, in run_interactive
|
||
self._cli_loop()
|
||
File "/usr/lib/python2.7/dist-packages/configshell/shell.py", line 820, in _cli_loop
|
||
self.run_cmdline(cmdline)
|
||
File "/usr/lib/python2.7/dist-packages/configshell/shell.py", line 934, in run_cmdline
|
||
self._execute_command(path, command, pparams, kparams)
|
||
File "/usr/lib/python2.7/dist-packages/configshell/shell.py", line 909, in _execute_command
|
||
result = target.execute_command(command, pparams, kparams)
|
||
File "/usr/lib/python2.7/dist-packages/targetcli/ui_node.py", line 225, in execute_command
|
||
return UINode.execute_command(self, command, pparams, kparams)
|
||
File "/usr/lib/python2.7/dist-packages/targetcli/ui_node.py", line 104, in execute_command
|
||
pparams, kparams)
|
||
File "/usr/lib/python2.7/dist-packages/configshell/node.py", line 1416, in execute_command
|
||
result = method(*pparams, **kparams)
|
||
File "/usr/lib/python2.7/dist-packages/targetcli/ui_node.py", line 123, in ui_command_saveconfig
|
||
CliConfig.save_running_config()
|
||
File "/usr/lib/python2.7/dist-packages/targetcli/cli_config.py", line 65, in save_running_config
|
||
config.load_live()
|
||
File "/usr/lib/python2.7/dist-packages/rtslib/config.py", line 565, in load_live
|
||
source=source, allow_new_attrs=True)
|
||
File "/usr/lib/python2.7/dist-packages/rtslib/config.py", line 190, in _load_parse_tree
|
||
token = self.validate_obj(token, cur)
|
||
File "/usr/lib/python2.7/dist-packages/rtslib/config.py", line 377, in validate_obj
|
||
valid_value = self.validate_val(valid_token['key'][1], id_type)
|
||
File "/usr/lib/python2.7/dist-packages/rtslib/config.py", line 355, in validate_val
|
||
% (val_type, value))
|
||
ConfigError: Unknown value type 'qla2xxx_wwn' when validating 50:01:43:80:03:af:dd:d8
|
||
```
|
||
|
||
### 解决方法 ###
|
||
|
||
```
|
||
vi /usr/share/pyshared/rtslib/config.py
|
||
347 elif val_type == 'naa':
|
||
348 if is_valid_wwn('naa', value):
|
||
349 valid_value = value
|
||
+350 elif val_type == 'qla2xxx_wwn':
|
||
+351 if is_valid_wwn('qla2xxx_wwn', value):
|
||
+352 valid_value = value
|
||
|
||
vi /usr/share/pyshared/rtslib/utils.py
|
||
559 elif wwn_type == 'unit_serial' \
|
||
560 and re.match(
|
||
561 "[0-9A-Fa-f]{8}(-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$", wwn):
|
||
562 return True
|
||
+563 elif wwn_type == 'qla2xxx_wwn' \
|
||
+564 and re.match(
|
||
+565 "[0-9A-Fa-f]{2}(:[0-9A-Fa-f]{2}){7}$", wwn):
|
||
+566 return True
|
||
```
|
||
|
||
|
||
## 13、配置完存储后,在HA-1和HA-2上重新加载模块 ##
|
||
|
||
```
|
||
rmmod qla2xxx
|
||
modprobe qla2xxx
|
||
```
|
||
|
||
## 14、重新存储服务器 ##
|
||
|
||
配置完存储或者修改了存储的配置后,需要重启存储服务器。
|
||
|
||
```
|
||
root@rocky:~# reboot
|
||
```
|
||
|
||
## 15、查看路径 ##
|
||
|
||
在HA-1和HA-2上安装完多路径后,可以使用下面的命令查看路径
|
||
|
||
```
|
||
multipath ll #查看路径
|
||
multipath -v3 #重新加载路径信息
|
||
multipath -F #清除路径信息
|
||
```
|
||
|
||
# 二、登录交换机 #
|
||
|
||
## 1、安装串口工具 ##
|
||
|
||
```
|
||
apt-get install minicom
|
||
```
|
||
|
||
## 2、minicom使用方法 ##
|
||
|
||
```
|
||
1、sudo minicom
|
||
|
||
2、ctrl+a,然后按z键,在弹出的页面按o键
|
||
|
||
3、配置串口设备:/dev/ttyUSB0
|
||
|
||
4、配置波特率:115200
|
||
|
||
5、设置保存为dfl
|
||
```
|
||
|
||
## 3、交换机设置ip地址 ##
|
||
|
||
```
|
||
FCSW1:admin> ipaddrset
|
||
Ethernet IP Address [172.16.0.120]:172.16.0.120
|
||
Ethernet Subnetmask [255.255.255.0]:255.255.255.0
|
||
Gateway IP Address [172.16.0.254]:172.16.0.254
|
||
DHCP [Off]:
|
||
```
|
||
|
||
## 4、查看交换机ip地址 ##
|
||
|
||
```
|
||
ipaddrshow
|
||
```
|
||
|
||
## 5、交换机账号密码 ##
|
||
|
||
交换机默认账户;admin,密码:passwrod
|
||
|
||
# 三、配置交换机 #
|
||
|
||
## 1、choose switchState: Offline (Persistent) to online ##
|
||
|
||
```
|
||
switchcfgpersistentenable
|
||
```
|
||
|
||
## 2、查看交换机的配置 ##
|
||
|
||
```
|
||
switchshow
|
||
```
|
||
|
||
## 3、查看zone情况 ##
|
||
|
||
```
|
||
zoneshow
|
||
```
|
||
|
||
## 4、创建zone ##
|
||
|
||
zonecreate "zone名称",“zone成员1;zone成员2”(其中zone成员可以使用端口号(格式:domain id,port id)、wwn和wwn别名。)
|
||
|
||
```
|
||
zonecreate "zone0","21:00:00:1b:32:90:ee:66;50:01:43:80:03:af:dd:da;50:01:43:80:03:af:dd:d8"
|
||
```
|
||
|
||
## 5、创建cfg ##
|
||
|
||
执行cfgcreate命令创建新分区配置,分区配置是zone的集合,一个分区配置可以包含一个或多个zone。命令格式为cfgcreate “分区配置名称”,“zone名称1; zone名称2,…”
|
||
|
||
```
|
||
cfgcreate "cfgzone","zone0"
|
||
```
|
||
|
||
## 6、使能分区配置 ##
|
||
|
||
执行cfgenable命令使能分区配置。命令格式为cfgenable 分区配置名称
|
||
|
||
```
|
||
cfgenable cfgzone
|
||
```
|
||
|
||
## 7、保存分区配置 ##
|
||
|
||
```
|
||
cfgsave
|
||
```
|
||
|
||
## 8、查看配置后的显示情况 ##
|
||
|
||
```
|
||
FCSW1:admin> zoneshow
|
||
|
||
Effective configuration:
|
||
cfg: cfgzone
|
||
zone: zone0 21:00:00:1b:32:90:ee:66
|
||
50:01:43:80:03:af:dd:da
|
||
50:01:43:80:03:af:dd:d8
|
||
```
|
||
|
||
## 9、向分区中添加新成员 ##
|
||
|
||
命令格式为zoneadd “分区名称”, “新成员1; 新成员2; …”
|
||
|
||
```
|
||
zoneadd "zone0","50:01:43:80:03:af:dd:da"
|
||
cfgsave
|
||
```
|
||
|
||
## 10、向分区配置中添加新成员 ##
|
||
|
||
命令格式为cfgadd “分区配置名称”, “zone名称1; zone名称2; …”
|
||
|
||
```
|
||
cfgadd "cfgnew","zone2;zone3"
|
||
cfgsave
|
||
```
|
||
|
||
# 四、参考文档 #
|
||
|
||
http://237085.blog.51cto.com/227085/1739225
|
||
|
||
http://xiayun.blog.51cto.com/2344243/1707098
|
||
|
||
http://www.linux-iscsi.org/wiki/FC
|
||
|
||
http://support.huawei.com/enterprise/docinforeader!loadDocument1.action?contentId=DOC1000050532&partNo=10072#it_osca_xcua_140071_mx210
|
||
|
||
https://www.penguinpunk.net/blog/wp-content/uploads/2015/03/fc_switches_v0.2.pdf
|
||
|
||
|