Yii 1.1 CActiveRecord 關連的部份修正
剛剛用Yii 的AR 寫的很開心,
下了這個
$criteria=new CDbCriteria;
$criteria->condition='products.id=:ID AND products_info.language_id=:languageID';
$criteria->params=array(':ID'=>$_GET['id'], ':languageID' => $this->_lang_id );
$criteria->order = 'products_content.content_orders ASC';
$model = Products::model()->with( 'products_info', 'products_content' )->find( $criteria );
一直出現
CDbCommand 無法執行 SQL 陳述: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘products.id’ in ‘where clause’
想說怪了…
再看了一下 sql log
543 Query SELECT `t`.`id` AS `t0_c0`, `products_info`.`products_id` AS `t1_c0`, `products_info`.`language_id` AS `t1_c1`, `products_info`.`name` AS `t1_c2`, `products_info`.`content` AS `t1_c3`, `products_content`.`id` AS `t2_c0`, `products_content`.`products_id` AS `t2_c1`, `products_content`.`language_id` AS `t2_c2`, `products_content`.`content_name` AS `t2_c3`, `products_content`.`content_value` AS `t2_c4`, `products_content`.`content_orders` AS `t2_c5` FROM `products` `t` LEFT OUTER JOIN `products_info` `products_info` ON (`products_info`.`products_id`=`t`.`id`) LEFT OUTER JOIN `products_content` `products_content` ON (`products_content`.`products_id`=`t`.`id`) WHERE (products.id='1' AND products_info.language_id='1') ORDER BY products_content.content_orders ASC
發現Products model 變成t 了
想說很怪
再去看了一下 1.1 CHANGELOG
發現了這段..
The alias name for the primary table in a relational AR query is changed to be ‘t’ (Qiang)
好吧乖乖的把products.id改成t.id
快快樂樂打造你自已的port
以我自已弄的Net-POP3-SSLWrapper為例
# mkdir /root/Net-POP3-SSLWrapper
# vim Makefile
# New ports collection makefile for: p5-Net-POP3-SSLWrapper
# Date created: 16 December 2009
# Whom: johnpupu <johnpupu @gmail.com>
#
# $FreeBSD$
#
PORTNAME= Net-POP3-SSLWrapper
PORTVERSION= 0.02
CATEGORIES= mail perl5
MASTER_SITES= CPAN
PKGNAMEPREFIX= p5-
MAINTAINER= johnpupu@gmail.com
COMMENT= Perl extension for simple POP3S wrapper for Net::POP3
BUILD_DEPENDS= ${SITE_PERL}/IO/Socket/SSL.pm:${PORTSDIR}/security/p5-IO-Socket-SSL
PERL_CONFIGURE= yes
MAN3= Net::POP3::SSLWrapper.3
.include <bsd .port.mk>
整個Makefile 我是看相同類型的port的Makefile 來參考的
#vim pkg-descr
This is a port of Net-POP3-SSLWrapper. WWW: http://search.cpan.org/dist/Net-POP3-SSLWrapper/
#fetch http://search.cpan.org/CPAN/authors/id/T/TO/TOKUHIROM/Net-POP3-SSLWrapper-0.02.tar.gz
#mv Net-POP3-SSLWrapper-0.02.tar.gz /usr/ports/distfiles
#cd /root/Net-POP3-SSLWrapper
#make makesum
這樣/root/Net-POP3-SSLWrapper 目錄裡應該就會有 Makefile, distinfo, pkg-descr 三個檔案
#cd /root/Net-POP3-SSLWrapper
#portlint -a ### 檢查Makefile 有沒有問題
#cp -Rp /root/Net-POP3-SSLWrapper /root/Net-POP3-SSLWrapper.new
#/root/create_pkg.sh /root/Net-POP3-SSLWrapper /root/Net-POP3-SSLWrapper.new
#cp /root/Net-POP3-SSLWrapper.new/pkg-plist /root/Net-POP3-SSLWrapper
這樣 應該就差不多了
然後 寫個測試的perl 看看有沒有問題
我原先的Makefile 是沒寫到BUILD_DEPENDS= ${SITE_PERL}/IO/Socket/SSL.pm:${PORTSDIR}/security/p5-IO-Socket-SSL
是看測試的perl 說沒有這個module 才去補上這個dependency
送pr …
#shar `find /root/Net-POP3-SSLWrapper -print` > ~/Net-POP3-SSLWrapper.shar
#send-pr -a ~/Net-POP3-SSLWrapper.shar -c 長輩的e-mail
PS:
1.
create_pkg.sh 請參考
http://blog.wu-boy.com/2009/11/18/1843/
2.
http://www.freebsd.org/doc/zh_TW/books/porters-handbook/plist-autoplist.html
這個自動產生pkg-plist的指令請在bash 底下run
csh 跑不起來..
3.我還沒驗證重作一遍…..不確定過程是完全沒少的
4.
得cls_bsd長輩指點
可以用
ports-mgmt/porttools
來檢查port 對不對
就直接在port 資料夾裡
port test 就會列出是否有錯誤了
5.
Q:
WARN: Makefile: “BUILD_DEPENDS” has to appear earlier.
A:
RUN_DEPENDS和BUILD_DEPENDS
中間不要有空行
6.
要是出現
FATAL: Makefile: duplicated manpage entry Net::POP3::SSLWrapper.3: content of MAN3 will be automatically added to pkg-plist.
表示沒把pkg-plist 中的man文件刪掉
所以請把pkg-plist 中的man 幹掉
手冊寫到
The MAN[1-9LN] variables will automatically add any manpages to pkg-plist (this means you must not list manpages in the pkg-plist——see generating PLIST for more).
ref.
http://www.freebsd.org/doc/zh_TW/books/porters-handbook/index.html
http://blog.wu-boy.com/2009/11/18/1843/
http://blog.wu-boy.com/2009/09/22/1670/
http://www.ptt.cc/man/FreeBSD/DEBD/D160/M.1135705310.A.E5B.html
http://blog.dragon2.net/2009/12/17/912.php
benchmarking with sysbench on X3650 M2
手邊剛好有x3650m2的機器
順手測了一下…FreeBSD 7.1 i386 & FreeBSD 8.0 AMD64
學Jeff Roberson弄一下..XD
就沒圖先看數據吧…
CPU: Intel(R) Xeon(R) CPU E5520 @ 2.27GHz (2266.76-MHz 686-class CPU)
real memory = 2137583616 (2038 MB)==>其實這台機器有12G, 不過i386只抓得到2G
avail memory = 2081353728 (1984 MB)
RAID 5 / 四顆 IBM 43W7538 146.8GB 10Krpm SAS
RAID controller MR10i
——————7.1 i386 ———————–
uname -a
FreeBSD ms1.xxx.xxx.xx 7.1-RELEASE-p9 FreeBSD 7.1-RELEASE-p9 #0: Tue Dec 15 15:53:44 CST 2009 root@xxx.xxx.xxx:/usr/obj/usr/src/sys/GENERIC i386
mysql-server-5.0.77
sysbench --test=oltp --num-threads=5 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 6075594
write: 0
other: 867942
total: 6943536
transactions: 433971 (7232.78 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 6075594 (101258.95 per sec.)
other operations: 867942 (14465.56 per sec.)
Test execution summary:
total time: 60.0006s
total number of events: 433971
total time taken by event execution: 293.7474
per-request statistics:
min: 0.47ms
avg: 0.68ms
max: 1.16ms
approx. 95 percentile: 0.79ms
Threads fairness:
events (avg/stddev): 86794.2000/4495.36
execution time (avg/stddev): 58.7495/0.10
sysbench --test=oltp --num-threads=10 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 9777810
write: 0
other: 1396830
total: 11174640
transactions: 698415 (11640.11 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 9777810 (162961.49 per sec.)
other operations: 1396830 (23280.21 per sec.)
Test execution summary:
total time: 60.0007s
total number of events: 698415
total time taken by event execution: 590.1649
per-request statistics:
min: 0.48ms
avg: 0.85ms
max: 205.14ms
approx. 95 percentile: 0.98ms
Threads fairness:
events (avg/stddev): 69841.5000/1335.06
execution time (avg/stddev): 59.0165/0.02
sysbench --test=oltp --num-threads=15 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 12752964
write: 0
other: 1821852
total: 14574816
transactions: 910926 (15181.88 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 12752964 (212546.30 per sec.)
other operations: 1821852 (30363.76 per sec.)
Test execution summary:
total time: 60.0009s
total number of events: 910926
total time taken by event execution: 886.4647
per-request statistics:
min: 0.56ms
avg: 0.97ms
max: 402.33ms
approx. 95 percentile: 1.01ms
Threads fairness:
events (avg/stddev): 60728.4000/606.53
execution time (avg/stddev): 59.0976/0.02
sysbench --test=oltp --num-threads=20 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 13327272
write: 0
other: 1903896
total: 15231168
transactions: 951948 (15865.47 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 13327272 (222116.62 per sec.)
other operations: 1903896 (31730.95 per sec.)
Test execution summary:
total time: 60.0012s
total number of events: 951948
total time taken by event execution: 1186.0876
per-request statistics:
min: 0.64ms
avg: 1.25ms
max: 994.84ms
approx. 95 percentile: 1.99ms
Threads fairness:
events (avg/stddev): 47597.4000/2590.43
execution time (avg/stddev): 59.3044/0.04
sysbench --test=oltp --num-threads=30 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 8234198
write: 0
other: 1176314
total: 9410512
transactions: 588157 (9802.05 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 8234198 (137228.77 per sec.)
other operations: 1176314 (19604.11 per sec.)
Test execution summary:
total time: 60.0034s
total number of events: 588157
total time taken by event execution: 1791.4983
per-request statistics:
min: 0.59ms
avg: 3.05ms
max: 1020.70ms
approx. 95 percentile: 7.91ms
Threads fairness:
events (avg/stddev): 19605.2333/3866.54
execution time (avg/stddev): 59.7166/0.06
sysbench --test=oltp --num-threads=40 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 6483008
write: 0
other: 926144
total: 7409152
transactions: 463072 (7717.23 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 6483008 (108041.20 per sec.)
other operations: 926144 (15434.46 per sec.)
Test execution summary:
total time: 60.0050s
total number of events: 463072
total time taken by event execution: 2393.3892
per-request statistics:
min: 0.62ms
avg: 5.17ms
max: 1218.90ms
approx. 95 percentile: 11.50ms
Threads fairness:
events (avg/stddev): 11576.8000/390.35
execution time (avg/stddev): 59.8347/0.02
——————-8.0 AMD 64—————————-
uname -a
mysql-server-5.1.41
FreeBSD ms2.xxx.xxx.xx 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:02:08 UTC 2009 root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
sysbench --test=oltp --num-threads=5 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 6130026
write: 0
other: 875718
total: 7005744
transactions: 437859 (7297.57 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 6130026 (102166.01 per sec.)
other operations: 875718 (14595.14 per sec.)
Test execution summary:
total time: 60.0006s
total number of events: 437859
total time taken by event execution: 296.7323
per-request statistics:
min: 0.51ms
avg: 0.68ms
max: 1.45ms
approx. 95 percentile: 0.77ms
Threads fairness:
events (avg/stddev): 87571.8000/2867.68
execution time (avg/stddev): 59.3465/0.03
sysbench --test=oltp --num-threads=10 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 9962218
write: 0
other: 1423174
total: 11385392
transactions: 711587 (11859.65 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 9962218 (166035.11 per sec.)
other operations: 1423174 (23719.30 per sec.)
Test execution summary:
total time: 60.0007s
total number of events: 711587
total time taken by event execution: 593.2102
per-request statistics:
min: 0.50ms
avg: 0.83ms
max: 2.41ms
approx. 95 percentile: 0.93ms
Threads fairness:
events (avg/stddev): 71158.7000/2261.35
execution time (avg/stddev): 59.3210/0.01
sysbench --test=oltp --num-threads=15 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 13259092
write: 0
other: 1894156
total: 15153248
transactions: 947078 (15784.37 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 13259092 (220981.20 per sec.)
other operations: 1894156 (31568.74 per sec.)
Test execution summary:
total time: 60.0010s
total number of events: 947078
total time taken by event execution: 889.9460
per-request statistics:
min: 0.63ms
avg: 0.94ms
max: 20.56ms
approx. 95 percentile: 1.06ms
Threads fairness:
events (avg/stddev): 63138.5333/1133.73
execution time (avg/stddev): 59.3297/0.01
sysbench --test=oltp --num-threads=20 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 13220214
write: 0
other: 1888602
total: 15108816
transactions: 944301 (15737.99 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 13220214 (220331.79 per sec.)
other operations: 1888602 (31475.97 per sec.)
Test execution summary:
total time: 60.0014s
total number of events: 944301
total time taken by event execution: 1190.1741
per-request statistics:
min: 0.74ms
avg: 1.26ms
max: 563.96ms
approx. 95 percentile: 1.87ms
Threads fairness:
events (avg/stddev): 47215.0500/2867.47
execution time (avg/stddev): 59.5087/0.03
sysbench --test=oltp --num-threads=30 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 13463828
write: 0
other: 1923404
total: 15387232
transactions: 961702 (16027.97 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 13463828 (224391.57 per sec.)
other operations: 1923404 (32055.94 per sec.)
Test execution summary:
total time: 60.0015s
total number of events: 961702
total time taken by event execution: 1789.5202
per-request statistics:
min: 0.81ms
avg: 1.86ms
max: 681.42ms
approx. 95 percentile: 2.84ms
Threads fairness:
events (avg/stddev): 32056.7333/2107.91
execution time (avg/stddev): 59.6507/0.03
sysbench --test=oltp --num-threads=40 --mysql-user=root --max-time=60 --mysql-db=test --max-requests=0 --oltp-read-only=on run
OLTP test statistics:
queries performed:
read: 12487580
write: 0
other: 1783940
total: 14271520
transactions: 891970 (14865.73 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 12487580 (208120.26 per sec.)
other operations: 1783940 (29731.47 per sec.)
Test execution summary:
total time: 60.0018s
total number of events: 891970
total time taken by event execution: 2390.2678
per-request statistics:
min: 0.89ms
avg: 2.68ms
max: 726.19ms
approx. 95 percentile: 3.32ms
Threads fairness:
events (avg/stddev): 22299.2500/1868.45
execution time (avg/stddev): 59.7567/0.02
apache-worker & php5 & mod_fastcgi
cd /usr/ports/www/apache22 make WITH_MPM=worker install clean
cd /usr/ports/lang/php5; make install clean
cd /usr/ports/www/mod_fastcgi make install clean
httpd.conf 中新增or把註解拿掉這兩行
LoadModule fastcgi_module libexec/apache22/mod_fastcgi.so
Include etc/apache22/extra/httpd-mpm.conf
編輯
/usr/local/etc/apache22/extra/httpd-mpm.conf
ThreadLimit 512
StartServers 1
MaxClients 512
MinSpareThreads 1
MaxSpareThreads 512
ThreadsPerChild 512
MaxRequestsPerChild 0
新增/usr/local/etc/apache22/Includes/fastcgi.conf
AddType application/x-httpd-php .php ScriptAlias /php-fcgi "/usr/local/bin/php-cgi" FastCgiServer "/usr/local/bin/php-cgi" -initial-env PHP_FCGI_CHILDREN=32 <directory /usr/local/bin > Options ExecCGI FollowSymLinks SetHandler fastcgi-script Order allow,deny Allow from all </directory> Action application/x-httpd-php /php-fcgi
ps
若之前php 是用php5_module來啟的話
記得把相關的php 都重編…
不然會一直出現
kernel: pid 86212 (php-cgi), uid 80: exited on signal 11
若一直出現這個就先把extension 都先拔掉
ref.
http://blog.wu-boy.com/2008/09/13/388/
http://blog.gslin.org/archives/2008/08/17/1624/
wens’s comment on http://blog.gslin.org/archives/2008/08/17/1624/
dovecot-lda
dovecot.conf
auth default {
socket listen {
master {
# Master socket provides access to userdb information. It's typically
# used to give Dovecot's local delivery agent access to userdb so it
# can find mailbox locations.
path = /var/run/dovecot/auth-master
mode = 0600
# Default user/group is the one who started dovecot-auth (root)
user = vmail
group = mail
}
}
master.cf
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/local/libexec/dovecot/deliver -f ${sender} -d ${recipient}
mail.cf
dovecot_destination_concurrency_limit = 1 dovecot_destination_recipient_limit = 1 virtual_transport = dovecot
dovecot-sql.conf
user_query = SELECT concat(/home/mbox/', maildir) AS home, 'maildir:/home/mbox/%u' AS mail , 150 AS uid, 150 AS gid FROM mailbox WHERE username = '%u' AND active = '1'
password_query = SELECT username AS user, password, concat('/home/mbox/', maildir) AS userdb_home, 'maildir:/home/mbox/%u' AS userdb_mail, 150 AS userdb_uid, 150 AS userdb_gid FROM mailbox WHERE username = '%u' AND active = '1'
ref.
http://wiki.dovecot.org/LDA/Postfix
Q:
Dec 12 02:28:15 mail dovecot: deliver(johnpupu@example.tw): Fatal: setgid(125(postfix)) failed with euid=143(dovecot), gid=6(mail), egid=6(mail): Operation not permitted
A:
像這樣的uid錯誤就是,dovecot-sql.conf 這個 uid 和master.cf中設的user id 沒不一樣造成的..
Q:
Dec 12 16:36:07 mail dovecot: deliver(johnpupu@example.tw): mail_location: Ambiguous mail location setting, don’t know what to do with it: /home/mbox/johnpupu@example.tw (try prefixing it with mbox: or maildir:)
A:
請乖乖的在dovecot-sql.conf把
maildir: 加在你的/home/mbox/%u 前面
就好了…
Q:
Relative home directory paths not supported (user johnpupu@example.tw): maildir:/home/mbox/johnpupu@example.tw
A:
這個問題就是user_query 的home 設錯了..
請設成
SELECT concat(‘/home/mbox/’, maildir) AS home,
就好了….
把mail_debug=yes 打開會看的滿清楚的
FreeNAS 得到iXsystems 支持
前一陣子FreeNAS 說0.7 是最後一版了
以後會轉成Linux 平台上 叫coreNAS
後來 剛剛看到消息說iXsystem 的工程師會大幅度的改寫
而FreeNAS Project 也會繼續下去了
目前會先昇上FreeBSD 8
看起來 可以繼續下去~~
勤能補拙 !!?
今天發生的一些討論如下~~
XX: 勤永遠不能補拙!!
XX的老闆: (笑了一下)勤能補拙是維他命!!
然後我問了強者長輩這件事他提了他的看法如下
聰明跟智慧是兩回事
很多東西需要累積, 不是聰明一點的人就會累積的快一點, 聰明人只是會找到比人家好一點少費一點力氣的方法
vim on eclipse
http://www.viplugin.com/viplugin/
挺好用的…..
UPDATE: 2009/11/23
http://vrapper.sourceforge.net/home/
這個不用錢 !!!! 讚
winbind cache refresh
man winbindd
SIGHUP
Reload the smb.conf(5) file and apply any parameter changes to the
running version of winbindd. This signal also clears any cached
user and group information. The list of other domains trusted by
winbindd is also reloaded.
所以只要
/usr/local/etc/rc.d/samba reload
就好了….
lib
ldd -a /usr/local/bin/mysql
ldconfig -r
/sbin/ldconfig -m /usr/local/lib
ldconfig
-m Instead of replacing the contents of the hints file with those
found in the directories specified, “merge” in new entries.
Directories recorded in the hints file by previous runs of
ldconfig are also rescanned for new shared libraries.
筆記一下…