Archive for the ‘FreeBSD’ category

配置FreeBSD的automount

November 6th, 2007

折腾了2小时,才把FreeBSD的automount跑起来。:-(

打开amd
在FreeBSD下,automount进程叫amd(/etc/rc.d/amd),参数直接写在amd_flags了,也可以写到/etc/amd.conf中
amd_enable=”YES”
amd_flags=”-a /mnt/.amd_mnt -c 10 -w 5 -l syslog /home /etc/amd.map”

配置amd
由于我要挂的是home目录,而FreeBSD的/home目录又是软link到/usr/home的,所以提前要处理一下。
#unlink /home
#mkdir /home
编辑/etc/amd.map文件
*               type:=nfs;rhost:=192.168.1.142;rfs:=/export/home/;sublink:=${key}
这样,当你在访问本机的/home/chifeng/目录的时候,就会自动的把192.168.1.142上面对应的/export/home/chifeng/挂过来作为我的根目录。但是实际上/home/chifeng只是amd进程对/mnt/.amd_mnt/192.168.1.142/export/home/chifeng/做的一个软链接,真正的挂载点是后者。

启动amd
#/etc/rc.d/amd start

更强大的配置可以用/etc/amd.conf,man一下amd.conf和amd吧。我就看了半天!

关于写一个munin插件iostat的记录

November 1st, 2007

仅记录一下过程

0,用上了munin之后,发觉在FreeBSD下不能统计到iostat状态,便发了mail到munin-users@lists.sourceforge.net,Nicolai老大给了一个用在NetBSD下的脚本,我改了一下,可以用了,但是发现一个问题,就是iostat在FreeBSD下默认第一行输出的是一个从开机到现在的平均io值,而不是一个当前值,这不符合munin统计的要求。折腾了半天,仍然没有能够找到一个合适的命令来得到当前的iostat值。最后写了个脚本把这个拿到,放到一个临时文件,然后再通过另外一个脚本来得到这个值,看似可以了。便作罢。

1,过了2天,看到Pierre说他写了一个脚本来统计FreeBSD下的iostat,便好奇的看了一眼,发觉也是统计的系统uptime时间的平均值,便回了封邮件进行反驳。最终看起来仍然得到的不是当前值。

2,前天正好skype:delphij老大,顺便聊了这个问题,他建议我发个PR试试,发了个PR:http://www.freebsd.org/cgi/query-pr.cgi?pr=117664

3,又等了一天,Peter和John分别给我回信解释这个情况,并建议我类似bsdsar那样来做,就跟我一开始的做法差不多。呵呵,基本明白了iostat为什么要这么做,又学到了一招。

附一下邮件内容如下:
Peter
————————————————————————
This is generic, rather than amd64-specific.

I believe you misunderstand iostat.  There is no “current value” as
you desire.  There are a variety of system counters that get updated
when various events occur and iostat reports the change in those
counters over the specified interval.  The only way to determine the
system activity, averaged over two seconds, is to sample the counters,
wait two seconds, sample the counters again and reports the differences.

I suggest you start a thread on (eg) freebsd-questions explaining what
you are trying to achieve and someone there may be able to assist.

In the meantime, you might like to investigate the sysutils/bsdsar port.

John
————————————————————————
There isn’t a ‘current value’ for iostat to dump.  The kernel just keeps
running counts and iostat simulates a current value by saving the values each
time and computing a delta for each line after the first.  However, for the
first line there is no saved value so it cannot compute a delta.  Probably
you need to write your own plugin that saves the previous values and computes
deltas when queried similar to how iostat behaves.

FreeBSD 8.0 Current

October 25th, 2007

ITtest1# uname -a
FreeBSD ITtest1.chifeng.name 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Wed Oct 24 20:37:11 CST 2007     root@ITtest1.chifeng.name:/usr/obj/usr/src/sys/GENERIC  i386

升级了一台测试机到8.0 Current.  :)

配置FreeBSD的NIS Client

October 22nd, 2007
配置NIS客户端分为2种情况:
1.和NIS server(包括master和slave)处于同一个网段,即可以被广播到.
a)  vi /etc/rc.conf加入如下2行
nisdomainname=”your_nis_domain
nis_client_enable=”YES”
b)  vi /etc/nsswitch.conf修改对应的选项适合自己的需要,贴一下我的供参考.
chifeng# cat /etc/nsswitch.conf
group: compat
group_compat: nis
hosts: files nis dns
networks: files
#passwd: compat
passwd: files nis
passwd_compat: nis
shadow: files nis
shells: files
automount: nis

c)  执行如下命令
chifeng# /etc/rc.d/ypbind start
配置完毕,执行ypwhich看看是否已经生效了.

2.不和NIS server处于同一个网段,不能被广播到.
a)  vi /etc/rc.conf,添加如下5行
nisdomainname=”your_nis_domain

nis_client_enable=”YES”
nis_client_flags=”-ypset -m -S your_nis_domain,nis_server1,nis_server2
#nis_ypset_enable=”YES”
#nis_ypset_flags=”your_nis_server_address
b)  vi /etc/nsswitch.conf修改对应的选项适合自己的需要
c)  执行如下命令启动NIS客户端
chifeng# /etc/rc.d/ypset start
chifeng# /etc/rc.d/ypbind start
配置完毕,执行ypwhich测试.

这儿仅说明了在FreeBSD下配置NIS client的2种情况,详细说明请参考handbook对应章节:
http://cnsnap.cn.freebsd.org/doc/zh_CN.GB2312/books/handbook/network-nis.html

配置了FreeBSD 6.2 amd64做NFS服务

October 16th, 2007

    通过用iozone对NFS的测试上,看起来amd64版本的FreeBSD比i386的略强一点,网卡,IO都表现的不错,因次使用了amd64版本的FreeBSD在DELL2950上。
    等xa收到之后,再在线跑跑,根据情况再做调整!

编译xorg&xfce4

September 23rd, 2007

在7.0current下编译xorg和xfce4,一共用了才4个多小时,core2的CPU真是快啊!zhongjian老大给换的新PC的确不错,又搞了个160G的硬盘,至少得装4个系统来用才行,不浪费硬盘空间。

Xorg启动之后,吃了不少的CPU资源,xfce4还算不错的说!

DELL OPTIPLEX745

September 21st, 2007

在DELL的745上装FreeBSD 6.2 Release->7.0 Current

键盘不认。
型号是普通的戴尔标配的usb键盘。xiangyu老弟试了所有口后,告知必须键盘必须插在机箱背面的右下角的usb口上,试了一下果然如此,解决。

网卡不认。
网卡是Broadcom(bge),6.2内核配置文件里面也有对应的驱动,但是还没明白为什么没有识别到。找了一块8139的网卡,用他临时上网update代码到7.0current,重新编了world和kernel,升级到7.0后,网卡正常识别。
chifeng# ifconfig
bge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
        ether 00:1a:a0:c2:19:c1
        media: Ethernet autoselect (none)
        status: no carrier
rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8<VLAN_MTU>
        ether 00:00:b4:c2:84:9b
        inet 172.20.33.119 netmask 0xffffff00 broadcast 172.20.33.255
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
chifeng# uname -sri
FreeBSD 7.0-CURRENT GENERIC

FreeNAS

September 13th, 2007

FreeNAS(http://sourceforge.net/projects/)
中文网址:http://www.freenas.cn

今天下午用了1个小时的时间,试用了FreeNAS,一个非常不错的FreeBSD的应用。
目前支持:
CIFS
NFS
FTP
AFP
Rsyncd
SSHD(scp)

非常不错,全部操作都可以通过web来管理,非常方便使用,用来做存储服务器再好不过了。
整个安装配置过程非常简单,也不大,几十MB就全部搞定,也可以装在CF卡或USB盘上。

freenas.jpg