2010年8月6日星期五

转 应该告诉儿童什么

发现twitter上不错的几句话记录一下:

告诉儿童:

1.平安成长比成功更重要.
2.背心短裤覆盖的地方,不许别人摸.
3.生命第一,财产第二.
4.小秘密要告诉妈妈.
5.不喝陌生人的饮料,不吃陌生人的糖果.
6.不与陌生人讲话.
7.遇到危险可以打破玻璃,破坏家具.
8.遇见危险可以自己先跑.
9.不保守坏人的秘密.
10.坏人可以骗.

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