Skip to content


tomcat 内存溢出

装完nginx环境重启后,tomcat不能启动 tail tomcat/logs/catalina.out

2008-8-25 15:55:37 org.apache.tomcat.util.net.JIoEndpoint processSocket 严重: Error allocating socket processor java.lang.OutOfMemoryError: Java heap space         at java.lang.Thread.(Thread.java:208)         at org.apache.tomcat.util.net.JIoEndpoint$Worker.start(JIoEndpoint.java:468)         at org.apache.tomcat.util.net.JIoEndpoint.newWorkerThread(JIoEndpoint.java:681) ….   

free -m 看了一下内存从2G变成了1G,让机房重插下内存后一切正常。

Posted in Tomcat, 技术.

Tagged with , .


mysql5.0升级至mysql5.1 需执行mysql_upgrade

http://dev.mysql.com/doc/refman/5.1/zh/installing.html#upgrading-from-5-0

Posted in Mysql, 技术.

Tagged with .


mysqlhotcopy备份数据库

首先是通过cpan自动安装

shell>perl -MCPAN -e shell cpan>install DBI cpan>install DBD::mysql ( 安装这个时test通不过) cpan>q (退出)

cpan手动安装

unset LANG cd ~/.cpan/build/DBI-1.607 perl Makefile.PL make test make install cd ../DBD-mysql-4.007 perl Makefile.PL –mysql_config=/opt/mysql/bin/mysql_config make make test

错误

 failed: Can’t load ‘/root/.cpan/build/DBD-mysql-4.007/blib/arch/auto/DBD/mysql/mysql.so’ ln -s /opt/mysql/lib/mysql/* /usr/lib/ make test

错误

/root/.cpan/build/DBD-mysql-4.007/blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: make realclean perl Makefile.PL –mysql_config=/opt/mysql/bin/mysql_config –libs=”-L/opt/mysql/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm”

错误

all skipped: ERROR: Access denied for user ‘root’@’localhost’ (using password: NO). Can’t continue test perl Makefile.PL –mysql_config=/opt/mysql/bin/mysql_config –libs=”-L/opt/mysql/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm” –testpassword=123456 make make test

错误

t/00base………………..String found where operator expected at t/00base.t line 20, near “BAIL_OUT “Unable to load DBI””         (Do you need to predeclare BAIL_OUT?) make realclean perl Makefile.PL –mysql_config=/opt/mysql/bin/mysql_config –libs=”-L/opt/mysql/lib/mysql -lmysqlclient -lz” –cflags=-I/opt/mysql/include/mysql –testhost=localhost –testsocket=/opt/mysql/mysql.sock –testdb=bugdb –testuser=root –testpassword=123456 make make test

错误

t/00base………………..String found where operator expected at t/00base.t line 20, near “BAIL_OUT “Unable to load DBI””         (Do you need to predeclare BAIL_OUT?)

(在另一机器上没出这个错)-_-*!!! 直接make install

检察是否安装成功

shell>perldoc DBI shell>perldoc DBI::mysql

从源码装 http://search.cpan.org/ http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql.pm#INSTALLATION

gzip -cd DBI-(version).tar.gz | tar xf – cd DBI-(version) perl Makefile.PL make make test make install cd .. gzip -cd Data-ShowTable-(version).tar.gz | tar xf – cd Data-ShowTable-3.3 perl Makefile.PL make make install

Data-ShowTable-3.3.tar.gz 安装时有个错误 *** ERROR: Unterminated I at line 724 in file ShowTable.pm 用以下方法解决 http://lists.mysql.com/perl/1015

cd .. gzip -cd DBD-mysql-(version)-tar.gz | tar xf – cd DBD-mysql-(version) perl Makefile.PL –mysql_config=/opt/mysql/bin/mysql_config –libs=”-L/opt/mysql/lib/mysql -lmysqlclient -lcrypt -lnsl -lm -lz” –cflags=-I/opt/mysql/include/mysql –testsocket=/opt/mysql/mysql.sock –testhost=localhost –testuser=root –testpassword=****** make make test make install

在数据库段分配一个专门用于备份的用户

mysql> grant select,reload,lock tables on *.* to ‘hotcopyer’@’localhost’ identified by ‘123456’; mysql> grant insert on hotcopy.checkpoint to hotcopyer@’localhost’; mysql> flush privileges;

建表记录下历史

create database hotcopy; create table checkpoint(time_stamp timestamp not null,src varchar(32),dest varchar(60), msg varchar(255)); cd /opt/mysql/bin/ ./mysqlhotcopy test_ucenter –noindices –allowold –checkpoint hotcopy.checkpoint –addtodest /home/admin –user=hotcopyer –password=123456

你也可以将备份用的用户和密码放在~/.my.cnf下

vi /root/.my.cnf

[client] host=localhost user=hotcopyer password=123456

我在运行mysqlhotcopy时会遇到”has gone away”错误,数据库为25张表,800M大小。

DBD::mysql::db do failed: MySQL server has gone away at /opt/mysql/bin/mysqlhotcopy line 513.

看了下备份执行时间为10S左右,和我my.cnf中的wait timeout一样,调大max_allowed_packet和wait_timeout参数后没有错误。 修改下配置为 vi /opt/mysql/my.cnf

max_allowed_packet = 4M #字段最大的可能值 wait_timeout = 60

以上参数放在my.cnf的[mysqlhotcopy]和/root/.my.cnf中的[client]无效。 wait_timeout = 60可能会占用太多的connection。 我将它改为 10,然后修改mysqlhostcopy脚本来解决”has gone away”错误

#vi /opt/mysql/bin/mysqlhotcopy 复制第177行的mysql连接至513行

my $dbh = DBI->connect(“dbi:mysql:$dsn;mysql_read_default_group=mysqlhotcopy”,                         $opt{user}, $opt{password}, {     RaiseError => 1,     PrintError => 0,     AutoCommit => 1, });

分析: mysqlhotcopy时会先连上数据库,然后lock table再复制数据库文件,最后unlock table, 由于复制数据文件会占用一定时间,所以再次执行unlock table时可能已超过设置的wait timeout时间, 我这里将它再连接一次就不会报错啦。 如用到checkpoint,那492行也要插一次

结论: mysqlhotcopy比较适合备份小型一点(1G以下)的数据库,还需留意下table lock wait timeout参数

定时及远程备份参考 使用crontab+ssh每天自动完全备份mysql数据  

Posted in cpan, Mysql, 备份, 技术.

Tagged with , , , , , .


linux下最·容易的增量备份,tar增量备份

linux备份真是太方便了,其实我们常用的tar就是很好的增量备份软件

使用 tar -g 参数进行增量备份实验

完整备份:

#建立测试路径与档案 mkdir test touch test/{a,b,c}; 在test下生成三个文件

#执行完整备份 tar -g snapshot -zcf backup_full.tar.gz test

#查看 tarball 内容 tar ztf backup_full.tar.gz test/ test/a test/b test/c

增量备份:

#新增一个档案 touch test/d

#执行第一次的增量备份 (注意 tarball 档名) tar -g snapshot -zcf backup_incremental_1.tar.gz test

#查看 tarball 内容 tar ztf backup_incremental_1.tar.gz test/ test/d

#新增一个档案, 并异动一个档案内容 touch test/e echo 123 > test/a

#执行第二次的增量备份 (注意 tarball 档名) tar -g snapshot -zcf backup_incremental_2.tar.gz test

#查看 tarball 内容 tar ztf backup_incremental_2.tar.gz test/ test/a test/e

还原备份资料:

#清空测试资料 rm -rf test

#开始进行资料还原 tar zxf backup_full.tar.gz tar zxf backup_incremental_1.tar.gz tar zxf backup_incremental_2.tar.gz

#查看测试资料 ls test a b c d e

使用 tar -u 参数进行增量备份

第一次备份:

#建立测试路径与档案 mkdir test touch test/a test/b test/c

#备份资料 tar zcf backup.tar.gz test

#查看 tarball 内容 tar ztf backup.tar.gz test/ test/a test/b test/c

增量备份:

#新增一个档案, 并异动一个档案内容 touch test/d echo 123 > test/a

#执行增量备份 (-u 参数只能执行於未压缩的 tarball) gunzip backup.tar.gz tar uf backup.tar test gzip backup.tar

#查看 tarball 内容 tar ztf backup.tar.gz test/ test/a test/b test/c test/ test/a test/d

还原备份资料:

#清除测试资料 rm -rf test

#解包 tarball tar zxf backup.tar.gz

#查看测试资料 ls test a b c d

Posted in linux 维护优化.

Tagged with , , , , .


用php控制word的打印边距

将生成的word文件另存为htm,用文本比较工具(如svn的diff)差看差异,就可以找着关键点了。

<!– @page Section1  {size:595.3pt 841.9pt;  margin:33.0pt 33.15pt 33.0pt 33.15pt; } div.Section1  {page:Section1;} ……

…….
…….

Posted in Others, 技术.

Tagged with , , , .


nginx+php(FCGI)+xcache+mysql on as4

一、系统环境 linux为redhat as4 全新安装,不带默认万维网服务,带开发工具和系统工具,加上mrtg、net-snmp-utils、sysstat

二、下载安装文件

mkdir src cd src vi lemp_down_list

输入以下内容

http://www.zlib.net/zlib-1.2.3.tar.gz http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.31.tar.gz ftp://xmlsoft.org/libxml2/libxml2-2.6.32.tar.gz ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.12.tar.gz http://fontconfig.org/release/fontconfig-2.6.0.tar.gz http://www.libgd.org/releases/gd-2.0.35.tar.bz2 http://ftp.gnu.org/pub/gnu/gettext/gettext-0.17.tar.gz http://mirror.optus.net/sourceforge/m/mc/mcrypt/libmcrypt-2.5.8.tar.gz http://mirror.x10.com/mirror/mysql/Downloads/MySQL-5.1/mysql-5.1.26-rc.tar.gz http://www.monkey.org/~provos/libevent-1.4.5-stable.tar.gz http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz http://www.php.net/get/php-5.2.6.tar.gz/from/this/mirror http://php-fpm.anight.org/downloads/head/php-5.2.6-fpm-0.5.8.diff.gz http://pecl.php.net/get/memcache-2.2.3.tgz http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz http://sysoev.ru/nginx/nginx-0.6.32.tar.gz

开始下载

wget -i lemp_down_list

三、安装基本包

A1、安装zlib

tar xzvf zlib-1.2.3.tar.gz cd zlib-1.2.3 ./configure –prefix=/usr/local/zlib make make install

A2、安装freetype

tar xzvf freetype-2.3.5.tar.gz cd freetype-2.3.5 ./configure –prefix=/usr/local/freetype make make install

A3、安装libpng

tar xzvf libpng-1.2.29.tar.gz tar xzvf libpng-1.2.31.tar.gz cd libpng-1.2.29 cd libpng-1.3.31 cp scripts/makefile.std makefile make test make install

A4、# tar -zxf libxml2-2.6.32.tar.gz

# cd libxml2-2.6.32 # ./configure –prefix=/usr/local/libxml # make; make install echo ‘/usr/local/libxml/lib’ >> /etc/ld.so.conf ldconfig -v

A5、安装 libxslt

# tar -zxf libxslt-1.1.24.tar.gz # cd libxslt-1.1.24 # ./configure –prefix=/usr/local/libxslt –with-libxml-prefix=/usr/local/libxml # make; make install

A6、安装jpeg

# mkdir -p /usr/local/jpeg6/{,bin,lib,include,man/man1,man1} # tar xzvf jpegsrc.v6b.tar.gz # cd jpeg-6b # ./configure –prefix=/usr/local/jpeg6 –enable-shared –enable-static # make

如果安装提示没有libtool,先安装libtool 然后进入jpeg-6b的源码目录,然后执行以下步骤,

# make install

在64位系统安装时使用以下命令

# CFLAGS=”-O3 -fPIC” ./configure –prefix=/usr/local/jpeg6 –enable-shared –enable-static # make # make install # make install-lib

如果安装PHP5,必需安装libxml2

A7、安装iconv

tar zxvf libiconv-1.12.tar.gc cd libiconv-1.12 ./configure –prefix=/usr/local/libiconv make make install ln -s /usr/local/libiconv/lib/* /usr/lib ldconfig -v

A8、安装fontconfig

tar xzvf fontconfig-2.5.0.tar.gz tar xzvf fontconfig-2.6.0.tar.gz cd fontconfig-2.5.0 cd fontconfig-2.6.0 ./configure –prefix=/usr/local/fontconfig –disable-docs –sysconfdir=/etc –mandir=/usr/share/man –with-freetype-config=/usr/local/freetype/bin/freetype-config

错误: /usr/local/fontconfig/bin/fc-cache: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory 解决:

ln -s /usr/local/lib/libionv.so.2 /usr/lib/libiconv.so.2

错误: checking for LIBXML2… configure: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. 解决:

wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz tar zxvf pkg-config-0.23.tar.gz cd pkg-config-0.23 ./configure make make install

错误: fcxml.c: In function FcConfigMessage': fcxml.c:484: error:va_start’ used in function with fixed args 解决:

export LIBXML2_CFLAGS=-I/usr/local/libxml/include/libxml2 export LIBXML2_LIBS=/usr/local/libxml/lib/libxml2.so

编译参数最后加 –enable-libxml2 再次config make make install

A9、安装GD

tar xzvf gd-2.0.35.tar.gz cd gd-2.0.35 ./configure –prefix=/usr/local/gd2 –with-jpeg=/usr/local/jpeg6/ –with-png –with-zlib –with-freetype=/usr/local/freetype/ –with-fontconfig=/usr/local/fontconfig make make install

错误: configure.ac:64: error: possibly undefined macro: AM_ICONV If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. 解决:

cd .. tar zxvf gettext-0.17.tar.gz cd gettext-0.17 ./configure –prefix=/usr/local/gettext –disable-java –disable-native-java make make install

/bin/sed: can’t read /lib/libattr.la: No such file or directory

ln -s /usr/lib/* /lib/

再安装gettext 再安装gd

X86 64位LINUX下安装GD的注意事项
错误提示: /usr/bin/ld: /usr/local/lib/libjpeg.a(jcapimin.o): relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC 进入Jpeg目录 CFLAGS=”-O3 -fPIC” ./configure make make install-lib 编译前需指定为64位编译模式,否则会出现以下错误: /usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32against `a local symbol’ can not be used when making a shared object;recompile with -fPIC /usr/local/lib/libz.a: could not read symbols: Bad value 解决办法 : 重新安装 zlib-1.2.3.tar.gz tar -zxvf zlib-1.2.3.tar.gz cd zlib-1.2.3 ./configure vi Makefile 找到 CFLAGS=-O3 -DUSE_MMAP 在后面加入-fPIC,即变成CFLAGS=-O3 -DUSE_MMAP -fPIC 接下面步骤 make make install nfig.so -L/usr/lib64 /usr/local/freetype/lib/libfreetype.so -lpng -lz -lm -Wl,–rpath -Wl,/usr/local/freetype/lib -Wl,-soname -Wl,libgd.so.2 -o .libs/libgd.so.2.0.0 /usr/bin/ld: /usr/local/lib/libpng.a(png.o): relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libpng.a: could not read symbols: Bad value collect2: ld returned 1 exit status 重新安装libpng;删除解压文件,重新解压 cp scripts/makefile.linux makefile vi Makefile 找到 CFLAGS=后加上-fPIC make test make install 再重新安接gd; vi Makefile 找到 CFLAGS=后加上-fPIC A10、安装 libmcrypt tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure –prefix=/usr/local/libmcrypt make make install 四、安装mysql 1.mysql安装 http://dev.mysql.com/doc/refman/5.1/en/index.html http://dev.mysql.com/doc/refman/5.1/en/installing-source.html /usr/sbin/groupadd website # 管理组 /usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql mysql -d /dev/null -s /sbin/nologin tar zxvf mysql-5.1.26-rc.tar.gz cd mysql-5.1.26-rc/ CFLAGS=”-O3″ CXX=gcc CXXFLAGS=”-O3 -felide-constructors -fno-exceptions -fno-rtti” ./configure –prefix=/opt/mysql –localstatedir=/opt/mysql/var –sysconfdir=/opt/mysql –without-debug –with-unix-socket-path=/opt/mysql/mysql.sock –with-big-tables –with-charset=gbk –with-collation=gbk_chinese_ci –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –with-extra-charsets=gbk,gb2312,utf8 –with-pthread –enable-thread-safe-client –with-innodb #–with-innodb时,mysql的data存放于/opt/mysql/var 下,无些参数时为/opt/mysql/data下 默认为/var/lib/mysql (在/etc/my.cnf中) 错误: /usr/bin/ld: cannot find -lncurses collect2: ld returned 1 exit status 解决: # yum -y install ncurses-devel make make install #512M内存和web共用 cp support-files/my-medium.cnf /opt/mysql/my.cnf #2G内存和web共用 #cp support-files/my-large.cnf /opt/mysql/my.cnf #删除默认的my.cnf rm /etc/my.cnf /opt/mysql/bin/mysql_install_db –defaults-file=/opt/mysql/my.cnf –basedir=/opt/mysql –datadir=/opt/mysql/var –user=mysql –pid-file=/opt/mysql/var/mysql.pid –skip-locking –socket=/opt/mysql/mysql.sock chmod +w /opt/mysql chown -R mysql:mysql /opt/mysql cd .. chgrp website /opt/mysql/my.cnf chmod 0664 /opt/mysql/my.cnf 2.自动运行mysql http://dev.mysql.com/doc/refman/5.1/en/automatic-start.html cp support-files/mysql.server /opt/mysql/bin/ chmod 755 /opt/mysql/bin/mysql.server #自动启动 cp support-files/mysql.server /etc/init.d/mysql chmod 755 /etc/init.d/mysql chkconfig –add mysql #某些linux上 #chkconfig –level 345 mysql on #开启服务 /etc/init.d/mysql start #关闭服务 #/etc/init.d/mysql stop 3.手动开启/关闭服务 /bin/sh /opt/mysql/bin/mysqld_safe –user=mysql & /opt/mysql/bin/mysqladmin -uroot -p shutdown Enter password: 4.mysql修改密码 #123456为密码 /opt/mysql/bin/mysqladmin -uroot password 123456 #测试密码 /opt/mysql/bin/mysql -uroot -p Enter password: 5.编辑my.cnf vi /opt/mysql/my.cnf 关闭log_bin 将log-bin=mysql-bin注释掉,需要热备份或主从服务器的可以保留,开启后会占很多空间 开启innodb 将innodb开头的注释去掉,除了innodb_log_arch_dir参数,开启它将无法启动msyql 修改完成后重启mysql服务 五、安装memcached 官方网站 http://www.monkey.org/~provos/libevent/ http://www.danga.com/memcached/download.bml 1.下载 wget http://www.monkey.org/~provos/libevent-1.4.5-stable.tar.gz wget http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz 2.安装libevent # tar zxvf libevent-1.4.5-stable.tar.gz # cd libevent-1.4.5 # ./configure –prefix=/usr # make # make install 3.安装memcached tar zxvf memcached-1.2.5.tar.gz cd memcached-1.2.5 ./configure –prefix=/opt/memcached –with-libevent=/usr make make install 4.启动Memcache的服务器端 # /opt/memcached/bin/memcached -d -m 100 -u root -l 127.0.0.1-p 12000 -c 256 -P /tmp/memcached.pid /opt/memcached/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory ========================== error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory #cp /usr/lib/libevent* /usr/lib64/ -R ========================== echo /usr/local/libevent/lib >> /etc/ld.so.conf ldconfig -d选项是启动一个守护进程, -m是分配给Memcache使用的内存数量,单位是MB,我这里是100MB, -u是运行Memcache的用户,我这里是root, -l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.54.96, -p是设置Memcache监听的端口,我这里设置了12000,最好是1024以上的端口, -c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定, -P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid, 5.如果要结束Memcache进程,执行: # kill `cat /tmp/memcached.pid` 也可以启动多个守护进程,不过端口不能重复。 5.图形介面监控memcached http://www.ooso.net/index.php/archives/462 六。安装php 1.php 补丁安装 tar zxvf php-5.2.6.tar.gz gzip -cd php-5.2.6-fpm-0.5.8.diff.gz | patch -d php-5.2.6 -p1 2.php安装 cd php-5.2.6 ./configure –prefix=/opt/php –with-config-file-path=/opt/php/etc –with-mysql=/opt/mysql –with-mysqli=/opt/mysql/bin/mysql_config –with-iconv-dir=/usr/local/libiconv –with-freetype-dir=/usr/local/freetype/ –with-jpeg-dir=/usr/local/jpeg6/ –with-png-dir –with-zlib=/usr/local/zlib/ –with-libxml-dir=/usr/local/libxml/ –enable-xml –enable-zend-multibyte –disable-debug –disable-ipv6 –disable-rpath –enable-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-fpm –enable-force-cgi-redirect –enable-mbstring –with-mcrypt=/usr/local/libmcrypt/ –with-gd –enable-gd-native-ttf 错误: checking for xml2-config path… configure: error: xml2-config not found. 解决: 编译参数最后加上 –with-xml-config=/usr/local/libxml/bin/xml2-config 错误: configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/ 解决: yum install curl-devel sed -i ‘s#-lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt#& -liconv#’ Makefile make make install cp php.ini-dist /opt/php/etc/php.ini chgrp website /opt/php/etc/php.ini chmod 0664 /opt/php/etc/php.ini chgrp website /opt/php/etc/php-fpm.conf chmod 0664 /opt/php/etc/php-fpm.conf cd ../ 3.编译安装PHP5扩展模块 tar zxvf memcache-2.2.3.tgz cd memcache-2.2.3/ /opt/php/bin/phpize 错误: Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable is set correctly and then rerun this script. 解决: # wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz # tar -zvxf m4-1.4.9.tar.gz # cd m4-1.4.9/ # ./configure && make && make install # cd ../ # wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.gz # tar -zvxf autoconf-2.61.tar.gz # cd autoconf-2.61/ # ./configure # make # make install 记得要用2.61 的autoconf-2.62会有错误,郁闷死了 Zend Extension Api No: 220060519 configure.in:77: warning: AC_CACHE_VAL(lt_prog_compiler_static_works, …): suspicious cache-id, must contain _cv_ to be cached ../../lib/autoconf/general.m4:1973: AC_CACHE_VAL is expanded from… ../../lib/autoconf/general.m4:1993: AC_CACHE_CHECK is expanded from… ./configure –with-php-config=/opt/php/bin/php-config make make install cd ../ tar zxvf xcache-1.2.2.tar.gz cd xcache-1.2.2/ /opt/php/bin/phpize ./configure –with-php-config=/opt/php/bin/php-config –enable-xcache –enable-xcache-coverager –enable-inline-optimization –disable-debug make make install cd ../ 4.修改php.ini文件 A 查找/opt/php/etc/php.ini中的extension_dir = “./” 修改为extension_dir = “/opt/php/lib/php/extensions/no-debug-non-zts-20060613/” 并在此行后增加以下几行,然后保存: extension = “memcache.so” B php.ini中 cgi.fix_pathinfo=1; 这样php-cgi方能正常使用SCRIPT_FILENAME这个变量,默认就是1 C 在php.ini尾部增加 [xcache-common] zend_extension = /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so [xcache.admin] xcache.admin.user = “xcache” ; xcache.admin.pass = md5($yourpasswd) ;如何生成md5密码: echo -n “password”| md5sum xcache.admin.pass = “0563ff87afd961147cc3b89fec551a87” #password is c1gstudio [xcache] xcache.cacher = On xcache.shm_scheme = “mmap” xcache.size = 32M ; cpu number (cat /proc/cpuinfo |grep -c processor) xcache.count = 2 xcache.slots = 8k xcache.ttl = 0 xcache.gc_interval = 0 xcache.var_size = 2M ; cpu number (cat /proc/cpuinfo |grep -c processor) xcache.var_count = 2 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_interval = 300 xcache.readonly_protection = Off xcache.mmap_path = “/dev/zero” D 让session使用memcached session.save_handler = memcache session.save_path = “tcp://127.0.0.1:12000” 5.创建用户组 /usr/sbin/groupadd www -g 48 /usr/sbin/useradd -g website www -d /dev/null -s /sbin/nologin mkdir -p /opt/htdocs/www/nginx chmod -R 0775 /opt/htdocs/ chown -R www:website /opt/htdocs/ 6.创建php-fpm配置文件 (php-fpm是为PHP打的一个FastCGI管理补丁,可以平滑变更php.ini配置而无需重启php-cgi): 在/opt/php/etc/目录中创建php-fpm.conf文件: rm -f /opt/php/etc/php-fpm.conf vi /opt/php/etc/php-fpm.conf All relative paths in this config are relative to php’s install prefix
Pid file /opt/php/logs/php-fpm.pid Error log file /opt/php/logs/php-fpm.log Log level notice When this amount of php processes exited with SIGSEGV or SIGBUS … 10 … in a less than this interval of time, a graceful restart will be initiated. Useful to work around accidental curruptions in accelerator’s shared memory. 1m Time limit on waiting child’s reaction on signals from master 5s Set to ‘no’ to debug fpm yes
Name of pool. Used in logs and stats. default Address to accept fastcgi requests on. Valid syntax is ‘ip.ad.re.ss:port’ or just ‘port’ or ‘/path/to/unix/socket’ 127.0.0.1:9000 Set listen(2) backlog -1 Set permissions for unix socket, if one used. In Linux read/write permissions must be set in order to allow connections from web server. Many BSD-derrived systems allow connections regardless of permissions. 0666 Additional php.ini defines, specific to this pool of workers. /usr/sbin/sendmail -t -i 0 Unix user of processes www Unix group of processes website Process manager settings Sets style of controling worker process count. Valid values are ‘static’ and ‘apache-like’ static Sets the limit on the number of simultaneous requests that will be served. Equivalent to Apache MaxClients directive. Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi Used with any pm_style. 20 Settings group for ‘apache-like’ pm style Sets the number of server processes created on startup. Used only when ‘apache-like’ pm_style is selected 20 Sets the desired minimum number of idle server processes. Used only when ‘apache-like’ pm_style is selected 5 Sets the desired maximum number of idle server processes. Used only when ‘apache-like’ pm_style is selected 250 Time limit on waiting execution of single request Should be used when ‘max_execution_time’ ini option does not terminate execution for some reason 31s Set open file desc rlimit 51200 Set max core size rlimit 0 Chroot to this directory at the start Chdir to this directory at the start Redirect workers’ stdout and stderr into main error log. If not set, they will be redirected to /dev/null, according to FastCGI specs yes How much requests each process should execute before respawn. Useful to work around memory leaks in 3rd party libraries. For endless request processing please specify 0 Equivalent to PHP_FCGI_MAX_REQUESTS 51200 Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect. Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+) Makes sense only with AF_INET listening socket. 127.0.0.1 Pass environment variables like LD_LIBRARY_PATH All $VARIABLEs are taken from current environment $HOSTNAME /usr/local/bin:/usr/bin:/bin /tmp /tmp /tmp $OSTYPE $MACHTYPE 2
和原始配置文件的差别 用户组->www max_children=64 MaxApareServers=250 rlimit_files=51200 max_requests=51200 去掉注释 7.优化文件句柄并开启php ulimit -SHn 51200 /opt/php/sbin/php-fpm start #/opt/php/sbin/php-fpm还有其他参数,包括:start|stop|quit|restart|reload|logrotate,修改php.ini后不重启php-cgi,重新加载配置文件使用reload。

七、安装Nginx 1.安装Nginx所需的pcre库 tar zxvf pcre-7.7.tar.gz cd pcre-7.7/ ./configure –enable-utf8 –enable-unicode-properties make && make install cd ../ 2.安装Nginx tar zxvf nginx-0.6.32.tar.gz cd nginx-0.6.32/ A 关闭debug模式来减少nginx大小 http://bianbian.org/technology/271.html du /opt/nginx/sbin/nginx #未做优化时的大小 1712 /opt/nginx/sbin/nginx #优化后的大小 404 /opt/nginx/sbin/nginx vi auto/cc/gcc # 最后几行sheft+g #注释这行 #CFLAGS=”$CFLAGS -g” B 伪装header vi src/core/nginx.h #define NGINX_VERSION “1.0” #define NGINX_VER “C1GWS/” NGINX_VERSION C 编译 ./configure –user=www –group=website –prefix=/opt/nginx –with-http_stub_status_module –with-http_ssl_module make make install cd ../ 3.修改权限 chown -R www:website /opt/nginx/logs/ chmod -R 0775 /opt/nginx/logs/ chown -R www:website /opt/nginx/conf/ chmod -R 0775 /opt/nginx/conf/ 4.创建Nginx配置文件 rm -f /opt/nginx/conf/nginx.conf vi /opt/nginx/conf/nginx.conf user www website; worker_processes 4; #cpu*2 error_log /opt/nginx/logs/nginx_error.log crit; pid /dev/shm/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; log_format access ‘$remote_addr – $remote_user [$time_local] “$request” ‘ ‘$status $body_bytes_sent “$http_referer” ‘ ‘”$http_user_agent” $http_x_forwarded_for’; charset utf-8; server_names_hash_bucket_size 128; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_intercept_errors on; # 解决 no input file specified fastcgi_connect_timeout 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 128k; fastcgi_buffers 4 128k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; fastcgi_temp_path /dev/shm; gzip on; gzip_min_length 1k; gzip_buffers 4 8k; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/html application/xml; server { listen 80; server_name devwww.c1gstudio.com; index index.html index.htm index.php; root /opt/htdocs/www; location ~ .*\.php?$ { include fcgi.conf; #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } access_log /opt/nginx/logs/access.log access; } server { listen 80; server_name devstatus.c1gstudio.com; index index.html index.htm index.php; root /opt/htdocs/status; error_page 404 /404.html; #error_page 500 502 503 504 /50x.html; location ~ .*\.php?$ { include fcgi.conf; #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } location /nginx { stub_status on; access_log off; auth_basic “NginxStatus”; auth_basic_user_file htpasswd; #用apache的htpasswd生成访问密码 #/opt/apache2/bin/htpasswd -c /opt/nginx/conf/htpasswd c1gstduio admin } # alias #localtion /alias/ { #alias /spool/w3/images/; #} #防盗链 location ~* ^.+\.(jpg|jpeg|gif|png|swf|rar|zip)$ { valid_referers none blocked *.yingjiesheng.com *.yingjiesheng.net localhost; if ($invalid_referer) { rewrite ^/ http://www.c1gstudio.com/logo.gif; return 403; } } # add expires header for static content location ~* ^.+\.(jpg|jpeg|gif|png|css|js|ico|html)$ { access_log off; root /opt/htdocs/www; expires 2h; break; } #禁止访问 location ~/\.ht { deny all; } location /(themes|templates_c)/ { deny all; } access_log /opt/nginx/logs/status.log access; } } 5.nginx的日志滚动 mkdir 0775 /opt/shell chgrp website /opt/shell vi /opt/shell/nginx_log.sh #!/bin/sh log_dir=/opt/nginx/logs yesterday=`date +%Y%m%d` lastday=`date +%Y%m%d -d ‘-1 month’` /bin/rm ${log_dir}/access.${lastday}.log /bin/rm ${log_dir}/nginx_error.${lastday}.log /bin/mv ${log_dir}/access.log ${log_dir}/access.${yesterday}.log /bin/mv ${log_dir}/nginx_error.log ${log_dir}/nginx_error.${yesterday}.log kill -USR1 `cat /opt/nginx/nginx.pid` /bin/gzip ${log_dir}/access.${yesterday}.log & /bin/gzip ${log_dir}/nginx_error.${yesterday}.log & 在crontab里每日23:59时 59 23 * * * /bin/sh /opt/shell/nginx_log.sh > /dev/null 2>&;1 http://www.bullog.cn/blogs/shunz/archives/157311.aspx 6.让nginx支持FastCGI http://wiki.codemongers.com/NginxSimpleCGI http://wiki.codemongers.com/NginxSimpleCGI?action=recall&rev=10 7.cpan安装 A #perl -MCPAN -e ‘install FCGI’ 一路回车 或使用原码安装 B #wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz #tar zxvf FCGI-0.67.tar.gz #cd FCGI-0.67 #perl Makefile.PL #make #make install #mkdir -p /var/run/nginx/ 如果makefile时遇到错误 perl Makefile.PL INSTALL_BASE=~ Can’t locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3. BEGIN failed–compilation aborted at Makefile.PL line 3. 安装perl-ExtUtils-MakeMaker yum install perl-ExtUtils-MakeMaker 将链接网页中的perl代码保存成perl-fcgi.pl并运行 chmod o+x /opt/shell/perl-fcgi.pl perl /opt/shell/perl-fcgi.pl 修改nginx配置文件 检查nginx配置文件/重新载入/关闭nginx /opt/nginx/sbin/nginx -t kill -HUP 进程号 # 重载配置文件 kill -15 进程号 # 关闭 8.pear升级 使用新装的pear代替系统的pear #which pear /usr/bin/pear #pear config-show Configuration (channel pear.php.net): ===================================== Auto-discover new Channels auto_discover Default Channel default_channel pear.php.net HTTP Proxy Server Address http_proxy PEAR server [DEPRECATED] master_server pear.php.net Default Channel Mirror preferred_mirror pear.php.net Remote Configuration File remote_config PEAR executables directory bin_dir /usr/bin PEAR documentation directory doc_dir /usr/share/pear/doc PHP extension directory ext_dir /usr/lib/php4 PEAR directory php_dir /usr/share/pear PEAR Installer cache directory cache_dir /tmp/pear/cache PEAR data directory data_dir /usr/share/pear/data PHP CLI/CGI binary php_bin /usr/bin/php PEAR test directory test_dir /usr/share/pear/test Cache TimeToLive cache_ttl 3600 Preferred Package State preferred_state stable Unix file mask umask 22 Debug Log Level verbose 1 PEAR password (for password maintainers) Signature Handling Program sig_bin /usr/bin/gpg Signature Key Directory sig_keydir /etc/pearkeys Signature Key Id sig_keyid Package Signature Type sig_type gpg PEAR username (for username maintainers) User Configuration File Filename /root/.pearrc System Configuration File Filename /etc/pear.conf #/opt/php/bin/pear config-show Configuration (channel pear.php.net): ===================================== Auto-discover new Channels auto_discover Default Channel default_channel pear.php.net HTTP Proxy Server Address http_proxy PEAR server [DEPRECATED] master_server pear.php.net Default Channel Mirror preferred_mirror pear.php.net Remote Configuration File remote_config PEAR executables directory bin_dir /opt/php/bin PEAR documentation directory doc_dir /opt/php/lib/php/doc PHP extension directory ext_dir /opt/php/lib/php/extensions/no-debug-non-zts-20060613 PEAR directory php_dir /opt/php/lib/php PEAR Installer cache directory cache_dir /tmp/pear/cache PEAR data directory data_dir /opt/php/lib/php/data PHP CLI/CGI binary php_bin /opt/php/bin/php PEAR test directory test_dir /opt/php/lib/php/test Cache TimeToLive cache_ttl 3600 Preferred Package State preferred_state stable Unix file mask umask 22 Debug Log Level verbose 1 cfg_dir download_dir php_ini temp_dir www_dir PEAR password (for password maintainers) Signature Handling Program sig_bin /usr/bin/gpg Signature Key Directory sig_keydir /opt/php/etc/pearkeys Signature Key Id sig_keyid Package Signature Type sig_type gpg PEAR username (for username maintainers) User Configuration File Filename /root/.pearrc System Configuration File Filename /opt/php/etc/pear.conf #mv /usr/bin/pear /usr/bin/pear.del #ln -s /opt/php/bin/pear /usr/bin/pear #pear list Installed packages, channel pear.php.net: ========================================= Package Version State Archive_Tar 1.3.2 stable Console_Getopt 1.2.3 stable PEAR 1.7.1 stable Structures_Graph 1.0.2 stable #pear upgrade pear #pear install Benchmark Cache_Lite DB HTTP Mail Mail_Mime Net_SMTP Net_Socket Pager XML_Parser XML_RPC #pear list Installed packages, channel pear.php.net: ========================================= Package Version State Archive_Tar 1.3.2 stable Benchmark 1.2.7 stable Cache_Lite 1.7.4 stable Console_Getopt 1.2.3 stable DB 1.7.13 stable Mail 1.1.14 stable Mail_Mime 1.5.2 stable Mail_mimeDecode 1.5.0 stable Net_SMTP 1.3.1 stable Net_Socket 1.0.9 stable PEAR 1.7.2 stable Pager 2.4.7 stable Structures_Graph 1.0.2 stable XML_Parser 1.3.0 stable XML_RPC 1.5.1 stable 八、awstats安装 linux awstats 安装 清除日志记录可以删除conf中DirData=”/var/lib/awstats” 下的文件 分析 perl /opt/awstats/wwwroot/cgi-bin/awstats.pl -config=sina -update 查看,在ie中输入 http://localhost/awstats/awstats.pl?config=sina 自动运行,在crontab中加入 10 8 * * * (cd /opt/awstats/wwwroot/cgi-bin/; ./awstats.pl -update -config=sina ) 九、apache与nginx+php cgi性能比较 http://www.guogoul.com/2008/07/08/nginx_2/ 十、快捷控制脚本 点此下载lemp脚本 /opt/lemp Usage: /opt/lemp start Start LEMP (nginx, MySQL, phpfpm, tomcat) startnginx Start only nginx startmysql Start only MySQL starttomcat Start only tomcat startphpfpm Start only phpfpm startmemcached Start only memcached stop Stop LEMP (nginx, MySQL, phpfpm, tomcat) stopnginx Stop only nginx stopmysql Stop only MySQL stoptomcat Stop only tomcat stopphpfpm Stop only phpfpm stopmemcached Stop only memcached reload Reload LEMP (nginx, MySQL, phpfpm ) reloadnginx Reload only nginx reloadmysql Reload only MySQL reloadphpfpm Reload only phpfpm restart Stop and start LEMP 十一、防arp http://bbs.linuxtone.org/thread-41-1-1.html 参考 http://blog.s135.com/read.php/351.htm http://31543.blog.51cto.com/21543/83964 =============================================================== update 2008/08/14 A 解决php 404错误为 no input file specified 在nginx.conf中增加 fastcgi_intercept_errors on; B 优化 #ulimit -SHn 51200 #vi /etc/rc.local 尾部增加 ulimit -SHn 51200 #vi /etc/sysctl.conf 尾部增加 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 300 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 #/sbin/sysctl -p C PHP FastCGI进程数多少合适? netstat -anpo | grep “php-cgi” | wc -l 如果实际使用的“FastCGI进程数”接近预设的“FastCGI进程数”,那么,说明“FastCGI进程数”不够用,需要增大。 ======================================================== update 2009-8-19 万恶的wp编辑器把文章搞乱了

Posted in Nginx, 技术.

Tagged with , , , , , , , , , , , , .


如果flash将层挡住了怎么办?

加上一句

Posted in HTML/XHTML/CSS, 技术.


sysstat 安装

This package provides the sar and iostat commands for Linux. Sar and iostat enable system monitoring of disk, network, and other IO activity

http://rpmfind.net/ 下打systat 或 http://pagesperso-orange.fr/sebastien.godard/download.html

含src的rpm安装方式

1.执行rpm -i sysstat-5.0.5-1.src.rpm

  1. cd /usr/src/redhat/SPECS
  2. rpmbuild -bp sysstat-5.0.5-1.specs 一个和你的软件包同名的specs文件
  3. cd /usr/src/redhat/BUILD/sysstat-5.0.5-1/ 一个和你的软件包同名的目录
  4. ./configure 这一步和编译普通的源码软件一样,可以加上参数
  5. make
  6. make install

wget http://perso.orange.fr/sebastien.godard/sysstat-8.0.4.1.tar.gz

tar zxvf sysstat-8.0.4.1.tar.gz

cd sysstat-8.0.4.1

./configure

make

make install

    这个包一但安装下去,一般包括如下的几个命令可以使用。

    sar     iostat     sa1     sa2     sadf     mpstat     sadc     sysstat

crontab -e

/10 /usr/lib/sa/sa1 1 1 53 23 /usr/lib/sa/sa2 -A

 # /etc/init.d/crond restart

http://www.ixpub.net/thread-749930-1-17.html

让普通用户能够使用sar命令,至少有两种办法: 1、将普通用户加到adm组中; 2、这个例子中,就是这个命令:chmod o+x /usr/lib/sa/sadc

查看软件版本


[root@localhost sysstat-8.1.6]# sar -V
sysstat version 8.1.6

查看系统使用的文件描述符

[root@localhost sysstat-8.1.6]# sar -v 2 3 Linux 2.6.9-5.ELsmp (localhost.localdomain)     10/20/2008      i686  (4 CPU)   03:14:44 PM dentunusd   file-nr  inode-nr    pty-nr 03:14:46 PM     57966       810     66883         2 03:14:48 PM     57966       810     66883         2 03:14:50 PM     57966       810     66883         2 Average:        57966       810     66883         2

  1. 查看CPU使用情况
    <!–

    Code highlighting produced by Actipro CodeHighlighter (freeware)
    http://www.CodeHighlighter.com/

    –>sar  2   5 // 每隔2秒,显示5次,CPU使用的情况
     
  2. 查看内存使用情况
    <!–

    Code highlighting produced by Actipro CodeHighlighter (freeware)
    http://www.CodeHighlighter.com/

    –>sar  2   5 // 每隔2秒,显示5次,内存使用的情况
     
    1. 查看网络吞吐量
    <!–

    Code highlighting produced by Actipro CodeHighlighter (freeware)
    http://www.CodeHighlighter.com/

    –>
    1. sar  n DEV  2   5 // 每隔2秒,显示5次,网络吞吐量情况
  • Posted in LINUX, 技术.


    linux 下 lynx 安装

    Lynx是一个基于文本的浏览器 下载地址 http://ftp.iasi.roedu.net/mirrors/lynx.isc.org/current/

    lynx 依赖于openssl

    安装lynx

    运行下面的命令安装lynx:

    ./configure --prefix=/usr --libdir=/etc --with-ssl --with-zlib && make && make install && make DOCDIR=/usr/share/doc/lynx-2.8.4/lynx_doc \    HELPDIR=/usr/share/doc/lynx-2.8.4/lynx_help install-doc && make DOCDIR=/usr/share/doc/lynx-2.8.4/lynx_doc \    HELPDIR=/usr/share/doc/lynx-2.8.4/lynx_help install-help && sed s/"t\/etc"/"t\/usr\/share\/doc\/lynx\-2\.8\.4"/ \    /etc/lynx.cfg > /etc/lynx.bak && mv /etc/lynx.bak /etc/lynx.cfg

    Posted in LINUX, 技术.


    自动mount分区

    fdisk -l 得到需挂载的硬盘/dev/sda1

    先mount一下

    mkdir /opt && chmod 0777 /opt

    mount /dev/sda1 /opt

    成功后改/etc/fstab里的LABEL名字的步骤如下:

    e2label /dev/sda1 /opt

    修改并写入/etc/fstab 例如: LABEL=/opt          /opt                   ext3    defaults        1 2

    重启

    Posted in LINUX, 技术.