我们在使用Oracle Universal Installer(OUI)在UNIX平台上安装Oracle软件的快结束的时候会提示我们要执行orainstRoot.sh脚本。执行这个脚本目的是什么呢?以Linux平台的10g版本Oracle为例我们一起探索一下。[@more@]
1.orainstRoot.sh脚本内容[root@secdb ~]# ls -l /oracle/oraInventory/orainstRoot.sh-rwxrwx--- 1 oracle oinstall 1614 Dec 21 2010 /oracle/oraInventory/orainstRoot.sh[root@secdb ~]# cat /oracle/oraInventory/orainstRoot.sh#!/bin/shAWK=/bin/awkCHMOD=/bin/chmodCHGRP=/bin/chgrpCP=/bin/cpECHO=/bin/echoMKDIR=/bin/mkdirRUID=`/usr/bin/id|$AWK -F( '{print $2}'|$AWK -F) '{print $1}'`if [ ${RUID} != "root" ];then $ECHO "This script. must be executed as root" exit 1fiif [ -d "/etc" ]; then$CHMOD 755 /etc;else$MKDIR -p /etc;fiif [ -f "/oracle/oraInventory/oraInst.loc" ]; then$CP /oracle/oraInventory/oraInst.loc /etc/oraInst.loc;$CHMOD 644 /etc/oraInst.locelseINVPTR=/etc/oraInst.locINVLOC=/oracle/oraInventoryGRP=oinstallPTRDIR="`dirname $INVPTR`";# Create the software inventory location pointer fileif [ ! -d "$PTRDIR" ]; then $MKDIR -p $PTRDIR;fi$ECHO "Creating the Oracle inventory pointer file ($INVPTR)";$ECHO inventory_loc=$INVLOC > $INVPTR$ECHO inst_group=$GRP >> $INVPTRchmod 644 $INVPTR# Create the inventory directory if it doesn't existif [ ! -d "$INVLOC" ];then $ECHO "Creating the Oracle inventory directory ($INVLOC)"; $MKDIR -p $INVLOC;fifi$ECHO "Changing permissions of /oracle/oraInventory.Adding read,write permissions for group.Removing read,write,execute permissions for world.";$CHMOD -R g+rw,o-rwx /oracle/oraInventory;if [ $? != 0 ]; then $ECHO "OUI-35086:WARNING: chmod of /oracle/oraInventoryAdding read,write permissions for group.,Removing read,write,execute permissions for world. failed!";fi$ECHO "Changing groupname of /oracle/oraInventory to oinstall.";$CHGRP -R oinstall /oracle/oraInventory;if [ $? != 0 ]; then $ECHO "OUI-10057:WARNING: chgrp of /oracle/oraInventory to oinstall failed!";fi$ECHO "The execution of the script. is complete."从注释上可以得出脚本的功能描述。# Create the software inventory location pointer file# Create the inventory directory if it doesn't exist因此orainstRoot.sh脚本作用就是创建Oracle软件安装清单的指向文件。2.指向文件内容[root@secdb ~]# cat /etc/oraInst.locinventory_loc=/oracle/oraInventoryinst_group=oinstall此文件给出了Oracle软件安装清单目录和属组的名字。3.小结 10g版本的orainstRoot.sh脚本相对于早期版本来讲,编写方法有所改进,灵活性也增加了很多。这里建议大家在探索Oracle世界的时候密切关注一切细节,往往从这些细节中我们会有很多意想不到的收获,例如这里提到的脚本编写技巧就值得我们体会。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22661144/viewspace-1058084/
,如需转载,请注明出处,否则将追究法律责任。