1、离线安装
1.1 下载1.2 解压 2、在线安装
1、离线安装 1.1 下载点击下载iostat离线包
1.2 解压基本语法:
tar [-cxtzjvfpPN] file
参数:
-c: 建立压缩档案
-x:解压
-t:查看内容
-r:向压缩归档文件末尾追加文件
-u:更新原压缩包中的文件
特别注意:在参数的下达中, c/x/t 仅能存在一个!不可同时存在! 因为不可能同时压缩与解压缩!!!
-z :是否同时具有 gzip 的属性,亦即是否需要用 gzip 压缩
-j :是否同时具有 bzip2 的属性,亦即是否需要用 bzip2 压缩
-v :压缩的过程中显示文件!这个常用,但不建议用在背景执行过程!
-f :使用档名,请留意,在 f 之后要立即接档名喔!不要再加参数!
例如使用『 tar -zcvfP tfile sfile』就是错误的写法,要写成『 tar -zcvPf tfile sfile』
-p :使用原文件的原来属性(属性不会依据使用者而变)
-P :可以使用绝对路径来压缩!
-N :比后面接的日期(yyyy/mm/dd)还要新的才会被打包进新建的文件中!
–exclude FILE:在压缩的过程中,不要将 FILE 打包!
例如
[root@VM-0-4-centos ~]# tar zxvf f.tar.gz #解.gz文件解压过程显示并且以文档名命名
这里使用第三方软件 SecureFX 上传文件
终于开始正常解压了
[root@VM-0-4-centos ~]# ll total 404 -rw-r--r-- 1 root root 412737 Feb 24 14:53 sysstat-11.1.1.tar.gz [root@VM-0-4-centos ~]# tar zxf sysstat-11.1.1.tar.gz #由于不想显示解压文件就去掉v了 [root@VM-0-4-centos ~]# ll total 408 drwxr-xr-x 8 1000 1000 4096 Aug 30 2014 sysstat-11.1.1 -rw-r--r-- 1 root root 412737 Feb 24 14:53 sysstat-11.1.1.tar.gz [root@VM-0-4-centos ~]#
进行离线安装
[root@VM-0-4-centos sysstat-11.1.1]# ./configure #环境编译
.
Check programs:
.
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether ln -s works... yes
checking for chmod... chmod
checking for chown... chown
checking for ar... ar
checking for install... install
checking for msgfmt... msgfmt
checking for xgettext... xgettext
checking for msgmerge... msgmerge
checking for bzip2... bzip2
checking for cp... /bin/cp
checking for chkconfig... /sbin/chkconfig
checking for pkg-config... pkg-config
checking for systemctl... /bin/systemctl
.
Check header files:
.
checking for ANSI C header files... (cached) yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking ctype.h usability... yes
checking ctype.h presence... yes
checking for ctype.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking libintl.h usability... yes
checking libintl.h presence... yes
checking for libintl.h... yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking net/if.h usability... yes
checking net/if.h presence... yes
checking for net/if.h... yes
checking regex.h usability... yes
checking regex.h presence... yes
checking for regex.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking for sys/stat.h... (cached) yes
.
Check typedefs, structures and compiler characteristics:
.
checking return type of signal handlers... void
checking for size_t... yes
checking for off_t... yes
.
Check library functions:
.
checking for strchr... yes
checking for strcspn... yes
checking for strspn... yes
checking for strstr... yes
checking for sensors support... yes
checking for sensors_get_detected_chips in -lsensors... no
checking for sensors lib... no
.
Check system services:
.
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
.
Check configuration:
.
checking run-commands directory... /etc/rc.d
checking sadc directory... /usr/local/lib64/sa
INFO: Directory /usr/local/lib64/sa will be created during installation stage.
checking system activity directory... /var/log/sa
INFO: Directory /var/log/sa will be created during installation stage.
checking sysstat configuration directory... /etc/sysconfig
checking National Language Support... yes
checking whether sa2 should process data file of the day before... no
checking number of daily data files to keep... 7
checking number of days after which data files are compressed... 10
checking preallocation factor value... 1
checking group for manual pages... man
checking whether man_group variable should be ignored... no
checking whether manual pages should be compressed... no
checking whether isag script should be installed... no
checking whether system activity directory should be cleaned... no
checking whether cron should start sar automatically... no
checking whether documentation should be installed... yes
checking whether object files should be stripped... yes
.
Now create files:
.
configure: creating ./config.status
config.status: creating sa1
config.status: creating sa2
config.status: creating cron/crontab
config.status: creating sysstat.sysconfig
config.status: creating version.h
config.status: creating sysconfig.h
config.status: creating prealloc.h
config.status: creating cron/sysstat.cron.daily
config.status: creating cron/sysstat.cron.hourly
config.status: creating cron/sysstat.crond
config.status: creating cron/sysstat.crond.sample.in
config.status: creating sysstat
config.status: creating sysstat.service
config.status: creating cron/sysstat-collect.service
config.status: creating cron/sysstat-collect.timer
config.status: creating cron/sysstat-summary.service
config.status: creating cron/sysstat-summary.timer
config.status: creating man/sa1.8
config.status: creating man/sa2.8
config.status: creating man/sadc.8
config.status: creating man/sadf.1
config.status: creating man/sar.1
config.status: creating man/sysstat.5
config.status: creating man/iostat.1
config.status: creating man/cifsiostat.1
config.status: creating man/nfsiostat-sysstat.1
config.status: creating contrib/isag/isag
config.status: creating Makefile
Sysstat version: 11.1.1
Installation prefix: /usr/local
rc directory: /etc/rc.d
Init directory: /etc/rc.d/init.d
Systemd unit dir: /usr/lib/systemd/system
Configuration directory: /etc/sysconfig
Man pages directory: ${datarootdir}/man
Compiler: gcc
Compiler flags: -g -O2
开始在这里出错了无法解决,后面找到解决办法了再补充重新写
尝试解决办法:1、检查make环境是不是配好;2、尝试重新安装gcc但是还是未解决
以下是报错
[root@VM-0-4-centos sysstat-11.1.1]# make
gcc -o sadc.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2 -DSA_DIR="/var/log/sa" -DSADC_PATH="/usr/local/lib64/sa/sadc" -DUSE_NLS -DPACKAGE="sysstat" -DLOCALEDIR="/usr/local/share/locale" sadc.c
In file included from sa.h:11,
from sadc.c:37:
sadc.c: In function ‘sa_sys_init’:
sadc.c:315:61: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context]
SREALLOC(act[i]->_buf0, void, act[i]->msize * act[i]->nr * act[i]->nr2);
~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
common.h:93:16: note: in definition of macro ‘SREALLOC’
if (SIZE) {
^~~~
sadc.c: In function ‘open_ofile’:
sadc.c:943:61: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context]
SREALLOC(act[p]->_buf0, void, act[p]->msize * act[p]->nr * act[p]->nr2);
~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
common.h:93:16: note: in definition of macro ‘SREALLOC’
if (SIZE) {
^~~~
gcc -o act_sadc.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2 -DSOURCE_SADC -DSA_DIR="/var/log/sa" -DSADC_PATH="/usr/local/lib64/sa/sadc" -DUSE_NLS -DPACKAGE="sysstat" -DLOCALEDIR="/usr/local/share/locale" activity.c
gcc -o sa_wrap.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2 -DSA_DIR="/var/log/sa" -DSADC_PATH="/usr/local/lib64/sa/sadc" -DUSE_NLS -DPACKAGE="sysstat" -DLOCALEDIR="/usr/local/share/locale" sa_wrap.c
gcc -o sa_common.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2 -DSA_DIR="/var/log/sa" -DSADC_PATH="/usr/local/lib64/sa/sadc" -DUSE_NLS -DPACKAGE="sysstat" -DLOCALEDIR="/usr/local/share/locale" sa_common.c
In file included from sa.h:11,
from sa_common.c:35:
sa_common.c: In function ‘allocate_structures’:
sa_common.c:87:63: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context]
SREALLOC(act[i]->buf[j], void, act[i]->msize * act[i]->nr * act[i]->nr2);
~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
common.h:93:16: note: in definition of macro ‘SREALLOC’
if (SIZE) {
^~~~
sa_common.c: In function ‘check_file_actlst’:
sa_common.c:1305:66: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context]
SREALLOC(*file_actlst, struct file_activity, FILE_ACTIVITY_SIZE * file_hdr->sa_act_nr);
common.h:93:16: note: in definition of macro ‘SREALLOC’
if (SIZE) {
^~~~
sa_common.c: In function ‘reallocate_vol_act_structures’:
sa_common.c:1432:61: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context]
SREALLOC(act[p]->buf[j], void, act[p]->msize * act[p]->nr * act[p]->nr2);
~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
common.h:93:16: note: in definition of macro ‘SREALLOC’
if (SIZE) {
^~~~
sa_common.c: In function ‘set_default_file’:
sa_common.c:450:8: warning: ‘/sa’ directive output may be truncated writing 3 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
"%s/sa%02d", sa_dir,
^~~
sa_common.c:449:3: note: ‘snprintf’ output between 6 and 270 bytes into a destination of size 256
snprintf(datafile, MAX_FILE_LEN,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"%s/sa%02d", sa_dir,
~~~~~~~~~~~~~~~~~~~~
rectime.tm_mday);
~~~~~~~~~~~~~~~~
sa_common.c:442:8: warning: ‘/sa’ directive output may be truncated writing 3 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
"%s/sa%04d%02d%02d", sa_dir,
^~~
sa_common.c:442:5: note: directive argument in the range [-2147481748, 2147483647]
"%s/sa%04d%02d%02d", sa_dir,
^~~~~~~~~~~~~~~~~~~
sa_common.c:442:5: note: directive argument in the range [-2147483647, 2147483647]
sa_common.c:441:3: note: ‘snprintf’ output between 12 and 292 bytes into a destination of size 256
snprintf(datafile, MAX_FILE_LEN,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"%s/sa%04d%02d%02d", sa_dir,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rectime.tm_year + 1900,
~~~~~~~~~~~~~~~~~~~~~~~
rectime.tm_mon + 1,
~~~~~~~~~~~~~~~~~~~
rectime.tm_mday);
~~~~~~~~~~~~~~~~
gcc -o rd_stats.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2 -DSOURCE_SADC -DSA_DIR="/var/log/sa" -DSADC_PATH="/usr/local/lib64/sa/sadc" -DUSE_NLS -DPACKAGE="sysstat" -DLOCALEDIR="/usr/local/share/locale" rd_stats.c
gcc -o count.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2 -DSOURCE_SADC -DSA_DIR="/var/log/sa" -DSADC_PATH="/usr/local/lib64/sa/sadc" -DUSE_NLS -DPACKAGE="sysstat" -DLOCALEDIR="/usr/local/share/locale" count.c
ar rvs librdstats.a rd_stats.o count.o
ar: creating librdstats.a
a - rd_stats.o
a - count.o
gcc -o rd_sensors.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2 -DSA_DIR="/var/log/sa" -DSADC_PATH="/usr/local/lib64/sa/sadc" -DUSE_NLS -DPACKAGE="sysstat" -DLOCALEDIR="/usr/local/share/locale" rd_sensors.c
ar rv librdsensors.a rd_sensors.o
ar: creating librdsensors.a
a - rd_sensors.o
gcc -o common.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2 -DSA_DIR="/var/log/sa" -DSADC_PATH="/usr/local/lib64/sa/sadc" -DUSE_NLS -DPACKAGE="sysstat" -DLOCALEDIR="/usr/local/share/locale" common.c
common.c: In function ‘get_dev_part_nr’:
common.c:214:35: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 1023 [-Wformat-truncation=]
snprintf(line, MAX_PF_NAME, "%s/%s/%s", dfile, drd->d_name, S_STAT);
^~
common.c:214:3: note: ‘snprintf’ output between 7 and 1285 bytes into a destination of size 1024
snprintf(line, MAX_PF_NAME, "%s/%s/%s", dfile, drd->d_name, S_STAT);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -o ioconf.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2 -DSA_DIR="/var/log/sa" -DSADC_PATH="/usr/local/lib64/sa/sadc" -DUSE_NLS -DPACKAGE="sysstat" -DLOCALEDIR="/usr/local/share/locale" ioconf.c
ioconf.c: In function ‘transform_devmapname’:
ioconf.c:502:15: error: called object ‘major’ is not a function or function pointer
dm_major = major(aux.st_rdev);
^~~~~
ioconf.c:478:41: note: declared here
char *transform_devmapname(unsigned int major, unsigned int minor)
~~~~~~~~~~~~~^~~~~
ioconf.c:503:15: error: called object ‘minor’ is not a function or function pointer
dm_minor = minor(aux.st_rdev);
^~~~~
ioconf.c:478:61: note: declared here
char *transform_devmapname(unsigned int major, unsigned int minor)
~~~~~~~~~~~~~^~~~~
make: *** [Makefile:161: ioconf.o] Error 1
2、在线安装
使用yum源安装iostat
[root@VM-0-4-centos ~]# yum provides iostat #查找iostat对应的软件包 [root@VM-0-4-centos ~]# yum -y install sysstat #进行安装iostat对应的软件包sysstat
进行简单使用,iostat常用命令格式如下:
iostat [参数] [时间] [次数] 命令参数说明如下: -c 显示CPU使用情况 -d 显示磁盘使用情况 -k 以K为单位显示 -m 以M为单位显示 -N 显示磁盘阵列(LVM) 信息 -n 显示NFS使用情况 -p 可以报告出每块磁盘的每个分区的使用情况 -t 显示终端和CPU的信息 -x 显示详细信息
常见用法
iostat -d -k 1 10 #查看TPS和吞吐量信息(磁盘读写速度单位为KB) iostat -d -m 2 #查看TPS和吞吐量信息(磁盘读写速度单位为MB) iostat -d -x -k 1 10 #查看设备使用率(%util)、响应时间(await) iostat -c 1 10 #查看cpu状态
使用的案例
[root@VM-0-4-centos ~]# iostat -x
%user:CPU处在用户模式下的时间百分比
%nice:CPU处在带NICE值的用户模式下的时间百分比
%system:CPU处在系统模式下的时间百分比
%iowait:CPU等待输入输出完成时间的百分比
%steal:管理程序维护另一个虚拟处理器时,虚拟CPU的无意识等待时间百分比
%idle:CPU空闲时间百分比
iostat命令的重点是用来监测磁盘性能的
Device:设备名称
rrqm/s:每秒合并到设备的读取请求数
wrqm/s:每秒合并到设备的写请求数
r/s:每秒向磁盘发起的读操作数
w/s:每秒向磁盘发起的写操作数
rkB/s:每秒读K字节数
wkB/s:每秒写K字节数
avgrq-sz:平均每次设备I/O操作的数据大小
avgqu-sz:平均I/O队列长度
await:平均每次设备I/O操作的等待时间 (毫秒),一般地,系统I/O响应时间应该低于5ms,如果大于 10ms就比较大了
r_await:每个读操作平均所需的时间;不仅包括硬盘设备读操作的时间,还包括了在kernel队列中等待的时间
w_await:每个写操作平均所需的时间;不仅包括硬盘设备写操作的时间,还包括了在kernel队列中等待的时间
svctm:平均每次设备I/O操作的服务时间 (毫秒)(这个数据不可信!)
%util:一秒中有百分之多少的时间用于I/O操作,即被IO消耗的CPU百分比,一般地,如果该参数是100%表示设备已经接近满负荷运行了
[root@VM-0-4-centos ~]# iostat -d 2 3
tps:每秒I/O数(即IOPS。磁盘连续读和连续写之和)
kB_read/s:每秒从磁盘读取数据大小,单位KB/s
kB_wrtn/s:每秒写入磁盘的数据的大小,单位KB/s
kB_read:从磁盘读出的数据总数,单位KB
kB_wrtn:写入磁盘的的数据总数,单位KB
性能监控指标
在日常运维中到底需要关注的字段,关注哪些输出内容就可以确定这台服务器是否存在IO性能瓶颈。
%iowait:如果该值较高,表示磁盘存在I/O瓶颈
await:一般地,系统I/O响应时间应该低于5ms,如果大于10ms就比较大了
avgqu-sz:如果I/O请求压力持续超出磁盘处理能力,该值将增加。如果单块磁盘的队列长度持续超过2,一般认为该磁盘存在I/O性能问题。需要注意的是,如果该磁盘为磁盘阵列虚拟的逻辑驱动器,需要再将该值除以组成这个逻辑驱动器的实际物理磁盘数目,以获得平均单块硬盘的I/O等待队列长度
%util:一般地,如果该参数是100%表示设备已经接近满负荷运行了



