2010年4月20日星期二

apache 中如何添加mod_info.c這個文件

最近做實驗,發現在1.3.x , 2.2.x version中mod_status是defult安裝的,但是mod_info不是default安裝的。

如何安裝呢?

------------------apache 1.3.x----
[root@web232 standard]# /usr/local/apache/bin/apxs -cia mod_info.c
apxs:Error: Sorry, no DSO support for Apache available
apxs:Error: under your platform. Make sure the Apache
apxs:Error: module mod_so is compiled into your server
apxs:Error: binary `/usr/local/apache/bin/httpd'.

應該是沒有按照要求進行編譯

./configure --prefix=/usr/local/ --enable-module=so

如果這樣編譯就可以了

在2.2.x環境下
---apache2.2.x----
[root@web233 generators]# /usr/local/apache2/bin/apxs -cia mod_info.c
/usr/local/apache2/build/libtool --silent --mode=compile gcc -prefer-pic   -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -g -O2 -pthread -I/usr/local/apache2/include  -I/usr/local/apache2/include   -I/usr/local/apache2/include   -c -o mod_info.lo mod_info.c && touch mod_info.slo
/usr/local/apache2/build/libtool --silent --mode=link gcc -o mod_info.la  -rpath /usr/local/apache2/modules -module -avoid-version    mod_info.lo
/usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apache2/build/libtool' mod_info.la /usr/local/apache2/modules
/usr/local/apache2/build/libtool --mode=install cp mod_info.la /usr/local/apache2/modules/
cp .libs/mod_info.so /usr/local/apache2/modules/mod_info.so
cp .libs/mod_info.lai /usr/local/apache2/modules/mod_info.la
cp .libs/mod_info.a /usr/local/apache2/modules/mod_info.a
chmod 644 /usr/local/apache2/modules/mod_info.a
ranlib /usr/local/apache2/modules/mod_info.a
PATH="$PATH:/sbin" ldconfig -n /usr/local/apache2/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/apache2/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/local/apache2/modules/mod_info.so
[activating module `info' in /usr/local/apache2/conf/httpd.conf]
[root@web233 modules]# pwd
/usr/local/apache2/modules
[root@web233 modules]# ls
httpd.exp  mod_info.so

已经增加了
# Example:
# LoadModule foo_module modules/mod_foo.so
LoadModule info_module        modules/mod_info.so  #這個是自動添加上的

添加如下內容:
<Location /server-info>
    SetHandler server-info
    Order deny,allow
    Allow from all    #我這裡是測試環境所以也就這樣設了 production 環境注意一下
</Location>
http://172.16.1.233/server-info

看到信息了

注意httpd.conf中間ExtendedStatus 在2.2.x版本是沒有的

ExtendedStatus On

加上restart apache

就可以看到信息了

2010年4月16日星期五

臨時開發vsftpd

 

yum install vsftpd

cd /etc/vsftpd

[root@carbon vsftpd]# ls
ftpusers  user_list  vsftpd.conf  vsftpd.conf.bak  vsftpd_conf_migrate.sh
[root@carbon vsftpd]#

 

 

[root@carbon vsftpd]# cat vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
listen=YES
listen_port=21
max_clients=100
max_per_ip=5
idle_session_timeout=600
data_connection_timeout=120
accept_timeout=60
connect_timeout=60
tcp_wrappers=YES
guest_enable=YES
#guest_username=vsftpd
guest_username=yourusername
virtual_use_local_privs=YES
#pam_service_name=ftp
chroot_local_user=YES
pasv_enable=YES
pasv_min_port=30998
pasv_max_port=30999
[root@carbon vsftpd]#

[root@carbon pam.d]# pwd
/etc/pam.d
[root@carbon pam.d]# cp vsftpd ftp  #否這server上的用戶登錄不上

[root@carbon pam.d]# vsftpd /etc/vsftpd/vsftpd.conf

[root@carbon pam.d]# netstat –tln

 

tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISEN

 

本地ftp---ok

遠程ftp –ok

2010年4月12日星期一

apache ab stress tool “apr_socket_recv: Connection reset by peer (104)” 的處理

使用apache 自帶的stresss tools ab, 如果併發設定的稍微大點就報錯了

類似:

[root@localhost bin]# ./ab -n 1000000 -c 2000 http://172.16.1.237/index.html

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.16.1.237 (be patient)

apr_socket_recv: Connection reset by peer (104)

Total of 80159 requests completed

開始懷疑是web server設置, os kernel parameter 設置的問題,後面發現不是, 而是ab 這個程序自身的問題,要打patch:

我用的是2.2.15 ,最新發佈的找到  srccode/support/ab.c

--修改代碼ab.c

   1367                 }

   1368                 return;

   1369             } else {

   1370                 //apr_err("apr_socket_recv", status); //原來的

   1371                 bad++;

   1372                 close_connection(c);

   1373                 return;

   1374             

   1375             }

   1376         }

   1377     }

make

使用這個新生成的ab做測試壓力可以達到20000

[root@localhost support]# ./ab -k -n 1000000 -c 20000 http://172.16.1.237/index.html

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.16.1.237 (be patient)

Completed 100000 requests

Completed 200000 requests

Completed 300000 requests

Completed 400000 requests

Completed 500000 requests

Completed 600000 requests

Completed 700000 requests

Completed 800000 requests

Completed 900000 requests

Completed 1000000 requests

Finished 1000000 requests

Server Software:        Apache/2.2.15

Server Hostname:        172.16.1.237

Server Port:            80

Document Path:          /index.html

Document Length:        62 bytes

Concurrency Level:      20000

Time taken for tests:   129.656 seconds

Complete requests:      1000000

Failed requests:        26877

   (Connect: 0, Receive: 8959, Length: 8959, Exceptions: 8959)

Write errors:           0

Keep-Alive requests:    982282

Total transferred:      344888716 bytes

HTML transferred:       61514602 bytes

Requests per second:    7712.75 [#/sec] (mean)

Time per request:       2593.110 [ms] (mean)

Time per request:       0.130 [ms] (mean, across all concurrent requests)

Transfer rate:          2597.69 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0  128 1551.6      0   93118

Processing:     1  583 3610.3    260  104485

Waiting:        0  284 639.7    252   54667

Total:          1  711 4610.9    260  128455

Percentage of the requests served within a certain time (ms)

  50%    260

  66%    349

  75%    397

  80%    424

  90%    476

  95%    504

  98%    664

  99%  12202

100%  128455 (longest request)

[root@localhost support]#

[root@localhost support]# ./ab -k -n 1000000 -c 30000 http://172.16.1.237/index.html

/root/httpd-2.2.15/support/.libs/lt-ab: Invalid Concurrency [Range 0..20000]

Usage: /root/httpd-2.2.15/support/.libs/lt-ab [options] [http://]hostname[:port]/path

 

再次修改src code, grep 一下20000,將這個參數加大

但是無論如何也上不了 30000,

[root@localhost support]# ./ab -k -n 1000000 -c 30000 http://172.16.1.237/index.html

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.16.1.237 (be patient)

Test aborted after 10 failures

apr_socket_connect(): Cannot assign requested address (99)

 

有時間再查,記錄一下

2010年4月11日星期日

ORACLE 11g RAC ons offline 處理

同事報生產環境的ons offline.但是神奇的是rac的node並沒有影響,記錄一下解決過程


[root@oracle02 trace]# which crs_start
/u01/app/11.1.0/crs/bin/crs_start
[root@oracle02 trace]# which crs_stop
/u01/app/11.1.0/crs/bin/crs_stop
這個的ora.oracle02.ons 可以從ora....e02.ons 和 host
[root@oracle02 trace]# crs_stop ora.oracle02.ons (Name 和Host)這兩個地方找到
Target set to OFFLINE for `ora.oracle02.ons`
[root@oracle02 trace]# crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora....b5.inst application    ONLINE    OFFLINE
ora.crpb5.db   application    ONLINE    OFFLINE
ora....d1.inst application    ONLINE    ONLINE    oracle01
ora....d2.inst application    ONLINE    ONLINE    oracle02
ora.crprod.db  application    ONLINE    ONLINE    oracle01
ora....SM1.asm application    ONLINE    ONLINE    oracle01
ora....01.lsnr application    ONLINE    ONLINE    oracle01
ora....e01.gsd application    ONLINE    ONLINE    oracle01
ora....e01.ons application    ONLINE    ONLINE    oracle01
ora....e01.vip application    ONLINE    ONLINE    oracle01
ora....SM2.asm application    ONLINE    ONLINE    oracle02
ora....02.lsnr application    ONLINE    ONLINE    oracle02
ora....e02.gsd application    ONLINE    ONLINE    oracle02
ora....e02.ons application    OFFLINE   OFFLINE
ora....e02.vip application    ONLINE    ONLINE    oracle02
[root@oracle02 trace]# crs_start ora.oracle02.ons
Attempting to start `ora.oracle02.ons` on member `oracle02`
Start of `ora.oracle02.ons` on member `oracle02` succeeded.
[root@oracle02 trace]# crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora....b5.inst application    ONLINE    OFFLINE
ora.crpb5.db   application    ONLINE    OFFLINE
ora....d1.inst application    ONLINE    ONLINE    oracle01
ora....d2.inst application    ONLINE    ONLINE    oracle02
ora.crprod.db  application    ONLINE    ONLINE    oracle01
ora....SM1.asm application    ONLINE    ONLINE    oracle01
ora....01.lsnr application    ONLINE    ONLINE    oracle01
ora....e01.gsd application    ONLINE    ONLINE    oracle01
ora....e01.ons application    ONLINE    ONLINE    oracle01
ora....e01.vip application    ONLINE    ONLINE    oracle01
ora....SM2.asm application    ONLINE    ONLINE    oracle02
ora....02.lsnr application    ONLINE    ONLINE    oracle02
ora....e02.gsd application    ONLINE    ONLINE    oracle02
ora....e02.ons application    ONLINE    ONLINE    oracle02
ora....e02.vip application    ONLINE    ONLINE    oracle02
[root@oracle02 trace]#
之前嘗試 onsctl stop |start 沒有什麼效果,原因待查
[root@oracle02 trace]# onsctl help
usage: /u01/app/oracle/product/11.1.0/bin/onsctl start|stop|ping|reconfig|debug
start                            - Start opmn only.
stop                             - Stop ons daemon
ping                             - Test to see if ons daemon is running
debug                            - Display debug information for the ons daemon
reconfig                         - Reload the ons configuration
help                             - Print a short syntax description (this).
detailed                         - Print a verbose syntax description.
[root@oracle02 trace]#
ref:  http://blog.roodo.com/mywork/archives/11858971.html

關於ons,好像是跟jdbc連接有關係,我們application使用的是dot net.所以沒有看到影響。得空研究一下。