centos . bootstrap?Bootstrapping
大家好,关于centos . bootstrap很多朋友都还不太明白,今天小编就来为大家分享关于Bootstrapping的知识,希望对各位有所帮助!
centos下coreseek安装及使用方法
Coreseek中文全文检索引擎
Coreseek是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索、论坛/站内搜索、数据库搜索、文档/文献检索、信息检索、数据挖掘等应用场景,用户可以免费下载使用
一,coreseek简介
官方
Coreseek是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索、论坛/站内搜索、数据库搜索、文档/文献检索、信息检索、数据挖掘等应用场景。商业使用(例如,嵌入到其他程序中)需要获得商业授权。
Coreseek是一个支持中文的全文搜索引擎,意图为其他应用提供高速、低空间占用、高相关度结果的中文全文搜索能力。CoreSeek可以非常容易的与SQL数据库和脚本语言集成。
在Sphinx发行版本中提供的原生搜索API支持PHP、Python、Perl、Rudy和Java。搜索API非常轻量化,可以在几个小时之内移植到新的语言上。第三方API接口和插件提供了对Perl、C#、Haskell、Ruby-on-Rails支持,以及对其他可能的语言或者框架的支持。
版本介绍
Coreseek 3.2稳定版
Coreseek 4.1测式版
Coreseek 5最新版
二,安装Coreseek
注:本文是以centos+mysql做为数据源支持为基础的coreseek安装教程.mysql安装略过.
1,下载coreseek 3.2稳定版,下载其他版本请去官网自行下载
cd/usr/local/src/
wget
tar xzvf coreseek-3.2.14.tar.gz
cd coreseek-3.2.14
安装coreseek之前需要先安装需要预装的软件:yum install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel(注:这是centos 64位
其他系统请参考
2,安装mmseg
$ cd mmseg-3.2.14
$./bootstrap#输出的warning信息可以忽略,如果出现error则需要解决
$./configure--prefix=/usr/local/mmseg3
$ make make install
$ cd..
##如果提示libtool: unrecognized option `--tag=CC',请查看libtool问题解决方案
##安装完成后,mmseg使用的词典和配置文件,将自动安装到/usr/local/mmseg3/etc中
##中文分词测试,如果显示不正常,请检查当前环境下的locale和UTF-8中文字符显示设置
$/usr/local/mmseg3/bin/mmseg-d/usr/local/mmseg3/etc src/t1.txt
中文/x分/x词/x测试/x
中国人/x上海市/x
Word Splite took: 1 ms.
3,安装coreseek
$ cd csft-3.2.14
##执行configure,进行编译配置:
$ sh buildconf.sh
$./configure--prefix=/usr/local/coreseek--without-unixodbc--with-mmseg--with-mmseg-includes=/usr/local/mmseg3/include/mmseg/--with-mmseg-libs=/usr/local/mmseg3/lib/--with-mysql
如查提示找不到mysql includes file则使用下面的编译命令
./configure--prefix=/usr/local/coreseek--without-unixodbc--with-mmseg--with-mmseg-includes=/usr/local/mmseg3/include/mmseg/--with-mmseg-libs=/usr/local/mmseg3/lib/--with-mysql-includes=/alidata/server/mysql/include/--with-mysql-libs=/alidata/server/mysql/bin/
make make install
4,测式coreseek
cd../testpack
$/usr/local/coreseek/bin/indexer-c etc/csft.conf
##以下为正常情况下的提示信息:
Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]
Copyright(c) 2007-2010,
Beijing Choice Software Technologies Inc()
using config file'etc/csft.conf'...
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
##
##csft-4.0版显示:ERROR: nothing to do.
##
$/usr/local/coreseek/bin/indexer-c etc/csft.conf--all
##以下为正常索引全部数据时的提示信息:(csft-4.0版类似)
Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]
Copyright(c) 2007-2010,
Beijing Choice Software Technologies Inc()
using config file'etc/csft.conf'...
indexing index'xml'...
collected 3 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 3 docs, 7585 bytes
total 0.075 sec, 101043 bytes/sec, 39.96 docs/sec
total 2 reads, 0.000 sec, 5.6 kb/call avg, 0.0 msec/call avg
total 7 writes, 0.000 sec, 3.9 kb/call avg, 0.0 msec/call avg
$/usr/local/coreseek/bin/indexer-c etc/csft.conf xml
##以下为正常索引指定数据时的提示信息:(csft-4.0版类似)
Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]
Copyright(c) 2007-2010,
Beijing Choice Software Technologies Inc()
using config file'etc/csft.conf'...
indexing index'xml'...
collected 3 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 3 docs, 7585 bytes
total 0.069 sec, 109614 bytes/sec, 43.35 docs/sec
total 2 reads, 0.000 sec, 5.6 kb/call avg, 0.0 msec/call avg
total 7 writes, 0.000 sec, 3.9 kb/call avg, 0.0 msec/call avg
$/usr/local/coreseek/bin/search-c etc/csft.conf
##以下为正常测试搜索时的提示信息:(csft-4.0版类似)
Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]
Copyright(c) 2007-2010,
Beijing Choice Software Technologies Inc()
using config file'etc/csft.conf'...
index'xml': query'': returned 3 matches of 3 total in 0.093 sec
displaying matches:
1. document=1, weight=1, published=Thu Apr 1 22:20:07 2010, author_id=1
2. document=2, weight=1, published=Thu Apr 1 23:25:48 2010, author_id=1
3. document=3, weight=1, published=Thu Apr 1 12:01:00 2010, author_id=2
words:
$/usr/local/coreseek/bin/search-c etc/csft.conf-a Twittter和Opera都提供了搜索服务
##以下为正常测试搜索关键词时的提示信息:(csft-4.0版类似)
Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]
Copyright(c) 2007-2010,
Beijing Choice Software Technologies Inc()
using config file'etc/csft.conf'...
index'xml': query'Twittter和Opera都提供了搜索服务': returned 3 matches of 3 total in 0.038 sec
displaying matches:
1. document=3, weight=24, published=Thu Apr 1 12:01:00 2010, author_id=2
2. document=1, weight=4, published=Thu Apr 1 22:20:07 2010, author_id=1
3. document=2, weight=3, published=Thu Apr 1 23:25:48 2010, author_id=1
words:
1.'twittter': 1 documents, 3 hits
2.'和': 3 documents, 15 hits
3.'opera': 1 documents, 25 hits
4.'都': 2 documents, 4 hits
5.'提供': 0 documents, 0 hits
6.'了': 3 documents, 18 hits
7.'搜索': 2 documents, 5 hits
8.'服务': 1 documents, 1 hits
$/usr/local/coreseek/bin/searchd-c etc/csft.conf
##以下为正常开启搜索服务时的提示信息:(csft-4.0版类似)
Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]
Copyright(c) 2007-2010,
Beijing Choice Software Technologies Inc()
using config file'etc/csft.conf'...
listening on all interfaces, port=9312
三,配置coreseek支持mysql数据源
1,配置csft_mysql.conf文件
复制mysql配置文件到coreseek安装目录etc/下(比如/usr/local/coreseek/etc/)
cp/usr/local/src/coreseek-3.2.14/testpack/etc/csft_mysql.conf/usr/local/coreseek/etc/
cd/usr/local/coreseek/etc/
vi csft_mysql.conf
下面加红部分是需要你自己配置的
官方参考文档:数据源配置:mysql数据源
其他数据源请参考官方
==============================================================
#源定义
sourcephperz
{
type= mysql
sql_host=localhost
sql_user=root
sql_pass=xxxx
sql_db=phperz
sql_port= 3306
sql_query_pre= SET NAMES utf8
sql_query=SELECT id,title,descs,status from article
#sql_query第一列id需为整数
#title、content作为字符串/文本字段,被全文索引
sql_attr_uint=status#从SQL读取到的值必须为整数
#sql_attr_timestamp= date_added#从SQL读取到的值必须为整数,作为时间属性
sql_query_info_pre= SET NAMES utf8#命令行查询时,设置正确的字符集
sql_query_info=SELECT* FROM article WHERE id=$id#命令行查询时,从数据库读取原始数据信息
}
#index定义
indexphperz
{
source=phperz#对应的source名称
path=/usr/local/coreseek/var/data/phperz#请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
docinfo= extern
mlock= 0
morphology= none
min_word_len= 1
html_strip= 0
#中文分词配置,详情请查看:
charset_dictpath=/usr/local/mmseg3/etc/#BSD、Linux环境下设置,/符号结尾
#charset_dictpath= etc/#Windows环境下设置,/符号结尾,最好给出绝对路径,例如:C:/usr/local/coreseek/etc/...
charset_type= zh_cn.utf-8
}
#全局index定义
indexer
{
mem_limit= 128M
}
#searchd服务定义
searchd
{
listen= 9312
read_timeout= 5
max_children= 30
max_matches= 1000
seamless_rotate= 0
preopen_indexes= 0
unlink_old= 1
pid_file=/usr/local/coreseek/var/log/searchd_mysql.pid#请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
log=/usr/local/coreseek/var/log/searchd_mysql.log#请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
query_log=/usr/local/coreseek/var/log/query_mysql.log#请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
}
==============================================================
2,建立索引
路经部分需要改成你自己的地址
/usr/local/coreseek/bin/indexer-c/usr/local/coreseek/etc/csft_mysql.conf--all
可能出现的错误
ERROR: index'phperz': sql_connect: Can't connect to local MySQL server through socket'/var/lib/mysql/mysql.sock'(2)(DSN=mysql://root:***@localhost:3306/phperz).
这是因为mysql的sock文件路经不正确导致的.
确认一下你的mysql.sock路经,建立一个软连接,比如
ln-s/tmp/mysql.sock/var/lib/mysql/mysql.sock
四,coreseek+php使用方式
复制安装止录下的/usr/local/src/coreseek-3.2.14/testpack/api/sphinxapi.php文件到你的项目里
你的程序里include sphinxapi.php
php使用方法见/usr/local/src/coreseek-3.2.14/testpack/api/test.php
另附我的使用方法:
===============================================================
$wd= trim($_GET['wd']);
include_once(JF_PATH./config/sph_cfg.php);
include_once(JF_PATH./include/sphinxapi.php);
$cl= new SphinxClient();
$cl-SetServer(SPH_SERVER_HOST, SPH_SERVER_POST);
$cl-SetConnectTimeout(3);
$cl-SetArrayResult(true);
$cl-SetMatchMode(1);
$cl-SetFilter(status, array(1));
$cl-SetLimits(0, 10);
$res=$cl-Query($wd, phperz_www);
if($res['matches']){
$rownum=$res['total'];
foreach($res['matches'] as$k=$v){
$re=$this-db-get_one(select* from article where id=.$v['id']);
if(!empty($re)){
$list[]=$re;
}
}
}
print_r($list);
===============================================================
五,coreseek日常维护
启动
/usr/local/coreseek/bin/searchd-c/usr/local/coreseek/etc/csft_mysql.conf
停止
/usr/local/coreseek/bin/searchd-c/usr/local/coreseek/etc/csft_mysql.conf--stop
建立索引
/usr/local/coreseek/bin/indexer-c/usr/local/coreseek/etc/csft_mysql.conf--all
重建索引
/usr/local/coreseek/bin/indexer-c/usr/local/coreseek/etc/csft_mysql.conf--all--rotate
你需要把启动命令加到开机自启动里
把重建索引命令加到计划任务里每天执行
本文为phperz原创,转载请注明出处.
centos6编译及安装ZLMediaKit解析
centos6安装ZLMediaKit
ZLMediaKit的作者是使用Ubuntu 16开发的,但是如果要跑到测试甚至于生产上必须要部署到centos上,笔者主要是使用centos6(centos7除了下面rpm包外,编译组件操作一致),因为有需求就装完给大家分享一下。
1.安装基础编译环境
1.1 gcc-5.4的安装
注意:centos6默认gcc的版本是gcc-4.4,此时需要升级到gcc-5.4,网络上说的升级到gcc-4.7以上以支持c11是错误的,实测gcc-4.8无法成功cmake出相关基础配置框架
wget
tar-zxvf gcc-5.4.0.tar.gz
cd gcc-5.4.0
./contrib/download_prerequisites
cd..
mkdir gcc-build-5.4.0
cd gcc-build-5.4.0
../gcc-5.4.0/configure–enable-checking=release–enable-languages=c,c++–disable-multilib
make&& make install(我的虚拟机是双核处理器2.5G内存,需要1个小时,早知多配置几个核心。。。等死了)
gcc-v此时系统gcc会自动变成gcc-5.4版本
1.2 cmake-3.10安装
暂时没有测试cmake3其他版本是否能安装,目前使用的3.10与作者版本一致
tar-zxvf cmake-3.10.0-rc4.tar.gz
cd cmake-3.10.0
./bootstrap
gmake&& gmake install
yum remove cmake
ln-s/usr/local/bin/cmake/usr/bin/cmake
ln-s/usr/local/bin/cpack/usr/bin/cpack
ln-s/usr/local/bin/ctest/usr/bin/ctest
#或者是写环境变量
export PATH=$PATH:/usr/local/bin
#配置进/etc/profile之后source也可以验证:
# cmake–version
cmake version 3.10.0-rc42.编译ZLMediaKit
2.1下载代码
git clone–depth=1
cd ZLMediaKit
git submodule init
git submodule update2.2安装依赖性
yum install mysql-devel.x86_64 openssl-devel ffmpeg ffmpeg-devel另外三个rpm包也需要安装,链接如下:
libx264-devel()
wget
libfaac-devel()
wget
libmp4v2-dev()
wget 编译
# mkdir linux_build
# ln-s linux_build/ build
# cd build
# cmake..
— The C compiler identification is GNU 5.4.0
…
— Configuring done
— Generating done
— Build files have been written to:/usr/local/src/install_pack/ZLMediaKit/build
# make编译好可执行的文件在ZLMediaKit/git/ZLMediaKit/build/bin下面
3.运行编译好的ZLMediaKit
cd ZLMediaKit/git/ZLMediaKit/build
./bin/MediaServer
# netstat-antlp| grep./MediaServer
tcp 0 0 0.0.0.0:555 0.0.0.0:* LISTEN 26771/./MediaServer
tcp 0 0 0.0.0.0:1936 0.0.0.0:* LISTEN 26771/./MediaServer
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 26771/./MediaServer
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 26771/./MediaServer
tcp 0 0 0.0.0.0:322 0.0.0.0:* LISTEN 26771/./MediaServer
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 26771/./MediaServer如果要修改端口,在编译前,找到ZLMediaKit/git/ZLMediaKit/server/main.cpp
在namespace mediakit{下面进行对各服务器端口号的修改
总结
以上所述是小编给大家介绍的centos6编译及安装ZLMediaKit解析,大家如有疑问可以留言,或者联系站长。感谢亲们支持!!!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
解决centos7.2中磁盘iowait过高(centos7启动后盘符错位问题)
(一)简述
每天都收到磁盘iowait告警信息,尤其是日志服务器在进行大量的读写操作过程中,从而造成系统处于崩溃边缘,为查找磁盘iowait由于什么原因造成的以及后续的系统的优化点。centos有许多查找问题的工具,也有高级的。
I/O Wait就是一个需要使用高级的工具来debug的问题,当然也有许多基本工具的高级用法。I/O wait的问题难以定位的原因是因为我们有很多工具可以告诉你说I/O受限了,但是并没有告诉你具体是哪些进程们引起的。
具体的思路如下:top。查看由cpu一行浪费在iowait上的cpu百分比=iostat-x 2 5查看某块磁盘正在被写入= iotop查找最高的磁盘I/O对应的进程= lsof-p pid查看通过一个进程打开所有文件或打开一个文件的所有进程。
(二)具体步骤如下:
(1)通过top命令来确认是否是I/O导致系统缓慢。
[root@iZ23iod5vslZ~]# toptop- 15:38:32 up 40 days, 5:59, 3 users, load average: 0.00, 0.01, 0.05Tasks: 128 total, 1 running, 127 sleeping, 0 stopped, 0 zombieCpu(s): 0.4 us, 0.2 sy, 0.0 ni, 99.2 id, 98 wa, 0.0 hi, 0.0 si, 0.1 stKiB Mem: 32520424 total, 31492136 used, 1028288 free, 412772 buffersKiB Swap: 0 total, 0 used, 0 free. 25902892 cached Mem PID USER PR NI VIRT RES SHR S CPU MEM TIME+ COMMAND 18988 root 20 0 11.647g 3.611g 7896 S 2.7 11.6 507:57.30 java 28 root 20 0 0 0 0 S 0.3 0.0 6:43.31 rcuos/3 1 root 20 0 49556 3412 1912 S 0.0 0.0 0:14.60 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:48.28 ksoftirqd/0 5 root 0-20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 7 root rt 0 0 0 0 S 0.0 0.0 0:00.83 migration/0 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/0 10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/1 11 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/2 12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/3 13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/4 14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/5 15 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/6 16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/7
从Cpu一行我们可以看到浪费在I/O Wait上的CPU百分比;这个数字越高说明越多的CPU资源在等待I/O权限.具体的解释如下:
0.4 us用户空间占用CPU的百分比。
0.2 sy内核空间占用CPU的百分比。
0.0 ni改变过优先级的进程占用CPU的百分比
2 id空闲CPU百分比
98 wa IO等待占用CPU的百分比
0.0 hi硬中断(Hardware IRQ)占用CPU的百分比
0.0 si软中断(Software Interrupts)占用CPU的百分比
在这里CPU的使用比率和windows概念不同,如果你不理解用户空间和内核空间,需要充充电了
(2)通过iostat-x 3 3查看那块磁盘正在被写入。
[root@iZ23iod5vslZ~]# iostat-x 3 3Linux 3.10.0-123.9.3.el7.x86_64(iZ23iod5vslZ) 08/14/2017 _x86_64_(4 CPU)avg-cpu: user nice system iowait steal idle 0.70 0.00 0.16 0.75 0.05 98.34Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm utilxvda 0.00 21.18 0.32 18.33 9.94 195.06 21.98 0.08 4.11 11.44 3.98 1.54 2.88xvdb 0.00 15.21 1.23 1.98 38.41 68.76 66.70 0.08 25.48 3.59 39.10 1.09 0.35xvdc 0.00 0.07 0.00 0.91 0.00 36.25 79.43 0.10 106.88 12.53 106.92 1.33 0.12avg-cpu: user nice system iowait steal idle 0.75 0.00 0.17 0.08 0.08 98.91Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm utilxvda 0.00 2.33 0.00 0.67 0.00 12.00 36.00 0.00 5.50 0.00 5.50 5.50 0.37xvdb 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.00xvdc 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.00avg-cpu: user nice system iowait steal idle 0.75 0.00 0.17 0.00 0.00 99.08Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm utilxvda 0.00 3.33 0.00 1.67 0.00 34.67 41.60 0.01 3.00 0.00 3.00 1.60 100.27xvdb 0.00 9.00 0.00 1.67 0.00 42.67 51.20 0.01 5.40 0.00 5.40 1.80 0.30xvdc 0.00 0.33 0.00 0.67 0.00 4.00 12.00 0.00 2.00 0.00 2.00 2.00 0.13
每隔三秒更新一次,一共打印了三次。-x时打印出扩展选项。第一次打印的信息可以被忽略,剩下的报告,都是基于上一次间隔的时间打印出来。
上述的列子中xvda的 util(利用率)是100.27,有进程往磁盘中写入数据。
(3)通过iotop查找高I/O对应的进程
[root@iZ23iod5vslZ~]# iotopTotal DISK READ: 0.00 B/s| Total DISK WRITE: 15.67 K/sActual DISK READ: 0.00 B/s| Actual DISK WRITE: 0.00 B/s TID PRIO USER DISK READ DISK WRITE SWAPIN IO COMMAND 18793 be/4 root 0.00 B/s 3.92 K/s 0.00 0.00 java-Djava.util.logging.config.file=/usr/to~p org.apache.catalina.startup.Bootstrap start18987 be/4 root 0.00 B/s 3.92 K/s 0.00 0.00 cronolog/guojinbao/tomcat/logs/catalina.Y-m-d.out18796 be/4 root 0.00 B/s 3.92 K/s 0.00 0.00 java-Djava.util.logging.config.file=/usr/to~p org.apache.catalina.startup.Bootstrap start13193 be/4 root 0.00 B/s 3.92 K/s 0.00 0.00 java-Djava.util.logging.config.file=/usr/to~p org.apache.catalina.startup.Bootstrap start 1 be/4 root 0.00 B/s 0.00 B/s 0.00 0.00 systemd--switched-root--system--deserialize 22 2 be/4 root 0.00 B/s 0.00 B/s 0.00 0.00 [kthreadd] 3 be/4 root 0.00 B/s 0.00 B/s 0.00 0.00 [ksoftirqd/0]16388 be/4 root 0.00 B/s 0.00 B/s 0.00 0.00 AliYunDun 5 be/0 root 0.00 B/s 0.00 B/s 0.00 0.00 [kworker/0:0H]16390 be/4 root 0.00 B/s 0.00 B/s 0.00 0.00 AliYunDun 7 rt/4 root 0.00 B/s 0.00 B/s 0.00 0.00 [migration/0] 8 be/4 root 0.00 B/s 0.00 B/s 0.00 0.00 [rcu_bh] 9 be/4 root 0.00 B/s 0.00 B/s 0.00 0.00 [rcuob/0] 10 be/4 root 0.00 B/s 0.00 B/s 0.00 0.00 [rcuob/1] 11 be/4 root 0.00 B/s 0.00 B/s 0.00 0.00 [rcuob/2]
从上述的例子中可以看出进程号为cronolog18987占用了大量的磁盘IO
(4)通过lsof-p pid查找由那个文件引起的IOwait
[root@iZ23iod5vslZ~]# lsof-p 18987COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEcronolog 18987 root cwd DIR 202,17 20480 2400258/guojinbao/tomcat/logscronolog 18987 root rtd DIR 202,1 4096 2/cronolog 18987 root txt REG 202,1 48627 152798/usr/local/sbin/cronologcronolog 18987 root mem REG 202,1 2107600 132826/usr/lib64/libc-2.17.socronolog 18987 root mem REG 202,1 160240 132819/usr/lib64/ld-2.17.socronolog 18987 root 0r FIFO 0,8 0t0 42614018 pipecronolog 18987 root 1w CHR 1,3 0t0 1028/dev/nullcronolog 18987 root 2u CHR 136,0 0t0 3/dev/pts/0(deleted)cronolog 18987 root 3w REG 202,17 5704875979 2400280/guojinbao/tomcat/logs/catalina.2017-08-14.out
lsof命令可以展示一个进程打开的所有文件,或者打开一个文件的所有进程。从这个列表中,我们可以找到具体是什么文件被写入,根据文件的大小和/proc中io文件的具体数据.
为了确认我们的怀疑,我们可以使用/proc文件系统,每个进程目录下都有一个叫io的文件,里边保存这和iotop类似的信息
[root@iZ23iod5vslZ~]# cat/proc/18987/io rchar: 58891582418wchar: 58891579778syscr: 46556085syscw: 46556077read_bytes: 212992write_bytes: 59580235776cancelled_write_bytes: 0
read_bytes和write_bytes是这个进程从磁盘读写的字节数。这个例子中cronolog读取了212992byte(0.2M)数据,写入了59580235776bytes(55.4G)数据到磁盘上。
(5)通过df-h/guojinbao来查看服务器那块磁盘的根目录
[root@iZ23iod5vslZ~]# df-h/guojinbao/Filesystem Size Used Avail Use Mounted on/dev/xvdb1 45G 38G 4.7G 89/guojinbao
最后,通过以上的信息我们可以放心的说lsof的结果就是我们要查找的文件