Archive for the ‘03. 配置笔记’ Category.

简单配置freebsd的shell

配置freebsd的shell,使登陆框有路径提示符。

没改之前:

proxy3# cd /
proxy3#
proxy3# ls

下面进行修改:

# cd ~

# ee .cshrc

原来的.cshrc

alias h         history 25
alias j         jobs -l
alias la        ls -a
alias lf        ls -FA
alias ll        ls -lA

# A righteous umask
umask 22

set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/X11R6/bin $HOME/bin)

setenv  EDITOR  vi
setenv  PAGER   more
setenv  BLOCKSIZE       K

if ($?prompt) then
        # An interactive shell — set some stuff up
        set prompt = “`hostname -s`# “
        set filec
        set history = 100
        set savehist = 100
        set mail = (/var/mail/$USER)
        if ( $?tcsh ) then
                bindkey “^W” backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
        endif
endif

将加粗下划线的部分修改一下,为:

alias h         history 25
alias j         jobs -l
alias la        ls -a
alias lf        ls -FA
alias ll        ls -lA

# A righteous umask
umask 22

set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/X11R6/bin $HOME/bin)

setenv  EDITOR  vi
setenv  PAGER   more
setenv  BLOCKSIZE       K

if ($?prompt) then
        # An interactive shell — set some stuff up
        set prompt = “%B%n@%m[%/]”
        set filec
        set history = 100
        set savehist = 100
        set mail = (/var/mail/$USER)
        if ( $?tcsh ) then
                bindkey “^W” backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
        endif
endif

退出重新登陆后就能看到如下的效果

funpowerproxy3[/root]cd /usr/local
funpowerproxy3[/usr/local]

freebsd command

ps -aux

netstat -m

netstat 1

top

pkg_info

systat -vm

systat -if

dmesg

netstat -an

代理服务器出现故障-mbuf

第三天下午(2005-01-19) netstat -m

$ date
Wed Jan 19 14:37:02 CST 2005
$ netstat -m
706/3856/131072 mbufs in use (current/peak/max):
        604 mbufs allocated to data
        102 mbufs allocated to packet headers
598/3770/32768 mbuf clusters in use (current/peak/max)
8504 Kbytes allocated to network (8% of mb_map in use)
0 requests for memory denied
0 requests for memory delayed
0 calls to protocol drain routines

,继续正常.

另外, 上次增加mbuf是在/boot/defaults/load.conf文件中增加了kern.ipc.nmbclusters=”32768″ , 今天看了一位前辈的kernel, 才知道也可以在内核中加入的. 

options        NMBCLUSTERS=32767 

 后面的数值自己计算, 方法如下:

kern.ipc.nmbclusters可以调整用来增加系统愿意申请的网络mbuf的数量。每

个cluster(簇)大概2K的内存,所以值1024代表保留2M内核内存作为网络缓冲区。

你可以简单的计算出需要多少。如果你有一个web服务器最多可以有1000个并发

连接,每个连接吃掉16K接收和发送缓冲区,你大概需要32MB的网络缓冲区来对

付它。一个比较粗糙的方法是乘以2,所以32MBx2 = 64MB/2K = 32768。所以这

个情况下你将需要设置nmbclusters到32768。我们建议为那些内存不多的机器

设置1024到4096而4096到32768为那些有很多内存的机器。无论如何如何你不能

设置一个很随意的值,这可能导致启动时崩溃。netstat(1)的-m选项可以用来查

看网络缓冲区的使用情况。老的FreeBSD系统没有这个sysctl,所以需要设置内核

配置选项NMBCLUSTERS。

继续关注中…………..

—————————————————–

第二天晚上(2005-01-18) netstat -m一切正常了,感觉,数据如下:

$ netstat -m
639/2880/131072 mbufs in use (current/peak/max):
        552 mbufs allocated to data
        87 mbufs allocated to packet headers
547/2754/32768 mbuf clusters in use (current/peak/max)
6228 Kbytes allocated to network (6% of mb_map in use)
0 requests for memory denied
0 requests for memory delayed
0 calls to protocol drain routines

估计是昨晚有人恶意攻击了,只能再看一段时间了,因为现在也不知道能做些什么,水平不够,呵:(

—————————————————–

发生那天晚上(2005-01-17)  显示器上不停出现如下字符:

All mbuf clusters exhausted , Please see tuning(7)

All mbuf clusters exhausted , Please see tuning(7)

All mbuf clusters exhausted , Please see tuning(7)

用google搜了一下,然后改动了/etc/defaults/loader.conf的kern.ipc.nmbclusters=””选项,目录数字加到32768,继续关注中.....

——————————————————————-

在/sys/i386/conf/的LINT文件中有这样一段:

options         NBUF=512

# Set the size of the mbuf KVM reservation, in clusters.  This is scaled
# by approximately 2048 bytes.  The system will auto-size the mbuf area
# to (512 + maxusers*16) if this option is not specified.
# maxusers is in turn computed at boot time depending on available memory
# or set to the value specified by “options MAXUSERS=x” (x=0 means
# autoscaling).
# So, to take advantage of autoscaling, you have to remove both
# NMBCLUSTERS and MAXUSERS (and NMBUFS) from your kernel config.
#
options         NMBCLUSTERS=1024

# Set the number of mbufs available in the system. Each mbuf
# consumes 256 bytes. The system will autosize this (to 4 times
# the number of NMBCLUSTERS, depending on other constraints)
# if this option is not specified.

———————————————————————-

man 7 tuning
看看有很多参数可以改
mbuf你改kern.ipc.nmbclusters

———————————————————————-

系统运行失败时自动运行fsck -y

有时freebsd启动到一半时就不“动”了,然后一般是运行fsck程序,今天在freebsdchina中看到能够自动运行fsck的方法,一看其实挺简单,就是没想到,呵

在rc.conf中加入下面一行:

fsck_y_enable=”YES” # Set to YES to do fsck -y if the initial preen fails.

少了一句:gateway_enable=….

重装freebsd后,竟然ipfilter和ipnat不能地址转换,最后才发现,原来是rc.conf中少了gateway_enable=”YES”这句,晕啊~~以后注意了:)

昨晚,今天 -freebsd下快速重启网卡

一台代理,搞了很长时间,以为是架构的问题,结果是测试的机器有问题,一直PING不通内网的网卡;

# ifconfig vr0 down  //STOP网卡

# ifconfig vr0 up  //START网卡

以前都是用重启机器来重启网卡,这下知道这两个命令后就简单了,呵:)

安装socks5

服务器准备重装SOCKS5服务,从天网上下了个socks5-v1.0r11.tar.gz,解压缩看了下INSTALL文件,安装挺简单,就直接./configure 然后make,结果不成功?!提示code 1 >> /usr/home/zw/socks5-v1.0r11/server,我晕,没办法,只能改用ports安装了,进入/usr/ports/net/socks5,然后make,提示要将压缩包放入/usr/ports/distfiles文件夹中,我再晕,我就把刚下载的包放入,然后回到/usr/ports/net/socks5,make,YEAR ,成功了!下来配置/etc/socks5.conf,然后运行/usr/local/bin/socks5,,用TOP也能看到socks5进程,接着我把/usr/local/bin/socks5放入/etc/rc.local中,重启,OK!

php mail() iGENUS 郁闷啊~~

C.igenus发邮件时出现528错误,其实这是php在编译过程中找不到/usr/sbin/sendmail文件造成的,qmail使用/var/qmail/bin/sendmail发信。解决如下:
a.添加链接
# ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
b.停止apache运行
c.重新编译php即可

装FreeBSD时的小插曲:)

找了台赛扬333的机器准备装freebsd,结果在选择SKIP DERNEL CONFIGURATION AND CONTINUE。。。后,就一直显示下面信息而停止安装了

acd0:MODE_SENSE_BIG command timeout-resetting
ata1:resetting devices…done
acd0:MODE_SENSE_BIG command timeout-resetting
ata1:resetting devices…done
acd0:MODE_SENSE_BIG command timeout-resetting
ata1:resetting devices…done
……….
Probing divice,please wait(this can take a few minutes

这倒是第一次碰到,知道显示中的acd0应该是光驱的接口,但认不到光驱的话怎么能用光盘起动呢?很是奇怪,没办法,只能用google搜索一下了,没想到一下就搜到了,原来在freebsd的使用手册中的[常见问题]的第一个就是说的他,和我的症状一样,提示说只要将光驱master改成slave就可以了,一改后,真行了,呵:)