Written on 9:59 上午 by Yu Lai
最近公司的svn server一整個狂當機,於是決定換一台電腦當Server,
除了repository的轉移外,也把OS從XP換到FreeBSD。
以下是安裝的一些過程。
1. 安裝FreeBSD
這個安裝就不寫了,有興趣的人可以參考 FreeBSD Handbook。
2. 安裝Apache
使用ports安裝,由於我們需要透過LDAP來認證使用者,
所以在安裝時記得把LDAP和AUTHNZ_LDAP選項勾選起來,
而在Apache安裝的過程中,會先安裝apr1套件,
此時也記得把LDAP選項勾選起來。
# cd /usr/ports/www/apache22
# make WITH_LDAP_MODULES=yes all install clean
3. 安裝Subversion
# cd /usr/ports/devel/subversion
# make -DWITH_SVNSERVE_WRAPPER -DWITH_MOD_DAV_SVN -DWITH_APACHE2_APR install clean
4. 設定Apache
先確認/usr/local/etc/apache22/httpd.conf裡有以下內容。
LoadModule dav_module libexec/apache22/mod_dav.so
LoadModule dav_svn_module libexec/apache22/mod_dav_svn.so
LoadModule authz_svn_module libexec/apache22/mod_authz_svn.so
LoadModule ldap_module libexec/apache22/mod_ldap.so
LoadModule authnz_ldap_module libexec/apache22/mod_authnz_ldap.so
接著編輯/usr/local/etc/apache22/Includes/svn.conf。
<Location /svn>
DAV svn
SVNParentPath /svn_repos
SVNListParentPath on
# our access control policy
#AuthzSVNAccessFile /svn_repos/svn-access-file
AuthType Basic
AuthName "Subversion repository"
# Make LDAP the authentication mechanism
AuthBasicProvider ldap
# Make LDAP authentication is final
AuthzLDAPAuthoritative on
AuthLDAPBindDN "CN=svn,CN=Users,DC=blahblah,DC=com"
AuthLDAPBindPassword "xxxxxxxx"
AuthLDAPURL "ldap://ldap-server/CN=Users,DC=blahblah,DC=com?sAMAccountName?sub?(objectClass=*)"
Require valid-user
</Location>
接著編輯/etc/rc.conf,把apache22_enable="YES"加入。最後啟動apache。
# /usr/local/etc/rc.d/apache22 start
5. 建立SVN Repository目錄
# mkdir -p /svn_repos
# chown -R www /svn_repos
6. 轉移SVN Repository
首先在windows下使用舊版的svnadmin將repository db檔dump出來。
D:\SVN>svnadmin dump repos > repos.dump
接著將repos.dump丟到FreeBSD下,再使用新版的svnadmin將dump檔load回去。
# svnadmin create repos
# svnadmin load repos < repos.dump
若repository很多的話,可以透過以下的perl script幫忙。
# cat > load.pl
foreach (@ARGV) {
s/.dump//;
print "Loading $_ repository.\n";
system "svnadmin create $_";
system "svnadmin load $_ < $_.dump";
}
^D
# perl load.pl *.dump
7. 建立定期備份的crontab
這裡我使用了crontab+perl script來進行每周日的早上4點進行備份的動作,
備份檔保留60天,超過的備份檔會被移除。
# mkdir -p /svn_backup
# cat > /svn_backup/backup.pl
#!/usr/bin/perl
# Get date information
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
$Month += 1;
$file_name = sprintf "/svn_backup/svn-%04d%02d%02d.tgz", $year, $mon, $mday;
# Do backup
system "/usr/local/etc/rc.d/apache22 stop"; # Stop apache
chdir "/svn_repos/";
system "tar zcvf $file_name *";
system "/usr/local/etc/rc.d/apache22 start"; # Start apache
# Remove old backup file
chdir "/svn_backup/";
@tgz_files = glob "*.tgz";
foreach $file (@tgz_files) {
unlink $file if -M $file > 60;
}
^D
# chmod +x /svn_backup/backup.pl
# crontab -e
0 4 * * 0 /svn_backup/backup.pl
Posted in
FreeBSD,
LDAP,
Perl,
subversion
|
Written on 9:41 上午 by Yu Lai
版權宣告:
轉載自yuwen學弟在築夢BBS(cd.twbbs.org)的個人板《P_yuwen》
autobench : Automating the process of benchmarking a web server
bonnie : Performance Test of Filesystem I/O
bonnie++ : Performance Test of Filesystem I/O
bytebench : The BYTE magazine benchmark suite
dbench : A simulation of the Ziff-Davis netbench benchmark
dbs : A distributed network benchmarking system
forkbomb : System stress testing tool
hpl : High Performance Computing Linpack Benchmark
httperf : A tool for measuring webserver performance
iozone : Performance Test of Sequential File I/O
iozone21 : Performance Test of Sequential File I/O (older version)
lmbench : A system performance measurement tool
nbench : BYTE Magazine's native benchmarks
netperf : Network performance benchmarking package
netpipe : A self-scaling network benchmark
nttcp : A client/server program for testing network performance
pipebench : Pipebench shows current throughput/amount of data through a pipe
pnetmark : Benchmarking tool for Common Language Runtime (CLR)
polygraph : A benchmarking tool for Web proxies
postal : Benchmark SMTP/POP servers
postmark : NetApps file system benchmark
pybench : An extensible benchmark suite for Python
rawio : Test performance of low-level storage devices
scimark2 : A Java benchmark for scientific and numerical computing
scimark2c : An ANSI C version of the SciMark2 benchmark
siege : A http regression testing and benchmarking utility
stream : Synthetic benchmark program that measures sustainable memory bandwidth
tcpblast : Measures the throughput of a tcp connection
tmetric : A bandwidth measurement tool
ttcp : Benchmarking tool for analysing TCP and UDP performance
ubench : Unix Benchmark Utility for CPU(s) and memory
webbench : Simple forking web benchmark
xengine : Reciprocating engine for X
himenobench : Himeno bench benchmark, solves Poisson eq. with Jacobi's method
blogbench : Performance Test of Filesystem I/O
dkftpbench : A FTP benchmark program
iperf : A tool to measure maximum TCP and UDP bandwidth
netio : Network benchmark
nqueens : N-queens benchmark
pathchirp : A measurement tool for available bandwidth estimation
pathload : A measurement tool for network path available bandwidth estimation
pathrate : A measurement tool for capacity estimation of network paths
pear-Benchmark : PEAR framework to benchmark PHP scripts or function calls
raidtest : Test performance of storage devices
unixbench : The BYTE magazine's Public Domain benchmark for UNIX
flops : Floating point benchmark to give your MFLOPS rating
libmicro : Set of utilities to benchmark productivity of system calls
thrulay : Network capacity tester
fhourstones : The Fhourstones Benchmark
gsbench : Benchmarking tool for GNUstep
gtkperf : Measure your system's GTK+ performance
imb : Intel MPI Benchmark
mdtest : A filesystem metadata benchmark utility
p5-Benchmark-Forking : Run benchmarks in separate processes
p5-Benchmark-Stopwatch : Simple timing of stages of your code
rubygem-railsbench : Scripts designed for benchmarking of Rails applications
super-smack : A benchmarking, stress testing, and load generation tool for Databases
sysbench : A modular, cross-platform and multi-threaded benchmark tool
tsung : Multi-protocol distributed load testing tool
sipp : SIP testing tool
xdd : Tool for measuring and characterizing disk subsystem I/O
Posted in
技術,
FreeBSD
|
Written on 9:54 上午 by Yu Lai
轉載自強者學弟yuwen的個人板P_yuwen @ cd.twbbs.org
最近因為某些特殊需求,所以必須要使用rainbowtable來輔助,在FreeBSD的ports中有rainbowcrack可以使用,於是就裝了起來,順道測試一下之前抓到的幾個rainbowtable的效率。沒想到一執行rcrack就噴了 = =
只好苦命的來trace code,才發現一個白爛的問題,做這個ports的人在某個function內,因為找不到從linux對應的code,就直接把那段code拔掉 = = 所以return 值亂七八糟的,當然會噴segmentation fault!所以就自己補上那一小段code,本來以為這世界就會再度快樂的運轉。
當然事情不是那麼的簡單,跑沒多久又改噴bus error = = 經過再苦命的trace才找到bug,因為每個rainbowtable去跑一次需要allocate 1G的記憶體,而我拿來測的機器的記憶體只有1G,不過SWAP也有1.5G,不知道為啥就是不會成功。(謎! 板上有長輩知道嗎),所以又找了台有2G RAM的機器來測,發現一樣跑步起來,後來寫了個test code才發現似乎是FreeBSD的malloc的問題。同樣的code,在一樣只有1G的linux上面卻是可以成功。(FreeBSD的libc中的malloc是jemalloc,而linux上面的是ptmalloc2)
My test code:
unsigned char* a = (unsigned char *)malloc(sizeof(unsigned char)*1G);
if(a == NULL) printf("Damn\n");
else printf("Thanks God!\n");
Result:
FreeBSD 6.2-Stable + 1G RAM => Damn
FreeBSD 6.2-Stable + 3G RAM => Damn
Debian etch => Thanks God!
所以就開始尋找替代方案啦,幾個有名的malloc都拿來測試看看,包含下列幾種:
libumem(Sun的),libdlmalloc(FreeBSD開發者弄得),libtcmalloc (google出品)
結果不管換上哪一套,在本來的機器上都可以跑了!!!看來真的是malloc的問題。
解決問題後,就開始想測測看上面這幾套的效能,測試的code如下:
char a[65535];
跑 10 次
random填滿 a[65535], 每個malloc 1~64K
跑 1000000 次
random選一個a[x],如果不是null就free,如果null就
random malloc一塊 1~64K
end 跑
end 跑
結果: tcmalloc > dlmalloc >>>>>>>>>>>>>>>>>>> libumem ~= jemallo ~= ptmalloc
結論: 如果需要大量頻繁的malloc/free,每次都是small allocation的話,應該可以先試試看tcmalloc or dlmalloc
這又帶出一個想法,築夢每次晚間的load都非常重,看了一下code發現其實bbs會頻繁的malloc/free。也許cd.twbbs.org可以改用tcmalloc or dlmalloc看看,也許可以增加一點效率~(ptt是改用dietlibc的malloc)
--
可惜手邊沒有bbs的機器來測, 手好癢阿~ Orz
PS: 最後補一個相關的ref: http://plog.longwin.com.tw/news-unix/2007/03/29/mysql_tcmalloc_2007
Posted in
技術,
C,
FreeBSD,
malloc
|
Written on 3:42 下午 by Yu Lai
今天Intel正式授權FreeBSD可以使用旗下Wireless Chipset的Firmware.
包含: Intel 2100, 2200BG, 2225BG, 2915ABG, and the 3945ABG devices
這是一大福音阿, 尤其嘉惠要在FreeBSD上面做無線網路研究的人,
以前notebook上面跑FreeBSD都得要望centrino興嘆 (不然就是得用
其他方式啟動, 而且不太穩定) 現在有了官方的直接support, 實在太棒了 :D
有網頁有真相: http://www.prweb.com/releases/2007/03/prweb509818.htm
Posted in
技術,
FreeBSD,
Network
|
Written on 3:08 下午 by Yu Lai
最近要搞在Mips的板子上搞Embedded Linux,
要透過網路開機來啟動,所以有了幾下的研究。
其概念為client開機時透過網卡的設定呼叫dhcp或bootp取得ip,
並向server以tftp的方式將boot image檔載入執行開機的動作。
在FreeBSD/Linux上可以透過網路開機,
設定的方法依照機器的網路卡功能的支援不同而有所不一樣。
以下是常見的幾種方式和設定方法:
(PS: 以下設定以Linux為主,FreeBSD則會有些許的不同。)
1. rboot
先介紹rboot
1.1 取得rbootd
如果你的網卡支援rboot開機的話,你必須有台Server來負
責handle boot request,所以首先你必須安裝rbootd。
1.2 設定rbootd
安裝完rbootd後需設定rbootd.conf來設定rbootd。
一般而言rbootd會位於/etc/rbootd.conf
設定範例如下:
# ethernet addr boot file comments
08:00:09:87:e4:8f lifimage_715 # PA/Linux kernel for 715/33
08:00:09:70:04:b6 lifimage_720 # PA/Linux kernel for 720
1.3 安裝boot file
將在rbootd.conf裡設定的boot file置於rbootd的目錄,一般是/var/lib/rbootd。
2. dhcp/tftp
這是最常見的一種方式,也是目前主流的diskless system建置的方法。
2.1 取得dhcp/tftp
先透過rpm或apt-get等方式來安裝server必要的檔案。
rpm: dhcp tftpd
(FreeBSD可以用Ports安裝/usr/ports/net/isc-dhcp3-server即可)
2.2 設定dhcp/tftp
1.修改/etc/inetd.conf或/etc/xinetd.d/tftp
inetd.conf中加入:
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot
xinetd.d/tftp:
service tftp
{
disable = no //yes改成no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -c -s /tftpboot //加上-c參數
per_source = 11
cps = 100 2
flags = IPv4
}
改完後接著重新啟動inetd或xined。
(FreeBSD則是改/etc/inetd.conf並在/etc/rc.conf中啟動inetd。)
這邊要注意的是我們必須將開機用的檔案放置於/tftpboot中。
2. 參考man 5 dhcpd.conf來修改dhcpd.conf,範例如下:
allow bootp;
default-lease-time 600;
max-lease-time 7200;
# This will tell the box its hostname while booting:
use-host-decl-names on;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option domain-name "foo.com";
option domain-name-server 192.168.1.4;
}
host tatooine {
hardware ethernet 00:40:05:18:0c:dd;
fixed-address 192.168.1.22;
filename "lifimage-tatooine";
option root-path "/exports/tatooineroot";
}
3. bootp/tftp
這是和dhcp/tftp類似,主要是dhcp已經將bootp的功能包含在一起的關係。
但由於網路架構的關係(e.g. 已有dhcp server),也是個常見的採用方式。
3.1 取得bootp/tftp
先透過rpm或apt-get等方式來安裝server必要的檔案。
rpm: bootp tftpd
(FreeBSD皆已內建其中)
3.2 設定bootp/tftp
1.修改/etc/inetd.conf或/etc/xinetd.d/tftp
inetd.conf中加入:
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot
bootps dgram udp wait root /usr/sbin/bootpd bootpd -i -t 120
xinetd.d/tftp和xinetd.d/bootps:
service tftp
{
disable = no //yes改成no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -c -s /tftpboot //加上-c參數
per_source = 11
cps = 100 2
flags = IPv4
}
service bootps
{
disable = no //yes改成no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/bootpd
server_args = -i -t 120
per_source = 11
cps = 100 2
flags = IPv4
}
改完後接著重新啟動inetd或xined。
(FreeBSD則是改/etc/inetd.conf並在/etc/rc.conf中啟動inetd。)
這邊要注意的是我們必須將開機用的檔案放置於/tftpboot中。
2. 參考man 5 bootptab來修改/etc/bootptab,範例如下:
vodka:hd=/tftpboot:\
:rp=/usr/src/parisc/:\
:ht=ethernet:\
:ha=080069088717:\
:ip=140.244.9.208:\
:bf=lifimage:\
:sm=255.255.255.0:\
:to=7200:
Posted in
技術,
FreeBSD,
Linux,
Network
|
Written on 12:36 上午 by Yu Lai
最近,在弄lab的ftp整合計畫。
要將另一台Linux的資料透過samba的方式來掛載到ftp那台FreeBSD上。
以下則是在弄的過程所得到的一些Notes。
首先,我們可以透過以下的指令來察看有提供連線的資料
smbutil view
掛載時則使用
mount_smbfs //[username]@[host]/[service] [mountpoint]
若要加入 /etc/fstab 使開機後自動mount,請先編輯 /etc/nsmb.conf
加入[host:user]的 section,注意! host及section都必須為"大寫",既使平常輸入的是小寫!
然後在該section加入
password=[encrypted_password] (由smbutil crypt算出)
最後,在 /etc/fstab 裡加上:
//[username]@[host]/[service] [mountpoint] smbfs rw,-I=xxx.xxx.xxx.xxx,-N,-u=[uid],-g=[gid] 0 0
要測試是否成功可以用:
mount -a
來觀看結果。
Posted in
技術,
File System,
FreeBSD,
Network
|
Written on 6:19 下午 by Yu Lai
Linux從Kernel 2.6.x開始對FreeBSD的UFS有著良好的支援,
對於FreeBSD的Slice也可以對應良好,但在mount時有些參數
仍需注意一下。
以下是在Linux上要mount UFS的一些注意的地方:
首先先用dmesg找到UFS所在的device node,
e.g.
hdc: ST380021A, ATA DISK drivehdc: max request size: 128KiB
hdc: 156312576 sectors (80032 MB) w/2048KiB Cache, CHS=65535/16/63, UDMA(33)
hdc: hdc1
hdc1: <bsd: hdc5 hdc6 hdc7 hdc8 hdc9 >
然後再執行mount指令來掛載ufs,因為要掛載slice,所以要在options中加入ufstype=ufs2。
# mount -t ufs -o ufstype=ufs2,ro /dev/hdc9 /mnt
Posted in
技術,
File System,
FreeBSD,
Linux
|