Tenho um total de quatro servidores em centro de dados baseado na nuvem. Eles executam CentOS ou Ubuntu Linux. Preciso de me certificar que o desempenho do sistema de ficheiros agrupados é razoável, uma vez que os meus servidores são partilhados com outros utilizadores. Como posso verificar a velocidade entre os dois servidores Linux usando opções de linha de comando para LAN/VLAN?

Pode testar a velocidade/resultado da rede entre Ubuntu/CentOS/Debian/Fedora Linux ou Unix box usando o comando iperf. Os comandos Iperf mostram informações sobre largura de banda, atraso, jitter, e perda de datagramas. É uma ferramenta para realizar medições de rendimento da rede. Pode testar a taxa de transferência TCP ou UDP. Para realizar um teste iperf o utilizador deve estabelecer tanto um servidor (para descartar tráfego) como um cliente (para gerar tráfego). Esta página explica como testar a velocidade/resultado da rede entre dois servidores Linux.

Privilégios de raiz

Pormenores tutoriais
Dificuldade level Easy
Sim
Requisitos Linux com iperf
Est. tempo de leitura 8 mintues

Minha amostra configurada para testar a velocidade/resultado da rede entre dois servidores Linux

Fig.01 Teste a velocidade da rede entre dois computadores Linuxp>Fig.01 Teste a velocidade da rede entre dois computadores Linux

Step 1 – Instalação

Necessita de instalar o iperf de acordo com a sua versão de distribuição Linux. Existem duas versões de iperf:

  1. iperf
  2. iperf3

O iperf/iperf3 funciona em Linux, Unix, Windows, *BSD e outros sistemas operativos.

Instalar iperf num servidor Ubuntu/Debian Linux

Digite o seguinte comando/apt comando para instalar iperf em ambos os servidores:
$ sudo apt-get update
$ sudo apt-get install iperf
br>br>Aqui está o que vemos no Ubuntu 20.04 Sistema LTS:

 password for vivek: Reading package lists... DoneBuilding dependency tree Reading state information... DoneThe following NEW packages will be installed: iperf0 upgraded, 1 newly installed, 0 to remove and 23 not upgraded.Need to get 76.5 kB of archives.After this operation, 213 kB of additional disk space will be used.Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 iperf amd64 2.0.13+dfsg1-1build1 Fetched 76.5 kB in 1s (70.5 kB/s) Selecting previously unselected package iperf.(Reading database ... 344795 files and directories currently installed.)Preparing to unpack .../iperf_2.0.13+dfsg1-1build1_amd64.deb ...Unpacking iperf (2.0.13+dfsg1-1build1) ...Setting up iperf (2.0.13+dfsg1-1build1) ...Processing triggers for man-db (2.9.1-1) ...

Uma nota sobre a instalação de iperf3 num Debian/Ubuntu Linux

Também é possível instalar iperf3 (versão mais recente) como se segue:
$ sudo apt-get install iperf3br>Outputs:

Reading package lists... DoneBuilding dependency tree Reading state information... DoneThe following additional packages will be installed: libiperf0The following NEW packages will be installed: iperf3 libiperf00 upgraded, 2 newly installed, 0 to remove and 23 not upgraded.Need to get 86.2 kB of archives.After this operation, 294 kB of additional disk space will be used.Do you want to continue? yGet:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 libiperf0 amd64 3.7-3 Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 iperf3 amd64 3.7-3 Fetched 86.2 kB in 1s (97.4 kB/s) Selecting previously unselected package libiperf0:amd64.(Reading database ... 344807 files and directories currently installed.)Preparing to unpack .../libiperf0_3.7-3_amd64.deb ...Unpacking libiperf0:amd64 (3.7-3) ...Selecting previously unselected package iperf3.Preparing to unpack .../iperf3_3.7-3_amd64.deb ...Unpacking iperf3 (3.7-3) ...Setting up libiperf0:amd64 (3.7-3) ...Setting up iperf3 (3.7-3) ...Processing triggers for man-db (2.9.1-1) ...Processing triggers for libc-bin (2.31-0ubuntu9.2) ...

Instalar iperf num servidor Linux Fedora mais recente/RHEL/CentOS 8

Digite o seguinte comando dnf para instalar iperf em ambos os servidores:
$ sudo dnf install iperf

Uma nota sobre a instalação do iperf3 num CentOS/RHEL/SL/Oracle Linux

Digite o seguinte comando:
$ sudo dnf install iperf3

Instalar iperf num servidor CentOS/RHEL/Oracle/Scientific Linux

Digite o seguinte comando yum para instalar iperf em ambos os servidores (primeira vez ligar o repo EPEL para CentOS/RHEL 7.x):
$ sudo yum install iperfbr> se estiver a utilizar a última versão do Fedora e CentOS/RHEL 8.x tente o comando dnf da seguinte forma:
$ sudo dnf install iperf3
>/p>

Como testar a velocidade de passagem da rede entre dois servidores Linux

Instalando iperf3 num CentOS ou RHEL 8.x servidor

Uma nota sobre a instalação de iperf3 num CentOS/RHEL/SL/Oracle Linux

Digite o seguinte comando:
$ sudo yum install iperf3

Passo 2 – Iniciar um servidor iperf no servidorA (modo servidor)

Digite o seguinte comando para executar iperf no modo servidor:
iperf -sbr>OR
>iperf3 -sbr>Exploração de amostras:

------------------------------------------------------------Server listening on TCP port 5001TCP window size: 85.3 KByte (default)------------------------------------------------------------

Por favor, anotar a porta TCP # 5001.

Uma nota sobre a configuração da firewall

Por favor note que deve abrir a porta TCP 5001 no serverA. Veja como usar ufw para abrir uma porta no Ubuntu/Debian Linux:
$ sudo ufw allow from 192.168.149.0/24 to 192.168.149.69 port 5001 proto tcpbr>CentOS/RHEL/Fedora os utilizadores precisam de abrir a porta usando FirewallD. Veja como configurar uma firewall usando FirewallD no CentOS 8:
sudo firewall-cmd --zone=public --add-port=5001/tcp --permanent
br> Também é possível alterar a porta passando a opção -p como se segue (por exemplo abrir e utilizar a porta TCP 2323):
iperf -s -p 2323
iperf3 -s -p 4242

-----------------------------------------------------------Server listening on 4242-----------------------------------------------------------

Passo 3 – Iniciar um servidor iperf em serverB (modo cliente)

Digite o seguinte comando para executar em modo cliente, ligando a 192.168.149.69:
iperf -c {ip-address-of-serverA-here}
iperf -c {ip-address-of-serverA-here} -p {tcp-port}
iperf -c 192.168.149.69 -p 2323
iperf -c 192.168.149.69

OR
iperf3 -c {ip-address-of-serverA-here}
iperf3 -c {ip-address-of-serverA-here} -p {tcp-port}
iperf3 -c 192.168.149.69 -p 2323
iperf3 -c 192.168.149.69
br>Exploração de amostras:

Fig.02: Resultado do teste de velocidade da rede Linux

Fig.02: Resultado do teste de velocidade da rede Linux

Como usar UDP em vez de TCP

No lado do servidor:
iperf -s -ubr>> No lado do cliente:
iperf -c 192.168.149.69 -u

Ver também: Como instalar o Speedtest-cli num CentOS / RHEL / Scientific / Fedora Linux Para verificar a velocidade da Internet a partir do Bash Shelll

Como definir o número de fios paralelos do cliente a executar (opções de modo cliente)

P>Passar a opção -P:
iperf -c 192.168.149.69 -P 3br> Também pode definir o tempo em segundos para transmitir por (por defeito 10 segs) da seguinte forma:
iperf -c 192.168.149.69 -P 3 -t 30br>Expressos de amostra:

div id=”8aaa42a6f1e”>

aqui é a saída de iperf3:
## on the server side ##
iperf3 -s
## on the client side ##
iperf3 -c 192.168.149.69
br>Exploração de amostras:

Connecting to host 192.168.149.69, port 5201 local 192.168.181.40 port 55522 connected to 192.168.149.69 port 5201 Interval Transfer Bandwidth Retr Cwnd 0.00-1.00 sec 235 MBytes 1.97 Gbits/sec 32 609 KBytes 1.00-2.00 sec 230 MBytes 1.93 Gbits/sec 21 670 KBytes 2.00-3.00 sec 159 MBytes 1.33 Gbits/sec 19 635 KBytes 3.00-4.00 sec 235 MBytes 1.97 Gbits/sec 7 686 KBytes 4.00-5.00 sec 229 MBytes 1.92 Gbits/sec 86 757 KBytes 5.00-6.00 sec 206 MBytes 1.73 Gbits/sec 6 537 KBytes 6.00-7.00 sec 210 MBytes 1.76 Gbits/sec 5 556 KBytes 7.00-8.00 sec 235 MBytes 1.97 Gbits/sec 10 617 KBytes 8.00-9.00 sec 245 MBytes 2.06 Gbits/sec 11 670 KBytes 9.00-10.00 sec 234 MBytes 1.96 Gbits/sec 10 713 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - Interval Transfer Bandwidth Retr 0.00-10.00 sec 2.17 GBytes 1.86 Gbits/sec 207 sender 0.00-10.00 sec 2.16 GBytes 1.86 Gbits/sec receiver

Obter ajuda é fácil

Digite o seguinte comando:
$ man iperf
$ man iperf3
$ iperf --help
$ iperf3 --help

div>>div>>div>>

Server or Client: -p, --port # server port to listen on/connect to -f, --format format to report: Kbits, Mbits, Gbits, Tbits -i, --interval # seconds between periodic throughput reports -F, --file name xmit/recv the specified file -A, --affinity n/n,m set CPU affinity -B, --bind <host> bind to the interface associated with the address <host> -V, --verbose more detailed output -J, --json output in JSON format --logfile f send output to a log file --forceflush force flushing output at every interval -d, --debug emit debugging output -v, --version show version information and quit -h, --help show this message and quitServer specific: -s, --server run in server mode -D, --daemon run the server as a daemon -I, --pidfile file write PID file -1, --one-off handle one client connection then exit --rsa-private-key-path path to the RSA private key used to decrypt authentication credentials --authorized-users-path path to the configuration file containing user credentialsClient specific: -c, --client <host> run in client mode, connecting to <host> --sctp use SCTP rather than TCP -X, --xbind <name> bind SCTP association to links --nstreams # number of SCTP streams -u, --udp use UDP rather than TCP --connect-timeout # timeout for control connection setup (ms) -b, --bitrate # target bitrate in bits/sec (0 for unlimited) (default 1 Mbit/sec for UDP, unlimited for TCP) (optional slash and packet count for burst mode) --pacing-timer # set the timing for pacing, in microseconds (default 1000) --fq-rate # enable fair-queuing based socket pacing in bits/sec (Linux only) -t, --time # time in seconds to transmit for (default 10 secs) -n, --bytes # number of bytes to transmit (instead of -t) -k, --blockcount # number of blocks (packets) to transmit (instead of -t or -n) -l, --length # length of buffer to read or write (default 128 KB for TCP, dynamic or 1460 for UDP) --cport <port> bind to a specific client port (TCP and UDP, default: ephemeral port) -P, --parallel # number of parallel client streams to run -R, --reverse run in reverse mode (server sends, client receives) --bidir run in bidirectional mode. Client and server send and receive data. -w, --window # set window size / socket buffer size -C, --congestion <algo> set TCP congestion control algorithm (Linux and FreeBSD only) -M, --set-mss # set TCP/SCTP maximum segment size (MTU - 40 bytes) -N, --no-delay set TCP/SCTP no delay, disabling Nagle's Algorithm -4, --version4 only use IPv4 -6, --version6 only use IPv6 -S, --tos N set the IP type of service, 0-255. The usual prefixes for octal and hex can be used, i.e. 52, 064 and 0x34 all specify the same value. --dscp N or --dscp val set the IP dscp value, either 0-63 or symbolic. Numeric values can be specified in decimal, octal and hex (see --tos above). -L, --flowlabel N set the IPv6 flow label (only supported on Linux) -Z, --zerocopy use a 'zero copy' method of sending data -O, --omit N omit the first n seconds -T, --title str prefix every output line with this string --extra-data str data string to include in client and server JSON --get-server-output get results from server --udp-counters-64bit use 64-bit counters in UDP test packets --repeating-payload use repeating pattern in payload, instead of randomized payload (like in iperf2) --username username for authentication --rsa-public-key-path path to the RSA public key used to encrypt authentication credentials indicates options that support a K/M/G suffix for kilo-, mega-, or giga- iperf3 homepage at: https://software.es.net/iperf/Report bugs to: https://github.com/esnet/iperf

/div>

Summing up

Esta página explicou como realizar testes de rendimento da rede entre dois servidores Linux ou Unix utilizando a ferramenta iperf3/iperf. Ver iperf documenation e iperf3 source code online para mais informações.

🐧 Obtenha os últimos tutoriais sobre Linux, Open Source & DevOps via RSS feed ou Weekly email newsletter.
🐧 5 comentários até agora… adicionar um ↓

.

Categoria Lista de comandos Unix e Linux
Gestão de ficheiros cat
Firewall Alpine Awall – CentOS 8 – OpenSUSE – RHEL 8 – Ubuntu 16.04 – Ubuntu 18.04 – Ubuntu 20.04
Utilitários de rede dig – host – ip – nmap
OpenVPN CentOS 7 – CentOS 8 – Debian 10 – Debian 8/9 – Ubuntu 18.04 – Ubuntu 20.04
Package Manager apk – apt
Process Management bg – chroot – cron – disown – fg – jobs – killall – kill – pidof – pstree – pwdx – time
Searching grep – whereis – which
Informação do utilizador grupos – id – lastcomm – último – tampa/libuser-tampa – logname – membros – utilizadores – whoami – who – w
WireGuard VPN Alpine – CentOS 8 – Debian 10 – Firewall – Ubuntu 20.04

Deixe uma resposta

O seu endereço de email não será publicado. Campos obrigatórios marcados com *