工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.wdlinux.cn 注册 | 登陆
浏览模式: 标准 | 列表分类:linux

nginx的一些记录

 

一直是用apache,也早早就听说过nginx的性能是如何如何的优越,却也一直没有亲自测试过.
最近有一台机的负载好大,CPU的资源,基本上是用完.

后用了nginx来试,而且,也把原来的PHP程序换成了CGI(因为这台机的功能,代码都很简单),这个nginx的编译,也是优化了CGI的编译的.速度确实快了好多.
主要原因,一是用nginx,且用了专门优化了CGI的,代码也换了,而且,对访问方式也作了一些调整


记录一些数据:
 所有连接 开始连接 正在连接 结束连接
apache 15万   2-4K   (2-5K) (120K)
nginx 10万   1K   60K    70K

有些值相差是比较大,我想这和我的设置时间有关
apache的连接时间都很短,而nginx的是apache的10倍差不多

不过从测试的结果来看,nginx的响应上,确实比apache快得多.
不过,流量或连接大到一定大的时候.nginx会直接丢掉,而apache等待的时间会长一点
所以,用nginx时,会丢掉一连接,从一些数据统计中,可以看到

硬件配置,双至强3.0,4G内存

 

configure: error: libjpeg.(a|so) not found

./configure --prefix=/www/servers/php --with-apxs2=/www/servers/httpd20/bin/apxs --with-mcrypt=/usr --with-gd=/usr --enable-gd-native-ttf --with-jpeg-dir=/usr --with-png-dir=/usr --with-ttf --with-zlib --with-freetype-dir=/usr --with-mysql=/www/servers/mysql --with-iconv --enable-mbstring --enable-ftp

configure: error: libjpeg.(a|so) not found
ln -sf libjpeg.so.62.0.0 libjpeg.so


configure: error: libpng.(a|so) not found.
yum install libpng-devel

centos 裁剪,定制

mkdir -p /storage/kickstart_build/isolinux/CentOS
mkdir -p /storage/kickstart_build/isolinux/ks
mkdir -p /storage/kickstart_build/isolinux/image
mkdir -p /storage/kickstart_build/isolinux/repodata
mkdir /storage/kickstart_build/all_rpms


cp -rp /media/isolinux/* /storage/kickstart_build/isolinux
cp /media/.discinfo /storage/kickstart_build/isolinux
cp -rp /media/repodata/comps.xml /storage/kickstart_build
cp -rp /media/CentOS/* /storage/kickstart_build/all_rpms


cd /storage/kickstart_build
chmod +x pare.pl
cd /storage/kickstart_build/isolinux/CentOS
/storage/kickstart_build/pare.pl /storage/kickstart_build/all_rpms i386


cd /storage/kickstart_build/isolinux/CentOS
mkdir /tmp/testdb
rpm --initdb --dbpath /tmp/testdb
rpm --test --dbpath /tmp/testdb -Uvh *.rpm

cd /storage/kickstart_build/isolinux
declare -x discinfo=`head -1 .discinfo`
createrepo -u "media://$discinfo" -g /storage/kickstart_build/comps.xml .

cd /storage/kickstart_build
mkisofs -o MYOS.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T isolinux/
 

1 安装一个简洁的系统
2 安装 anaconda,anaconda-runtime
3 mount,mkdir /centos,cp光盘内所有到/centos
4 剪裁软件包,可根据install.log,放到 /centos/centos,也可直接替换CentOS
5 cd /centos,createrepo -g repodata/coms.xml .  执行两次
6 cp anaconda-ks.cfg ks.cfg
 vi isolinux.cfg
default linux > default linux ks=cdrom:/ks.cfg
7 make iso
mkisofs -o MYOS.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T centos/


 

运行perl程序出现: : bad interpreter: No such file or directory

运行perl程序时出现: bad interpreter: No such file or directory 这样的错误提示.

原因:这是在windows下通过写字板或其他编辑工具编写的perl程序,windows环境下每行的结束符是CRLF(Carriage-Return, Line-Feed). 在linux下结束符却是LF,所以每行多了一个CR串.
处理:通过以下脚本对每行结束符进行替换

#!/usr/bin/perl

die "Usage: $0 < files >\n" unless @ARGV;

for $file (@ARGV)
{
    open IN, $file or die "$0: Cannot open $file for input!\n";

    my @lines = <IN>;

    close IN;
    open OUT, "> $file" or die "$0: Cannot open $file for output!\n";

    s/\r$// for @lines;
    print OUT for @lines;
}

Privilege separation user sshd does not exist

启动sshd提示:

Privilege separation user sshd does not exist

google了一下,找到了解决方法。

方法一(推荐):
修改/etc/passwd文件,在其中加入
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
或者
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
我加入的是:
sshd:x:109:65534::/var/run/sshd:/usr/sbin/nologin
参考
http://www.unixguide.net/comments/sun/ssh_installation.shtml/37.shtml
http://www.gipsky.com/modules/newbb/viewtopic.php?topic_id=966

方法二(不推荐):
修改/etc/ssh/sshd_config文件
将其中
UsePrivilegeSeparation yes
修改为
UsePrivilegeSeparation no
虽然能解决问题,但是降低了ssh的安全级别。

解开RPM包

rpm2cpio a.rpm | cpio --extract --make-directories

 

2009.07.03

rpm -ivh kchmviewer-3.1-1.el5.5.x86_64.rpm --prefix=/home/chc/rpms/tmp

因为rpm实际上使用cpio格式打包的,因此可以先转成cpio然后解压,如下所示:
rpm2cpio kchmviewer-3.1-1.el5.5.x86_64.rpm | cpio -div

rhel5

Installing PEAR environment:      /www/servers/php/lib/php/
/home/r00t/php-5.2.6/sapi/cli/php: error while loading shared libraries: /usr/local/gd/lib/libgd.so.2: cannot rest
ore segment prot after reloc: Permission denied
make[1]: *** [install-pear-installer] Error 127
make: *** [install-pear] Error 2


Nov 14 16:54:45 localhost setroubleshoot:      SELinux is preventing /home/r00t/php-5.2.6/conftest from loading /u
sr/local/gd/lib/libgd.so.2.0.0 which requires text relocation.      For complete SELinux messages. run sealert -l7f26cea9-91e8-4b3a-93e0-6298e6c4e265


failed to connect to server


chcon -t textrel_shlib_t /usr/local/gd/lib/libgd.so.2

 

###
checking for MySQL UNIX socket location... /tmp/mysql.sock
checking for mysql_close in -lmysqlclient_r... no
checking for mysql_error in -lmysqlclient_r... no
configure: error: mysql configure failed. Please check config.log for more information.

没找到解决办法,把PHP换为4的就可以了

 

linux下硬盘检测工具

linux下硬盘检测工具: smartmontools

工具主页: http://smartmontools.sourceforge.net/

Smartmontools for SCSI硬盘: http://smartmontools.sourceforge.net/smartmontools_scsi.html

smartctl命令参数列表:

The following options are currently available for SCSI disks and tape drives unless otherwise noted:

  • -a | --all : equivalent to the combination -i -H -A -l error -l selftest options invoked in that order.

  • -A | --attributes : outputs the current device temperature, trip temperature, the number of elements in the grown defect list (GLIST) and data from the start-stop log page. Outputs some vendor specific information if available.

  • -C | --captive : used in conjunction with -t short or -t long options to do short or long self tests in the foreground. [Has no effect on tape drives.]

  • -d TYPE | --device=TYPE where TYPE is "ata", "scsi", "sat", "marvell", "3ware,N", "hpt,L/N[,M]" or "cciss,N". Overrides utility's guess about the class of the device which is based on the form of the nominated device's name.

  • -h | --help : outputs lengthy usage message and exits without any other action.

  • -H | --health : outputs single device health metric determined by the device manufacturer. This will be "OK" or a failure message.

  • -i | --info : outputs device identification information (derived from a SCSI INQUIRY command) and whether the device supports SMART (and temperature warnings) and if those facilities are currently enabled. The type of transport (e.g. FC or SAS) is also reported, if available. Some users have reported disks that report the wrong transport.

  • -l TYPE | --log=TYPE where TYPE is either "background", "selftest" or "error". Decodes are outputs the requested log. Note that --all does not include --log=background .

  • -q TYPE | --quietmode=TYPE where TYPE is either "silent" or "errorsonly". When the type is silent then nothing is output to the console but the exit status is set (so it is suitable for scripts). For "errorsonly" only errors are output to the console. The exit status is always set. [See the smartctl man page.]

  • -r TYPE | --report=TYPE where TYPE is either "ioctl[,<n>]" or "scsiioctl[,<n>]". Turns on low level debugging of issued commands and responses. These commands are issued through a system command called an "ioctl" in Unix. The debug can be for all issued commands (i.e. "ioctl") or only SCSI commands ("scsiioctl"). Optionally the TYPE can have a comma and a number post pended to increase the volume of debug. See this section for more details.

  • -s VALUE | --smart=VALUE where VALUE is either "on" or "off". Enables or disables SMART monitoring (and temperature warnings).

  • -S VALUE | --saveauto=VALUE where VALUE is either "on" or "off". Controls whether the error log values are preserved across device power cycles.

  • -t TEST | --test=TEST where TEST is either "offline", "short" or "long". Despite its name "offline" is a short foreground test that all SCSI devices should support. A "short" self test is typically 2 minutes or less. A "long" self test will be considerably longer than 2 minutes, depending on the size of the media. The estimated time that a "long" self test will take is printed after the "selftest" log (i.e. with '-l selftest' or '-a')

  • -V | --version : outputs the smartctl version number (including the cvs version of all its source files) and build information then exits without any other action.

  • -X | --abort : will terminate a background short or long self test. Usually the self test log notes that a self test has been aborted. [Has no effect on tape drives.]

简单用法:
1、smartctl -a  <device>         检查该设备是否已经打开SMART技术。
2、smartctl -s on <device>    如果没有打开SMART技术,使用该命令打开SMART技术。
3、smartctl -t short <device>    后台检测硬盘,消耗时间短;
      smartctl -t long <device>      后台检测硬盘,消耗时间长;
      smartctl -C -t short <device> 前台检测硬盘,消耗时间短;
      smartctl -C -t long <device>  前台检测硬盘,消耗时间长。
其实就是利用硬盘SMART的自检程序。
4、smartctl -X <device>  中断后台检测硬盘。
5、smartctl -l selftest <device>  显示硬盘检测日志。
6、smartctl -l error <device> 显示硬盘错误汇总。

或用 badblocks 工具