Home mail me! Syndicate this site using RSS

Archive for FreeBSD


MySQL集群(NDB)安装脚本

Jim Dowling为我们写了一个安装和管理MySQL集群(MySQL Cluster)的BASH脚本,支持安装本地集群和分布式集群,提问式的安装方式,非常方便,相信每个人都很容易上手。

http://www.jimdowling.info/ndbinstaller-trac/wiki/DetailedLocalhostInstall这里以图文的方式介绍了这个脚本的整个安装过程。

更多资料请访问:http://www.jimdowling.info/ndbinstaller-trac/

安装脚本下载(右键另存为)

wget http://www.jimdowling.info/ndbinstaller/ndbinstaller.sh
# or
svn co http://www.jimdowling.info/ndbinstaller/

Find命令技巧

find命令功能其实很强,针对某些特定条件的日志文件特别有效,下面列举几个技巧:

1.查找90天以前的文件,并用LS列出全名

# find /data/webdata -mtime +90 -type f -exec ls -l -h {} \;

2.查找修改时间超过90天的文件

# find /data/webdata -mtime +90

3.查找修改时间超过90天,并且不包含click_15和click_16目录的文件

# find /data/webdata -mtime +90 \( -path /data/webdata/click_15 -o -path /data/webdata/click_16 \) -prune -o -print

4.查找修改时间超过90天,并需确认删除

# find /data/webdata -mtime +90 -ok rm -R {} \;

Upgrade SQLite2 to SQLite3

很简单的一条命令:

sqlite2 mydb.db .dump | sqlite3 mydb-new.db

如果需要很多数据库,写个简单的脚本即可。

#!/bin/bash
#
# description: Upgrade SQLite2 to SQLite3
#
 
DBPATH="/data/db"
 
for oldfile in $(find ${DBPATH} -name "*.db"); do
        newfile="${oldfile}.bak"
        sqlite2 $oldfile .dump | sqlite3 $newfile
        mv -f $newfile $oldfile
        echo $newfile
        echo $oldfile

自行编译安装PHP

实际上这种文章已经很多了,网上也到处都是,之所以写这篇文章,目的是为了解决其中一个问题。

# cd /usr/local/src
# wget http://cn.php.net/distributions/php-5.2.3.tar.gz
# tar -zxvf php-5.2.3.tar.gz
# cd php-5.2.3
# ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --cache-file=../config.cache --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-force-cgi-redirect --disable-debug --enable-pic --disable-rpath --enable-inline-optimization --with-exec-dir=/usr/bin --with-freetype-dir --with-png-dir=/usr/local --with-gd=shared --enable-gd-native-ttf --with-iconv --with-jpeg-dir=/usr/local --with-openssl --with-png --with-pcre-regex --with-zlib --with-layout=GNU --enable-magic-quotes --enable-sockets --enable-sysvsem --enable-sysvshm --enable-track-vars --enable-trans-sid --enable-memory-limit --enable-shmop --with-mime-magic=/usr/share/file/magic.mime --with-apxs2=/usr/sbin/apxs --with-sqlite --with-pdo-sqlite --without-pear --disable-xmlwriter --disable-xmlreader --disable-xml --disable-simplexml --disable-libxml --disable-dom --disable-ipv6 --disable-json --disable-hash --with-mysql --with-pdo-mysql

很多人在执行到这一步的时候,会出现以下问题:
Read more…

Fix too many FIN_WAIT_2 connections under freebsd

查看FIN_WAIT_2连接数:

bsd#netstat -an | grep FIN_WAIT_2 | wc -l
2523

修改Lighttpd配置文件,加入下面这条语句:

server.max-keep-alive-requests = 0
bsd#netstat -an | grep FIN_WAIT_2 | wc -l
91

如果服务器开启了ipfw2防火墙的话,还需要执行:

sysctl -w net.inet.ip.fw.dyn_keepalive=0

p.s. 若为APACHE服务器,同理。

Install Marvell 88e8050 NIC Drivers on FreeBSD 6.x

There is two method to install marvell 88e8050 nic driver: install the binary version from marvell official website or compile the driver source from andre’s homepage.

1. Install the binary version from marvell official website.
download the driver from http://www.marvell.com/drivers

#tar -xvf mykbsd60x86-8.12.2.3.tar
#cp if_myk.ko /boot/kernel/
#kldload if_myk.ko

Read more…