2004年09月09日

咖啡加糖 02:26:58
噢,王云跟人合伙出书了
普罗米修斯 17:17:06
啊?
咖啡加糖 02:28:04
意料之中的事,你很吃惊啊?
普罗米修斯 17:18:27
为什么?
咖啡加糖 02:30:02
她有惊人之举都不足为奇啊(好的或者坏的),何况不是什么大事
普罗米修斯 17:20:42
书叫什么名字?
咖啡加糖 02:32:14
好像是营销的,<<从营销新手到营销冠军>>,人民邮电出版的

 

使用Oracle9i数据库的九大注意事项

   Oracle数据库的9.2.0.1.0版本中的Oracle HTTP Server有如下变化:

  一、关于Apache Jserv进程

  Oracle HTTP Server支持的Apache Jserv进程的最大数目已经从Apache发布的缺省值最大值25增加到最大值128,这个值是不可实时配置的。

  二、JDK/JRE 认证

  Oracle被认证使用JDK/JRE 1.3.1_01和JDK/JRE 1.2.2_07两者来建立和配置带有mod_jserv 模块的Java应用程序。

  在 9.2.0.1.0版本中,所有的Java类库(如BC4J、XDK)连同JDK 1.1.8_10被装载和编译。这些编译类被认证运行在Java JRE支持的版本中,并且他们必须没被重新编译。

  三、模块mod_plsql 的需求

  针对一个特定的后端数据库使用mod_plsql 模块,你需要手动安装Oracle PL/SQL Web 工具包(OWA PL/SQL packages)在特定的后端数据库上。OWA PL/SQL packages应安装在SYS数据库模式下,确保你只安装它一次。注意已经存在的Oracle Application Server(OAS)用户迁移到Oracle HTTP Server时,必须替换这些包的老版本。

  在Oracle HTTP Server中使用PL/SQL网关的更多信息请查阅http://hostname.domain:port/pls/admin_/title.htm
  四、恢复应用服务器的OWA包

  当你安装新的mod_plsql OWA包时,它们被放在SYS数据库用户模式下,这会为应用服务器(Oracle Application Server)使用OAS PL/SQL cartridge组件带来问题,如果你遇到这些问题并且想继续使用OAS的PL/SQL cartridge组件,就必须重新建立一些同义词,使得这些同义词参照到OWA包。在源数据库上建立同义词的步骤如下:

  1.SYS帐户在SQL*Plus中连接到数据库

  2.在SQL*Plus中运行下列命令,这将删除所有在Oracle HTTP Server安装进程中建立的OWA公共同义词。

  drop public synonym OWA_CUSTOM;

  drop public synonym OWA_GLOBAL;

  drop public synonym OWA;

  drop public synonym HTF;

  drop public synonym HTP;

  drop public synonym OWA_COOKIE;

  drop public synonym OWA_IMAGE;

  drop public synonym OWA_OPT_LOCK;

  drop public synonym OWA_PATTERN;

  drop public synonym OWA_SEC;

  drop public synonym OWA_TEXT;

  drop public synonym OWA_UTIL;

  drop public synonym OWA_INIT;

  drop public synonym OWA_CACHE;

  drop public synonym WPG_DOCLOAD;
  3.连接到OWA包的安装模式oas_public,确保该用户具有CREATE PUBLIC SYNONYM权限,如果没有,则须手动为此用户授此权限。

  4.运行下列命令。这将重新建立OWA公共同义词使其参照到Oracle Application Server 的OWA包。

  create public synonym OWA_CUSTOM for OWA_CUSTOM;

  create public synonym OWA_GLOBAL for OWA_CUSTOM;

  create public synonym OWA for OWA;

  create public synonym HTF for HTF;

  create public synonym HTP for HTP;

  create public synonym OWA_COOKIE for OWA_COOKIE;

  create public synonym OWA_IMAGE for OWA_IMAGE;

  create public synonym OWA_OPT_LOCK for OWA_OPT_LOCK;

  create public synonym OWA_PATTERN for OWA_PATTERN;

  create public synonym OWA_SEC for OWA_SEC;

  create public synonym OWA_TEXT for OWA_TEXT;

  create public synonym OWA_UTIL for OWA_UTIL;

  create public synonym OWA_INIT for OWA_CUSTOM;

  create public synonym OWA_CACHE for OWA_CACHE;

  create public synonym WPG_DOCLOAD for WPG_DOCLOAD;
  五、在同样的Oracle主目录中重新安装时防止Oracle HTTP Server的配置改变

  确认已经保存了httpd.conf、jserv.conf、zone.properties和所有的你已经改变的Oracle HTTP Server配置文件的复制文件。根据你安装Oracle9i的版本2(9.2.0.1.0)到与以前的Oracle的相同主目录下的方式不同,这些配置文件可能会被新闻件覆盖。

  六、为Apache Jserv应用增加内存>

  如果Apache Jserv日志文件或浏览器报告“Out Of Memory”,原因是JVM内存溢出,这通常发生在被JVM把持的数据超出它的内存分配单元。增加为JVM分配的内存池的最大值的步骤如下:

  1.在文件$ORACLE_HOME/Apache/Jserv/etc/jserv.properties中增加一行 wrapper.bin.parameters=-mxm

  的单位是兆字节(MB),内存缺省值是1 MB,Oracle推荐使用128 MB,则增加如下wrapper.bin.parameters=-mx128m

  2.重新启动Web服务器

  七、NLS注意事项
 
  1.针对mod_plsql

  配置mod_plsql时,环境变量NLS_LANG是在每个Web server实例级别配置而不是在DAD级别配置。确保在启动你的Oracle HTTP Server实例前正确配置环境变量NLS_LANG。

  2.针对Oracle PSP(PL/SQL页面)

  对于Oracle PSP,环境变量NLS_LANG必须在使用loadpsp命令行程序加载 PL/SQL服务器页面(PSPs)到数据库之间配置。

  3.在Jserv和OracleJSP中使用JDBC OCI8驱动程序

  如果通过JDBC OCI8驱动器连接到数据库时,在文件jserv.properties中需要合适的NLS_LANG设置。比如:
  wrapper.env=NLS_LANG=AMERICAN_AMERICA.UTF8

  八、为EJBs配置listener.ora文件

  在9.2.0.1.0版本中,Oracle HTTP Server的安装没有配置listener.ora文件来运行Enterprise JavaBeans (EJBs),为了运行EJBs,你需要如下配置listener.ora文件:

  LISTENER =

  (DESCRIPTION_LIST =

  (DESCRIPTION =

  (ADDRESS_LIST =

  (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
  )

  (ADDRESS_LIST =

  (ADDRESS = (PROTOCOL = IPC)(KEY = icache))

  )

  (ADDRESS_LIST =

  (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1521))

  )

  )
 (DESCRIPTION =

  (PROTOCOL_STACK =

  (PRESENTATION = GIOP)

  (SESSION = RAW)

  )

  (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 2481))

  )

  )

  SID_LIST_LISTENER =

  (SID_LIST =

  (SID_DESC =

  (SID_NAME = PLSExtProc)

  (ORACLE_HOME = )

  (PROGRAM = extproc)

  )

  (SID_DESC =

  GLOBAL_DBNAME = icache)

  (ORACLE_HOME = )

  (SID_NAME = icache)

  )

  其中是你的计算机的实际主机名,是你的Oracle主目录$ORACLE_HOME。

  九、使用Oracle XSU的限制

  在9.2.0.1.0版本中,Oracle XML SQL Utility (XSU)没有包含setEncoding方法,为了下载XSU的支持编码功能的最新版本,请查阅http://otn.oracle.com/tech/xml/oracle_xsu/


作者Blog:http://blog.csdn.net/spirityj/

互联网的日益普及使得以信息、创意和智慧为代表的“虚拟团队”正以“随风潜入夜、润物细无声”的姿态成为企业组织发展的新趋势。

咋一听,虚拟团队这个词也许令你有点丈二和尚摸不着头脑,但实际上,你身边就活跃着无数的“虚拟团队”。他们可能是咨询顾问,可能是企业营销活动的策划师,也可能是网页制作人员。他们不是你每天都能见面、坐在同一办公室并肩作战的同事,他们通过Internet、电话、传真或者网络视频来与你进行频频沟通。

总而言之,他们是“虚拟”的,同时,他们又是实实在在的。他们由一批更为专业的人才所组成,他们呼之即来,来之能战,战之能胜。你不拥有他们,但可调用他们的知识和经验;你不是他们的老板,却要像老板一样管理和协调他们。

无形团队的优势

竞争优势。对于善用网络资源,善用公司内部人力、财力的你来说,“虚拟团队”可以在最少成本、最低风险的情况下,为你创造出更多的价值与利润。

杠杆优势。现代通信与信息技术的使用使得“地球村”成为了现实,区位不再成为直接影响人们工作与生活地点的因素,这就使得组织可以动态地集聚和利用世界各地的优秀人才,能够充分获取世界各地的技术、知识、产品信息资源,收集各地顾客的相应信息。同时,通过知识共享、信息共享、技术手段共享等,优秀成员好的经验、灵感能够很快在数字化管理网络内得以推广,实现优势互补和有效合作。

效率优势。团队是高效组织应付环境变化的有效手段之一,而虚拟团队利用最新的网络、邮件、移动电话、可视电话会议等技术实现基本的沟通。团队成员之间可以及时地进行信息交流,“一呼天下应”,可以防止信息滞留,从而缩短了信息沟通和交流所用的时间,能够确保及时作出相对正确的决策。

成本优势。虚拟团队在相当程度上实现了“无边界组织”,使得组织可以大量利用外部人力资源条件,从而减轻了组织内部人工成本压力。在此基础上,组织可以大力精简机构,重新设计组织构架,使人员朝有利于组织发展的方向流动,促使组织结构扁平化。此外,团队柔性的工作模式减少了成员的办公费用、为聚集开会而支付的旅行费用等,也减少了重新安置员工的费用,从而大幅降低了管理成本。

无形团队的管理特征:有形

虚拟团队依赖信息技术实现远程沟通,其技术上的诱惑力显而易见,能够在相当程度上实现“运筹帷幄,决胜千里”。但也使得团队管理与协调问题更加复杂化,稍有不慎,就会造成管理失控。面对这种无形的团队,唯有依靠有形的管理,才能真正做到“形散而神聚”!

创建信任氛围。虚拟团队管理的核心问题实质上是信任的建立和维系。因此虚拟团队的管理体系和管理思维都应围绕“信任”展开。首先,高科技唯有高接触,才能建立起高信任。网络时代最常见的失误是企图在纯粹的数字化中建立信任。试想,当你联系的对象都是数字化代码或单纯的电邮地址,你怎么能给予对方信任呢?实际上网络经济中的最大悖论就是:组织的虚拟程度越高,人们对人情味的需求就越强烈,它的成员愈是需要见面。就算是视频会议,如果能让开会的人彼此熟知屏幕上的影像是谁,开起来将更容易,也更有生产力。其次,信任需要界限。无限的信任既不现实,也不合理。组织对虚拟团队成员的信任其实是一种信心,即对成员能力与承诺的信心。做到这一点,必须对组织进行重新建构,比如改变过往以层分派下达的安排方式,转而建立任务封闭式的独立工作单元。使他们在各自的领域内充分发挥知识结构优势,进行创造性的活动。当然,这种封闭式工作单元如果不能及时跟上市场、客户和技术的变化,也会给整个组织造成巨大损失,因此,成员必须时刻紧跟变化的步伐,形成一种不断学习的文化。

调整成员角色定位。虚拟团队成员一般以知识型员工居多,远程管理使得组织的监督与控制功能弱化,这种情况下,仍然沿用传统的“员工”定位是行不通的。在虚拟团队中,需要对成员重新定位,把他们从“劳动者”角色转为“会员”角色。作为会员,他们需签订会员协议,享有相应权利和责任,最重要的是参与管理。成员归属的对象也不应是某个“地方”,而是由所有团队成员组成的虚拟“社区”。因此,我们应当注意营造团队的“社区”氛围,使成员产生归属感,增强群体意识,允许自由交流,使他们成为朋友和伙伴。

建立有效的激励与约束机制。团队运作仅依靠信任关系的维系还是不够的,还必须建立起有效的激励与约束机制,以调动成员的积极性,规避成员的道德风险。首先,信而有约。在给予充分信任的同时,必须保证个体目标和整个团队目标的一致性,这就要求把信任和契约联系在一起,以契约的形式明确成员的权利、义务以及违约责任等。其次,在把握虚拟团队成员组成特点的基础上,深入研究各虚拟成员的需要,构建有效的激励机制,如建立良好的团队环境、提供挑战性的工作、给予丰厚的回报、组织跨地域学习、交流。众所周知,建立团队激励机制的最大困难在于难以衡量个体的业绩,这也意味着在虚拟团队管理中,往往需要把激励机制建立在团队产出的基础上,这就要求激励框架要有对团队内部协调性的刺激,通过把个人收益和团队业绩结合起来,促使成员更加努力工作。

跨文化管理与协调。组建虚拟团队特别是全球化的跨组织虚拟团队,出现文化冲突是不可避免的。为此,首先可以通过文化敏感性培训,让成员了解文化差异的状况,以及可能带来的相应问题,使成员接受和认可他人的文化背景,尊重他人的语言风格以及行为习惯、宗教信仰等,以减少因不同文化带来的冲突。其次,在尊重成员个体文化背景的基础上,加强团队文化建设,形成与整体目标一致的团队文化。此外,促进工作、信息标准化,通过与工作有关的程序、方法的标准化,可获得一定范围内的统一性,有利于沟通。例如规定成员每天至少接收两次E-mail,以解决因作息时间不同而导致的信息反馈的延迟;再如,在与工作有关的信件中,尽量使用标准格式,从而避免因文化差异造成的误解问题。

虚拟的团队本身可以说是无形的,而管理却实实在在。不难预计,谁能顺利地实现转型,谁就能在知识经济时代占尽先机!

# 嘘—-不要告诉他们我做了好事,这会影响我的形象的!

# 你竟然带了一个又老又没用的家伙回来,而且不是我。

# 爱情来得快去得也快,只有猪肉卷是永恒的。

# 加菲猫肯定不是为猪肉卷而生,但猪肉卷一定是为加菲猫而生。   

# 欧迪,我们去吃冰激凌吧,不过你得看着我吃。   

# 我应该对欧迪有礼貌。――(吲迪一脚)――很抱歉,欧迪?现在我做到了。   

# 我不能让那只鸡在我的名字后面写字。  

# 这个汉堡包的味道不错,但不如前八个好。   

# 欧迪,走,我们去买一个或九个汉堡包当晚餐。   

# 肚子大不可怕,可怕的是肚子里没有好东西。  

# 有了意大利面,谁还会吃老鼠呢?   

# “欧迪在窗外冻得瑟瑟发抖,真可怜。我真有点不忍心看他这样。不,难道我能坐视不管吗?我必须做点什么。”加菲拉上了窗帘。   

# 你可以让小猫离开肉饼,但不能让肉饼离开小猫。   

# 如果你不想给谁东西吃的话,就得让它想着点什么。   

# 巧克力的麻烦是:你把它吃了,它就没了。   

# 最可爱的东西莫过于一张放着猪肉卷的小桌子。   

# (深沉状……)――我是在做梦吗?――(冲到自己“床”前,掀起被子……)被子里没有我,不是在睡觉……   

# 这个世界上还有很多比钱更重要的东西,比如说意大利面。   

# 能从这种不让体重增加的运动中得到乐趣真是太好了。   

# 失败的人特点是会不断地失败。如果你想看看他的失败的话,他是不会让你失望的。   

# 加菲猫要有了三个愿望:“第一个是要猪肉卷,第二个还是猪肉卷,第三个,哦,你错啦,我想要更多的愿望,那样我就能得到更多的猪肉卷啦。”   

# 今后我永远不做对不起欧迪的事,……也许,也许不是永远。   

# 现在,你能把星期一还给我们吗?还有星期三和整个八月,威斯康星州和巧克力糖。……对了,还有一点,你能把我的硬币也还给我吗?   

# 有一位漂亮的女士对乔恩说你真可爱,而你还问我有什么不对!   

# 如果你不能击败你的敌人,那么就加入他们。   

# 纳尔曼,你好。我现在在阿布扎比。这里最糟糕的地方不在于没有意大利面条,也不在于离家几千英里。最可怕的地方在于–这里挤满了被邮寄来的,可爱的猫!   

# “加菲猫,你不会是真的要把我用快件寄到阿布扎比去吧?”   

# “不,纳尔曼,我不会的。我会用慢件,这样可以便宜一点。”   

# 不,水果蛋糕!这是我不吃的三样东西之一。另外两样是葡萄干,还有蜗牛。   

# ――乔恩,你要是猜出这里面有多少巧克力豆,这罐子里的东西就都归你。   

――我猜你已经把它们都吃光了。   

――你猜对了!   

# 纳尔曼:加菲猫,你是来为我辩护的吗?   

加菲猫:不是;我来是为了确认你有罪的。   

… …   

# 你说猫委员会会判纳尔曼多少年刑,我看最好判99年。   

… …   

# 返希你能帮我个忙吗?帮我申请做一只狗,最好是西班牙狮子狗!   

# 狗的问题就在于,它们身上没有装一个ON/OFF开关。   

# 我还得对欧迪说一声对不起――(这时欧迪站在桌子边上,走过去一脚踢将下去。)――现在得说两声。   

# 今天是星期一,一切都不对劲,我该做点什么呢?哦,我知道了。――(吲迪一脚,返闲浮在空中)――哎!今天连地球引力都没精神了。   

# 就到这儿吧!我要去睡今天的第三个午觉了。   

# 我向星星许了个愿。我并不是真的相信它,但是反正也是免费的,而且也没有证据证明它不灵。   

# 我在蹦极,你看不出来吗?   

# 睡了美美的一觉,16个小时,我是喜欢睡短觉的。   

# 加菲猫看见小狗欧迪跑进了一个古城堡,就跟了进去。打开一扇门,一个大厅黑咕隆冬的。   

# 加菲猫喊:“欧迪!”   

回音(渐弱):“欧迪――欧迪――欧迪――”   

加菲猫又喊:“你在哪里?”   

回音(还是渐弱的):“你在哪里?――你在哪里?――你在哪里?――”   

加菲猫想:这声音不错。   

加菲猫继续喊:“加菲猫是世界上最美丽最英俊的猫!”   

回音(渐强的):“不可能――胡说――瞎说――骗人的――”   

# 乔恩:“加菲猫,你猜我给你带什么来了?”   

加菲:不管是什么,只要能吃就行。   

# 乔恩在洗澡,Garfield在睡觉。   

加菲:那些一边洗澡一边唱歌的人应该拉到街上去枪毙。   

# 加菲在饭桌旁等着开饭,乔恩却忙着要出门。   

加菲:嗨,你没有忘记什么重要的事情吗?   

……   

加菲:要知道,在有些州不给猫做早饭是重罪。   

# 加菲:(讲述一个故事)很久很久以前,有一个小姑娘……(画面出现odie身穿公主裙的背影)……她……(odie突然转过身来,伸着长长的舌头)……她丑的就像冰箱里什么都没有一样!!   

# 加菲手里拿着一个冰激凌,对odie说:odie,要不要舔一下?odie满心欢喜的诚恳又期待的望着加菲。加菲伸出舌头在odie脸上很用力的舔了一下,继续吃冰激凌……   

# 虽然欧迪是条狗,但它有时候也过着狗一样的生活。——–猫哲学家   

# (凄凉的小提琴音乐之后)   

嗨!   

高高地抬起你的头,迈开大步朝前走!   

你要向人们证明你不是一个任人欺负的土豆,   

# 你手里握着一只鸟, 那是远远不够的。

2004年09月08日

http://www.oracle.com/technology/tech/opensource/php/apache/inst_php_apache_linux.html

Installing Oracle, PHP, and Apache on Linux

By Robert Clevenger

Are you ready to start using PHP to talk to an Oracle Database? Let’s walk through the steps required to install the Oracle Database, Apache HTTPD Server, and PHP as an Apache module on Linux. Check out the OTN Linux Center to see what versions of Linux are certified for use with the Oracle Database. We will be using Red Hat Enterpise Linux AS (formerly Red Hat Linux Advanced Server 2.1) for this example.

Software Requirements:

Software Version URL
Oracle RDBMS 9.2 /software/products/oracle9i/index.html
Apache HTTPD Server 1.3.28 http://httpd.apache.org/download.cgi
PHP – PHP Hypertext Processor 4.3.2 http://www.php.net/downloads.php

Installing Oracle

You have a choice here. You may either install the database locally on this Linux machine, or you may decide to use an Oracle server located on another machine on your network. If your database will be remote, then only the Oracle Client needs to be installed on this machine. If you database is local, then the full Oracle RDBMS Server needs to be installed. There is one important point to note if you decide to install the software under your Oracle user’s directory (/home/oracle/Oracle92) instead of a new directory (such as /u01/app/oracle/product/9.2). You must ensure that your Oracle user’s directory can be read by the user “nobody“, as this is the user that the Apache HTTPD server and PHP uses. A better solution is to not install the database under the Oracle user’s directory.

Example

# chmod 755 /home/oracle 

Installing Apache HTTP Server

Now that the Oracle Database is installed, you should install Apache. You must install Apache before you can install PHP, since PHP will be installed into Apache.

Here are the commands to install Apache from the the downloaded tar.gz file downloaded from the Apache Web Site. Make special note to include the configure option of “--enable-module=so” as this allows PHP to be compiled as a Dynamic Shared Object (DSO). Also, the “--prefix=” line tells the configure command where Apache will be installed during the command “make install”

Information about GNU TAR

If you are familiar with the TAR command on UNIX systems, you may be wondering why we do not need to invoke gunzip to extract the tar file. Since Linux includes the GNU version of TAR, a new ‘z’ flag is added, and this automatically includes support for uncompressing a gzipped tar file.

Notes:

  1. Your default document root will be /usr/local/apache/htdocs
  2. Make sure to run these as the root user; at a minumim the command "make install” MUST be executed as the root user.

 

# tar zxvf apache_1.3.28.tar.gz # cd apache_1.3.28 # ./configure --prefix=/usr/local/apache \ --enable-module=so # make # make install # /usr/local/apache/bin/apachectl start

You should now test that Apache is up and running on your machine by opening your web browser to the URL http://localhost

Note: You may need to replace “localhost” with your machine’s DNS name if you are behing a firewall, or if localhost does not resolve for some other reason.

Now you should stop the Apache HTTP Server, here is the command:

 # /usr/local/apache/bin/apachectl stop

Installing PHP

Apache is installed, so you can now install PHP. You will uncompress the PHP package, giving you a directory named “php-4.3.2″. You must change into this directory. Now you use the standard UNIX/Linux way of building and installing software from source; configure, make, and then make install.

Notes:

  1. If you do not have the ORACLE_HOME environment variable already set (you probably do not), then replace $ORACLE_HOME with the location of your Oracle Home.
  2. If you get an error about apxs and you see the help screen from apxs displayed, then you need to recompile Apache and ensure that –enable-module=so is specified to the configure command.
  3. You need to change to the root user to perform these commands, or at least you need to be root for the last two.
# tar zxvf php-4.3.2.tar.gz # cd php-4.3.2 # ./configure --with-oci8=$ORACLE_HOME \ --with-apxs=/usr/local/apache/bin/apxs \ --enable-sigchild # make # make install # cp php.ini-dist /usr/local/lib/php.ini 

You must also edit the httpd.conf file which is usually located in /usr/local/apache/conf. You must add the following lines:


# # This will load the PHP module into Apache. Put this line with other LoadModule lines. # LoadModule php4_module libexec/libphp4.so # # This next section will add a handler for .php files, put it with other IfModule lines. #<IfModule mod_php4.c>AddType application/x-httpd-php .php</IfModule>

Starting the Oracle Database

To start the Oracle Database, you must be the Oracle user; normally oracle. You change to the oracle user using the command “su – oracle”. This will change your user and also update the environment for this user. After you change to the Oracle user, you may invoke sqlplus to start the Oracle instance. Following the database startup, the network listener needs to be started. Finally you should change users back to the previous user.

Note: If you are already logged on as the Oracle user, you do NOT need to use the “su” command to become the Oracle user, nor the “exit” at the last line of the example.

# su - oracle # cd $ORACLE_HOME/bin # sqlplus '/ as sysdba' SQL> startup
 ORACLE instance started.
 Total System Global Area 235999352 bytes Fixed Size 450680 bytes Variable Size 201326592 bytes Database Buffers 33554432 bytes Redo Buffers 667648 bytes Database mounted. Database opened.
SQL> exit # lsnrctl start
 LSNRCTL for Linux: Version 9.2.0.1.0 - Production on 25-JUN-2003 21:50:37 Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved. Starting /home/oracle/Oracle92//bin/tnslsnr: please wait... TNSLSNR for Linux: Version 9.2.0.1.0 - Production
 (snip)
 The command completed successfully # exit 
 

Starting the Apache HTTP Server

When you start the Apache HTTP Server, you need to ensure that the required Oracle environment variables are set properly for Oracle. These are the same variables set by the oraenv or coraenv shell scripts normally installed in the directory /usr/local/bin or some other location specified when running the root.sh script during installation. At a minimum, you must have ORACLE_HOME and ORACLE_SID defined. If you run into any issues, you should set the rest of the environment variables recommended in the Installation Guide for Oracle on Linux.

To simplify things, you may create a script to start Apache. I did this and named it start_apache.

start_apache

#!/bin/sh ORACLE_HOME=/u01/app/oracle/product/9.2 ORACLE_SID=orcl export ORACLE_HOME ORACLE_SID echo "Oracle Home: $ORACLE_HOME" echo "Oracle SID: $ORACLE_SID" echo Starting Apache ./apachectl start 

Testing Apache and PHP with Oracle

Testing PHP with Oracle is easy. You simply need to place a PHP file into your htdocs directory; normally /usr/local/apache/htdocs.

Here are two files, the first is used to test basic PHP installation. If PHP is installed you should see a large page full of PHP configuration information. The second file will display part of the ENAME and SAL columns from EMP table in the SCOTT schema. This requires the SCOTT schema be installed, otherwise you will need to modify the page.

phptest.php

<html> <head> <title>PHP Installation Test</title> </head> <body> <?php phpinfo(); ?> </body> </html>

oci8test.php

Note: If your Oracle Database is not local, edit the 2nd line as follows–replacing MyDatabaseTNSEntryName with the TNS entry for your Server:
$db_conn = ocilogon( "scott", "tiger", "MyDatabaseTNSEntryName" );

<?php $db_conn = ocilogon( "scott", "tiger" ); $cmdstr = "select ename, sal from emp"; $parsed = ociparse($db_conn, $cmdstr); ociexecute($parsed); $nrows = ocifetchstatement($parsed, $results); echo "<html><head><title>Oracle PHP Test</title></head><body>"; echo "<center><h2>Oracle PHP Test</h2><br>"; echo "<table border=1 cellspacing='0' width='50%'>\n\<tr>\n"; echo "<td><b>Name</b></td>\n<td><b>Salary</b></td>\n</tr>\n"; for ($i = 0; $i < $nrows; $i++ ) { echo "<tr>\n"; echo "<td>" . $results["ENAME"][$i] . "</td>"; echo "<td>$ " . number_format($results["SAL"][$i], 2). "</td>"; echo "</tr>\n"; } echo "<tr><td colspan='2'> Number of Rows: $nrows</td></tr></table>"; echo "<br><em>If you see data, then it works!</em><br></center></body></html>\n"; ?> 

Conclusion

You should now have the Oracle Database, Apache HTTPD Server, and PHP installed and configured. At this point you are ready to either start learning PHP or writing PHP applications on the Oracle platform.

Robert Clevenger is a Principal Product Manager for Oracle’s Application Development Tools. Robert joined Oracle in 1997 supporting developers on Windows platforms. In 1999 Robert joined the development team of JDeveloper and helped create the all java Oracle9i release of the product. After the first Oracle9i release, he moved into Product Management to focus on Open Source projects and working more closely with Oracle partners.

Linux DevCenter    
 Published on Linux DevCenter (http://www.linuxdevcenter.com/)
 http://www.linuxdevcenter.com/pub/a/linux/2003/09/04/oracle_install.html
 See this if you’re having trouble printing code examples



Installing Oracle 9iR2 on Red Hat 9

by Roko Roic
09/04/2003

There are an ever-growing number of reasons to run the Oracle database server on a Linux-based OS. The price factor is obvious, as OS licenses can really boost the total price of your multiple workstation or clustered (RAC) server installation. Then there’s the stability factor, the possibility of total remote administration, the availability of platform source code, speed, flexible filesystem, the strong Unix legacy …. Heck, even Oracle itself runs its business on what they like to call Unbreakable Linux.

Red Hat’s latest and greatest Linux distribution release comes with quite a few improvements, many of which are targeted at the needs of the workstation user. As new hardware owners become early adopters, this OS will surely dominate Linux developers’ workstations in the months to come. Support for cutting-edge hardware and software technologies, easier maintenance via graphical configuration tools, polished office and productivity applications, a unified interface, development tools, and, of course, Red Hat’s reputation will also make it the OS of choice for many Oracle developers. Unfortunately, unless the current version was certified, Oracle installation hardly ever ran smoothly on Red Hat Linux. Still, where there’s a will, there’s always a way. With a little help from this article, you will have your Oracle 9iR2 server running in no time on your new Red Hat 9 box. Let us begin.

Adding Users and Groups

First, you will need to create the Oracle installation and users and groups. Oracle installation needs two Unix user groups and one runtime Oracle user.

Log in as root and issue the following commands in a terminal:

[root@miniroko]# groupadd dba [root@miniroko]# groupadd oinstall [root@miniroko]# useradd -g oinstall -G dba oracle [root@miniroko]# passwd oracle

The last command will prompt you to enter the password for your oracle user. Make sure you remember it, because you will probably need it as we go along.

Creating Directories

Oracle recommends OFA, the Optimal Flexible Architecture directory structure for a deployment server, but on a development machine and for the sake of simplicity, we will install everything under /opt/ora9.

Just make sure you have at least 3.5GB available for a full installation including one database, and issue the following commands as root:

[root@miniroko]# mkdir -p /opt/ora9/product/9.2 [root@miniroko]# mkdir /var/opt/oracle [root@miniroko]# chown oracle.dba /var/opt/oracle [root@miniroko]# chown -R oracle.dba /opt/ora9 [root@miniroko]# chmod 755 /var/opt/oracle

You have now created Oracle runtime directories and granted write privileges to user oracle and execute privileges to group dba.

Installing Required Tools and Libraries

You will need to install the following Red Hat backward-compatibility and software-development packages before we get further underway. All of these packages can be found on Red Hat installation CDs 1-3.

gcc-3.2.2-5 cpp-3.2.2-5 glibc-devel-2.3.2-11.9 binutils-2.13.90.0.18-9 compat-gcc-7.3-2.96.118.i386.rpm compat-libgcj-7.3-2.96.118.i386.rpm compat-libgcj-devel-7.3-2.96.118.i386.rpm nss_db-compat-2.2-20.i386.rpm

You can install these packages using Redhat’s graphical package manager available in Start menu->System Settings->Add/Remove Applications, or from the command line, using:

rpm -Uvh <package_name>

Replace package_name with each RPM listed above.


Important notice: A shrink-wrapped Red Hat 9 and the freely downloadable version do not contain the same glibc package. The purchased version contains some patches needed for Oracle Intelligent Agent to run correctly, while the downloaded version does not contain these patches. If you are unsure which version of Red Hat you have installed, you will be on the safe side if you replace your glibc packages with prepatched glibc packages prepared by Jason McIntosh. His RPMs were built from the same source (*.rpms) files as the original ones, but with the required patches applied.

If your system contains a non-empty /lib/i686 directory, fetch the i686 packages. Otherwise, you may run into trouble with misplaced libraries. Where an i686 version of the package is not available, just use whatever is.

Once you have downloaded all of the packages, use the command line rpm tool to upgrade:

% rpm -UVh package_name

Setting Kernel Parameters

Red Hat religiously sets some kernel parameters too conservatively. Check your hardware configuration and assign enough shared memory, open files, and ports, or you may run into trouble installing and running Oracle. Append these lines to /etc/sysctl.conf to set kernel parameters:

kernel.shmmax = 536870912 kernel.shmmni = 4096 kernel.shmall = 2097152 kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000

Append these lines to /etc/security/limits.conf to modify your resource limits:

oracle soft nofile 65536 oracle hard nofile 65536 oracle soft nproc 16384 oracle hard nproc 16384

Reboot the system so the kernel changes can take effect. If rebooting is not an option, you can change the kernel params at runtime by issuing:

[root@miniroko]# echo 250 32000 100 128 > /proc/sys/kernel/sem [root@miniroko]# echo 536870912 > /proc/sys/kernel/shmmax [root@miniroko]# echo 4096 > /proc/sys/kernel/shmmni [root@miniroko]# echo 2097152 > /proc/sys/kernel/shmall [root@miniroko]# echo 65536 > /proc/sys/fs/file-max [root@miniroko]# echo 1024 65000 > /proc/sys/net/ipv4/ip_local_port_range

For a full explanation of the /proc filesystem and available parameters, you might want to read Red Hat’s Online Linux Manual.



Oracle Regular Expressions Pocket Reference

Related Reading

Oracle Regular Expressions Pocket Reference
By Jonathan Gennick, Peter Linsley

Table of Contents

Read Online–Safari
Search this book on Safari:

 

Code Fragments only



Setting up the oracle User Environment

Log in as the oracle user:

% su - oracle

I will assume that you are using the default bash shell for this user. Setting environment variables in other shells may differ from this example, so check your shell’s manual page or set bash as the oracle user’s shell. We will set up Oracle basic environment (users, paths, locale) and some extra values needed for Oracle to run correctly on Red Hat 9. Put the following lines at the end of ~/.bashrc:

# oracle 9i export ORACLE_BASE=/opt/ora9 export ORACLE_HOME=/opt/ora9/product/9.2 export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH export ORACLE_OWNER=oracle export ORACLE_SID=ora9i export ORACLE_TERM=xterm # Use old Linuxthreads with floating stacks instead of # the new Native POSIX Thread Library (NPTL) export LD_ASSUME_KERNEL=2.4.1 export THREADS_FLAG=native # Edit paths export LD_LIBRARY_PATH=/opt/ora9/product/9.2/lib:$LD_LIBRARY_PATH export PATH=/opt/ora9/product/9.2/bin:$PATH # # change this NLS settings to suit your country: # example: # german_germany.we8iso8859p15, american_america.we8iso8859p2 etc. # export NLS_LANG='croatian_croatia.ee8iso8859p2'

If you are using other national settings for Oracle (these are Croatian), consult the supported settings and change the NLS_LANG variable accordingly.

The Red Hat 9 Linux kernel comes with the new Native POSIX Thread Library, which causes Oracle installation to hang. By setting the LD_ASSUME_KERNEL variable to an older kernel version, we are making Linux use the old Linuxthreads library. For more information about the difference between these threading methods, please consult the Red Hat 9 Release notes.

“>

Running the Installer

To install 9iR2 on Linux, Oracle recommends at least 512MB of RAM and at least 400MB of swap space. If you have less then 512MB of RAM and upgrading is not an option, you can resize your swap partition or create temporary swapping space. The later is a much more convenient option, as you will be needing this space only during the installation.

To set up a temporary Linux swap area, execute these lines as root:

% dd if=/dev/zero of=tmp_swap bs=1k count=900000 % chmod 600 tmp_swap % mkswap tmp_swap % swapon tmp_swap

After you finish installing, you can free this space:

% swapoff tmp_swap % rm tmp_swap

Now that you have all the major obstacles out of the way, you can run the installer. Please remember that the Oracle installer must be run from X. You will need to allow the local oracle user to write to your X display:

$ xhost +127.0.0.1

Do not change to your CD-ROM mount directory (e.g., /mnt/cdrom), because you will not be able to unmount the first CD to insert others when asked. Start the installer from your home directory using:

$ su - oracle $ /mnt/cdrom/install/linux/runInstaller

Installation

We will not describe the installation process in detail, as Oracle provides extensive documentation on that subject and it is way beyond the scope of this article. It is pretty much self-explanatory, but if you run into trouble, there’s always a help button to assist you. If you need more help, check the docs directory on the Oracle CDs, the online Oracle Documentation, or Oracle Linux Center. During the installation, Oracle will ask you to insert other disks. When asked, open up a new console, unmount the current disk with umount /dev/cdrom (as root) and replace the disk. If Red Hat 9 does not mount it automagically, mount it yourself with mount /dev/cdrom and choose to continue with the installation wizard.

As you go along, your installation may produce three different errors:

  • You may see an error dialog informing about problems with ins_oemagent.mk. Ignore this one; we will fix it in post installation.

    Warning dialog screenshot
    Figure 1. ins_oemagent.mk errors

  • A dialog may inform you about an Error in invoking target install of makefile $ORACLE_HOME/ctx/lib/ins_ctx.mk.

    Warning dialog screenshot
    Figure 2. makefile error

    When this happens, open up a new X terminal and log in as the oracle user. Execute the following commands:

    [oracle@miniroko oracle]$ cd $ORACLE_HOME/install [oracle@miniroko install]$ tail make.log

    You will see a line like this:

    gcc -o ctxhx -L/opt/ora9/product/9.2/ctx/lib/ -L/opt/ora9/product/9.2/lib/ -L/opt/ora9/product/9.2/lib/stubs/ /opt/ora9/product/9.2/ctx/lib/ctxhx.o -L/opt/ora9/product/9.2/ctx/lib/ -lm -lsc_ca -lsc_fa -lsc_ex -lsc_da -lsc_ut -lsc_ch -lsc_fi -lctxhx -lc -Wl,-rpath,/opt/ora9/product/9.2/ctx/lib -lnls9 -lcore9 -lnls9 -lcore9 -lnls9 -lxml9 -lcore9 -lunls9 -lnls9

    Screenshot gnome terminal
    Figure 3. The make.log

    Copy this line, add -ldl at the end, and run it in $ORACLE_HOME/bin.

    [oracle@miniroko]$ cd $ORACLE_HOME/bin [oracle@miniroko bin]$ gcc -o ctxhx -L/opt/ora9/product/9.2/ctx/lib/ -L/opt/ora9/product/9.2/lib/ -L/opt/ora9/product/9.2/lib/stubs/ /opt/ora9/product/9.2/ctx/lib/ctxhx.o -L/opt/ora9/product/9.2/ctx/lib/ -lm -lsc_ca -lsc_fa -lsc_ex -lsc_da -lsc_ut -lsc_ch -lsc_fi -lctxhx -lc -Wl,-rpath,/opt/ora9/product/9.2/ctx/lib -lnls9 -lcore9 -lnls9 -lcore9 -lnls9 -lxml9 -lcore9 -lunls9 -lnls9 -ldl

    Now you have fixed the problem, so hit the ignore button on the dialog and the installation will continue.

  • The installation may inform you that agent failed to start. Choose ignore on this one; we will also fix it in post installation.

Do not create a database at the end of the installation. Not all things are operational at this point, and we still need to perform some minor fixes. Click on Software only and continue. Don’t worry, you will be able to create your database later using dbca, the Oracle database configuration assistant.

Database Create Screenshot
Figure 4. Do not create a database

Post-Installation

Let’s fix the issues Oracle had with ins_ctx.mk and starting the agent. Open a new terminal and log in as the oracle user. Execute these lines:

[oracle@miniroko oracle]$ cd $ORACLE_HOME/network/lib [oracle@miniroko lib]$ make -f ins_net_client.mk install

Now edit the $ORACLE_HOME/ctx/lib/ins_ctx.mk file. Change lines 13-14 from:

ctxhx: $(CTXHXOBJ) $(LINK) $(CTXHXOBJ) $(INSO_LINK)

to

ctxhx: $(CTXHXOBJ) $(LINK) -ldl $(CTXHXOBJ) $(INSO_LINK)

You are now ready to retry making:

[oracle@miniroko lib]$ make -f $ORACLE_HOME/ctx/lib/ins_ctx.mk install

Voila, you now have a fully working installation of Oracle 9iR2 database server. If you wish, you can now create your Oracle database using dbca.

Starting and Stopping the Database

svrmgrl is no longer supported by Oracle, so use sqlplus for startup and shutdown operations. To start the server:

[root@miniroko]# su - oracle [oracle@miniroko oracle]$ lsnrctl start [oracle@miniroko oracle]$ sqlplus /nolog SQL*Plus: Release 9.2.0.1.0 - Production on ?et Svi 29 13:52:34 2003 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. SQL> connect / as sysdba Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 93393176 bytes Fixed Size 450840 bytes Variable Size 75497472 bytes Database Buffers 16777216 bytes Redo Buffers 667648 bytes Database mounted. Database opened. SQL> exit Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.1.0 - Production

To shut down the server:

[root@miniroko]# su - oracle [oracle@miniroko oracle]$ lsnrctl stop [oracle@miniroko oracle]$ sqlplus /nolog SQL*Plus: Release 9.2.0.1.0 - Production on ?et Svi 29 13:55:32 2003 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. SQL> connect / as sysdba Connected. SQL> shutdown Database closed. Database dismounted. ORACLE instance shut down. SQL> exit Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.1.0 - Production

To integrate Oracle with Red Hat’s SysV init process and make startup and shutdown automatic, you can use Gurulab’s Oracle9i RHL Run Package. I do not recommend Oracle’s native scripts $ORACLE_HOME/bin/dbstart and $ORACLE_HOME/bin/dbshut, as they do not always work as advertised and require some changes.

Conclusion

You now have a fully featured Oracle installation on your computer. Please remember that Oracle 9.2 is not certified for Red Hat 9, and that this combination is not endorsed in production and deployment environments. As a workstation, however, it is perfectly stable and usable.

Roko Roic currently works at Tis.kis, developing core and user-level GSM related systems.


Return to the Linux DevCenter.

Copyright ? 2004 O’Reilly Media, Inc.

如何集成Linux/Apache/PHP4/FastCGI/Oracle/MySQL环境

蓝森林 http://www.lslnet.com 2000年8月16日 22:12

作 者: 张宏

一. 准备工作
要实现将以上环境集成,必需先准备好以下软件包:

(一)数据库的Perl接口
1.perl5的Oracle数据库DBI驱动程序:DBD-Oracle-1.03.tar.gz
2.perl5的通用数据库接口程序:DBI-1.13.tar.gz
3.perl5的MySQL数据库DBI驱动程序:Msql-Mysql-modules-1.2209.tar.gz

(二)Oracle数据库
4.Oracle 8iR2(8.1.6) for Linux安装盘:oracle8161.tar.gz

(三)MySQL数据库
5.MySQL 3.22.32服务器程序包:MySQL-3.22.32-1.i386.rpm
6.MySQL客户端程序包:MySQL-client-3.22.32-1.i386.rpm
7.MySQL开发包(头文件/库文件):MySQL-devel-3.22.32-1.i386.rpm
8.MySQL共享库程序包:MySQL-shared-3.22.32-1.i386.rpm

(三)Apache服务器
9.Apache 1.3.12源码包:apache_1.3.12.tar.gz

(四)PHP模块
10.PHP 4.0.0源码包:php-4.0.0.tar.gz

(五)FastCGI模块
11.FastCGI模块源码包:mod_fastcgi_2.2.4.tar.gz
12.FastCGI的perl开发模块:FCGI-0.53.tar.gz

二. 安装Oracle客户端
由于Oracle 8.1.6是在XWindows下安装的,所以必须是事先配置好XWindow,如果你的
显卡不支持XWindow,也可以用exceed进行远程安装(这里不提远程如何安装).
安装Oracle 8.1.6 for Linux详细参见<Oracle 8.1.6安装HOWTO>
在此简单列出操作过程:

(一)设置环境变量:
在/etc/profile中加入:
export ORACLE_HOME=/opt/oracle8i/u01
export ORACLE_BASE=/opt/oracle8i
export ORACLE_OWNER=oracle
export ORACLE_SID=ORCL
export ORACLE_TERM=ansi
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export NLS_LANG=”SIMPLIFIED CHINESE_CHINA.ZHS16CGB231280″

(二)建立oracle组和用户
#/usr/sbin/groupadd dba
#/usr/sbin/useradd -g dba oracle
#/usr/bin/passwd oracle

(三)创建$ORACLE_HOME目录
#mkdir /opt
#mkdir /opt/oracle8i
#mkdir /opt/oracle8i/u01
#chown -R oracle.dba /opt

(四)安装reacle 8iR2
以oracle用户登录,解开Oracle安装包:
$tar zxvf oracle8161.tar.gz
$startx 启动XWindow界面,并打开一个rxvt终端窗口
$cd Oracle8iR2
$./runInstaller
此时出现Oracle安装界面,在安装时选择安装client/Application User
(如果Oracle服务器不在本机上运行,另有专用机器),安装完毕后配置SQL*Net8并
测试连接远程服务器通过即可.

三. 安装MySQL服务器和客户端
以root身分进入,安装MySQL各个包:
#rpm -ivh MySQL-3.22.32-1.i386.rpm
#rpm -ivh MySQL-client-3.22.32-1.i386.rpm
#rpm -ivh MySQL-devel-3.22.32-1.i386.rpm
#rpm -ivh MySQL-shared-3.22.32-1.i386.rpm

四. 安装Perl的数据库接口模块
以root身分进入,然后执行:
#tar zxvf DBI-1.13.tar.gz
#cd DBI-1.13
#perl Makefile.PL
#make
#make test
#make install
#cd ..
#rm -rf DBI-1.13
#
#tar zxvf DBD-Oracle-1.03.tar.gz
#cd DBD-Oracle-1.03
#perl Makefile.PL
#make
#make test
#make install
#cd ..
#rm -rf DBD-Oracle-1.03
#
#tar zxvf Msql-Mysql-modules-1.2209.tar.gz
#cd Msql-Mysql-modules-1.2209
#perl Makefile.PL
选择1(MySQL)和y(支持Mysql.pm)
#make
#make test
#make install
#

五. 安装Apache+PHP+FastCGI

(一)解开Apache/PHP/FastCGI包:
#tar zxvf apache_1.3.12.tar.gz
#tar zxvf php-4.0.0.tar.gz
#tar mod_fastcgi_2.2.4.tar.gz

(二)编译PHP4
配置apache编译参数
#cd apache_1.3.12
#./configure –prefix=/usr/local/apache
配置PHP编译参数
#cd ../php-4.0.0
#./configure –with-apache=../apache_1.3.12 \
> –with-mysql \
> –with-oracle=$ORACLE_HOME \
> –with-oci8=$ORACLE_HOME \
> –enable-track-vars
编译PHP模块:
#make
#make install
创建php.ini参数文件
#cp php.ini-dist /usr/local/lib/php.ini
#cd ..

(三)添加FastCGI模块:
#mv mod_fastcgi_2.2.4 apache_1.3.12/src/modules/fastcgi

(四)编译安装Apache
#cd apache_1.3.12
配置编译参数
#./configure –prefix=/usr/local/apache \
> –activate-module=src/modules/php4/libphp4.a \
> –activate-module=src/modules/fastcgi/libfastcgi.a
编译Apache
#make
安装Apache
#make install

(五)关闭原有系统自带的Apache
#/etc/rc.d/init.d/httpd stop

(六)配置Apache自身参数:
1.编辑/usr/local/apache/conf/httpd.conf文件,修改以下参数:
ServerName host.mydomain.name
DocumentRoot “/home/httpd/html”
<Directory “/home/httpd/html”>
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ “/home/httpd/cgi-bin/”
<Directory “/home/httpd/cgi-bin”>
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.html index.phtml index.php index.htm index.shtml index.fcgi
2.修改自启动链接
#cd /etc/rc.d/init.d
#ln -fs /usr/local/apache/bin/apachectl httpd

(七)配置PHP4.0参数:
1.修改/usr/local/apache/conf/httpd.conf文件,修改以下参数:
增加一行:
AddType application/x-httpd-php .php .phtml .php3
2.修改/usr/local/apache/bin/apachectl脚本,使启动支持中文ORACLE环境:
在文件中66行(“start)”)下面加入几行:
export ORACLE_HOME=/opt/oracle8i/u01
export ORACLE_BASE=/opt/oracle8i
export ORACLE_SID=ORCL
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export NLS_LANG=”SIMPLIFIED CHINESE_CHINA.ZHS16CGB231280″
3.修改/usr/local/apache/conf/srm.conf以在CGI程序中使用环境变量:
PassEnv ORACLE_HOME
PassEnv ORACLE_BASE
PassEnv LD_LIBRARY_PATH
PassEnv NLS_LANG
PassEnv ORACLE_SID
PassEnv PATH

(八)配置FastCGI执行环境:
1.修改/usr/local/apache/conf/httpd.conf文件,修改以下参数:
增加几行:
############ FastCGI Configures Begin ##########################
AddHandler fastcgi-script .fcg .fcgi .fpl
<Location /fcgi>
SetHandler fastcgi-script
Order deny,allow
Allow from all
Options ExecCGI Indexes Includes
</Location>
############### FastCGI Configure End ###########################
2.创建fcgi的执行目录
#mkdir /home/httpd/html/fcgi
3.安装FCGI的Perl运行模块:
#tar zxvf FCGI-0.53.tar.gz
#cd FCGI-0.53
#perl Makefile.PL
#make
#make install

六.启运并测试
1.启动Apache服务器:
#/etc/rc.d/init.d/httpd start
2.编写PHP测试程序:
第一个测试程序:/home/httpd/html/t1.php
内容:
<? phpinfo() ?>
第二个测试PHP与Oracle连接的PHP程序(表已经建好):
<?
$conn=OCIlogon(“username”,”password”,”dblink”);
$stmt=ociparse($conn,”insert into testtable (name,id) values (‘中文测试’,15)”);
ociexecute($stmt);
$stmt=ociparse($conn,”select name from testtab where id=15″);
ocidefinebyname($stmt,”NAME”,&$nick);
ociexecute($stmt);
ocifetch($stmt);
echo “my name is $nick”;
?>
查看是否为中文输出
第三个测试PHP与MySQL连接的PHP程序(表已经建好):
<?
$conn=mysql_connect(“host”,”username”,”password”);
mysql_query(“insert into testtable (name,id) values (‘中文测试’,15)”);
$result=mysql_query(“select name from testtab where id=15″);
$query_data=mysql_fetch_row($result);
$nick=$query_data[0];
echo “my name is $nick”;
?>
3. 编写FastCGI的测试代码: /home/httpd/html/fcgi/test.fcgi
#!/usr/bin/perl
use FCGI;
use DBI;
$dbname=”oracle”;
$user=”user”;
$passwd=”password”;
$dbh=”";

while(FCGI::accept()>=0) {
&parse_form();
$id=$FORM{‘id’};
$para=$FORM{‘para’};
print “Content-type: text/html\n\n”;
print “<html><body>\n”;
if (!$dbh){
print “no oracle, need to connect<br>\n”;
$dbh = DBI->connect(“dbi:Oracle:$dbname”,$user,$passwd);
}else{
print “OK, oracle aleady connected<br>\n”;
}
$sth=$dbh->prepare(“select name from testtable where id=15″);
$sth->execute;
@recs=$sth->fetchrow_array;
$sth->finish;
print “参数id=”.$id.” and my name is @recs[0] <br>\n”;
print “参数para=”.$para.”<br>\n</html>”;
}
####传入参数处理部分#######
sub parse_form {
my($buffer);
my($pairs);
my(@pairs);
my($name);
my($value);
my $meth = $ENV{‘REQUEST_METHOD’};

if ($meth eq ‘GET’ || $meth eq ‘HEAD’) {
$buffer = $ENV{‘QUERY_STRING’};
}
elsif ($meth eq ‘POST’) {
read(STDIN, $buffer, $ENV{‘CONTENT_LENGTH’});
}
undef %FORM;
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(“C”, hex($1))/eg;
$value =~ s/<!–(.|\n)*–>//g;

if ($allow_html != 1) {
$value =~ s/<([^>]|\n)*>//g;
}
$FORM{$name} = $value;
}
}
测试看看FastCGI是否正常执行了

2004年08月24日

随着Linux供应商Lycoris推出PowerPak 1.4,在Linux桌面系统下运行Windows应用程序变得更加容易了。

     使用软件开发商CodeWeavers的技术的一个新程序可以让用户在免交Windows授权费的前提下运行微软的应用程序。CodeWeavers的首席运营官Jon Parshall日前表示集成在PowerPak 1.4中的这个软件让Windows用户向Linux系统迁移更加容易了。

  “我们的系统不需要一份得到完全授权的Windows操作系统的拷贝,这和其他模拟解决方案不同”,他说,“这个系统的工作原理是哄骗微软的程序让它们以为自己是运行在Windows电脑之上”。

2004年08月19日

本文主要介绍Tomcat4.0.6和Tomcat4.1.18两个版本下数据库连接池的配置,及程序对连接池的JNDI查找,并提供相应测试代码。最后指出配置及应用过程中的常见问题及解决方法。

一、Tomcat简介
Tomcat是Apache  Jakarta的子项目之一,是Sun公司推荐的JSP、Servlet容器。作为一款优秀的应用服务器,Tomcat提供了数据库连接池、SSL、Proxy等许多通用组件功能,其中连接池是4.0以上版本的新增功能,应用非常广泛。

二、Tomcat4的连接池
Tomcat4的开发可分为两个阶段,4.0.6是第一阶段最推荐的release版本,内置的数据库连接池为Tyrex  0.9.7.0,Tyrex由exolab.org开发,相关信息可以参见www.  exolab.org。之后,Tomcat的开发者在4.0.x的基础上对Tomcat进行了重构,重构后的release版本推荐4.1.18,这时内置的连接池改为DBCP,DBCP也是由Jakarta  Commons的一个子项目。
接下来,将分别以4.0.6和4.1.18为例介绍这两种连接池对Oracle8.1.7的配置。

三、对Tomcat4.0.6的Tyrex配置

为方便起见,将连接池置于ROOT下,JNDI名设为jdbc/OracleDB,数据库服务器IP为192.168.0.50,SID为oradb,操作系统Win2000,jdk1.3.1,配置步骤如下。

第一步:配置server.xml

在server.xml文件中找到
<!–  Tomcat  Root  Context  –><!–  <Context  path=”"  docBase=”ROOT”  debug=”0″/>–>
将其改为
<!–  Tomcat  Root  Context  –>  <Context  path=”"  docBase=”ROOT”  debug=”0″>  <Resource  name=”jdbc/OracleDB”  auth=”Container”  type=”javax.sql.DataSource”/>  <ResourceParams  name=”jdbc/OracleDB”>  <parameter>  <name>user</name>  <value>holen</value>  </parameter>  <parameter>  <name>password</name>  <value>holen</value>  </parameter>  <parameter>  <name>driverClassName</name>  <value>oracle.jdbc.driver.OracleDriver</value>  </parameter>  <parameter>  <name>driverName</name>  <value>jdbc:oracle:thin:@192.168.0.50:1521:oradb</value>  </parameter>  </ResourceParams>  </Context>

说明:将ROOT的Context从注释中移出来,并定义Resource项,如下:

<Resource  name=”jdbc/OracleDB”  auth=”Container”  type=”javax.sql.DataSource”/>

Resource项(即连接池的DataSource对象),有3个属性name、auth、type,name项是JNDI的名称定义,程序通过JNDI才能找到此对象,这里取名jdbc/OracleDB;auth项即连接池管理权属性,这里取值Container,申明为容器管理;type项即对象的类型,这里取值javax.sql.DataSource,申明为数据库连接池,Tyrex不但可以用作数据库连接池,还有许多别的功能,有兴趣的朋友可以打开Tyrex的jar包看看或访问www.  exolab.org,在这里就不多说了。
在接下来的<ResourceParams>域内容里包含四个参数user、password、driverClassName、driverName,依次为数据库的用户名、密码、JDBC驱动和数据库地址。
用户名、密码是为访问数据库准备的,这里均取值holen。
driverClassName即数据库的JDBC驱动名称,如Oracle8.1.7的JDBC驱动包名叫classes.jar,一般位于Oracle安装目录下的ora81\jdbc\lib目录下,初始扩展名为ZIP,需要手工把classes.zip改名为classes.jar,并放到common/lib下。这里取值oracle.jdbc.driver.OracleDriver,此类由classes.jar提供。

<parameter>  <name>driverClassName</name>  <value>oracle.jdbc.driver.OracleDriver</value></parameter>

对于其他数据库,如MySql,其driverClassName一般为org.gjt.mm.mysql.Driver。

最后一个参数即driverName,即数据库的地址(准确点说应该叫url,4.1.18就改叫url了)
<parameter>  <name>driverName</name>  <value>jdbc:oracle:thin:@192.168.0.50:1521:oradb</value></parameter>

在这里填写里的是Oracle的访问地址,若是MySql、DB2、SqlServer或其他数据库,请填写相应的地址。

第二步:将Oracle的JDBC驱动classes12.jar拷贝到Tomcat安装目录的common/lib下,其他数据库也一样,请把其相应的JDBC驱动包置于common/lib,如MySql的JDBC驱动包mm.mysql-2.0.14.jar。

至此,配置完成,测试代码将在后面给出。

四、对Tomcat4.1.18的DBCP配置

配置方法与4.0.6稍有不同,以下是配置步骤

第一步:配置server.xml
在server.xml文件中找到
<!–  Tomcat  Root  Context  –><!–  <Context  path=”"  docBase=”ROOT”  debug=”0″/>–>
将其改为
<!–  Tomcat  Root  Context  –>  <Context  path=”"  docBase=”ROOT”  debug=”0″>  <Resource  name=”jdbc/OracleDB”  auth=”Container”  type=”javax.sql.DataSource”/>  <ResourceParams  name=”jdbc/OracleDB”>  <parameter>  <name>factory</name>  <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>  </parameter>  <parameter>  <name>driverClassName</name>  <value>oracle.jdbc.driver.OracleDriver</value>  </parameter>  <parameter>  <name>url</name>  <value>jdbc:oracle:thin:@192.168.0.50:1521:oradb</value>  </parameter>  <parameter>  <name>username</name>  <value>holen</value>  </parameter>  <parameter>  <name>password</name>  <value>holen</value>  </parameter>  <parameter>  <name>maxActive</name>  <value>20</value>  </parameter>  <parameter>  <name>maxIdle</name>  <value>10</value>  </parameter>  <parameter>  <name>maxWait</name>  <value>-1</value>  </parameter>  </ResourceParams>  </Context>
说明:从配置文件可以看出,DBCP的配置与Tyrex类似,但功能更加丰富。相同就不多说,重点讲述不同的地方。

factory参数:

<parameter>  <name>factory</name>  <value>org.apache.commons.dbcp.BasicDataSourceFactory</value></parameter>

即基础对象工厂,这里取值org.apache.commons.dbcp.BasicDataSourceFactory,即DBCP自带的工厂,也可以用别的。
需说明一点是,虽然4.1.18里主推DBCP作连接池,但仍然可以使用Tyrex作为连接池,而且此时的Tyrex已从0.9.7.0升级到了1.0,支持JTA/JCA对象等,对象的获取仍然是通过JNDI,具体的配置方法可以参见Tomcat文档。

url参数:
<parameter>  <name>url</name><value>jdbc:oracle:thin:@192.168.0.50:1521:oradb</value>

url是数据库访问地址,在前提已提到。

接下来有三个参数,均为连接数相关,如下:
<parameter>  <name>maxActive</name>  <value>20</value></parameter><parameter>  <name>maxIdle</name>  <value>10</value></parameter><parameter><name>maxWait</name>  <value>-1</value></parameter>

maxActive是最大激活连接数,这里取值20个,表示同时最多有20个与数据库的连接。
maxIdle是最大空闲连接数,这里取值10个,表示即使没有连接请求时,依然可以保持10空闲的连接,而不被清除,随时处于待命状态。关于对象的状态,有兴趣的朋友可以看看EJB方面的资料。
maxWait是最大等待秒钟数,这里取值-1,表示无限等待,直到超时为止,也可以取值9000,即表示9秒后超时。
关于maxActive与maxIdle的一点建议,对于企业级应用,其两者的值一般比较接近,或者相同,关键是要分析应用的大小。

第二步:配置web.xml
打开webapps/ROOT/WEB-INF下web.xml,加入如下内容: 

<resource-ref>  <description>Oracle  Datasource  example</description>  <res-ref-name>jdbc/OracleDB</res-ref-name>  <res-type>javax.sql.DataSource</res-type>  <res-auth>Container</res-auth>  </resource-ref>

说明:此步可以省略,即不配置web.xml也可以使用连接池,但正式项目应用时还是建议加上。

第三步:将Oracle的JDBC驱动classes12.jar拷贝到Tomcat安装目录的common/lib下。

至此,配置完成,测试代码将在后面给出。

五、测试代码

下面写一个JSP文件testdb.jsp,并将testdb.jsp置于webapps/ROOT目录下,测试一下配置是否正确,此测试对以上两个版本均适合。

数据库如下:

Create  table  test(id  varchar2(12),name  varchar2(30))

testdb.jsp内容如下:

<%@  page  contentType=”text/html;charset=GBK”%><%@  page  import=  “java.sql.*  “%><%@  page  import=  “javax.naming.*  “%><%  try{  Context  initCtx  =  new  InitialContext();  Context  ctx  =  (Context)  initCtx.lookup(“java:comp/env”);  //获取连接池对象  Object  obj  =  (Object)  ctx.lookup(“jdbc/OracleDB”);  //类型转换  javax.sql.DataSource  ds  =  (javax.sql.DataSource)obj;  Connection  conn  =  ds.getConnection();  Statement  stmt  =  conn.createStatement();  String  strSql  =  “  insert  into  test(id,name)  values(”00001”,”holen”)  “;  stmt.executeUpdate(strSql);  strSql  =  “  select  id,name  from  test  “;  ResultSet  rs  =  stmt.executeQuery(strSql);  if(rs.next()){  out.println(rs.getString(1));  out.println(rs.getString(2));  }  }catch(Exception  ex){  ex.printStackTrace();  throw  new  SQLException(“cannot  get  Connection  pool.”);  }%><hr>

说明:先通过JNDI找到jdbc/OracleDB对象,这里是分两步完成的,也可以一步完成,如Object  obj  =  (Object)  ctx.lookup(“java:comp/env  /jdbc/OracleDB”);
然后将得到的对象转换成DataSource类型,进而得到连接,得到连接后就可以进行相应的数据库操作了。
这里对数据库进行了两步操作,第一步是插入一条记录,第二步是从数据库中取出记录,并显示第一条记录的内容。

打开网页,在地址栏中输入http://localhost:8080/testdb.jsp,若一切正常,将显示”00001  holen”。

六、总结
以上配置了Tomcat4.0.6和Tomcat4.1.18的内置连接池,Tomcat4其他版本的配置方法与之类似,调用方法也一样。连接池配置主要就是修改server.xml及web.xml。
需要说明一点的是,Tomcat4.1.18有一个管理界面,通过此操作界面可以配置连接池及其他功能,不过通过这种方式配置的连接池不可用(测试时会发现程序运行很慢,原因是JNDI能找到,但不能建立连接),这是管理工具的一个BUG,已报至Tomcat  BUG列表,更详细的情况可以参见tomcat-user的邮件列表。

选用纯 JSP 还是纯 Servlet 设计站点都有它的局限性,Struts 就是把它们联系在一起的一种有力工具。采用 Struts 能开发出基于 MVC 模式的应用,关于 MVC 的概念可以参见 GoF 的《设计模式——可复用面向对象软件的基础》。

你现在要做的是,下载、安装、配置好以下的工具,版本不同的话操作可能会有些差异,具体的看它们的文档吧:

  • Tomcat 4.1.24
  • Apache 2.0.43, w/ mod_jk2 2.0.43
  • Java 2 SDK Standard Edition 1.4.0
  • Struts 1.1
  • Eclipse 2.1.0

Struts 是用 Java 写的,应此它需要 JDK 1.2 或者更高版本。如果你用的是 JDK 1.4,就像我,XML parser 和 JDBC 2.0 Optional Package Binary 就已经被默认的包含了。

新项目

在这个例程中我们要开发一个简单的 web 应用,允许用户登录和注销。简单起见,数据被设定为常数,而不是保存在数据库中,毕竟这里要讲的是 Struts,而不是 Java。

首先在你的 Tomcat 配置的应用主目录中创建一个目录,比方说 logonApp。在 logonApp 中创建目录 src 和 WEB-INF,在 WEB-INF 中创建目录 classes 和 lib,从 Struts 的分发中拷贝 struts.jar 到 lib 目录,而且也把拷贝 $CATALINA_HOME/common/lib/servlets.jar 到 lib 目录。从 Struts 的分发中拷贝所有的 struts*.tld 到 WEB-INF 目录。

现在打开 Eclipse,你会看到四个 view。现在我们要建立一个新的项目,点击 File -> New Project,打开了一个窗口,在第一个窗格中选择 Java,在第二个窗格中选择 Java Project,点击 Next。输入项目名称(为了好记,就也叫 logonApp 吧),去掉 use default 复选框的对勾,浏览到 logonApp 目录,点击 Next。出现一个新的窗口,在 Source tab 上点击 Add Folder,添加 $APP_BASE/src,在 Default output folder 中填入 $APP_BASE/WEB-INF/classes,点击 Finish。点击 Window -> Open Perspective -> Resource,看看 .project 文件是否已经自动包含了 lib 目录中所有的 jar 文件。

你的 logonApp/WEB-INF/web.xml 应该如下所示:

<?xml version="1.0"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"> <web-app> <!-- Action Servlet Configuration --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- The Welcome File List --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- Struts Tag Library Descriptors --> <taglib> <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri> <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri> <taglib-location>/WEB-INF/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri> <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> </taglib> </web-app> 

Struts 的配置文件 logonApp/WEB-INF/struts-config.xml 如下:

<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> <form-beans> <form-bean name="logonForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="username" type="java.lang.String"/> <form-property name="password" type="java.lang.String"/> </form-bean> </form-beans> <global-forwards> <forward name="success" path="/main.jsp"/> <forward name="logoff" path="/logoff.do"/> </global-forwards> <action-mappings> <action path="/logon" type="org.monotonous.struts.LogonAction" name="logonForm" scope="session" input="logon"> </action> <action path="/logoff" type="org.monotonous.struts.LogoffAction"> <forward name="success" path="/index.jsp"/> </action> </action-mappings> <controller> <!-- The "input" parameter on "action" elements is the name of a local or global "forward" rather than a module-relative path --> <set-property property="inputForward" value="true"/> </controller> <message-resources parameter="org.monotonous.struts.ApplicationResources"/> </struts-config> 

创建 View

现在回到 Eclipse,建立一个新页面 index.jsp:

<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:html locale="true"> <head> <title><bean:message key="index.title" /></title> <html:base/> </head> <body> <html:errors/> <html:form action="/logon"> <bean:message key="prompt.username"/> <html:text property="username"/> <br/> <bean:message key="prompt.password"/> <html:password property="password"/> <br/> <html:submit> <bean:message key="index.logon"/> </html:submit> </html:form> </body> </html:html> 

成功登录后的页面 main.jsp:

<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:html> <head> <title><bean:message key="main.title"/></title> <html:base/> </head> <body> <html:link forward="logoff"> <bean:message key="main.logoff"/> </html:link> </body> </html:html> 

你可能注意到这两个页面中都使用了方便国际化的特性,这至少需要一个默认的属性文件 ApplicationResources.properties:

index.title=Struts Homepage prompt.username=Username prompt.password=Password index.logon=Log on main.title=Struts Main page main.logoff=Log off error.password.mismatch=Invalid username and/or password. 

创建 Controller

LogonAction.java:

package org.monotonous.struts; import java.util.Locale; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.MessageResources; import org.apache.commons.beanutils.PropertyUtils; public final class LogonAction extends Action { public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Locale locale = getLocale(request); MessageResources messages = getResources(request); // Validate the request parameters specified by the user ActionErrors errors = new ActionErrors(); String username = (String) PropertyUtils.getSimpleProperty(form, "username"); String password = (String) PropertyUtils.getSimpleProperty(form, "password"); if ((username != "foo") || (password != "bar")) errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.password.mismatch")); // Report any errors we have discovered back to the original form if (!errors.isEmpty()) { saveErrors(request, errors); return (mapping.getInputForward()); } // Save our logged-in user in the session HttpSession session = request.getSession(); // Do something with session... // Remove the obsolete form bean if (mapping.getAttribute() != null) { if ("request".equals(mapping.getScope())) request.removeAttribute(mapping.getAttribute()); else session.removeAttribute(mapping.getAttribute()); } // Forward control to the specified success URI return (mapping.findForward("success")); } } 

LogoffAction.java:

package org.monotonous.struts; import java.util.Locale; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.MessageResources; public final class LogoffAction extends Action { public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Locale locale = getLocale(request); MessageResources messages = getResources(request); HttpSession session = request.getSession(); session.removeAttribute("userattrib"); session.invalidate(); // Forward control to the specified success URI return (mapping.findForward("success")); } } 

到浏览器里面欣赏一下吧,不过还不到开香槟的时候,也许你应该为这个应用考虑一些安全措施,下一次我再讲咯。