# Armazenamento



# Config. ISCSI com multipath no Debian 10

## 1. Introdução

<span style="font-weight: 400;">iSCSI é um dos padrões para armazenamento de dados em rede. Utilizado para conexão entre dispositivos como storages, servidores, computadores e outras estações de trabalho. Neste protocolo, os comandos SCSI são transportados sobre a rede IP.</span>

<span style="font-weight: 400;"><span data-ttu-id="48202-108"> Multipath usa componentes redundantes - adaptadores, cabos e comutadores - para criar caminhos lógicos entre o servidor e o dispositivo de armazenamento.</span> <span data-ttu-id="48202-109">Se houver uma falha de componente, fazendo com que um caminho lógico falha, a lógica de vários caminhos usará um caminho alternativo de E/S para que os aplicativos ainda possam acessar seus dados. Eventualmente pode melhorar o desempenho ao rebalancear novamente a carga em todos esses caminhos</span> </span>

## <span style="font-weight: 400;">2. Ferramentas utilizadas</span>

<span style="font-weight: 400;">Os softwares utilizados na produção deste tutorial é apresentado a seguir:</span>

<div id="bkmrk-debian-10%2C-64-bits-o">- <span style="font-weight: 400;">Debian 10, 64 bits  
    </span>
- <span style="font-weight: 400;">open-iscsi 2.0.874-7.1</span>
- <span style="font-weight: 400;">multipath-tools 0.7.9</span>

</div>## <span style="font-weight: 400;">3. Configurando o serviço</span>

<span style="font-weight: 400;">Todos os comandos executados nesse tutorial foram executados com o usuário **root**.</span>

3.1. Instalação dos pacotes

```shell
apt install multipath-tools multipath-tools-boot
```

3.2. Descobrir os targets

```shell
iscsiadm -m discovery -t sendtargets -p 192.168.50.2 # O IP indicado aqui é de uma das interfaces do storage
```

<table id="bkmrk-192.168.50.2%3A3260%2C1-" style="width: 809px;"><tbody><tr><td style="width: 808px;">192.168.50.2:3260,1 iqn.2017-10.com.hpe:storage.msa2052.15088aa10e  
192.168.50.3:3260,2 iqn.2017-10.com.hpe:storage.msa2052.15088aa10e  
192.168.51.2:3260,3 iqn.2017-10.com.hpe:storage.msa2052.15088aa10e  
192.168.51.3:3260,4 iqn.2017-10.com.hpe:storage.msa2052.15088aa10e</td></tr></tbody></table>

3.3. Realizar a conexão ao target

```shell
iscsiadm -m node --login
```

<table id="bkmrk-logging-in-to-%5Biface" style="width: 863px;"><tbody><tr><td style="width: 862px;">Logging in to \[iface: default, target: iqn.2017-10.com.hpe:storage.msa2052.15088aa10e, portal: 192.168.50.2,3260\] (multiple)  
Logging in to \[iface: default, target: iqn.2017-10.com.hpe:storage.msa2052.15088aa10e, portal: 192.168.51.3,3260\] (multiple)  
Logging in to \[iface: default, target: iqn.2017-10.com.hpe:storage.msa2052.15088aa10e, portal: 192.168.51.2,3260\] (multiple)  
Logging in to \[iface: default, target: iqn.2017-10.com.hpe:storage.msa2052.15088aa10e, portal: 192.168.50.3,3260\] (multiple)  
Login to \[iface: default, target: iqn.2017-10.com.hpe:storage.msa2052.15088aa10e, portal: 192.168.50.2,3260\] successful.  
Login to \[iface: default, target: iqn.2017-10.com.hpe:storage.msa2052.15088aa10e, portal: 192.168.51.3,3260\] successful.  
Login to \[iface: default, target: iqn.2017-10.com.hpe:storage.msa2052.15088aa10e, portal: 192.168.51.2,3260\] successful.  
Login to \[iface: default, target: iqn.2017-10.com.hpe:storage.msa2052.15088aa10e, portal: 192.168.50.3,3260\] successful.</td></tr></tbody></table>

3.4. Listar as sessões ativas

```shell
iscsiadm -m session -o show
```

<table id="bkmrk-tcp%3A-%5B1%5D-192.168.50." style="width: 808px;"><tbody><tr><td style="width: 807px;">tcp: \[1\] 192.168.50.2:3260,1 iqn.2017-10.com.hpe:storage.msa2052.15088aa10e (non-flash)  
tcp: \[2\] 192.168.51.3:3260,4 iqn.2017-10.com.hpe:storage.msa2052.15088aa10e (non-flash)  
tcp: \[3\] 192.168.51.2:3260,3 iqn.2017-10.com.hpe:storage.msa2052.15088aa10e (non-flash)  
tcp: \[4\] 192.168.50.3:3260,2 iqn.2017-10.com.hpe:storage.msa2052.15088aa10e (non-flash)</td></tr></tbody></table>

3.5. Exibe informações dos dispositivos

```shell
multipath -v3
```

<table id="bkmrk-...-...%C2%A0-sa%C3%ADda-omi" style="width: 808px;"><tbody><tr><td style="width: 807px;">...

... Saída omitida

...  
===== paths list =====  
uuid hcil dev dev\_t pri dm\_st chk\_st vend/prod  
360080e50002c8d920000146c5d1bca10 2:0:0:0 sdc 8:32 50 undef undef HPE,MSA 1  
360080e50002c8d920000146c5d1bca10 3:0:0:0 sda 8:0 10 undef undef HPE,MSA 1  
360080e50002c8d920000146c5d1bca10 4:0:0:0 sdb 8:16 50 undef undef HPE,MSA 1  
360080e50002c8d920000146c5d1bca10 5:0:0:0 sdd 8:48 10 undef undef HPE,MSA 1  
Dec 13 16:23:15 | libdevmapper version 1.02.155 (2018-12-18)  
Dec 13 16:23:15 | DM multipath kernel driver v1.13.0  
Dec 13 16:23:15 | sdc: udev property ID\_WWN whitelisted  
Dec 13 16:23:15 | wwid 360080e50002c8d920000146c5d1bca10 not in wwids file, skipping sdc  
Dec 13 16:23:15 | sdc: orphan path, only one path  
Dec 13 16:23:15 | sysfs prioritizer refcount 4  
Dec 13 16:23:15 | sda: udev property ID\_WWN whitelisted  
Dec 13 16:23:15 | wwid 360080e50002c8d920000146c5d1bca10 not in wwids file, skipping sda  
Dec 13 16:23:15 | sda: orphan path, only one path  
Dec 13 16:23:15 | sysfs prioritizer refcount 3  
Dec 13 16:23:15 | sdb: udev property ID\_WWN whitelisted  
Dec 13 16:23:15 | wwid 360080e50002c8d920000146c5d1bca10 not in wwids file, skipping sdb  
Dec 13 16:23:15 | sdb: orphan path, only one path  
Dec 13 16:23:15 | sysfs prioritizer refcount 2  
Dec 13 16:23:15 | sdd: udev property ID\_WWN whitelisted  
Dec 13 16:23:15 | wwid 360080e50002c8d920000146c5d1bca10 not in wwids file, skipping sdd  
Dec 13 16:23:15 | sdd: orphan path, only one path  
Dec 13 16:23:15 | sysfs prioritizer refcount 1  
Dec 13 16:23:15 | unloading sysfs prioritizer  
Dec 13 16:23:15 | unloading const prioritizer  
Dec 13 16:23:15 | unloading tur checker

</td></tr></tbody></table>

3.6. Adicionar o WWID do disco compartilhado via iSCSI para a configuração

```shell
multipath -a 360080e50002c8d920000146c5d1bca10
```

<table id="bkmrk-wwid-%27360080e50002c8" style="width: 807px;"><tbody><tr><td style="width: 806px;">wwid '360080e50002c8d920000146c5d1bca10' added</td></tr></tbody></table>

3.7. Associar o WWID a um nome, para facilitar o gerenciamento

```shell
nano /etc/multipath.conf # Abrir o arquivo
```

<table id="bkmrk-%2Fetc%2Fmultipath.conf-" style="width: 810px;"><tbody><tr><td style="width: 809px;">/etc/multipath.conf</td></tr><tr><td style="width: 809px;">\# Adicionar este trecho ao final do arquivo

multipaths {  
 multipath {  
 wwid 360080e50002c8d920000146c5d1bca10  
 alias meusdados  
 }  
}

</td></tr></tbody></table>

3.8. Reiniciar o serviço para aplicar as alterações

```shell
systemctl restart multipathd
```

3.9. Verificar se o dispositivo multipath foi criado

```shell
multipath -l
```

<table id="bkmrk-meusdados-%28360080e50" style="width: 810px;"><tbody><tr><td style="width: 809px;">meusdados (360080e50002c8d920000146c5d1bca10) dm-0 HPE,MSA 2052 SAN  
size=128G features='3 queue\_if\_no\_path queue\_mode mq' hwhandler='1 alua' wp=rw  
|-+- policy='service-time 0' prio=0 status=active  
| |- 3:0:0:0 sdg 8:32 active undef running  
| `- 6:0:0:0 sdf 8:16 active undef running  
`-+- policy='service-time 0' prio=0 status=enabled  
 |- 4:0:0:0 sde 8:0 active undef running  
 `- 7:0:0:0 sdh 8:48 active undef running</td></tr></tbody></table>

3.10. Configurar a conexão aos dispositivos via iSCSI no boot

```shell
sed 's/node.startup = manual/node.startup = automatic/' -i /etc/iscsi/iscsid.conf
sed 's/node.startup = manual/node.startup = automatic/' -i /etc/iscsi/nodes/*/*/default
sed 's/node.conn\[0\].startup = manual/node.conn\[0\].startup = automatic/' -i /etc/iscsi/nodes/*/*/default
```

  
 Referências

[https://openwares.net/2019/07/03/debian-buster-multipath-configuration/](https://openwares.net/2019/07/03/debian-buster-multipath-configuration/)

[https://docs.microsoft.com/pt-br/azure/storsimple/storsimple-8000-configure-mpio-windows-server](https://docs.microsoft.com/pt-br/azure/storsimple/storsimple-8000-configure-mpio-windows-server)