显示标签为“Linux”的博文。显示所有博文
显示标签为“Linux”的博文。显示所有博文

2010年5月12日星期三

realVNC Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list! 處理

 

參考:http://cha.homeip.net/blog/2005/08/137.html

vnc-4_1_3-x86_linux.tar.gz

 

安裝realvnc for linux 後發現啟動不了

查看~/.vnc/xxx.log發現

Couldn't open RGB_DB '/usr/X11R6/lib/X11/rgb'

Xvnc Free Edition 4.1.3 - built Oct 15 2008 12:55:42
Copyright (C) 2002-2008 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 40201000, The XFree86 Project, Inc

Wed May 12 22:18:05 2010
vncext:      VNC extension running!
vncext:      Listening for VNC connections on port 5901
vncext:      Listening for HTTP connections on port 5801
vncext:      created VNC server for screen 0
error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!

Fatal server error:
could not open default font 'fixed'
xsetroot:  unable to open display 'pennyho.test.com:1'
Warning: This program is an suid-root program or is being run by the root user.
The full text of the error or warning message cannot be safely formatted
in this environment. You may get a more descriptive message by running the
program as a non-root user or by removing the suid bit on the executable.
xterm Xt error: Can't open display: %s

(gnome-session:22056): Gtk-WARNING **: cannot open display:
vncconfig: unable to open display "pennyho.crp.com:1"

發現/usr/X11R6/lib/X11/ 沒有內容

google了一下發現http://www.linuxquestions.org/questions/linux-desktop-74/vnc-problems-could-not-open-default-font-fixed-481175/

 

cp –rf /usr/share/X11 /usr/X11R6/lib/X11

再次啟動,vncserver 查看一下端口

# netstat -untlp |grep Xvnc
tcp        0      0 0.0.0.0:5801                0.0.0.0:*                   LISTEN      3463/Xvnc
tcp        0      0 0.0.0.0:5901                0.0.0.0:*                   LISTEN      3463/Xvnc
tcp        0      0 0.0.0.0:6001                0.0.0.0:*                   LISTEN      3463/Xvnc

出來了

remote 瀏覽器訪問5801端口 ok!

記錄一下備忘

記錄一下我的過程:

tar xvfz vnc-4_1_3-x86_linux.tar.gz
cd vnc-4_1_3-x86_linux

  ./vncinstall /usr/local/bin

mkdir -p /usr/X11R6/lib/modules/extensions/

  cd vnc-4_1_3-x86_linux

cp vnc.so /usr/X11R6/lib/modules/extensions/
mkdir -p /usr/local/vnc/classes
  cp java/* /usr/local/vnc/classes
cp -rf /usr/share/X11 /usr/X11R6/lib/X11

# which vncserver
/usr/local/bin/vncserver

 

# netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:771                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:904                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:25300               0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN
tcp        0      0 :::22                       :::*                        LISTEN

]# vncserver

You will require a password to access your desktops.

Password:
Verify:

New 'CRRACTEST.localdomain:1 (root)' desktop is CRRACTEST.localdomain:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/CRRACTEST.localdomain:1.log

# netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:771                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:904                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:5801                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:5901                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:6001                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:25300               0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN
tcp        0      0 :::22                       :::*                        LISTEN

從remote IE or firefox :

:5801">http://vncserver<ip>:5801

就可以訪問到了

當然如果希望gnome or kde env,修改 ~/.vnc/xstartup文件

GNOME:

xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &

KDE:

xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
startkde &

補充完畢

2010年5月4日星期二

vmware安裝在Centos5.3上的報錯vmware gcc: error trying to exec 'cc1': execvp: No such file or directory

 

運行

vmware-config.pl ,報錯

vmware gcc: error trying to exec 'cc1': execvp: No such file or directory

糾結了半天原來認為是kernel 的問題,後來發現

gcc-c++ 沒有安裝

yum install gcc-c++

再次運行 過去了

記錄一下備忘

2010年5月3日星期一

keepalived failover實驗

實驗keepalived 對2個lvs server進行failover的切換

要求:

1.可以切換過去

2.發送mail

安裝keepalived-1.1.19.tar.gz 目前最新的

./configure

make

make install 三部曲

#cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/

#cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/

#mkdir /etc/keepalived

#cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/

#cp /usr/local/sbin/keepalived /usr/sbin/

然後便捷.conf文件

! Configuration File for keepalived
global_defs {
   notification_email {
                yourname@yourdomain //要收到mail的address
   }
   notification_email_from lvs-machine@lvsdomain  發送
   smtp_server 127.0.0.1 
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
# VIP1
vrrp_instance VI_1 {
    state MASTER            

    smtp_alert    #這個是關鍵,如果沒有這個不會發mail!
    interface eth0
    virtual_router_id 51
    priority 150        advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.16.1.240
    }
}

virtual_server 172.16.1.240 80 {
    delay_loop 6
    lb_algo wrr
    lb_kind DR
    persistence_timeout 60
    protocol TCP

    real_server 172.16.1.233 80 {
        weight 3
        TCP_CHECK {
        connect_timeout 10
        nb_get_retry 3
        delay_before_retry 3
        connect_port 80
        }
     }
}
[root@lvserver keepalived]#

backup

! Configuration File for keepalived
global_defs {
   notification_email {
                yourname@yourdomain
   }
   notification_email_from  lvs-backup@lvs-domain
   smtp_server 127.0.0.1   #default 啟動sendmail 25端口
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

# VIP1
vrrp_instance VI_1 {
    state BACKUP             #.......MASTER..BACKUP
        smtp_alert
    interface eth0
    virtual_router_id 51
    priority 99    # ......100..99
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.16.1.240
    }
}

virtual_server 172.16.1.240 80 {
    delay_loop 6
    lb_algo wrr
    lb_kind DR
    persistence_timeout 60
    protocol TCP

    real_server 172.16.1.233 80 {
        weight 3
        TCP_CHECK {
        connect_timeout 10
        nb_get_retry 3
        delay_before_retry 3
        connect_port 80
        }
     }
}

在default情況下,master 掉了會切換到slave(backup) lvs server, 但是當master 回來的時候會取代slave,還是master.

這個要跟實際應用策略有關係。

要注意就是:

smtp_alert的設置,否則不會收到mail

測試發現他發出來的mail不是太明顯,沒有辦法編輯格式,後來想了一下,可以使用其他的手段做一個mail script.發送。

網上很多資料。不再列舉了

記錄一下,備忘!

 

參考:

http://www.linuxtone.org/thread-1077-1-1.html

2010年5月2日星期日

sendmail “cannot open `/usr/share/sendmail-cf/m4/cf.m4': No such file or directory” 問題處理

在生成sendmail configure file的時候報錯了

m4 sendmail.mc >sendmail.cf

cannot open `/usr/share/sendmail-cf/m4/cf.m4': No such file or directory

網上查一下少

sendmail-cf


這個包



因為我這裡使用的是OEL 5.4 從iso上面找到



[root@lvserver Server]# rpm -Uvh sendmail-cf-8.13.8-2.el5.x86_64.rpm

warning: sendmail-cf-8.13.8-2.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159


Preparing...                ########################################### [100%]


   1:sendmail-cf            ########################################### [100%]


[root@lvserver Server]#



 



再次運行m4 sendmail.mc >sendmail.cf     ok



[root@lvserver ~]# netstat -tln

Active Internet connections (only servers)


Proto Recv-Q Send-Q Local Address               Foreign Address             State


tcp        0      0 127.0.0.1:199               0.0.0.0:*                   LISTEN


tcp        0      0 0.0.0.0:904                 0.0.0.0:*                   LISTEN


tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN


tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN


tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN   <-here


tcp        0      0 0.0.0.0:860                 0.0.0.0:*                   LISTEN


tcp        0      0 :::22                       :::*                        LISTEN



 



發一個mail測試一下:



[root@lvserver ~]# mail -s "lvs222 test"    youname@example.com.hk </dev/null


Null message body; hope that's ok


[root@lvserver ~]#



收到,測試成功記錄一下,



sendmail的配置文件的地址:



[root@lvserver mail]# pwd

/etc/mail



啟動關閉


[root@lvserver init.d]# pwd


/etc/init.d

[root@lvserver init.d]# ./sendmail

Usage: ./sendmail {start|stop|restart|condrestart|status}




記錄一下備忘!

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年3月29日星期一

apache(2.2.15) +php(5.2.10) 實驗

這次測試加在php動態頁面的效果

apache pre-fork mode:

1, apache compiled

./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --with-mpm=prefork

 

2 php compiled

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --with-mysql=/usr/local/webserver/mysql    --with-apxs2=/usr/local/apache2/bin/apxs

 

3. make 
make ZEND_EXTRA_LIBS='-liconv'

4 .make install

 

5. 編輯測試文件

[root@LB1 bin]# cd /usr/local/apache2/htdocs/

[root@LB1 htdocs]# ls

index.html

[root@LB1 htdocs]# vi index.php

[root@LB1 htdocs]# cat index.php

<?php

phpinfo();

?>

[root@LB1 htdocs]#

6, apache httpd.conf中添加:

 

設置web server環境

#載入php5的函式庫
LoadModule php5_module        modules/libphp5.so
#指定php執行的副檔名
AddType application/x-httpd-php .php .phtml .inc .php3
#原始碼副呈現的副檔名
AddType application/x-httpd-php-source .phps

<IfModule mpm_worker_module>

    StartServers          2

    MaxClients          150

    MinSpareThreads      25

    MaxSpareThreads      75

    ThreadsPerChild      25

    MaxRequestsPerChild   0

</IfModule>

7  壓力baseline收集

php 頁面部分

===prefork mode====

[root@LB1 bin]#  ./ab -n 10000 -c 10 http://172.16.1.222/index.php

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.222 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests

Server Software:        Apache/2.2.15

Server Hostname:        172.16.1.222

Server Port:            80

Document Path:          /index.php

Document Length:        40213 bytes

Concurrency Level:      10

Time taken for tests:   5.047 seconds

Complete requests:      10000

Failed requests:        0

Write errors:           0

Total transferred:      403848771 bytes

HTML transferred:       402178437 bytes

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

Time per request:       5.047 [ms] (mean)

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

Transfer rate:          78146.56 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   0.6      0       8

Processing:     1    5   0.8      5      12

Waiting:        0    1   0.9      1       8

Total:          2    5   0.8      5      13

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

  50%      5

  66%      5

  75%      5

  80%      6

  90%      6

  95%      6

  98%      7

  99%      7

100%     13 (longest request)

[root@LB1 bin]#

 

btw:再進行work方式的時候使用類似上面的辦法報錯了“

[root@LB1 bin]# ./apachectl start

[Mon Mar 29 23:57:53 2010] [crit] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP.

Pre-configuration failed

”解決,參見 上一篇文章

worker 方式:

1, apache complied

./configure --prefix=/usr/local/httpd2 --enable-so --enable-rewrite --with-mpm=worker

2, php compiled

./configure --prefix=/usr/local/php2 --with-config-file-path=/usr/local/phpw --with-mysql=/usr/local/webserver/mysql    --with-apxs2=/usr/local/httpd2/bin/apxs  --enable-maintainer-zts

3. make 
make ZEND_EXTRA_LIBS='-liconv'

4 .make install

5. 編輯測試文件

[root@LB1 bin]# cd /usr/local/apache2/htdocs/

[root@LB1 htdocs]# ls

index.html

[root@LB1 htdocs]# vi index.php

[root@LB1 htdocs]# cat index.php

<?php

phpinfo();

?>

[root@LB1 htdocs]#

6, apache httpd.conf中添加:

 

設置web server環境

#載入php5的函式庫
LoadModule php5_module        modules/libphp5.so
#指定php執行的副檔名
AddType application/x-httpd-php .php .phtml .inc .php3
#原始碼副呈現的副檔名
AddType application/x-httpd-php-source .phps

<IfModule mpm_worker_module>

    StartServers          2

    MaxClients          150

    MinSpareThreads      25

    MaxSpareThreads      75

    ThreadsPerChild      25

    MaxRequestsPerChild   0

</IfModule>

啟動apache

7 收集壓力基準:

[root@LB1 htdocs]# cd ../bin

[root@LB1 bin]# ./ab -n 10000 -c 10 http://172.16.1.222/index.php

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.222 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests

Server Software:        Apache/2.2.15

Server Hostname:        172.16.1.222

Server Port:            80

Document Path:          /index.php

Document Length:        40284 bytes

Concurrency Level:      10

Time taken for tests:   4.213 seconds

Complete requests:      10000

Failed requests:        3

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

Write errors:           0

Total transferred:      404509865 bytes

HTML transferred:       402839865 bytes

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

Time per request:       4.213 [ms] (mean)

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

Transfer rate:          93762.80 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   0.2      0       4

Processing:     1    4   1.8      4      45

Waiting:        0    3   1.5      3      30

Total:          1    4   1.8      4      46

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

  50%      4

  66%      4

  75%      5

  80%      5

  90%      6

  95%      7

  98%      8

  99%      9

100%     46 (longest request)

[root@LB1 bin]#

對比發現 ,從動態頁面來看,worker方式的優勢就顯現出來了,處理能力明顯被pre-fork方式強。

記錄一下,備忘

Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP. Pre-configuration failed 的處理

在pre-fork mode下apache+php5運行沒有問題, 但是在worker mode, apache啟動的時候,報錯了

如何處理呢, 發現別人已經遇到這個問題

./configure --prefix=/usr/local/php2 --with-config-file-path=/usr/local/php2 --with-mysql=/usr/local/webserver/mysql    --with-apxs2=/usr/local/httpd2/bin/apxs  --enable-maintainer-zts --with-experimental-zts

紅色字體上後加入的

重新configure; make ; make install ok

Btw, php5.2.10 直接make 報錯

make使用

make ZEND_EXTRA_LIBS='-liconv'

猜想應該是php5.2.10內部的libconv可能不好用吧。

make install後, 運行apache ok.

記錄一下!

如何加快make的速度

如果您有編譯的經歷,對opensource的長時間make 一定有體會,比如php, 比如mysql的源代碼安裝

看到別人的一個安裝文檔用到了make –j 10,

man make 查了一下, 發現

[root@LB1 httpd-2.2.15]# make -j 10

-j [jobs], --jobs[=jobs]

            Specifies the number of jobs (commands) to run simultaneously.  If there  is  more than one -j option, the last one is effective.  If the -j option is given without an argument, make  will  not  limit the number of jobs that can run simultaneously.

就是啟動多個job 來運行make , 記錄一下,提高效率

類似:error while loading shared libraries: libiconv.so.2 問題的處理

安裝apache2.2以後,發現啟動不了

報類似的錯誤:

 

error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory

查找發現這個文件在/usr/local/lib下面

查看/etc/ld.so.conf 發現裏面沒有內容

將/usr/local/lib 添加在這個文件中

運行ldconfig

再次運行ok, 記錄一下備忘!

2010年3月28日星期日

apache web server 實驗

項目需要, 做了一個 apache baseline的實驗, 發現再PC上, 我的測試機器是dell optiplex 755 , apache mpm worker mode 並沒有 pre-fork mode 的效率高,可能是multi-core的優勢沒有顯示出來吧,留一個記錄備查!

[root@LB1 bin]# uname -at
Linux LB1.localdomain 2.6.18-164.el5 #1 SMP Thu Sep 3 04:15:13 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
[root@LB1 bin]#

[root@LB1 bin]# free
total used free shared buffers cached
Mem: 2015392 1099068 916324 0 131880 582036
-/+ buffers/cache: 385152 1630240
Swap: 4063224 0 4063224
[root@LB1 bin]#



[root@LB1 proc]# cat cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Duo CPU E8200 @ 2.66GHz
stepping : 6
cpu MHz : 2000.000
cache size : 6144 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx smx est tm2 cx16 xtpr lahf_lm
bogomips : 5319.97
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:

processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Duo CPU E8200 @ 2.66GHz
stepping : 6
cpu MHz : 2000.000
cache size : 6144 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx smx est tm2 cx16 xtpr lahf_lm
bogomips : 5319.98
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:





[root@LB1 httpd-2.2.15]# ./configure --with-mpm=prefork --prefix=/usr/local/apache_prefork --with-included-apr --with-expat=builtin

[root@LB1 httpd-2.2.15]# make -j 10

-j [jobs], --jobs[=jobs]
Specifies the number of jobs (commands) to run simultaneously. If
there is more than one -j option, the last one is effective. If
the -j option is given without an argument, make will not limit
the number of jobs that can run simultaneously.


[root@LB1 httpd-2.2.15]# make install




第二组


[root@LB1 httpd-2.2.15]# ./configure --with-mpm=worker --prefix=/usr/local/apache_worker --with-included-apr --with-expat=builtin


[root@LB1 httpd-2.2.15]# make -j 10


[root@LB1 httpd-2.2.15]# make install




分别配置参数


StartServers 5
MinSpareServers 5
MaxSpareServers 75
MaxClients 150
MaxRequestsPerChild 0






StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0

[root@LB1 conf]#



测试第一组: prefork mode

[root@LB1 bin]# ./apachectl start
[root@LB1 bin]# netstat -tln |grep 80
tcp 0 0 :::80 :::* LISTEN
[root@LB1 bin]#



[root@LB1 bin]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 16039
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 16039
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
[root@LB1 bin]# ulimit -n 102400
[root@LB1 bin]#




[root@LB1 bin]# ./ab -n 10000 -c 10 http://172.16.1.222/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.222 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software: Apache/2.2.15
Server Hostname: 172.16.1.222
Server Port: 80

Document Path: /index.html
Document Length: 44 bytes

Concurrency Level: 10
Time taken for tests: 0.737 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 2950000 bytes
HTML transferred: 440000 bytes
Requests per second: 13565.19 [#/sec] (mean)
Time per request: 0.737 [ms] (mean)
Time per request: 0.074 [ms] (mean, across all concurrent requests)
Transfer rate: 3907.94 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 0 1 0.1 1 8
Waiting: 0 0 0.1 0 1
Total: 0 1 0.2 1 8

Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 1
95% 1
98% 1
99% 1
100% 8 (longest request)
[root@LB1 bin]#





第二组 worker

[root@LB1 bin]# ./ab -n 10000 -c 10 http://172.16.1.222/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.222 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software: Apache/2.2.15
Server Hostname: 172.16.1.222
Server Port: 80

Document Path: /index.html
Document Length: 44 bytes

Concurrency Level: 10
Time taken for tests: 0.790 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 2950295 bytes
HTML transferred: 440044 bytes
Requests per second: 12660.63 [#/sec] (mean)
Time per request: 0.790 [ms] (mean)
Time per request: 0.079 [ms] (mean, across all concurrent requests)
Transfer rate: 3647.71 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 0 1 0.5 1 16
Waiting: 0 0 0.4 0 15
Total: 0 1 0.5 1 16

Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 1
95% 2
98% 2
99% 2
100% 16 (longest request)
[root@LB1 bin]#

2010年3月3日星期三

Awk 做url

學習了一個小技巧

ls | awk '{print "<a href="$0">"$0"</a><br />"}' > index.html 

將目錄下的東西寫道成href

ref:

http://ithelp.ithome.com.tw/question/10021489

2010年3月2日星期二

add a disk to linux

在xen上增加一個disk,當人是vritual的:)


[root@Mocktrade dev]# fdisk /dev/xvdb  # xvdb 難道xen下的disk都是xvdx嗎?
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 4895.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-4895, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-4895, default 4895):
Using default value 4895
Command (m for help): p
Disk /dev/xvdb: 40.2 GB, 40265318400 bytes
255 heads, 63 sectors/track, 4895 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1        4895    39319056   83  Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@ dev]#
[root@ dev]#
[root@ dev]# mkfs
mkfs         mkfs.cramfs  mkfs.ext2    mkfs.ext3
[root@ dev]# mkfs.ext3 -b 4096 /dev/xvdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
4915200 inodes, 9829764 blocks
491488 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
300 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@ /]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda3            26306612   7741500  17207220  32% /
/dev/xvda1              101086     19708     76159  21% /boot
tmpfs                  1572864         0   1572864   0% /dev/shm
[root@ /]# mkdir /u01


[root@/]# mount /dev/xvdb1 /u01
[root@ /]# cd /u01
[root@ u01]# touch reame.txt
[root@ u01]# ls
lost+found  reame.txt
[root@ u01]# cd /etc
[root@ etc]# vi fstab

cat /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/xvdb1             /u01                   ext3    defaults        1 1
LABEL=SWAP-xvda2        swap                    swap    defaults        0 0


[root@ etc]# df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda3             26G  7.4G   17G  32% /
/dev/xvda1             99M   20M   75M  21% /boot
tmpfs                 1.5G     0  1.5G   0% /dev/shm
/dev/xvdb1             37G  177M   35G   1% /u01
[root@]#

reboot

記錄一下,備忘!

2010年2月25日星期四

oracle exp parfile mode

發現一個oracle exp的方法不錯,就是用file方式。記錄一下備查

 

oracle@opensolaris:~$ cat experfstat.par
userid=perfstat/perfstat
owner=perfstat
DIRECT=y
CONSISTENT=y
file=/export/home/oracle/perfstat.dmp
grants=y
indexes=y
oracle@opensolaris:~$

oracle@opensolaris:~$ exp parfile=experfstat.par
Export: Release 10.2.0.1.0 - Production on Thu Feb 25 17:55:39 2010
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in UTF8 character set and AL16UTF16 NCHAR character set
server uses AL32UTF8 character set (possible charset conversion)
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user PERFSTAT
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user PERFSTAT
About to export PERFSTAT's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export PERFSTAT's tables via Direct Path ...
. . exporting table         STATS$BG_EVENT_SUMMARY        308 rows exported
. . exporting table          STATS$BUFFERED_QUEUES          0 rows exported
. . exporting table     STATS$BUFFERED_SUBSCRIBERS          0 rows exported
. . exporting table   STATS$BUFFER_POOL_STATISTICS         14 rows exported
. . exporting table          STATS$CR_BLOCK_SERVER          0 rows exported
. . exporting table     STATS$CURRENT_BLOCK_SERVER          0 rows exported
. . exporting table        STATS$DATABASE_INSTANCE          1 rows exported
. . exporting table          STATS$DB_CACHE_ADVICE        294 rows exported
. . exporting table                 STATS$DLM_MISC          0 rows exported
. . exporting table   STATS$DYNAMIC_REMASTER_STATS          0 rows exported
. . exporting table       STATS$ENQUEUE_STATISTICS        826 rows exported
. . exporting table          STATS$EVENT_HISTOGRAM       6692 rows exported
. . exporting table               STATS$FILESTATXS         70 rows exported
. . exporting table           STATS$FILE_HISTOGRAM        350 rows exported
. . exporting table               STATS$IDLE_EVENT         70 rows exported
. . exporting table  STATS$INSTANCE_CACHE_TRANSFER          0 rows exported
. . exporting table        STATS$INSTANCE_RECOVERY         14 rows exported
. . exporting table         STATS$JAVA_POOL_ADVICE         28 rows exported
. . exporting table                    STATS$LATCH       5348 rows exported
. . exporting table           STATS$LATCH_CHILDREN          0 rows exported
. . exporting table     STATS$LATCH_MISSES_SUMMARY         14 rows exported
. . exporting table             STATS$LATCH_PARENT          0 rows exported
. . exporting table        STATS$LEVEL_DESCRIPTION          5 rows exported
. . exporting table             STATS$LIBRARYCACHE        154 rows exported
. . exporting table              STATS$MUTEX_SLEEP          0 rows exported
. . exporting table                   STATS$OSSTAT        238 rows exported
. . exporting table               STATS$OSSTATNAME         17 rows exported
. . exporting table                STATS$PARAMETER       3696 rows exported
. . exporting table                  STATS$PGASTAT        196 rows exported
. . exporting table        STATS$PGA_TARGET_ADVICE        196 rows exported
. . exporting table    STATS$PROCESS_MEMORY_ROLLUP        376 rows exported
. . exporting table           STATS$PROCESS_ROLLUP        111 rows exported
. . exporting table     STATS$PROPAGATION_RECEIVER          0 rows exported
. . exporting table       STATS$PROPAGATION_SENDER          0 rows exported
. . exporting table           STATS$RESOURCE_LIMIT         70 rows exported
. . exporting table                 STATS$ROLLSTAT        154 rows exported
. . exporting table         STATS$ROWCACHE_SUMMARY        532 rows exported
. . exporting table                 STATS$RULE_SET         14 rows exported
. . exporting table                 STATS$SEG_STAT          0 rows exported
. . exporting table             STATS$SEG_STAT_OBJ          4 rows exported
. . exporting table            STATS$SESSION_EVENT          0 rows exported
. . exporting table                  STATS$SESSTAT          0 rows exported
. . exporting table          STATS$SESS_TIME_MODEL          0 rows exported
. . exporting table                      STATS$SGA         56 rows exported
. . exporting table                  STATS$SGASTAT        318 rows exported
. . exporting table        STATS$SGA_TARGET_ADVICE        112 rows exported
. . exporting table       STATS$SHARED_POOL_ADVICE        196 rows exported
. . exporting table                 STATS$SNAPSHOT         14 rows exported
. . exporting table                  STATS$SQLTEXT        362 rows exported
. . exporting table                 STATS$SQL_PLAN        330 rows exported
. . exporting table           STATS$SQL_PLAN_USAGE          0 rows exported
. . exporting table           STATS$SQL_STATISTICS         14 rows exported
. . exporting table              STATS$SQL_SUMMARY        885 rows exported
. . exporting table   STATS$SQL_WORKAREA_HISTOGRAM         67 rows exported
. . exporting table      STATS$STATSPACK_PARAMETER          1 rows exported
. . exporting table        STATS$STREAMS_APPLY_SUM          0 rows exported
. . exporting table          STATS$STREAMS_CAPTURE          0 rows exported
. . exporting table      STATS$STREAMS_POOL_ADVICE          0 rows exported
. . exporting table                  STATS$SYSSTAT       5180 rows exported
. . exporting table             STATS$SYSTEM_EVENT        798 rows exported
. . exporting table           STATS$SYS_TIME_MODEL        266 rows exported
. . exporting table               STATS$TEMPSTATXS         14 rows exported
. . exporting table           STATS$TEMP_HISTOGRAM         14 rows exported
. . exporting table                   STATS$THREAD         14 rows exported
. . exporting table      STATS$TIME_MODEL_STATNAME         19 rows exported
. . exporting table                 STATS$UNDOSTAT          8 rows exported
. . exporting table                 STATS$WAITSTAT        252 rows exported
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.
oracle@opensolaris:~$

2010年1月31日星期日

疑似ARP attack 常用的cmd

arp attack原理很簡單,主要是利用arp protocol的弱點,我的理解是,攻擊的機器可以主動申請被攻擊的機器修改自己的 arp cache table, 問題就在這裡,所以,所有的攻擊和反攻擊也是圍繞它來進行

arp 的命令

[root@TEST2 ~]# arp  #主要是查詢本機內的arp cache table
Address                  HWtype  HWaddress           Flags Mask            Iface
server.aaa.com       ether   00:AA:BB:CC:DD:2C   C                     eth0
172.16.1.67              ether   00:1E:4F:C8:66:08   C                     eth0

如何獲得所有的本段的MAC呢?

發起一個廣播

ping –b <ip段>

例如

[root@CRRACTEST2 ~]# ping -b 172.16.1.255
WARNING: pinging broadcast address
PING 172.16.1.255 (172.16.1.255) 56(84) bytes of data.
64 bytes from 172.16.1.68: icmp_seq=1 ttl=64 time=0.320 ms
64 bytes from 172.16.1.124: icmp_seq=1 ttl=64 time=0.326 ms (DUP!)
64 bytes from 172.16.1.112: icmp_seq=1 ttl=64 time=0.501 ms (DUP!)
64 bytes from 172.16.1.17: icmp_seq=1 ttl=64 time=0.506 ms (DUP!)
64 bytes from 172.16.1.83: icmp_seq=1 ttl=64 time=0.530 ms (DUP!)
64 bytes from 172.16.1.31: icmp_seq=1 ttl=255 time=0.553 ms (DUP!)
64 bytes from 172.16.1.25: icmp_seq=1 ttl=64 time=1.12 ms (DUP!)
64 bytes from 172.16.1.200: icmp_seq=1 ttl=64 time=1.45 ms (DUP!)
64 bytes from 172.16.1.254: icmp_seq=1 ttl=64 time=2.46 ms (DUP!)
64 bytes from 172.16.1.250: icmp_seq=1 ttl=64 time=6.71 ms (DUP!)

目的是獲得(更新)arp cache table  <IP MAC>

[root@CRRACTEST2 ~]# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
172.16.1.25              ether   00:15:C7:8F:B6:D0   C                     eth0
172.16.1.67              ether   00:1E:5F:C6:44:08   C                     eth0
172.16.1.83              ether   00:0C:40:72:D4:21   C                     eth0
[root@CRRACTEST2 ~]#

 

如何根據MAC獲取IP呢?

arp -n |grep EC:4F  |awk '{print $1}'

nmap -sP 172.16.1.0/24 |grep arp -n |grep EC:6F  |awk '{print $1}'

[root@test ~]# rpm -Uvh fping-2.4-1.b2.2.el5.rf.x86_64.rpm
warning: fping-2.4-1.b2.2.el5.rf.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing...                ########################################### [100%]
   1:fping                  ########################################### [100%]

fping -v
fping: Version 2.4b2_to_ipv6 $Date: 2002/01/16 00:33:42 $
fping: comments to david@remote.net
fping -c 1 -g 172.16.1.0/24

 

如果發現arp cache table中發現2個ip對應MAC相同, 或者 gatway的不是缺省設定的,就有要引起懷疑了

另外,在gatway 的設定時儘量不要使用192.168.*.1 or 172.16.*.1類似的 IP地址, 而是使用 *.2 這樣也可以繞過一些attack tool

CRS-0184: Cannot communicate with the CRS daemon. 的處理

有一段時間沒有用RAC的測試環境了,重新啟動後,發現報錯了

[oracle@oracle01 ~]$ crs_stat -t
CRS-0184: Cannot communicate with the CRS daemon.

我記得itpub上有人處理過類似的問題,今天終於有機會實踐一把了

在/var/tmp/有一個.oracle目錄

將這個目錄中的東西清空

rm –rf *

然後在root用戶下啟動crs

crsctl start crs

等待一段時間發現還是沒有辦法帶動起來crs全部的services

[oracle@oracle01 ~]$ crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora....SM1.asm application    ONLINE    OFFLINE
ora....01.lsnr application    ONLINE    OFFLINE
ora....e01.gsd application    ONLINE    OFFLINE
ora....e01.ons application    ONLINE    OFFLINE
ora....e01.vip application    ONLINE    OFFLINE
ora....SM2.asm application    ONLINE    ONLINE    croracle02
ora....02.lsnr application    ONLINE    ONLINE    croracle02
ora....02.lsnr application    ONLINE    OFFLINE
ora....e02.gsd application    ONLINE    OFFLINE
ora....e02.ons application    ONLINE    ONLINE    croracle02
ora....e02.vip application    ONLINE    ONLINE    croracle02
ora....SM3.asm application    ONLINE    OFFLINE
ora....03.lsnr application    ONLINE    OFFLINE
ora....e03.gsd application    ONLINE    OFFLINE
ora....e03.ons application    ONLINE    OFFLINE
ora....e03.vip application    ONLINE    OFFLINE
ora....SM4.asm application    ONLINE    OFFLINE
ora....04.lsnr application    ONLINE    OFFLINE
ora....e04.gsd application    ONLINE    OFFLINE
ora....e04.ons application    ONLINE    OFFLINE
ora....e04.vip application    ONLINE    OFFLINE
ora....02.inst application    ONLINE    OFFLINE
ora....d1.inst application    ONLINE    OFFLINE
ora....d3.inst application    ONLINE    OFFLINE
ora....d4.inst application    ONLINE    OFFLINE
ora.crprod.db  application    ONLINE    OFFLINE

看到之後oracle02 這個node的服務啟動了

沒有辦法重新啟動服務器(我的是vmware 呵呵)

reboot後正常

 

[oracle@oracle01 ~]$ crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    croracle01
ora....01.lsnr application    ONLINE    ONLINE    croracle01
ora....e01.gsd application    ONLINE    ONLINE    croracle01
ora....e01.ons application    ONLINE    ONLINE    croracle01
ora....e01.vip application    ONLINE    ONLINE    croracle01
ora....SM2.asm application    ONLINE    ONLINE    croracle02
ora....02.lsnr application    ONLINE    ONLINE    croracle02
ora....02.lsnr application    ONLINE    OFFLINE
ora....e02.gsd application    ONLINE    ONLINE    croracle02
ora....e02.ons application    ONLINE    ONLINE    croracle02
ora....e02.vip application    ONLINE    ONLINE    croracle02
ora....SM3.asm application    ONLINE    OFFLINE
ora....03.lsnr application    ONLINE    OFFLINE
ora....e03.gsd application    ONLINE    OFFLINE
ora....e03.ons application    ONLINE    OFFLINE
ora....e03.vip application    ONLINE    ONLINE    croracle01
ora....SM4.asm application    ONLINE    OFFLINE
ora....04.lsnr application    ONLINE    OFFLINE
ora....e04.gsd application    ONLINE    OFFLINE
ora....e04.ons application    ONLINE    OFFLINE
ora....e04.vip application    ONLINE    ONLINE    croracle02
ora....02.inst application    ONLINE    ONLINE    croracle02
ora....d1.inst application    ONLINE    ONLINE    croracle01
ora....d3.inst application    ONLINE    OFFLINE
ora....d4.inst application    ONLINE    OFFLINE
ora.crprod.db  application    ONLINE    ONLINE    croracle02
[oracle@croracle01 ~]$

 

[oracle@oracle01 ~]$ sqlplus / as sysdba;

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Feb 3 01:50:41 2010

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> select * from v$active_instances;

INST_NUMBER
-----------
INST_NAME
--------------------------------------------------------------------------------
          1
croracle01.localdomain:crprod1

          2
croracle02.localdomain:croracle02

SQL>

 

看來reboot對oracle也是好使的!

2010年1月22日星期五

RedHat Linux NFS server and solaris NFS client 實驗

臨時需要將一個老舊的Solaris2.7上面的數據備份出來,但是這個Sun的server不支持USB,如何處理呢?

想了一個辦法NFS, NFS是sun開發的,估計應該支持,所以找了一個RedHat的server做個NFS server, 這個Solaris nfs方式mount上去

參考鳥哥的nfs server的設定:

RedHat端:

[oracle@oracle03 mnt_usb]$ cat /etc/exports
/mnt_usb  *(rw,no_root_squash)
[oracle@oracle03 mnt_usb]$

/mnt_usb是server機器的一個目錄文件

對任何機器都開放

當然前提是server端已經安裝了nfs server的軟件:

 

  /etc/init.d/portmap restart
  /etc/init.d/nfs start

驗證:
  netstat –ultn

  netstat -ultn |grep 111


  netstat -ultn |grep 2049

rpcinfo -p localhost

因為沒有設置防火牆,所以沒有安全方面的問題,如果你有,自己檢查一下

如果上述都正常,成功一半了

另一半在Soaris這裡

相對簡單:

root權限

建立一個目錄作為mount的節點:

# mkdir /backup

# mount -F nfs -o rw 172.16.12.24:/mnt_usb /backup

如果沒有報錯就說明成功了!

做一個備份的測試

test>tar cvf - ivantest |gzip -c >/backup/www1/ivantest.tar.gz
ivantest/
ivantest/a.txt
test>

沒有問題,從server哪裡可以看到,解壓也成功了

2010年1月21日星期四

Awk處理根據行處理文本的例子

現有一個測試文本

a.txt

107542 A000904
104005 A000426
  64636 A000347
  54304 A000900
  52480 A000901
  34814 A000930
  14346 A000562
  10239 A000929
   9821 A000782
  8515 A000417
   7161 A000599
   6961 A000813
   6845 A000422
   5676 A000092
   5329 A000685
   5288 A000547
   4939 A000834
   4829 A000903
   4804 A000011
   4245 A000010
   4161 A000302
   3831 A000550

如何取行號>10的呢?

[root@test tmp]# awk 'NR > 10 {print $1 "----" $2}' a.txt >/tmp/b.txt

查看b.txt的文本

b.txt
------------
7161----A000599
6961----A000813
6845----A000422
5676----A000092
5329----A000685
5288----A000547
4939----A000834
4829----A000903
4804----A000011
4245----A000010
4161----A000302
3831----A000550

如何取行號<10的呢?

[root@test tmp]# awk 'NR < 10 {print $1 "----" $2}' a.txt >/tmp/c.txt

c.txt
107542----A000904
104005----A000426
64636----A000347
54304----A000900
52480----A000901
34814----A000930
14346----A000562
10239----A000929
9821----A000782

第10行是什麼呢?

10    8515 A000417

[root@test tmp]# awk 'NR <= 10 {print $1 "----" $2}' a.txt >/tmp/d.txt
[root@CRRACTEST tmp]# cat d.txt
107542----A000904
104005----A000426
64636----A000347
54304----A000900
52480----A000901
34814----A000930
14346----A000562
10239----A000929
9821----A000782
8515----A000417
[root@test tmp]#

記錄一下,這個腳本對於大文本處理相當有用!

2009年12月30日星期三

(RedHat, CentOS,OEL)手動清理memory的實驗

環境是CentOS5.2

[root@test ~]# free –m
                        total       used       free     shared    buffers     cached
Mem:         15721      14056       1664          0        533      11283
-/+ buffers/cache:       2239      13481
Swap:        16386          0      16386
[root@test ~]# sync;sync;sync
[root@test~]# echo 3 > /proc/sys/vm/drop_caches
[root@test~]# free –m
                      total       used       free     shared    buffers     cached
Mem:         15721       1837      13883          0          0         44
-/+ buffers/cache:       1792      13928
Swap:        16386          0      16386
[root@LITHIUM ~]#

explain:

Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become
free.

To free pagecache, use echo 1 > /proc/sys/vm/drop_caches;

to free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 > /proc/sys/vm/drop_caches.

Because this is a non-destructive operation and dirty objects
are not freeable, the user should run sync(8) first.