eygle.com   eygle.com
eygle.com  
 

« January 2007 | Blog首页 | March 2007 »

上一页 1 2


February 6, 2007

2007 我的新书写作计划

作者:eygle

出处:http://blog.eygle.com

在完成了上一本书《深入浅出Oracle》之后,收到了很多读者朋友的反馈,自己也认识到了书中的一些不足,再加上原计划写的东西在上一本书中没有写完,所以就有了写下一本书的计划。

这个计划也被我列入了2007的几大计划之一,这本书可能会是《深入浅出Oracle》的姊妹篇,两书互相补充。

上一本书很多读者认为关于Windows的内容过少,这一本会稍微增加一些Windows上的介绍,或者指出特定内容在不同平台上的区别,使读者能够在不同平台上都能学习和测试书中的内容。

另外,新书会仍然贯彻我一贯主张的由点及面的学习方法,不管深入还是浅显的知识都会由点引出并且扩展深入下去。

上一本书很多读者反映太难了,这本书会有所考虑,增加部分章节介绍基础一点的内容,但是不会太多。

这本书会隐含这样一条主线,即一个刚接触Oracle的初学者如果想快速成为一个DBA,需要顺序学习哪些知识就能够初步具备DBA的工作技能...因为有过这样思考和培养经验,所以对于这个主线我有较深的把握。当然,所有提到的内容都不是泛泛的,都是由点及面、由浅入深的介绍过程。

很多读者建议我仔细写下备份恢复的内容,这一部分内容在这本书中将是一个重点,目前这一章已经在写作之中。

新书的名称还没有认真去思考,现在最重要的就是把这本书写下去,吸取上一本书的经验及教训,希望这本书能够有更多的东西能够奉献给大家。

-The End-

Posted by eygle at 10:37 AM | Comments (24)


February 5, 2007

如何判断一个字符串是否为数字或日期?

作者:eygle

出处:http://blog.eygle.com

昨天有一个朋友在MSN上问,如何判断一个字符串是否为数字?
我说,写一个函数吧。于是给出了一个例子:

SQL> CREATE OR REPLACE FUNCTION is_number (parmin VARCHAR2)
2 RETURN NUMBER
3 IS
4 val NUMBER;
5 BEGIN
6 val := TO_NUMBER (NVL (parmin, 'a'));
7 RETURN 1;
8 EXCEPTION
9 WHEN OTHERS
10 THEN
11 RETURN 0;
12 END;
13 /

Function created.

SQL> select is_number('a') from dual;

IS_NUMBER('A')
--------------
0

SQL> select is_number('0.998') from dual;

IS_NUMBER('0.998')
------------------
1

SQL> select is_number('9999999999999999') from dual;

IS_NUMBER('9999999999999999')
-----------------------------
1

今天,这个朋友在MSN上又问:如何判断一个字符是否是日期?
我说,再写一个函数吧。

补注:由于session的语言设置会影响日期的输出格式,所以时间被转换为字符可能有多种形式。
以下这个函数只能满足部分情况,仅供参考。

SQL> CREATE OR REPLACE FUNCTION is_date (parmin VARCHAR2)
2 RETURN NUMBER
3 IS
4 val DATE;
5 BEGIN
6 val := TO_DATE (NVL (parmin, 'a'), 'yyyy-mm-dd hh24:mi:ss');
7 RETURN 1;
8 EXCEPTION
9 WHEN OTHERS
10 THEN
11 RETURN 0;
12 END;
13 /

Function created.

SQL> select is_date('a') from dual;

IS_DATE('A')
------------
0

SQL> select is_date('2004-05-05') from dual;

IS_DATE('2004-05-05')
---------------------
1

SQL> select is_date('2004/01/01') from dual;

IS_DATE('2004/01/01')
---------------------
1

SQL> select is_date('01/01/04') from dual;

IS_DATE('01/01/04')
-------------------
1

SQL> select is_date('01-jan-04') from dual;

IS_DATE('01-JAN-04')
--------------------
1

这两者是何其相似啊!

-The End-

Posted by eygle at 10:16 AM | Comments (7)


February 4, 2007

ITPUB年会回顾-阿里巴巴的数据库管理优化体系

作者:eygle

出处:http://blog.eygle.com

在上次ITPUB年会上,我主持了数据库分会场的讨论,现场的气氛非常热烈,也有了很多很有价值的讨论,现在有时间把我关心的一些内容整理引用在这里,供大家参考。

针对阿里巴巴的数据库管理,我向biti提出了如下一个问题,IT168现场作了记录,我根据记忆作了一点修正:
主持人:通过刚才大家发言,我们看到了,厂商是从自身的角度进行优化方面技术的更新。接下来有请我们ITPUB的资深专家来自阿里巴巴的冯春培先生。
阿里巴巴目前的数据库管理是非常先进的,不管技术上,人员上,还是规范上都是国内领先的。我们请冯先生介绍一下阿里巴巴是怎样进行数据库管理以及优化的?

冯先生:突然之间把我叫起来说这个事情。其实这件事情如果要谈的话,大家在ITPUB经常看到我们公司招聘DBA,而且数量还是满多的,因为阿里巴巴整个集团下面包括淘宝、支付宝等等,各部分都有DBA需求,这是我们内部的一些机制决定的。

在我们公司内部分为开发和管理团队。开发团队会面对所有的应用,需求产生的时候,他们基本上会来征求我们的意见,当然这个也会经过漫长的过程,我们可以否决商业部门的需求。我们控制到开发部门,分析部门,需求产出的部门,这里面的关系很复杂。从这一级评判对我们的数据库到底有多大的影响。我们让大家都知道,我们都是系在一条线上的蚂蚱,这样子大家才能朝着一个方向走。
这样的话,分析完了以后,到开发部门的环节。我们除了配合它们进行设计以外,我们都会对它的执行计划、应用进行检查。当然82原理大家也知道,我能判断出这个重点在哪里?这样会节省一些时间。

做完了之后,我们预计一年之后,两年之后会是什么样子。我们现在执行频率不高,我们的数据库都会预测一年后,两年后到底会变成什么样子。我们尽量避免数据库中人为的一些原因,不管分析还是建索引也好,导致它的执行计划发生改变,有时候对我来说,这是非常恐怖的事情。这样子让我们对这种事情都比较谨慎。这是开发环节,我们的控制力度是比较大的。当然在各种公司的环境是不一样了。

像我们刚进阿里巴巴的时候,你说话,人家都不认识你,人家凭什么信呢?所以我们站在开发人员,需求人员的立场考虑,经过一个长期磨合过程之后,他们信任我们提出的建议确实是为了大家好,不是我们为了逃避责任或者减轻负担,我们的目的都是为了大家好。让他们对我们产生信任感,即使我们否定了他们的需求,他们也认为这个问题肯定是行不通的。尤其在跨部门的情况下,各个部门都会有矛盾,大家的考核利益不一样,这种情况下,可能就超越了我们普通简单定义DBA的范畴。但是我们确实朝着这个方向做了很多的努力。

我估计阿里巴巴集团,现在不算北京、雅虎,杭州这块,DBA的数量,现在已经应该有差不多超过20个。预计2007年还会招超过十个人。我想这个团队已经很大了,但是我们依然会觉得平时的工作好象还是有点人手不是那么充沛的感觉。
我们DBA能扩展到这样大的团队或者部门,上面的领导为什么会留存你们这个部门那么多人呀?

在做2007年人员预算时,我们的部门的预算一个人都没有被砍掉。大家都不愿意砍掉我们的预算人员,因为他们觉得增加我们这样的工作人员大家觉得值得。这样彼此之间能够理解、信任的情况下,做很多事情会觉得比较愉快一点。不然的话,我就是一个给人家擦屁股的工作,每天出了问题都是我的。我干得好没人知道,干得不好,上面的总监、副总裁都知道了。这样一种情况下,超越了我们传统简简单单做技术的范畴。具体到技术的细节,我们在内部也会做很多的事情。跟开发人员的培训,或者说是DBA几个站点之间的事故、教训、经验、总结也是经常进行的。特别是以前,人数不太多的时候,吃顿饭几个小时大家都在谈这个东西。那时候讨论技术的氛围比较好一点。经过长期的沟通、磨合使得我们在公司里面提高了DBA在大家心中的地位。整个做事情愉快一点。

----------------------------
从阿里巴巴的经验中我们可以看到,DBA不仅仅是一个技术工作,更是一个需要沟通、协调的工作,只有能够充分发挥DBA的价值,数据库管理员这个概念在一个企业中才能够得到重视并且发挥越来越重要的作用。

biti的回答很有参考价值,所以收录在这里,供大家学习参考!

-The End-

Posted by eygle at 10:42 PM | Comments (10)


February 3, 2007

终极恢复孰弱孰强-DUL vs AUL

作者:eygle

出处:http://blog.eygle.com

这几天在帮朋友作数据恢复,由于已经到了无可救药的地步,只能使用终极手段进行恢复,直接从文件中读取数据进行恢复。

在恢复过程中反复对比了DULdcba的AUL,感觉到了两者的不同。

DUL在处理文件损坏的情况下,如文件部分缺失、数据块损坏的恢复明显要弱于AUL,AUL经过几次修正之后已经能够很好的处理这些情况。

DUL可以通过如下设置跳过文件的损坏部分:

0 1 D:\DUL\DATAFILE\SYS1ORCL.DBF
1 2 D:\DUL\DATAFILE\USR1ORCL.DBF startblock 1 endblock 1000000
1 2 D:\DUL\DATAFILE\USR1ORCL.DBF startblock 1000001 endblock 2000000
1 2 D:\DUL\DATAFILE\USR1ORCL.DBF startblock 2000001 endblock 2550000

但是在扫描存在大量坏块的文件时,大量的错误信息让人崩溃;而AUL可以很容易的安静地处理这些损坏。

在处理LOB对象时,我做过测试AUL在存在SYSTEM的情况下,能够非常完美的恢复图片对象:

D:\oradata\EYGLE\DATAFILE>aul4b.exe
Register Code: 25FV-NFCH-B53H-RO9V-SZHV
AUL : AnySQL UnLoader(MyDUL) for Oracle 8/8i/9i/10g, release 4.0.1

(C) Copyright Lou Fangxin 2005-2006 (AnySQL.net), all rights reserved.

AUL> open crl.txt

* ts# fno rfn ver bsize blocks filename
- ---- ---- ---- --- ----- ---------- -----------------------------------
Y 4 4 4 a2 8192 640 O1_MF_USERS_2G8OJYYS_.DBF
AUL> scan extents
2007-02-02 10:52:09
2007-02-02 10:52:09
AUL> scan table to table.txt
2007-02-02 10:52:29
2007-02-02 10:52:29

AUL> list table eygle;
UNLOAD TABLE eygle.EYGLE TO EYGLE.txt;
UNLOAD TABLE eygle.EYGLE_BLOB TO EYGLE_BLOB.txt;
AUL> UNLOAD TABLE eygle.EYGLE_BLOB TO EYGLE_BLOB.txt;
2007-02-02 10:58:16
Unload OBJD=14367 FILE=4 BLOCK=19 CLUSTER=0 ...
2007-02-02 10:58:16
AUL>

这个数据卸载或加载之后,与原数据完全相符:

E:\rec\blobtest>sqlldr eygle/eygle control=EYGLE_BLOB_sqlldr.ctl

SQL*Loader: Release 10.2.0.1.0 - Production on 星期五 2月 2 11:43:32 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

SQL*Loader-292: 加载 XML, LOB 或 VARRAY 列时忽略 ROWS 参数

加载完成 - 逻辑记录计数 2。

E:\rec\blobtest>sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on 星期五 2月 2 11:43:41 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.


连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> connect eygle/eygle
已连接。
SQL> desc eygle_blob;
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
FID NUMBER
FNAME VARCHAR2(50)
FDESC VARCHAR2(200)
FPIC BLOB

SQL> select fid,fname,length(fpic) from eygle_blob;

FID FNAME LENGTH(FPIC)
---------- -------------------------------------------------- ------------
1 1.jpg 333769
2 2.jpg 300332
1 1.jpg 333769
2 2.jpg 300332

SQL>

当然,DUL也有很强大的地方,比如转储文件格式等方面要优于AUL。

不过AUL最大的好处在于可以很快地得到技术支持,DCBA最近正在编写完备AUL的手册用于指导用户恢复,而且DCBA修复Bug的速度也是超快的,在这次恢复中他就为我修复了一个Bug,感谢DCBA对我的大力支持。

其实很多时候,到达用户现场后,你就只剩下一个想法,尽快帮用户最大程度的恢复数据,因为到了最后的阶段,数据已经影响到了很多人的生活,我们能做的就是尽最大可能以最快速度进行恢复。

-The End-

Posted by eygle at 8:22 PM | Comments (21)


DBA警世录:有些习惯DBA需要养成

作者:eygle

出处:http://blog.eygle.com

这几天,在帮助一个朋友进行数据恢复。

造成故障的原因很简单,因为维护升级时错误的连接到生产主机,结果导致生产库故障,数据文件被删除并部分覆盖。

因为这个案例,我想说一下作为一个DBA应该养成的一些基本习惯。
以前曾经写过一篇What Kind Of DBA we need-我们需要什么样的DBA?

今天想说的是一些在工作中应该养成的习惯或者说基本守则:
1.经常使用hostname命令
在Linux/Unix上,我们使用ssh或telnet等通过多次跳转,很容易变更了连接主机,如果不经过确认就可能在不正确的主机上执行了错误的操作。
通过hostname命令可以确认我们连接到的主机,避免发生不应该的误操作。在执行中要操作之前一定要通过hostname命令确认连接主机,这是DBA或者系统管理员应该养成的习惯:

[oracle@jumper oracle]$ hostname
jumper.hurray.com.cn

2.使用pwd确认路径
经常有朋友在错误的路径下错误的执行了"rm -rf *"等命令,这类错误的发生率居然也是很高的。
所以作为一个DBA,经常性的执行pwd命令来确认自己的工作路径:

[oracle@jumper oracle]$ pwd
/opt/oracle

3.确认instance_name等数据库中要信息
在执行truncate/drop等操作之前,应该确认连接到了哪个数据库,从v$database或v$instance等视图中可以获得这些信息(可能需要授权)

SQL> select instance_name,host_name from v$instance;

INSTANCE_NAME HOST_NAME
---------------- ----------------------------------------------------------------
eygle jumper.hurray.com.cn

4.通过id命令确认用户信息
要经常通过id命令确认用户信息,以免切换用户而导致不自觉的异常操作。

[gqgai@jumper gqgai]$ id
uid=2003(gqgai) gid=101(dba) groups=101(dba)

我见到过的案例,用户切换为root,误操作删除过整个操作系统,导致了严重的故障。

通过一些良好习惯的养成,可以使得我们少犯错误。
所以,有一些习惯是需要养成的。

以前的DBA四大守则也应该引起诸位初学DBA的朋友注意:
http://www.eygle.com/archives/2006/03/the_four_rule_for_dba.html


-The End-

Posted by eygle at 2:44 PM | Comments (14)


February 1, 2007

配置Apache2支持FastCGI 升级到MT3.34

作者:eygle

出处:http://blog.eygle.com

看到很多朋友已经将MT升级到了MT3.34,今天也忍不住升级一下。

首先要安装FastCGI支持,从fastcgi网站下载:

[root@eygle tmp]# wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
--13:41:43-- http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
=> `mod_fastcgi-2.4.2.tar.gz'
正在解析主机 www.fastcgi.com... 209.212.66.200
Connecting to www.fastcgi.com|209.212.66.200|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:98,295 (96K) [application/x-tar]

100%[======================================================>] 98,295 95.38K/s

13:41:47 (95.19 KB/s) - `mod_fastcgi-2.4.2.tar.gz' saved [98295/98295]

我的Apache用的是2.2.0版本,安装参考INSTALL.AP2文件,遵循如下步骤:

*NIX
====

$ cd
$ cp Makefile.AP2 Makefile
$ make
$ make install

If your Apache2 installation isn't in /usr/local/apache2, then
set the top_dir variable when running make (or edit the
Makefile), e.g.

$ make top_dir=/opt/httpd/2.0.40

Add an entry to httpd.conf like this:

LoadModule fastcgi_module modules/mod_fastcgi.so

可是不幸得是,Make的时候就遇到一堆的错误:

[root@eygle mod_fastcgi-2.4.2]# make top_dir=/opt/httpd-2.2.0/
/opt/httpd-2.2.0/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/opt/httpd-2.2.0//srclib/pcre -I. -I/opt/httpd-2.2.0//os/unix -I/opt/httpd-2.2.0//server/mpm/prefork -I/opt/httpd-2.2.0//modules/http -I/opt/httpd-2.2.0//modules/filters -I/opt/httpd-2.2.0//modules/proxy -I/opt/httpd-2.2.0//include -I/opt/httpd-2.2.0//modules/generators -I/opt/httpd-2.2.0//modules/mappers -I/opt/httpd-2.2.0//modules/database -I/opt/httpd-2.2.0/srclib/apr/include -I/opt/httpd-2.2.0/srclib/apr-util/include -I/opt/httpd-2.2.0//modules/proxy/../generators -I/opt/httpd-2.2.0//modules/ssl -I/opt/httpd-2.2.0//modules/dav/main -prefer-pic -c mod_fastcgi.c && touch mod_fastcgi.slo
mod_fastcgi.c: In function `init_module':
mod_fastcgi.c:270: error: `ap_null_cleanup' undeclared (first use in this function)
mod_fastcgi.c:270: error: (Each undeclared identifier is reported only once
mod_fastcgi.c:270: error: for each function it appears in.)
mod_fastcgi.c: In function `process_headers':
mod_fastcgi.c:725: warning: return makes pointer from integer without a cast
mod_fastcgi.c:729: warning: assignment makes pointer from integer without a cast
mod_fastcgi.c:739: warning: assignment makes pointer from integer without a cast
mod_fastcgi.c:768: warning: initialization makes pointer from integer without a cast
mod_fastcgi.c:838: warning: return makes pointer from integer without a cast
mod_fastcgi.c:842: warning: return makes pointer from integer without a cast
mod_fastcgi.c: In function `set_uid_n_gid':
mod_fastcgi.c:1022: warning: passing arg 1 of `memcpy' makes pointer from integer without a cast
mod_fastcgi.c:1024: warning: assignment makes pointer from integer without a cast
mod_fastcgi.c:1033: warning: assignment makes pointer from integer without a cast
mod_fastcgi.c:1034: warning: assignment makes pointer from integer without a cast
mod_fastcgi.c: In function `do_work':
mod_fastcgi.c:2321: error: `ap_null_cleanup' undeclared (first use in this function)
mod_fastcgi.c: In function `create_fcgi_request':
mod_fastcgi.c:2479: warning: assignment makes pointer from integer without a cast
mod_fastcgi.c:2492: warning: assignment makes pointer from integer without a cast
mod_fastcgi.c: In function `apache_is_scriptaliased':
mod_fastcgi.c:2534: warning: initialization makes pointer from integer without a cast
mod_fastcgi.c: In function `post_process_for_redirects':
mod_fastcgi.c:2559: warning: passing arg 1 of `ap_internal_redirect_handler' makes pointer from integer without a cast
mod_fastcgi.c: In function `check_user_authentication':
mod_fastcgi.c:2682: warning: assignment makes pointer from integer without a cast
mod_fastcgi.c:2700: warning: comparison between pointer and integer
mod_fastcgi.c: In function `check_user_authorization':
mod_fastcgi.c:2749: warning: assignment makes pointer from integer without a cast
mod_fastcgi.c:2765: warning: comparison between pointer and integer
mod_fastcgi.c: In function `check_access':
mod_fastcgi.c:2809: warning: assignment makes pointer from integer without a cast
mod_fastcgi.c:2826: warning: comparison between pointer and integer
make: *** [mod_fastcgi.slo] 错误 1

这个错误通过网上的一个帖子得到了解决,首先创建一个Patch文件:

[root@eygle mod_fastcgi-2.4.2]# vi a

@@ -73,6 +73,36 @@
#define ap_reset_timeout(a)
#define ap_unblock_alarms()

+/* starting with apache 2.2 the backward-compatibility defines for
+ * 1.3 APIs are not available anymore. Define them ourselves here.
+ */
+#ifndef ap_copy_table
+
+#define ap_copy_table apr_table_copy
+#define ap_cpystrn apr_cpystrn
@@ -73,6 +73,36 @@
#define ap_reset_timeout(a)
#define ap_unblock_alarms()

+/* starting with apache 2.2 the backward-compatibility defines for
+ * 1.3 APIs are not available anymore. Define them ourselves here.
+ */
+#ifndef ap_copy_table
+
+#define ap_copy_table apr_table_copy
+#define ap_cpystrn apr_cpystrn
+#define ap_destroy_pool apr_pool_destroy
+#define ap_isspace apr_isspace
+#define ap_make_array apr_array_make
+#define ap_make_table apr_table_make
+#define ap_null_cleanup apr_pool_cleanup_null
+#define ap_palloc apr_palloc
+#define ap_pcalloc apr_pcalloc
+#define ap_psprintf apr_psprintf
+#define ap_pstrcat apr_pstrcat
+#define ap_pstrdup apr_pstrdup
+#define ap_pstrndup apr_pstrndup
+#define ap_push_array apr_array_push
+#define ap_register_cleanup apr_pool_cleanup_register
+#define ap_snprintf apr_snprintf
+#define ap_table_add apr_table_add
+#define ap_table_do apr_table_do
"a" [新] 38L, 1207C 已写入

然后应用这个patch文件:

[root@eygle mod_fastcgi-2.4.2]# patch -fcgi.h < a
File to patch: fcgi.h
patching file fcgi.h

再次编译错误得到解决:

[root@eygle mod_fastcgi-2.4.2]# make
/opt/httpd-2.2.0/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/opt/httpd-2.2.0/srclib/pcre -I. -I/opt/httpd-2.2.0/os/unix -I/opt/httpd-2.2.0/server/mpm/prefork -I/opt/httpd-2.2.0/modules/http -I/opt/httpd-2.2.0/modules/filters -I/opt/httpd-2.2.0/modules/proxy -I/opt/httpd-2.2.0/include -I/opt/httpd-2.2.0/modules/generators -I/opt/httpd-2.2.0/modules/mappers -I/opt/httpd-2.2.0/modules/database -I/opt/httpd-2.2.0/srclib/apr/include -I/opt/httpd-2.2.0/srclib/apr-util/include -I/opt/httpd-2.2.0/modules/proxy/../generators -I/opt/httpd-2.2.0/modules/ssl -I/opt/httpd-2.2.0/modules/dav/main -prefer-pic -c mod_fastcgi.c && touch mod_fastcgi.slo
/opt/httpd-2.2.0/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/opt/httpd-2.2.0/srclib/pcre -I. -I/opt/httpd-2.2.0/os/unix -I/opt/httpd-2.2.0/server/mpm/prefork -I/opt/httpd-2.2.0/modules/http -I/opt/httpd-2.2.0/modules/filters -I/opt/httpd-2.2.0/modules/proxy -I/opt/httpd-2.2.0/include -I/opt/httpd-2.2.0/modules/generators -I/opt/httpd-2.2.0/modules/mappers -I/opt/httpd-2.2.0/modules/database -I/opt/httpd-2.2.0/srclib/apr/include -I/opt/httpd-2.2.0/srclib/apr-util/include -I/opt/httpd-2.2.0/modules/proxy/../generators -I/opt/httpd-2.2.0/modules/ssl -I/opt/httpd-2.2.0/modules/dav/main -prefer-pic -c fcgi_pm.c && touch fcgi_pm.slo
/opt/httpd-2.2.0/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/opt/httpd-2.2.0/srclib/pcre -I. -I/opt/httpd-2.2.0/os/unix -I/opt/httpd-2.2.0/server/mpm/prefork -I/opt/httpd-2.2.0/modules/http -I/opt/httpd-2.2.0/modules/filters -I/opt/httpd-2.2.0/modules/proxy -I/opt/httpd-2.2.0/include -I/opt/httpd-2.2.0/modules/generators -I/opt/httpd-2.2.0/modules/mappers -I/opt/httpd-2.2.0/modules/database -I/opt/httpd-2.2.0/srclib/apr/include -I/opt/httpd-2.2.0/srclib/apr-util/include -I/opt/httpd-2.2.0/modules/proxy/../generators -I/opt/httpd-2.2.0/modules/ssl -I/opt/httpd-2.2.0/modules/dav/main -prefer-pic -c fcgi_util.c && touch fcgi_util.slo
/opt/httpd-2.2.0/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/opt/httpd-2.2.0/srclib/pcre -I. -I/opt/httpd-2.2.0/os/unix -I/opt/httpd-2.2.0/server/mpm/prefork -I/opt/httpd-2.2.0/modules/http -I/opt/httpd-2.2.0/modules/filters -I/opt/httpd-2.2.0/modules/proxy -I/opt/httpd-2.2.0/include -I/opt/httpd-2.2.0/modules/generators -I/opt/httpd-2.2.0/modules/mappers -I/opt/httpd-2.2.0/modules/database -I/opt/httpd-2.2.0/srclib/apr/include -I/opt/httpd-2.2.0/srclib/apr-util/include -I/opt/httpd-2.2.0/modules/proxy/../generators -I/opt/httpd-2.2.0/modules/ssl -I/opt/httpd-2.2.0/modules/dav/main -prefer-pic -c fcgi_protocol.c && touch fcgi_protocol.slo
/opt/httpd-2.2.0/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/opt/httpd-2.2.0/srclib/pcre -I. -I/opt/httpd-2.2.0/os/unix -I/opt/httpd-2.2.0/server/mpm/prefork -I/opt/httpd-2.2.0/modules/http -I/opt/httpd-2.2.0/modules/filters -I/opt/httpd-2.2.0/modules/proxy -I/opt/httpd-2.2.0/include -I/opt/httpd-2.2.0/modules/generators -I/opt/httpd-2.2.0/modules/mappers -I/opt/httpd-2.2.0/modules/database -I/opt/httpd-2.2.0/srclib/apr/include -I/opt/httpd-2.2.0/srclib/apr-util/include -I/opt/httpd-2.2.0/modules/proxy/../generators -I/opt/httpd-2.2.0/modules/ssl -I/opt/httpd-2.2.0/modules/dav/main -prefer-pic -c fcgi_buf.c && touch fcgi_buf.slo
/opt/httpd-2.2.0/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/opt/httpd-2.2.0/srclib/pcre -I. -I/opt/httpd-2.2.0/os/unix -I/opt/httpd-2.2.0/server/mpm/prefork -I/opt/httpd-2.2.0/modules/http -I/opt/httpd-2.2.0/modules/filters -I/opt/httpd-2.2.0/modules/proxy -I/opt/httpd-2.2.0/include -I/opt/httpd-2.2.0/modules/generators -I/opt/httpd-2.2.0/modules/mappers -I/opt/httpd-2.2.0/modules/database -I/opt/httpd-2.2.0/srclib/apr/include -I/opt/httpd-2.2.0/srclib/apr-util/include -I/opt/httpd-2.2.0/modules/proxy/../generators -I/opt/httpd-2.2.0/modules/ssl -I/opt/httpd-2.2.0/modules/dav/main -prefer-pic -c fcgi_config.c && touch fcgi_config.slo
/opt/httpd-2.2.0/srclib/apr/libtool --silent --mode=link gcc -g -O2 -pthread -o mod_fastcgi.la -rpath /opt/apache/modules -module -avoid-version mod_fastcgi.lo fcgi_pm.lo fcgi_util.lo fcgi_protocol.lo fcgi_buf.lo fcgi_config.lo
[root@eygle mod_fastcgi-2.4.2]# make install
make[1]: Entering directory `/opt/mod_fastcgi-2.4.2'
/opt/httpd-2.2.0/srclib/apr/libtool --silent --mode=install cp mod_fastcgi.la /opt/apache/modules/
make[1]: Leaving directory `/opt/mod_fastcgi-2.4.2'
make: *** 没有规则可以创建“install”需要的目标“install-modules”。 停止。

之后修改Apache的配置文件,增加一行:

LoadModule fastcgi_module modules/mod_fastcgi.so

再更改mt目录下相应的文件:

mv mt.cgi mt.fcgi
mv mt-comments.cgi mt-comments.fcgi
mv mt-tb.cgi mt-tb.fcgi
mv mt-view.cgi mt-view.fcgi
mv mt-search.cgi mt-search.fcgi

最后更改一下mt-config.cgi文件:
AdminScript mt.fcgi
CommentScript mt-comments.fcgi
TrackbackScript mt-tb.fcgi
SearchScript mt-search.fcgi
ViewScript mt-view.fcgi

现在重起Apache,服务器就应该运行在fastcgi模式下了,可是没那么简单,发现日志里面报错:

[Thu Feb 01 14:55:49 2007] [warn] FastCGI: (dynamic) server "/opt/apache/www.eygle.com/cgi-bin/mt/mt.fpl" restarted (pid 31719)
Can't locate FCGI.pm in @INC (@INC contains: /opt/apache/www.eygle.com/cgi-bin/mt/extlib lib /usr/lib/perl5/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1

fastcgi不能定位FCGI.pm,原来perl还没装fcgi模块,赶快再装一个:

[root@eygle logs]# cpan
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.7601)
ReadLine support available (try 'install Bundle::CPAN')

cpan> d /FCGI/
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
Database was generated on Wed, 17 Jan 2007 23:26:48 GMT
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
ftp://mirrors.hknet.com/CPAN/authors/01mailrc.txt.gz
Going to read /root/.cpan/sources/authors/01mailrc.txt.gz
CPAN: Compress::Zlib loaded ok
Fetching with LWP:
ftp://mirrors.hknet.com/CPAN/modules/02packages.details.txt.gz
Going to read /root/.cpan/sources/modules/02packages.details.txt.gz
Database was generated on Wed, 31 Jan 2007 23:28:14 GMT

There's a new CPAN.pm version (v1.8802) available!
[Current version is v1.7601]
You might want to try
install Bundle::CPAN
reload cpan
without quitting the current session. It should be a seamless upgrade
while we are running...

Fetching with LWP:
ftp://mirrors.hknet.com/CPAN/modules/03modlist.data.gz
Going to read /root/.cpan/sources/modules/03modlist.data.gz
Going to write /root/.cpan/Metadata
Distribution J/JU/JURACH/FCGI-ProcManager-0.17.tar.gz
Distribution P/PE/PEVANS/FCGI-Async-0.07.tar.gz
Distribution S/SK/SKIMO/FCGI-0.67.tar.gz
3 items found

cpan> install S/SK/SKIMO/FCGI-0.67.tar.gz
Running make for S/SK/SKIMO/FCGI-0.67.tar.gz
Fetching with LWP:
ftp://mirrors.hknet.com/CPAN/authors/id/S/SK/SKIMO/FCGI-0.67.tar.gz
CPAN: Digest::MD5 loaded ok
Fetching with LWP:
ftp://mirrors.hknet.com/CPAN/authors/id/S/SK/SKIMO/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/S/SK/SKIMO/FCGI-0.67.tar.gz ok
Scanning cache /root/.cpan/build for sizes
FCGI-0.67/
FCGI-0.67/configure.in
FCGI-0.67/threaded.PL
FCGI-0.67/test.pl
FCGI-0.67/FCGI.XL
FCGI-0.67/remote.PL
FCGI-0.67/configure.readme
FCGI-0.67/version.pm
FCGI-0.67/echo.PL
FCGI-0.67/MANIFEST
FCGI-0.67/typemap
FCGI-0.67/fcgi_config.h.in
FCGI-0.67/ChangeLog
FCGI-0.67/FCGI.PL
FCGI-0.67/configure
FCGI-0.67/Makefile.PL
FCGI-0.67/README
FCGI-0.67/LICENSE.TERMS
FCGI-0.67/fcgiapp.c
FCGI-0.67/os_unix.c
FCGI-0.67/os_win32.c
FCGI-0.67/fastcgi.h
FCGI-0.67/fcgiapp.h
FCGI-0.67/fcgimisc.h
FCGI-0.67/fcgios.h
FCGI-0.67/fcgi_config_x86.h

CPAN.pm: Going to build S/SK/SKIMO/FCGI-0.67.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for FCGI
Running ./configure for you
Please read configure.readme for information on how to run it yourself
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for ssize_t... yes
checking for sun_len in sys/un.h... no
checking for fpos_t in stdio.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking for unistd.h... (cached) yes
checking for a fileno() prototype in stdio.h... yes
checking whether cross-process locking is required by accept()... no
checking whether va_arg(arg, long double) crashes the compiler... no
checking for an ANSI C-conforming const... yes
configure: creating ./config.status
config.status: creating fcgi_config.h
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" FCGI.PL FCGI.pm
Generating FCGI.pm
cp FCGI.pm blib/arch/FCGI.pm
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" FCGI.XL FCGI.xs
Generating FCGI.xs for Perl version 5.008005
/usr/bin/perl /usr/lib/perl5/5.8.5/ExtUtils/xsubpp -typemap /usr/lib/perl5/5.8.5/ExtUtils/typemap -typemap typemap FCGI.xs > FCGI.xsc && mv FCGI.xsc FCGI.c
gcc -c -I. -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -DVERSION=\"0.67\" -DXS_VERSION=\"0.67\" -fPIC "-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE" FCGI.c
gcc -c -I. -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -DVERSION=\"0.67\" -DXS_VERSION=\"0.67\" -fPIC "-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE" fcgiapp.c
gcc -c -I. -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -DVERSION=\"0.67\" -DXS_VERSION=\"0.67\" -fPIC "-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE" os_unix.c
Running Mkbootstrap for FCGI ()
chmod 644 FCGI.bs
rm -f blib/arch/auto/FCGI/FCGI.so
gcc -shared -L/usr/local/lib FCGI.o fcgiapp.o os_unix.o -o blib/arch/auto/FCGI/FCGI.so
chmod 755 blib/arch/auto/FCGI/FCGI.so
cp FCGI.bs blib/arch/auto/FCGI/FCGI.bs
chmod 644 blib/arch/auto/FCGI/FCGI.bs
Manifying blib/man3/FCGI.3pm
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" echo.PL echo.fpl
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" remote.PL remote.fpl
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" threaded.PL threaded.fpl
/usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
1..1
# Running under perl version 5.008005 for linux
# Current time local: Thu Feb 1 14:59:37 2007
# Current time GMT: Thu Feb 1 06:59:37 2007
# Using Test.pm version 1.25
ok 1
/usr/bin/make test -- OK
Running make install
Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/FCGI.pm
Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/FCGI/FCGI.bs
Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/FCGI/FCGI.so
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/share/man/man3/FCGI.3pm
Writing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/FCGI/.packlist
Appending installation info to /usr/lib/perl5/5.8.5/i386-linux-thread-multi/perllocal.pod
/usr/bin/make install -- OK

cpan> quit
Terminal does not support GetHistory.
Lockfile removed.

现在Fastcgi终于生效了,不过没感觉有什么改善,有待进一步的观察!
参考文档:
http://www.lifewiki.net/sixapart/HostingMTUnderFastCGI
http://easun.org/archives/mt334_fastcgi.html
http://www.anysql.net/weblog/mt_fastcgi_scode.html
http://www.fastcgi.com/archives/fastcgi-developers/2005-December/004060.html

-The End-

Posted by eygle at 3:11 PM | Comments (3)


上一页 1 2


CopyRight © 2004-2008 eygle.com, All rights reserved.