Производителността на диска може да бъде тясно гърло в работата на вашия сървър. Записите в хранилището преминават през различни слоеве на абстракция, което затруднява отстраняването на грешки. Има много инструменти, които да ни помогнат в тази дилема. Ето някои от тях.
Инструменти за наблюдение на производителността на диска
иостат
Iostat е ефективен инструмент за наблюдение на производителността на диска. Iostat дава общ преглед на информацията за използване на диска и процесора. Полезно, когато искате да отстраните грешки при четене/запис на диска.
инсталация
sudo apt-get install sysstat
употреба и примери
По-долу е използването на командата според страницата на ръководството.
iostat [ -c ] [ -d ] [ -N ] [ -n ] [ -h ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ] [ device […] | ALL ] [ -p [ device [,…] | ALL ] ] [ interval [ count ] ]
По-долу е опростената версия и често използвани примери за команди
iostat [option] [interval[count]]
Показване на стандартен отчет за istat
iostat
За показване на отчета на устройството на непрекъснати интервали
iostat -d 2 displays the continuous device report at two seconds interval
За показване на отчета за диска на непрекъснат интервал няколко пъти
iostat -d 3 6 generates 6 reports of running iostat at three seconds interval
За да отпечатате разширените резултати. Разширеният изход съдържа допълнителна и по-подробна информация
iostat -x 3 prints the extended results
За показване на информация за дял
iostat -p 1 3 Displays the reports for every partition at 1 sec interval 3 times
Примерен изход
Изходът на iostat съдържа два раздела.
По-долу е стандартният изход на iostat
avg-cpu: %user %nice %system %iowait %steal %idle 5.40 0.01 7.98 0.08 0.00 86.52 Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn sdb 0.00 0.00 0.00 0 0 sda 0.00 0.00 0.00 0 0
Разширеният изход на iostats
avg-cpu: %user %nice %system %iowait %steal %idle 14.90 0.00 11.90 0.31 0.00 72.89 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sdb 0.00 0.00 0.00 186.50 0.00 1924.00 20.63 4.78 25.63 0.00 25.63 0.21 3.95 sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Заглавията се превеждат по следния начин
Секция 1
* %user : Show the percentage of CPU utilization that occurred while executing at the user (application) level. * %nice : Show the percentage of CPU utilization that occurred while executing at the user level with nice priority. * %system : Show the percentage of CPU utilization that occurred while executing at the system (kernel) level. * %iowait : Show the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request. * %steal : Show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor. * %idle : Show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.
Раздел II
* rrqm/s : The number of read requests merged per second that were queued to the device. * wrqm/s : The number of write requests merged per second that were queued to the device. * r/s : The number (after merges) of read requests completed per second for the device. * w/s : The number (after merges) of write requests completed per second for the device. * avgrq-sz : The average size (in sectors) of the requests that were issued to the device. * avgqu-sz : The average queue length of the requests that were issued to the device. * await : The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them. * r_await : The average time (in milliseconds) for read requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them. * w_await : The average time (in milliseconds) for write requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them. * svctm : The average service time (in milliseconds) for I/O requests that were issued to the device. Warning! Do not trust this field anymore! This field will be removed in a future sysstat version. * %util : Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%.
iop
ioping е инструмент за проверка на латентността на съхранението, точно както подсказва името. Това дава изход, подобен на ping.
blktrace и btt за мониторинг на диска с блоков слой
Инсталирай
sudo apt-get install blktrace
използване
sudo su * mount -t debugfs debugfs /sys/kernel/debug * blktrace -d /dev/sda -w 60 # dump binary for one of more disk for 60 sec * blkrawverify sda # creates sda.verify.out * less sda.verify.out * grep invalid sdbs.verify.out #can be used to check for errors. * blkparse -i sda -d bp.sda.bin parse the contents of all percore files and creates a single binary file * btt -A -i bp.sda.bin > bp.sda.txt * less bp.sda.txt
за iostat подобен изход
* btt -I bp.sda.iostat -i bp.sda.bin * less bp.sdbs.iostat
изход
====================== All Devices =================== ALL MIN AVG MAX N ----------- --------- --------- -------- ------ Q2Q 0.000000001 0.001756012 0.051593892 13062 Q2G 0.000000262 0.000001294 0.000099171 12953 G2I 0.000000158 0.000001338 0.000514283 12952 Q2M 0.000000105 0.000000168 0.000001178 110 I2D 0.000001180 0.011021668 4.961414109 12932 M2D 0.000005243 0.058989823 4.883649101 109 D2C 0.000400768 0.027376846 0.083938666 13027 Q2C 0.000404366 0.038901493 5.010404572 13027 ==================== Device Overhead ==================== DEV Q2G G2I Q2M I2D D2C ---------- | --------- --------- --------- --------- --------- ( 8, 16) | 0.0033% 0.0034% 0.0000% 28.1256% 70.3748% ---------- | --------- --------- --------- --------- --------- Overall | 0.0033% 0.0034% 0.0000% 28.1256% 70.3748% ==================== Device Merge Information ================== DEV | #Q #D Ratio | BLKmin BLKavg BLKmax Total ----------| ---- ---- ----- | ------ ------ ------ ---- ( 8, 16) | 13063 12953 1.0 | 8 16 512 ================ Device Q2Q Seek Information ================= DEV | NSEEKS MEAN MEDIAN | MODE ---- | --------- ---------- -------- | ---------- ( 8, 16) | 13063 66700285.0 0 | 0(123) --------- | --------- ---------- -------- | ---------- Overall | NSEEKS MEAN MEDIAN | MODE Average | 13063 66700285.0 0 | 0(123) ================= Device D2D Seek Information =================== DEV | NSEEKS MEAN MEDIAN | MODE ---- | --------- ---------- -------- | ---------- ( 8, 16) | 12953 66827985.0 0 | 0(15) -------- | --------- ---------- -------- | ---------- Overall | NSEEKS MEAN MEDIAN | MODE Average | 12953 66827985.0 0 | 0(15) Q2Q — time between requests sent to the block layer Q2G — how long it takes from the time a block I/O is queued to the time it gets a request allocated for it G2I — how long it takes from the time a request is allocated to the time it is Inserted into the device's queue Q2M — how long it takes from the time a block I/O is queued to the time it gets merged with an existing request I2D — how long it takes from the time a request is inserted into the device's queue to the time it is actually issued to the device M2D — how long it takes from the time a block I/O is merged with an exiting request until the request is issued to the device D2C — service time of the request by the device Q2C — total time spent in the block layer for a request
Инструменти за използване и манипулиране на дискове
команда du и df
du: използва се за проверка на използването на съхранение на файлове и папки в директория
du -h : gives the output in human readable form. du -ah : disk usage of all files and folders in human readable form
df: Използване на заявка за съхранение на дисковете и монтираната файлова система
df -h : Display information in human readable form
fdisk -l
Lists the partition information about the storage devices in the machine
Инструменти за маркиране на дискове
Fio — Гъвкав io тестер
е мощен инструмент за маркиране и мониторинг. Това ни позволява да дефинираме много полезни тестови работни натоварвания.
Инсталиране
On ubuntu sudo apt-get install fio
Инсталиранеот източници
git clone — branch fio-2.1.8 http://git.kernel.dk/fio.git fio-2.1.8 # or wget http://brick.kernel.dk/snaps/fio-<version>.tar.bz2 && tar -xjvf fio-<version>.tar.bz2 fio cd fio ./configure make make install
Как да използвате
- Може да се изпълнява като команда в командния ред с всички параметри, предадени в командния ред
- Файл със задача може да се използва с всички аргументи, посочени в него
fio — help : Common help for fio tool fio — cmdhelp=cmd : Provides help for a particular command fio -name=test -filename=test -filesize=1G -rw=randwrite -bs=8k -iodepth=4 -numjobs=4 -ioengine=libaio -direct=1 -runtime=60 -group_reporting -status-interval -output=output.txt
Горното е примерна команда fio с повечето често срещани параметри в нея. Всеки параметър е обяснен по-долу
* name : name of the test being run * filename : name of the file to be used for the workload * filesize : size of the file to be used for workload *rw : the operations to be performed by default it is read. rw: IO direction alias: readwrite type: string (opt=bla) default: read valid values: read Sequential read : write Sequential write : trim Sequential trim : randread Random read : randwrite Random write : randtrim Random trim : rw Sequential read and write mix : readwrite Sequential read and write mix : randrw Random read and write mix * bs : The size of the data to be read or written by fio. default is 4k * iodepth : Number of io buffers to keep in flight. default is 1 * numjobs : Number of fio threads to be run. default is 1 * ioengine : The ioengine used for the operation ioengine: IO engine to use type: string (opt=bla) default: sync valid values: sync Use read/write : psync Use pread/pwrite : vsync Use readv/writev : libaio Linux native asynchronous IO : posixaio POSIX asynchronous IO : mmap Memory mapped IO : splice splice/vmsplice based IO : netsplice splice/vmsplice to/from the network : sg SCSI generic v3 IO : null Testing engine (no data transfer) : net Network IO : syslet-rw syslet enabled async pread/pwrite IO : cpuio CPU cycle burner engine : binject binject direct inject block engine : rdma RDMA IO engine : e4defrag ext4 defrag engine : falloc fallocate() file based engine : external Load external engine (append name) * direct : for direct io (O_DIRECT) * runtime : the duration for which the fio has to run * group_reporting : To have only one report for all the fio threads * status_interval : The period in which the report has to be printed * output : To write the report to the file specified.
Резултатът
По-долу е примерен резултат
test: (g=0): rw=read, bs=4K-4K/4K-4K/4K-4K, ioengine=sync, iodepth=1 fio-2.1.11 Starting 1 process Jobs: 1 (f=1): [R(1)] [100.0% done] [120.7MB/0KB/0KB /s] [30.9K/0/0 iops] [eta 00m:00s] test: (groupid=0, jobs=1): err= 0: pid=36869: Wed Apr 27 18:04:32 2016 read : io=1024.0MB, bw=116794KB/s, iops=29198, runt= 8978msec slat (usec): min=8, max=56062, avg=12.19, stdev=177.22 clat (usec): min=1, max=94472, avg=32.62, stdev=372.42 lat (usec): min=2, max=94472, avg=32.84, stdev=372.42 clat percentiles (usec): | 1.00th=[ 1], 5.00th=[ 1], 10.00th=[ 1], 20.00th=[ 2], | 30.00th=[ 2], 40.00th=[ 2], 50.00th=[ 2], 60.00th=[ 2], | 70.00th=[ 2], 80.00th=[ 2], 90.00th=[ 2], 95.00th=[ 2], | 99.00th=[ 1704], 99.50th=[ 1720], 99.90th=[ 2704], 99.95th=[ 2736], | 99.99th=[ 2768] bw (KB /s): min=86528, max=123656, per=99.74%, avg=116486.88, stdev=13431.87 lat (usec) : 2=13.80%, 4=84.06%, 10=0.56%, 20=0.01%, 50=0.01% lat (usec) : 750=0.01%, 1000=0.01% lat (msec) : 2=1.22%, 4=0.33%, 10=0.01%, 20=0.01%, 50=0.01% lat (msec) : 100=0.01% cpu : usr=4.79%, sys=7.69%, ctx=4103, majf=0, minf=9 IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0% submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% issued : total=r=262144/w=0/d=0, short=r=0/w=0/d=0 Run status group 0 (all jobs): READ: io=1024.0MB, aggrb=116793KB/s, minb=116793KB/s, maxb=116793KB/s, mint=8978msec, maxt=8978msec Disk stats (read/write): sda: ios=4066/7, merge=4/8, ticks=16370/260, in_queue=16620, util=97.48%
Първата част на изхода дава общ преглед на параметрите, използвани за изпълнение на fio теста и обобщение на теста
test: (g=0): rw=read, bs=4K-4K/4K-4K/4K-4K, ioengine=sync, iodepth=1 *_//basic parameters used_* fio-2.1.11 Starting 1 process Jobs: 1 (f=1): [R(1)] [100.0% done] [120.7MB/0KB/0KB /s] [30.9K/0/0 iops] [eta 00m:00s] test: (groupid=0, jobs=1): err= 0: pid=36869: Wed Apr 27 18:04:32 2016 read : io=1024.0MB, bw=116794KB/s, iops=29198, runt= 8978msec *_// summary of the run_*
Следващият раздел представя няколко нови термина със специфични значения.
Slat е основно забавянето на подаването на заявка. Това е времето, необходимо за изпращане на заявка до io опашката.
slat (usec): min=8, max=56062, avg=12.19, stdev=177.22
Clat е латентността на завършване на операцията. Това е времето, от което заявката е подадена на опашката до завършването на заявката. Това не включва летвата. Персентилът на clat е процентилно разпределение на IO операциите извън работното време. Например изходът по-долу казва, че 90 процентила от операциите имат клауз, равен на 2 или по-малко. Процентните стойности включват предишните стойности. Това означава, че 99,50-ият персентил включва всички операции с клаут по-малък или равен на 1720.
clat (usec): min=1, max=94472, avg=32.62, stdev=372.42 lat (usec): min=2, max=94472, avg=32.84, stdev=372.42 clat percentiles (usec): | 1.00th=[ 1], 5.00th=[ 1], 10.00th=[ 1], 20.00th=[ 2], | 30.00th=[ 2], 40.00th=[ 2], 50.00th=[ 2], 60.00th=[ 2], | 70.00th=[ 2], 80.00th=[ 2], 90.00th=[ 2], 95.00th=[ 2], | 99.00th=[ 1704], 99.50th=[ 1720], 99.90th=[ 2704], 99.95th=[ 2736], | 99.99th=[ 2768]
Fio дава процентно разпределение на стойностите на латентността. lat стойност е общото време за изпълнение на заявка. Това е отделно изчислена стойност. Тя не е сборът от летвата и плочата.
lat (usec) : 2=13.80%, 4=84.06%, 10=0.56%, 20=0.01%, 50=0.01% lat (usec) : 750=0.01%, 1000=0.01% lat (msec) : 2=1.22%, 4=0.33%, 10=0.01%, 20=0.01%, 50=0.01% lat (msec) : 100=0.01%
Следващият раздел дава подробности за използването на процесора.
- IO дълбочини: е броят на io буферите в полет.
- Изпращане : е броят заявки, изпратени наведнъж.
- завършено : е броят заявки, завършени наведнъж.
cpu : usr=4.79%, sys=7.69%, ctx=4103, maxf=0, minf=9 IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0% submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% issued : total=r=262144/w=0/d=0, short=r=0/w=0/d=0
Разделът по-долу дава статистика на диска. ios дава общите сливания за четене/запис дава общите сливания за операция за четене/запис. ticks дава общите тикове, взети за операция за четене/запис, in_queue дава общото време, прекарано в опашката. util дава процентното използване на диска.
Disk stats (read/write): sda: ios=4066/7, merge=4/8, ticks=16370/260, in_queue=16620, util=97.48%
справка
иостат
fio