http://liyanblog.cn/李岩的博客 李岩 java lucene 搜索 nosql hadoop 博客 mongodb, linux2024-03-19T10:51:30+08:00李岩的博客阿里云 linux系统 磁盘扩容savagertnullhttp://liyanblog.cn/articles/2019/09/26/1569466004520.html2019-09-26T10:46:44+08:00<p>磁盘扩容操作:<br />fdisk -l 查看有哪些盘<br /><br />umount /data 卸载磁盘<br />fdisk /dev/vdb 对磁盘进行操作。可以新建删除分区。。<br />[root@iZbp13okxpwhhgbz5t0j7jZ ~]# fdisk /dev/vdb<br />Welcome to fdisk (util-linux 2.23.2).<br /><br />Changes will remain in memory only, until you decide to write them.<br />Be careful before using the write command.<br /><br /><br />Command (m for help): m<br />Command action<br /> a toggle a bootable flag<br /> b edit bsd disklabel<br /> c toggle the dos compatibility flag<br /> d delete a partition<br /> g create a new empty GPT partition table<br /> G create an IRIX (SGI) partition table<br /> l list known partition types<br /> m print this menu<br /> n add a new partition<br /> o create a new empty DOS partition table<br /> p print the partition table<br /> q quit without saving changes<br /> s create a new empty Sun disklabel<br /> t change a partition's system id<br /> u change display/entry units<br /> v verify the partition table<br /> w write table to disk and exit<br /> x extra functionality (experts only)<br /><br />Command (m for help): d<br />Selected partition 1<br />Partition 1 is deleted<br /><br />Command (m for help): <br />Command (m for help): p<br /><br />Disk /dev/vdb: 257.7 GB, 257698037760 bytes, 503316480 sectors<br />Units = sectors of 1 * 512 = 512 bytes<br />Sector size (logical/physical): 512 bytes / 512 bytes<br />I/O size (minimum/optimal): 512 bytes / 512 bytes<br />Disk label type: dos<br />Disk identifier: 0x00000000<br /><br /> Device Boot Start End Blocks Id System<br /><br />Command (m for help): n<br />Partition type:<br /> p primary (0 primary, 0 extended, 4 free)<br /> e extended<br />Select (default p): p<br />Partition number (1-4, default 1): <br />First sector (2048-503316479, default 2048): <br />Using default value 2048<br />Last sector, +sectors or +size{K,M,G} (2048-503316479, default 503316479): <br />Using default value 503316479<br />Partition 1 of type Linux and of size 240 GiB is set<br /><br />Command (m for help): p<br /><br />Disk /dev/vdb: 257.7 GB, 257698037760 bytes, 503316480 sectors<br />Units = sectors of 1 * 512 = 512 bytes<br />Sector size (logical/physical): 512 bytes / 512 bytes<br />I/O size (minimum/optimal): 512 bytes / 512 bytes<br />Disk label type: dos<br />Disk identifier: 0x00000000<br /><br /> Device Boot Start End Blocks Id System<br />/dev/vdb1 2048 503316479 251657216 83 Linux<br /><br />Command (m for help): w<br />The partition table has been altered!<br /><br />Calling ioctl() to re-read partition table.<br /><br />WARNING: Re-reading the partition table failed with error 16: Device or resource busy.<br />The kernel still uses the old table. The new table will be used at<br />the next reboot or after you run partprobe(8) or kpartx(8)<br />Syncing disks.<br />[root@iZbp13okxpwhhgbz5t0j7jZ ~]# fdisk -l<br /><br />Disk /dev/vda: 21.5 GB, 21474836480 bytes, 41943040 sectors<br />Units = sectors of 1 * 512 = 512 bytes<br />Sector size (logical/physical): 512 bytes / 512 bytes<br />I/O size (minimum/optimal): 512 bytes / 512 bytes<br />Disk label type: dos<br />Disk identifier: 0x000b2d99<br /><br /> Device Boot Start End Blocks Id System<br />/dev/vda1 * 2048 41943039 20970496 83 Linux<br /><br />Disk /dev/vdb: 257.7 GB, 257698037760 bytes, 503316480 sectors<br />Units = sectors of 1 * 512 = 512 bytes<br />Sector size (logical/physical): 512 bytes / 512 bytes<br />I/O size (minimum/optimal): 512 bytes / 512 bytes<br />Disk label type: dos<br />Disk identifier: 0x00000000<br /><br /> Device Boot Start End Blocks Id System<br />/dev/vdb1 2048 503316479 251657216 83 Linux<br /><br /><br />重新分区后,对磁盘进行格式化。<br />使用 resize2fs 指令扩大文件系统大小,原有数据不会丢失。 <br /> <br />e2fsck -f /dev/xvdb1 时间会相对长 180G大概5分钟<br /> <br />resize2fs /dev/xvdb1 <br /><br />然后在挂载磁盘即可扩容成功。</p>
<p>mount /dev/vdb1 /data 挂载磁盘</p>监控某个进程的cpu开销,监控每秒cpu占用最高的Pid ,监控top信息脚本savagertnullhttp://liyanblog.cn/articles/2019/07/03/1562146051379.html2019-10-10T15:07:55+08:00<p> </p>
<p>监控某个进程的cpu开销<br />#!/bin/bash<br />PID=5586<br />FileName="res.txt"<br />echo -en "%CPU\t%MEM\t$PID" > $FileName<br />for (( i = 0; i < 30; i++ )) do<br /> ttime=`date +"%m-%d %H:%M:%S"`<br /> output=`top -n 1 -p $PID > tmp`<br /> res=`gawk '{if (NR == 8) { printf "%d\t%d", $10, $11 } }' tmp`<br /> echo -en "$res\t$ttime\n" >> $FileName<br /> sleep 1<br />done<br /><br />监控每秒cpu占用最高的Pid vi a.sh<br />#!/bin/bash<br />FileName="res.txt"<br />echo -en "%CPU\t%MEM\t%PID\t%TIME" > $FileName<br />for (( i = 0; i < 30; i++ )) do<br /> ttime=`date +"%m-%d %H:%M:%S"`<br /> output=`top -i -b -n 1 > tmp`<br /> res=`gawk '{if (NR == 8 && $9>1) { printf "%d\t%d\t%d", $9, $10,$1 } }' tmp`<br /> if [ -n "$res" ] ; then<br /> echo -en "$res\t$ttime\n" >> $FileName<br /> fi<br /> sleep 1<br />done<br /><br />然后用nohup sh a.sh &</p>屏蔽爬虫ip抓取。自动执行没小时一次savagertnullhttp://liyanblog.cn/articles/2018/06/28/1530157278851.html2018-06-28T11:41:19+08:00<p># 每小时执行一次上面的脚本crontable 0 */1 * * * sh /script/block_ip.sh<br />#功能 每小时限制一下ip。每小时访问大于1000次的ip被封锁。<br />#!/bin/sh<br />lastdate=`/bin/date -d last-minute +%Y%m%d`<br />IP_LIST_FILE=/script/deny.txt<br />/bin/cat /opt/web_logs/cctv_access_$lastdate.log | grep `date -d last-minute +%Y:%H`|awk '{print $1}' |sort |uniq -c|sort -nr|head -n 10 |awk '{if($1>1000) {print $2} }' >$IP_LIST_FILE<br /><br />IPTABLES_BIN=/sbin/iptables<br />BAD_IP_ADDR_LIST=$(grep -Ev "^#" $IP_LIST_FILE)<br /><br />#######ACCEPT wanghailou access 202.108.16.65/27 202.108.17.0/24 220.181.168.0/24#############<br /><br />for i in $BAD_IP_ADDR_LIST<br />do<br />echo -n "Blocking $i ...";<br />$IPTABLES_BIN -D INPUT -s $i -j DROP<br />$IPTABLES_BIN -D OUTPUT -d $i -j DROP<br /><br />$IPTABLES_BIN -A INPUT -s $i -j DROP<br />$IPTABLES_BIN -A OUTPUT -d $i -j DROP<br />echo "DONE.";<br /><br />done<br /><br /></p>linux系统内存和虚拟内存 swap 交换 页面savagertnullhttp://liyanblog.cn/articles/2016/11/25/1480042713704.html2016-11-25T10:58:33+08:00<div id="cnblogs_post_body">
<p>1. page in/out操作指把块设备中的页读入内存或把内存中的页写入块设备</p>
<div class="cnblogs_code">
<pre>When ever program or data needs to be accessed and is read in from its permanent location on disk, this is called a page in request.
When ever program or data needs to be saved and is written to a permanent location on disk, this is called a page out request.</pre>
</div>
<p>2. page in/out中的页指disk sector,大小为512字节,而不是虚拟内存中的4k大小的页</p>
<div class="cnblogs_code">
<pre>The kernel tracks each disk page (512b) read in within the pgpgin (pages paged in) counter</pre>
</div>
<p>3. pgpgin/pgpgout是指主存(内存)与块设备(硬盘)之间的page in/out的页数.</p>
<div class="cnblogs_code">
<pre>these counters are related to virtual memory "paging" only in the fact that they are doing disk io to load a memory page with data from disk or write the data from a memory page back to disk</pre>
</div>
<p>4. pswpin/pswpout是指虚拟内存中,从块设备swap区中读入/读出的页数.因此是被包含在pgpgin/pgpgout中的.</p>
<div class="cnblogs_code">
<p> pages swapped in or out are also counted within pages paged in or out respectively since swap io is still ultimately block device based.</p>
</div>
</div>
<div class="clear"> </div>
<div class="clear">-------------------------------------------华丽的分割线----------------------------------------------------------</div>
<div class="clear">为了提高磁盘存取效率, Linux做了一些精心的设计, 除了对dentry进行缓存(用于VFS,加速文件路径名到inode的转换), 还采取了两种主要Cache方式:Buffer Cache和Page Cache.前者针对磁盘块的读写,后者针对文件inode的读写.这些Cache有效缩短了I/O系统调用(比如read,write,getdents)的时间.<br /><br />内存活动基本上可以用3个数字来量化:活动虚拟内存总量,交换(swapping)率和调页(paging)率.其中第一个数字表明内存的总需求量,后两个数字表示那些内存中有多少比例正处在使用之中.目标是减少内存活动或增加内存量,直到调页率保持在一个可以接受的水平上为止.<br /><br />活动虚拟内存的总量(VM)=实际内存大小(size of real memory)(物理内存)+使用的交换空间大小(amount of swap space used)<br /><br />当程序运行需要的内存大于物理内存时,UNIX系统采用了调页机制,即系统copy一些内存中的页面到磁盘上,腾出来空间供进程使用。<br />大多数系统可以忍受偶尔的调页,但是频繁的调页会使系统性能急剧下降。<br /><br />UNIX内存管理:UNIX系统通过2种方法进行内存管理,“调页算法”,“交换技术”。<br />调页算法是将内存中最近不常使用的页面换到磁盘上,把常使用的页面(活动页面)保留在内存中供进程使用。<br />交换技术是系统将整个进程,而不是部分页面,全部换到磁盘上。正常情况下,系统会发生一些交换过程。<br />当内存严重不足时,系统会频繁使用调页和交换,这增加了磁盘I/O的负载。进一步降低了系统对作业的执行速度,即系统I/O资源问题又会影响到内存资源的分配。<br /><br />Unix的虚拟内存<br /><br />Unix的虚拟内存是一个十分复杂的子系统,它实现了进程间代码与数据共享机制的透明性,并能够分配比系统现有物理内存更多的内存,某些操作系统的虚存甚至能通过提供缓存功能影响到文件系统的性能,各种风格的UNIX的虚存的实现方式区别很大,但都离不开下面的4个概念。<br /><br />1:实际内存<br />实际内存是指一个系统中实际存在的物理内存,称为RAM。实际内存是存储临时数据最快最有效的方式,因此必须尽可能地分配给应用程序,现在的RAM的形式有多种:SIMM、DIMM、Rambus、DDR等,很多RAM都可以使用纠错机制(ECC)。<br /><br />2:交换空间<br />交换空间是专门用于临时存储内存的一块磁盘空间,通常在页面调度和交换进程数据时使用,通常推荐交换空间的大小应该是物理内存的二到四倍。<br /><br />3:页面调度<br />页面调度是指从磁盘向内存传输数据,以及相反的过程,这个过程之所以被称为页面调度,是因为Unix内存被平均划分成大小相等的页面;通常页面大小为4KB和8KB(在Solaris中可以用pagesize命令查看)。当可执行程序开始运行时,它的映象会一页一页地从磁盘中换入,与此类似,当某些内存在一段时间内空闲,就可以把它们换出到交换空间中,这样就可以把空闲的RAM交给其他需要它的程序使用。<br /><br />4:交换<br />页面调度通常容易和交换的概念混淆,页面调度是指把一个进程所占内存的空闲部分传输到磁盘上,而交换是指当系统中实际的内存已不够满足新的分配需求时,把整个进程传输到磁盘上,交换活动通常意味着内存不足。<br /><br />vmstat监视内存性能:该命令用来检查虚拟内存的统计信息,并可显示有关进程状态、空闲和交换空间、调页、磁盘空间、CPU负载和交换,cache刷新以及中断等方面的信息。</div>sar 命令 分析系统性能 io性能savagertnullhttp://liyanblog.cn/articles/2016/11/25/1480042282870.html2016-11-25T10:51:22+08:00<p> </p>
<p>//查看指定文件CPU使用记录<br /> #sar -f /var/log/sa/sa03<br /> 00:00:01 CPU %user %nice %system %iowait %idle<br /> 00:10:01 all 52.32 0.00 30.92 1.40 15.37<br /> 00:20:01 all 50.11 0.00 28.97 0.82 20.10<br /> 00:30:01 all 45.94 0.00 26.23 0.88 26.95<br /> 00:40:02 all 44.92 0.00 25.54 0.81 28.73<br /> 00:50:01 all 45.34 0.00 26.17 0.77 27.72<br /> 01:00:01 all 43.23 0.00 24.85 0.94 30.97<br /> 01:10:01 all 43.65 0.00 25.15 0.84 30.36<br /> 01:20:01 all 43.13 0.00 24.99 0.92 30.96</p>
<p>//查看指定文件1/5/15分钟平均负载记录<br /> #sar -q -f /var/log/sa/sa03<br /> 00:00:01 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15<br /> 00:10:01 5 330 15.00 17.72 17.09<br /> 00:20:01 4 331 8.02 13.84 16.11<br /> 00:30:01 4 331 17.79 13.42 14.56<br /> 00:40:02 12 332 11.66 12.31 13.51<br /> 00:50:01 3 326 13.88 12.23 12.90<br /> 01:00:01 26 337 10.10 12.03 12.42<br /> 01:10:01 8 334 12.34 10.78 11.46<br /> 01:20:01 13 329 10.00 11.58 11.49</p>
<p>//查看指定文件7点到9点CPU使用记录,如要看负载加参数-q<br /> #sar -s 07:00:00 -e 10:00:00 -f /var/log/sa/sa03<br /> 07:00:01 CPU %user %nice %system %iowait %idle<br /> 07:10:01 all 42.39 0.00 23.54 0.64 33.43<br /> 07:20:01 all 41.42 0.00 24.47 0.77 33.34<br /> 07:30:01 all 42.93 0.00 25.55 0.75 30.77<br /> 07:40:01 all 50.33 0.00 29.08 0.66 19.92<br /> 07:50:01 all 51.40 0.00 30.30 0.69 17.61<br /> 08:00:01 all 47.63 0.00 28.37 0.66 23.34<br /> 08:10:01 all 44.23 0.00 26.30 0.71 28.76<br /> 08:20:01 all 43.46 0.00 24.58 0.58 31.37<br /> 08:30:01 all 43.86 0.00 26.06 0.60 29.49<br /> 08:40:01 all 44.80 0.00 26.86 0.66 27.67<br /> 08:50:02 all 47.46 0.00 27.16 0.51 24.87<br /> 09:00:01 all 46.10 0.00 27.61 0.47 25.81<br /> 09:10:01 all 46.95 0.00 27.95 0.69 24.40<br /> 09:20:02 all 49.30 0.00 28.27 0.79 21.64<br /> 09:30:01 all 49.99 0.00 29.07 0.64 20.30<br /> 09:40:01 all 51.41 0.00 30.75 0.52 17.32<br /> 09:50:01 all 51.49 0.00 30.20 0.66 17.65<br /> Average: all 46.77 0.00 27.42 0.65 25.16</p>
<p>安装sysstat工具包后会自动每10分钟采集一次<br /> 脚本在/etc/cron.d/sysstat<br /> 默认只保留7天的文件<br /> 要保留更长时间要修改配置文件<br /> 有人觉得是修改/etc/sysconfig/sysstat这个文件,其实不是的<br /> 应该是/usr/lib/sa/sa2(64位/usr/lib64/sa/sa2),来看看里面的代码<br /> HISTORY=7<br /> [ -r /etc/sysconfig/sysstat ] && . /etc/sysconfig/sysstat<br /> [ ${HISTORY} -gt 28 ] && HISTORY=28<br /> #就是这个了,如果sysstat文件设置了历史天数超过28天就不会生效的<br /> 超过28天就要修改这个地方了。</p>
<p>不要小看这个命令,它能够让你对系统运行情况了如指掌。</p>
<p>细化补充:<br /> -A:所有报告的总和<br /> <br /> -u:输出CPU使用情况的统计信息<br /> <br /> -v:输出inode、文件和其他内核表的统计信息<br /> <br /> -d:输出每一个块设备的活动信息<br /> <br /> -r:输出内存和交换空间的统计信息<br /> <br /> -b:显示I/O和传送速率的统计信息<br /> <br /> -a:文件读写情况<br /> <br /> -c:输出进程统计信息,每秒创建的进程数<br /> <br /> -R:输出内存页面的统计信息<br /> <br /> -y:终端设备活动情况<br /> <br /> -w:输出系统交换活动信息<br /> <br /> <strong> 内存分页监控:</strong><br /> sar -r -f /var/log/sa29 //查看历史内存<br /> kbmemfree:这个值和free命令中的free值基本一致,所以它不包括buffer和cache的空间.<br /> <br /> kbmemused:这个值和free命令中的used值基本一致,所以它包括buffer和cache的空间.<br /> <br /> %memused:这个值是kbmemused和内存总量(不包括swap)的一个百分比.<br /> <br /> kbbuffers和kbcached:这两个值就是free命令中的buffer和cache.<br /> <br /> kbcommit:保证当前系统所需要的内存,即为了确保不溢出而需要的内存(RAM+swap).<br /> <br /> %commit:这个值是kbcommit与内存总量(包括swap)的一个百分比.<br /> <br /> <strong>内存分页监控</strong><br /> <br /> 例如,每10秒采样一次,连续采样3次,监控内存分页:<br /> <br /> sar -B 10 3<br /> 输出项说明:<br /> <br /> pgpgin/s:表示每秒从磁盘或SWAP置换到内存的字节数(KB)<br /> <br /> pgpgout/s:表示每秒从内存置换到磁盘或SWAP的字节数(KB)<br /> <br /> fault/s:每秒钟系统产生的缺页数,即主缺页与次缺页之和(major + minor)<br /> <br /> majflt/s:每秒钟产生的主缺页数.<br /> <br /> pgfree/s:每秒被放入空闲队列中的页个数<br /> <br /> pgscank/s:每秒被kswapd扫描的页个数<br /> <br /> pgscand/s:每秒直接被扫描的页个数<br /> <br /> pgsteal/s:每秒钟从cache中被清除来满足内存需要的页个数<br /> <br /> %vmeff:每秒清除的页(pgsteal)占总扫描页(pgscank+pgscand)的百分比<br /> <br /> <strong>I/O和传送速率监控</strong><br /> <br /> 每10秒采样一次,连续采样3次,报告缓冲区的使用情况,需键入如下命令:<br /> <br /> sar -b 10 3<br /> <br /> 屏幕显示如下:<br /> <br /> 18:51:05 tps rtps wtps bread/s bwrtn/s<br /> <br /> 18:51:15 0.00 0.00 0.00 0.00 0.00<br /> <br /> 18:51:25 1.92 0.00 1.92 0.00 22.65<br /> <br /> 18:51:35 0.00 0.00 0.00 0.00 0.00<br /> <br /> Average: 0.64 0.00 0.64 0.00 7.59<br /> <br /> 输出项说明:<br /> <br /> tps:每秒钟物理设备的 I/O 传输总量<br /> <br /> rtps:每秒钟从物理设备读入的数据总量<br /> <br /> wtps:每秒钟向物理设备写入的数据总量<br /> <br /> bread/s:每秒钟从物理设备读入的数据量,单位为 块/s<br /> <br /> bwrtn/s:每秒钟向物理设备写入的数据量,单位为 块/s<br /> <br /> <strong>6. 进程队列长度和平均负载状态监控</strong><br /> <br /> 例如,每10秒采样一次,连续采样3次,监控进程队列长度和平均负载状态:<br /> <br /> sar -q 10 3<br /> <br /> 屏幕显示如下:<br /> <br /> 19:25:50 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15<br /> <br /> 19:26:00 0 259 0.00 0.00 0.00<br /> <br /> 19:26:10 0 259 0.00 0.00 0.00<br /> <br /> 19:26:20 0 259 0.00 0.00 0.00<br /> <br /> Average: 0 259 0.00 0.00 0.00<br /> <br /> 输出项说明:<br /> <br /> runq-sz:运行队列的长度(等待运行的进程数)<br /> <br /> plist-sz:进程列表中进程(processes)和线程(threads)的数量<br /> <br /> ldavg-1:最后1分钟的系统平均负载(System load average)<br /> <br /> ldavg-5:过去5分钟的系统平均负载<br /> <br /> ldavg-15:过去15分钟的系统平均负载<br /> <br /> <strong>7. 系统交换活动信息监控</strong><br /> <br /> 例如,每10秒采样一次,连续采样3次,监控系统交换活动信息:<br /> <br /> sar - W 10 3<br /> <br /> 屏幕显示如下:<br /> <br /> 19:39:50 pswpin/s pswpout/s<br /> <br /> 19:40:00 0.00 0.00<br /> <br /> 19:40:10 0.00 0.00<br /> <br /> 19:40:20 0.00 0.00<br /> <br /> Average: 0.00 0.00<br /> <br /> 输出项说明:<br /> <br /> pswpin/s:每秒系统换入的交换页面(swap page)数量<br /> <br /> pswpout/s:每秒系统换出的交换页面(swap page)数量<br /> <br /> <strong>8. 设备使用情况监控</strong><br /> <br /> 例如,每10秒采样一次,连续采样3次,报告设备使用情况,需键入如下命令:<br /> <br /> # sar -d 10 3 –p<br /> <br /> 屏幕显示如下:<br /> <br /> 17:45:54 DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util<br /> <br /> 17:46:04 scd0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00<br /> <br /> 17:46:04 sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00<br /> <br /> 17:46:04 vg_livedvd-lv_root 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00<br /> <br /> 17:46:04 vg_livedvd-lv_swap 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00<br /> <br /> 其中:<br /> <br /> 参数-p可以打印出sda,hdc等磁盘设备名称,如果不用参数-p,设备节点则有可能是dev8-0,dev22-0<br /> <br /> tps:每秒从物理磁盘I/O的次数.多个逻辑请求会被合并为一个I/O磁盘请求,一次传输的大小是不确定的.<br /> <br /> rd_sec/s:每秒读扇区的次数.<br /> <br /> wr_sec/s:每秒写扇区的次数.<br /> <br /> avgrq-sz:平均每次设备I/O操作的数据大小(扇区).<br /> <br /> avgqu-sz:磁盘请求队列的平均长度.<br /> <br /> await:从请求磁盘操作到系统完成处理,每次请求的平均消耗时间,包括请求队列等待时间,单位是毫秒(1秒=1000毫秒).<br /> <br /> svctm:系统处理每次请求的平均时间,不包括在请求队列中消耗的时间.<br /> <br /> %util:I/O请求占CPU的百分比,比率越大,说明越饱和.<br /> <br /> 1. avgqu-sz 的值较低时,设备的利用率较高。<br /> <br /> 2. 当%util的值接近 1% 时,表示设备带宽已经占满。<br /> <br /> <strong> inode、文件和其他内核表监控</strong><br /> <br /> 例如,每10秒采样一次,连续采样3次,观察核心表的状态,需键入如下命令:<br /> <br /> sar -v 10 3<br /> <br /> 屏幕显示如下:<br /> <br /> 17:10:49 dentunusd file-nr inode-nr pty-nr<br /> <br /> 17:10:59 6301 5664 12037 4<br /> <br /> 17:11:09 6301 5664 12037 4<br /> <br /> 17:11:19 6301 5664 12037 4<br /> <br /> Average: 6301 5664 12037 4<br /> <br /> 输出项说明:<br /> <br /> dentunusd:目录高速缓存中未被使用的条目数量<br /> <br /> file-nr:文件句柄(file handle)的使用数量<br /> <br /> inode-nr:索引节点句柄(inode handle)的使用数量<br /> <br /> pty-nr:使用的pty数量<br /> <br /> <strong>查看页面交换发生状况</strong><br /> sar -W<br /> 页面发生交换时,服务器的吞吐量会大幅下降;服务器状况不良时,如果怀疑因为内存不足而导致了页面交换的发生,可以使用这个命令来确认是否发生了大量的交换;<br /> pswpin/s:每秒系统换入的交换页面(swap page)数量<br /> pswpout/s:每秒系统换出的交换页面(swap page)数量</p>物理内存swap交换调节。 swappiness设置savagertnullhttp://liyanblog.cn/articles/2016/11/10/1478765744861.html2016-11-10T16:15:45+08:00<p>swappiness <br /> Ubuntu Feisty默认的vm.swappiness值是60,这一默认值已经很合适了。但你可以改小一些降低swap的加载,系统性能会有一点点的提升 <br /> 输入: <br /> 代碼: <br /> sysctl -q vm.swappiness <br /> <br /> 你会看到值是60, 更改: <br /> 代碼: <br /> sudo sysctl vm.swappiness=10 <br /> <br /> 这样你就将值由60改为10,这可以大大降低系统对于swap的写入,建议内存为512m或更多的朋友采用此方法。如你你发现你对于swap的使用极少,可以将值设为0。这并不会禁止你对swap的使用,而是使你的系统对于swap的写入尽可能的少,同时尽可能多的使用你的实际内存。这对于你在切换应用程序时有着巨大的作用,因为这样的话它们是在物理内存而非swap分区中。 <br /> 如果你想永久得改变这一值,你需要更改 sysctl.conf 文件: <br /> 代碼: <br /> sudo kate /etc/sysctl.conf <br /> <br /> 添加: <br /> vm.swappiness=10 <br /> 到末行,需要重启生效。 <br /> 我2G内存, 把它设置为0</p> linux下持续不断 ping 然后记录日志savagertnullhttp://liyanblog.cn/articles/2016/09/02/1472802242553.html2016-09-02T15:44:02+08:00<p> linux下持续不断 ping 然后记录日志 </p>
<p>nohup ping 192.168.0.1 -c 172800 | awk '{ print $0"\t" strftime("%H:%M:%S",systime()) } '>ping.log &</p>
<p> </p>
<p>其中172800 是一天的描述 。每秒ping一次</p>Linux sar命令详解savagertnullhttp://liyanblog.cn/articles/2015/11/04/1446601780756.html2015-11-04T09:49:40+08:00<div id="cnblogs_post_body">
<p>今天在读《大规模Web服务开发技术》一书的时候,书中提到了sar这个命令,感觉很有用,有必要整理学习一下。(对于一位Linux初学者,不能放过任何一个学习机会 :P)</p>
<p>打开自己的CentOS,敲入“sar”,表示很失望:</p>
<p>[root@localhost ~]# sar <br />bash: sar: command not found</p>
<p>竟然没有安装,不过还好linux下安装还是非常方便的。</p>
<p><span style="color: #0000ff;">[root@localhost ~]# yum install sysstat </span> <br />Loaded plugins: fastestmirror <br />Loading mirror speeds from cached hostfile <br /> * base: mirrors.grandcloud.cn <br /> * extras: mirrors.grandcloud.cn <br /> * updates: mirrors.grandcloud.cn <br />addons | 1.9 kB 00:00 <br />base | 1.1 kB 00:00 <br />extras | 2.1 kB 00:00 <br />updates | 1.9 kB 00:00 <br />updates/primary_db | 255 kB 00:01 <br />Setting up Install Process <br />Resolving Dependencies <br />--> Running transaction check <br />---> Package sysstat.i386 0:7.0.2-11.el5 set to be updated <br />--> Finished Dependency Resolution</p>
<p>Dependencies Resolved</p>
<p>================================================================================ <br /> Package Arch Version Repository Size <br />================================================================================ <br />Installing: <br /> sysstat i386 7.0.2-11.el5 base 182 k</p>
<p>Transaction Summary <br />================================================================================ <br />Install 1 Package(s) <br />Upgrade 0 Package(s)</p>
<p>Total download size: 182 k <br />Is this ok [y/N]: y <br />Downloading Packages: <br />sysstat-7.0.2-11.el5.i386.rpm | 182 kB 00:01 <br />Running rpm_check_debug <br />Running Transaction Test <br />Finished Transaction Test <br />Transaction Test Succeeded <br />Running Transaction <br /> Installing : sysstat 1/1</p>
<p>Installed: <br /> sysstat.i386 0:7.0.2-11.el5 </p>
<p>Complete!</p>
<p>注:Sar是后台进程sadc的前端显示工具,安装名为“sysstat”的包后,sadc就会自动从内核收集报告并保存。</p>
<p>下面对sar的一般用法进行总结,以备忘之。</p>
<p> </p>
<p><strong>sar –u 查看CPU使用率</strong></p>
<p><span style="color: #0000ff;">[root@localhost ~]# sar -u</span> <br />Linux 2.6.18-194.26.1.el5 (localhost) 2012年04月29日</p>
<p>09时39分42秒 LINUX RESTART</p>
<p>09时40分01秒 CPU %user %nice %system %iowait %steal %idle <br />09时50分01秒 all 0.14 0.00 0.58 0.12 0.00 99.15 <br />10时00分01秒 all 0.06 0.00 0.50 0.16 0.00 99.27 <br />10时10分01秒 all 0.11 0.06 0.95 2.58 0.00 96.30 <br />10时20分01秒 all 0.12 0.19 0.82 1.41 0.00 97.46 <br />10时30分01秒 all 0.14 0.00 0.54 0.12 0.00 99.20 <br />10时40分01秒 all 0.15 0.00 0.54 0.16 0.00 99.15 <br />Average: all 0.12 0.04 0.65 0.76 0.00 98.43</p>
<p><br />这里:</p>
<p>%user : 用户模式下消耗的CPU时间的比例;</p>
<p>%nice:通过nice改变了进程调度优先级的进程,在用户模式下消耗的CPU时间的比例;</p>
<p>%system:系统模式下消耗的CPU时间的比例;</p>
<p>%iowait:CPU等待磁盘I/O而导致空闲状态消耗时间的比例;</p>
<p>%steal:利用Xen等操作系统虚拟化技术时,等待其他虚拟CPU计算占用的时间比例;</p>
<p>%idle:CPU没有等待磁盘I/O等的空闲状态消耗的时间比例;</p>
<p><span style="color: #d16349;">注:</span></p>
<p><span style="color: #d16349;">如果 %iowait 的值过高,表示硬盘存在I/O瓶颈 <br />如果 %idle 的值高但系统响应慢时,有可能是 CPU 等待分配内存,此时应加大内存容量 <br />如果 %idle 的值持续低于 10,则系统的 CPU 处理能力相对较低,表明系统中最需要解决的资源是 CPU。</span></p>
<p> </p>
<p><strong>sar –q 查看平均负荷</strong></p>
<p><span style="color: #0000ff;">[root@localhost ~]# sar -q</span> <br />Linux 2.6.18-194.26.1.el5 (localhost) 2012年04月29日</p>
<p>09时39分42秒 LINUX RESTART</p>
<p>09时40分01秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 <br />09时50分01秒 0 152 0.00 0.02 0.05 <br />10时00分01秒 0 152 0.00 0.00 0.00 <br />10时10分01秒 0 156 0.39 0.09 0.03 <br />10时20分01秒 0 151 0.00 0.03 0.01 <br />10时30分01秒 0 151 0.00 0.00 0.00 <br />10时40分01秒 0 151 0.00 0.00 0.00 <br />10时50分01秒 0 151 0.00 0.00 0.00 <br />Average: 0 152 0.06 0.02 0.01</p>
<p>runq-sz: 运行队列的长度(等待运行的进程数) <br />plist-sz: 进程列表中进程(processes)和线程(threads)的数量 <br />ldavg-1: 最后1分钟的系统平均负载(System load average) <br />ldavg-5: 过去5分钟的系统平均负载 <br />ldavg-15: 过去15分钟的系统平均负载</p>
<p><strong>sar –r 查看内存使用情况</strong></p>
<p><span style="color: #0000ff;">[root@localhost ~]# sar -r</span> <br />Linux 2.6.18-194.26.1.el5 (localhost) 2012年04月29日</p>
<p>09时39分42秒 LINUX RESTART</p>
<p>09时40分01秒 kbmemfree kbmemused %memused kbbuffers kbcached kbswpfree kbswpused %swpused kbswpcad <br />09 时50分01秒 481572 553492 53.47 35592 384508 2097144 0 0.00 0 <br />10时00 分01秒 480960 554104 53.53 36032 384512 2097144 0 0.00 0 <br />10时10分01秒 404952 630112 60.88 77764 399432 2097144 0 0.00 0 <br />10时20分01秒 375824 659240 63.69 87356 410892 2097144 0 0.00 0 <br />10时30分01秒 371860 663204 64.07 87756 411064 2097144 0 0.00 0 <br />…</p>
<p>kbmemfree:空闲物理内存量;</p>
<p>kbmemused:使用中的物理内存量;</p>
<p>%memused:物理内存量使用率;</p>
<p>kbbuffers:内核中作为缓冲区使用的物理内存容量;</p>
<p>kbcacheed:内核中作为缓存使用的物理内存容量;</p>
<p>kbswpfree:交换区的空闲容量;</p>
<p>kbswpused:使用中的交换区容量;</p>
<p> </p>
<p><strong>sar –W 查看页面交换发生状况</strong></p>
<p><span style="color: #0000ff;">[root@localhost ~]# sar -W</span></p>
<p>14时30分01秒 pswpin/s pswpout/s <br />14时40分01秒 0.00 0.00 <br />14时50分01秒 0.00 0.00 <br />15时00分01秒 0.00 0.00 <br />Average: 0.00 0.00</p>
<p>…</p>
<p> </p>
<p><strong>sar –b 查看I/O和传送速率的统计信息</strong></p>
<p><span style="color: #0000ff;">[root@localhost ~]# sar -b 1 5</span> <br />Linux 2.6.18-194.26.1.el5 (localhost) 2012年04月29日</p>
<p>15时08分18秒 tps rtps wtps bread/s bwrtn/s <br />15时08分19秒 0.00 0.00 0.00 0.00 0.00 <br />15时08分20秒 0.00 0.00 0.00 0.00 0.00 <br />15时08分21秒 0.00 0.00 0.00 0.00 0.00 <br />15时08分22秒 13.27 0.00 13.27 0.00 220.41 <br />15时08分23秒 0.00 0.00 0.00 0.00 0.00 <br />Average: 2.66 0.00 2.66 0.00 44.17</p>
<p>tps: 每秒钟物理设备的 I/O 传输总量 <br />rtps: 每秒钟从物理设备读入的数据总量 <br />wtps: 每秒钟向物理设备写入的数据总量 <br />bread/s: 每秒钟从物理设备读入的数据量,单位为 块/s <br />bwrtn/s: 每秒钟向物理设备写入的数据量,单位为 块/s</p>
<p> </p>
<p>其他还有:</p>
<p>sar –c 每秒钟创建的进程数</p>
<p>sar -n DEV 输出网络设备状态的统计信息</p>
<p> </p>
<p>注:默认情况是对过去时间段进行数据统计,一般从最近的0:00开始显示。如果想继续查看一天前的报告,可以用-f选项指定保存在/var/log /sa目录下的日志文件中。如果想周期性的查看当前数据可以命令后面加上数字参数,如sar –q 1 3 ,表示:1秒1次,共3次。</p>
</div>Linux下如何进行FTP设置 savagertnullhttp://liyanblog.cn/articles/2015/09/07/1441593548906.html2015-09-07T10:39:09+08:00<h2 style="text-align: center; color: #333; font-size: 18px;">Linux下如何进行FTP设置</h2>
<div class="article-content">
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">目录:</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 9pt; line-height: normal;" lang="EN-US"> </span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">一、Redhat/CentOS</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">安装vsftp软件</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">二、Ubuntu/Debian</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">安装vsftp软件</span></span></p>
<p align="left"><span style="color: #999999; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;"><br /> </span></span></p>
<p align="left"><strong><span style="font-style: normal; font-variant: normal; font-size: 14pt; line-height: normal;"><span style="font-family: 微软雅黑;">一、Redhat/CentOS安装vsftp软件</span></span></strong></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">1.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">更新yum源</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">首先需要更新系统的yum源,便捷工具下载地址:http://help.aliyun.com/manual?spm=0.0.0.0.zJ3dBU&helpId=1692</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">2.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">安装vsftp</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">使用yum命令安装vsftp</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#yum install vsftpd -y</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">3.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">添加ftp帐号和目录</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">先检查一下nologin的位置,通常在/usr/sbin/nologin或者/sbin/nologin下。</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">使用下面的命令创建帐户,该命令指定了/alidata/www/wwwroot为用户pwftp的家目录,您可以自己定义帐户名和目录:</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#useradd -d /alidata/www/wwwroot -s /sbin/nologin pwftp</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">修改该帐户密码:</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#passwd pwftp</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">修改指定目录的权限</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#chown -R pwftp.pwftp /alidata/www/wwwroot</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">4.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">配置vsftp</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">编辑vsftp配置文件,命令如下:</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#vi /etc/vsftpd/vsftpd.conf</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">将配置文件中”anonymous_enable=YES “改为 “anonymous_enable=NO”</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">取消如下配置前的注释符号:</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">local_enable=YES</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">write_enable=YES</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">chroot_local_user=YES</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">保存修改,按ESC键,输入:wq</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">5.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">修改shell配置</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">vi</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">编辑/etc/shells,如果该文件里没有/usr/sbin/nologin或者/sbin/nologin(具体看当前系统配置)则追加进去</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">6.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">启动vsftp服务并测试登录</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">使用命令启动vsftp服务:</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#service vsftpd start</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">然后用帐号pwftp测试下是否可以登陆ftp。目录是/alidata/www/wwwroot。</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;"> </span></span></p>
<p align="left"><strong><span style="font-style: normal; font-variant: normal; font-size: 14pt; line-height: normal;"><span style="font-family: 微软雅黑;">二、Ubuntu/Debian安装vsftp软件</span></span></strong></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">1.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">更新软件源</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">首先需要更新系统的软件源,便捷工具下载地址:http://help.aliyun.com/manual?spm=0.0.0.0.zJ3dBU&helpId=1692</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">2.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">安装vsftp</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">使用apt-get命令安装vsftp</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#apt-get install vsftpd -y</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">3.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">添加ftp帐号和目录</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">先检查一下nologin的位置,通常在/usr/sbin/nologin或者/sbin/nologin下。</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">使用下面的命令创建帐户,该命令指定了/alidata/www/wwwroot为用户pwftp的家目录,您可以自己定义帐户名和目录:</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#useradd -d /alidata/www/wwwroot -s /sbin/nologin pwftp</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">修改该帐户密码:</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#passwd pwftp</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">修改指定目录的权限</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#chown -R pwftp.pwftp /alidata/www/wwwroot</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">4.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">配置vsftp</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">编辑vsftp配置文件,命令如下:</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#vi /etc/vsftpd.conf</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">将配置文件中”anonymous_enable=YES “改为 “anonymous_enable=NO”</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">取消如下配置前的注释符号:</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">local_enable=YES</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">write_enable=YES</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">chroot_local_user=YES</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">chroot_list_enable=YES</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">chroot_list_file=/etc/vsftpd.chroot_list</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">保存退出</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">编辑/etc/vsftpd.chroot_list文件,将ftp的帐户名添加进去,保存退出</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">5.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">修改shell配置</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">vi</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">编辑/etc/shells,如果该文件里没有/usr/sbin/nologin或者/sbin/nologin(具体看当前系统配置)则追加进去</span></span></p>
<p align="left"><span style="font-family: 微软雅黑;"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US">6.</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;">重启vsftp服务并测试登录</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">使用命令启动vsftp服务:</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;" lang="EN-US"><span style="font-family: 微软雅黑;">#service vsftpd restart</span></span></p>
<p align="left"><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal;"><span style="font-family: 微软雅黑;">然后用帐号pwftp测试下是否可以登陆ftp。目录是/alidata/www/wwwroot。</span></span></p>
</div> VPN连上后如何同时上外网savagertnullhttp://liyanblog.cn/articles/2015/04/11/1428758746823.html2015-04-11T21:25:46+08:00<pre>1、去除“在远程网络上使用默认网关”。<br /><br /> VPN拨号属性-》网络-》TCP/IP-》属性-》高级-》IP设置,<br /> 去除“在远程网络上使用默认网关”即可。<br /> 重新VPN拨号,然后PING外网测试,可以看到即使在VPN的网络环境下,<br /> 你还是可以连接到公网的,但此时你不能正常连接VPN内的设备。<br /><br />2、在VPN联通后,在命令行输入IPCONFIG /ALL 看到你在VPN网络中所获取的地址<br /> 如:192.168.2.3<br /><br /> 在命令行下加入你要访问的网络及网关地址,(也就是将你要链接的内网地址加入route,也就是下面红色部分)<br /> 比如对方网络为192.168.1.0 255.255.255.0,所获取的网关地址为192.168.2.3<br /><br /> route add <span style="color: #ff0000;">192.168.1.0</span> mask 255.255.255.0 192.168.2.3 <br /><br />现在再连接VPN内的设备和访问公网,应该没有问题了</pre>