zoukankan      html  css  js  c++  java
  • 又一次发现Oracle太美之orainstRoot.sh

    又一次发现Oracle太美之orainstRoot.sh
    我们安装数据库软件的时候,都要会运行orainstRoot.sh,今天就来细致看看这个脚本是来干嘛的。
    平台为RedHat 6.4 x64位的,数据库版本号为11.2.0.4.2
    以下是脚本的内容
    [oracle@rh64 ~]$ cd /u01/app/oraInventory/
    [oracle@rh64 oraInventory]$ ls -ltr
    total 24
    drwxrwx--- 2 oracle oinstall 4096 Oct 30  2013 ContentsXML
    -rwxrwx--- 1 oracle oinstall 1620 Oct 30  2013 orainstRoot.sh
    -rw-rw---- 1 oracle oinstall   56 Oct 30  2013 oraInst.loc
    drwxrwx--- 3 oracle oinstall 4096 May 14 02:47 backup
    drwxrwx--- 2 oracle oinstall 4096 May 14 03:16 logs
    drwxrwx--- 2 oracle oinstall 4096 May 15 00:27 oui
    [oracle@rh64 oraInventory]$ cat orainstRoot.sh 
    #!/bin/sh
    AWK=/bin/awk
    CHMOD=/bin/chmod
    CHGRP=/bin/chgrp
    CP=/bin/cp
    ECHO=/bin/echo
    MKDIR=/bin/mkdir
    RUID=`/usr/bin/id|$AWK -F( '{print $1}'|$AWK -F= '{print $2}'`
    if [ ${RUID} != "0" ];then
       $ECHO "This script must be executed as root"
       exit 1
    fi
    ----->>>这里会首先校验权限,看看是不是以root用户运行的,假设不是就退出
    if [ -d "/etc" ]; then
    $CHMOD 755 /etc;
    else
    $MKDIR -p /etc;
    fi
    if [ -f "/u01/app/oraInventory/oraInst.loc" ]; then
    $CP /u01/app/oraInventory/oraInst.loc /etc/oraInst.loc;
    $CHMOD 644 /etc/oraInst.loc
    else
    INVPTR=/etc/oraInst.loc
    INVLOC=/u01/app/oraInventory
    GRP=oinstall
    PTRDIR="`dirname $INVPTR`";
    ----->>>假设Central Inventory存在的话,即上面的oraInst.loc,就会复制一份到/etc/以下,作为Central Inventory Pointer File,从名字上就能知道。
    这个是Central Inventory的Pointed File

    # Create the software inventory location pointer file
    if [ ! -d "$PTRDIR" ]; then
     $MKDIR -p $PTRDIR;
    fi
    $ECHO "Creating the Oracle inventory pointer file ($INVPTR)";
    $ECHO    inventory_loc=$INVLOC > $INVPTR
    $ECHO    inst_group=$GRP >> $INVPTR
    chmod 644 $INVPTR
    # Create the inventory directory if it doesn't exist
    if [ ! -d "$INVLOC" ];then
     $ECHO "Creating the Oracle inventory directory ($INVLOC)";
     $MKDIR -p $INVLOC;
    fi
    fi
    ----->>>>假设不存在,就会一一创建,而且须要改动权限
    $ECHO "Changing permissions of /u01/app/oraInventory.
    Adding read,write permissions for group.
    Removing read,write,execute permissions for world.
    ";
    $CHMOD -R g+rw,o-rwx /u01/app/oraInventory;
    ----->>>>对于这个文件夹,组要有读写权限,宿主要有读写运行的权限
    if [ $? != 0 ]; then
     $ECHO "OUI-35086:WARNING: chmod of /u01/app/oraInventory
    Adding read,write permissions for group.
    ,Removing read,write,execute permissions for world.
     failed!";
    fi
    $ECHO "Changing groupname of /u01/app/oraInventory to oinstall.";
    $CHGRP -R oinstall /u01/app/oraInventory;
    ----->>>注意这里的组是oinstall
    if [ $? != 0 ]; then
     $ECHO "OUI-10057:WARNING: chgrp of /u01/app/oraInventory to oinstall failed!";
    fi
    $ECHO "The execution of the script is complete."
    [oracle@rh64 oraInventory]$ 


    从上面看到,这个脚本无非就是创建oraInst.loc,然后给这个产品文件夹改动权限,注意组权限是读写,宿主为777。oraInventory的组要是oinstall
    其它也没有多少东西。

    知道干嘛的即可了。学会了就没啥了。哪里报错哪里又一次检查就OK了。

  • 相关阅读:
    SWTDesigner注册器
    C# 创建、部署和调用WebService的简单示例
    (android实战)应用在线版本更新
    jQuery获取Select选择的Text和 Value(转)
    Android 判断sd卡和sim卡是否可用
    Android开发中如何固定屏幕显示!
    入侵网站简单方法总结
    【Android】防止UI界面被输入法遮挡(画面随输入法自适应)
    关于字符编码的问题
    最好用的mysql密码忘记的解决方法
  • 原文地址:https://www.cnblogs.com/mqxnongmin/p/10805001.html
Copyright © 2011-2022 走看看