Oracle 11gR2(11.2.0.4.0)搭建RAC时root.sh执行脚本分析

Oracle 11gR2搭建RAC时,root.sh脚本扮演关键角色,主要执行/u01/app/11.2.0/grid/crs/config/rootconfig.sh,调用rootcrs.pl初始化和配置集群。脚本涉及创建文件、设置权限、ACL信息、TFA、checkpoint、OCR、CSS、OHASD等配置,并按阶段进行,简化了故障排查和重复运行。

在oracle 11g搭建RAC的时候,最后通常会执行两个脚本,第二个脚本比较重要也是最容易出错的地方。
先了解oracle11g r2集群各个组件:
这里写图片描述
/u01/app/oraInventory/orainstRoot.sh
/u01/app/11.2.0/grid/root.sh
先看看root.sh脚本内容:

[root@node2 app]# more /u01/app/11.2.0/grid/root.sh 
#!/bin/sh
. /u01/app/11.2.0/grid/install/utl/rootmacro.sh "$@"
. /u01/app/11.2.0/grid/install/utl/rootinstall.sh

#
# Root Actions related to network
#
/u01/app/11.2.0/grid/network/install/sqlnet/setowner.sh 

#
# Invoke standalone rootadd_rdbms.sh
#
/u01/app/11.2.0/grid/rdbms/install/rootadd_rdbms.sh

/u01/app/11.2.0/grid/rdbms/install/rootadd_filemap.sh 
/u01/app/11.2.0/grid/crs/config/rootconfig.sh
EXITCODE=$? 
if [ $EXITCODE -ne 0 ]; then
        exit $EXITCODE
fi

. /u01/app/11.2.0/grid/install/utl/rootmacro.sh 负责一些和gi_home 相关的验证工作。
. /u01/app/l l .2.0/grid/install/utl/rootinstall.sh 负责创建一些本地文件。
. /u01/app/11.2. 0/grid/network/install/sqlnet/setowner.sh 负责创建GI 相关的临时文件。
. /u01/app/11.2.0/grid/rdbms/install/rootadd_rdbms.sh 负责验证一些文件的权限。
. /u01/app/11.2.0/grid/rdbms/install/rootadd_filemap.sh 负责验证一些文件的权限。
以上脚本的功能都很简单, 而且并没有包含配置集群或者初始化集群的步骤。
root.sh 脚本的核心部分是/u01/app/ 11.2. 0/g rid/crs/c onfig/rootconfig.sh 脚本。这个脚本的作
用就是通过调用< gi_home>/crs/install/rootcrs.pl 脚本来初始化和配置集群,如下是rootconfig.sh脚本片段:

[root@node2 app]# more /u01/app/11.2.0/grid/crs/config/rootconfig.sh
#!/bin/sh
ORACLE_HOME=/u01/app/11.2.0/grid
ROOTSCRIPT_ARGS=""
#if upgrade/force/verbose command line args are passed, set ROOTSCRIPT_ARGS accordingly.
for var in "$@"
do
  if [ "$var" = "-upgrade" ]; then
    ROOTSCRIPT_ARGS=$ROOTSCRIPT_ARGS"$var "
  elif [ "$var" = "-force" ]; then
    ROOTSCRIPT_ARGS=$ROOTSCRIPT_ARGS"$var "
  elif [ "$var" = "-verbose" ]; then
    ROOTSCRIPT_ARGS=$ROOTSCRIPT_ARGS"$var "
  fi
done

. $ORACLE_HOME/install/utl/rootmacro.sh

SU=/bin/su
SW_ONLY=false
ADDNODE=false
GI_WIZARD=false
HA_CONFIG=false
RAC9I_PRESENT=false
CMDLLROOTSH_CMD=$ORACLE_HOME/crs/install/cmdllroot.sh
CONFIGSH_CMD="$ORACLE_HOME/crs/config/config.sh"
ROOTHASPL="$ORACLE_HOME/perl/bin/perl -I$ORACLE_HOME/perl/lib -I$ORACLE_HOME/crs/install $ORACLE_HOME/crs/install/roothas.pl"
ROOTCRSPL="$ORACLE_HOME/perl/bin/perl -I$ORACLE_HOME/perl/lib -I$ORACLE_HOME/crs/install $ORACLE_HOME/crs/install/rootcrs.pl"
ROOTSCRIPT=""
ISLINUX=false
EXITCODE=0
# For addnode cases
CRSCONFIG_ADDPARAMS=$ORACLE_HOME/crs/install/crsconfig_addparams
# If addparams file exists
if [ -f $CRSCONFIG_ADDPARAMS ]; then
  # get the value of LAST[tail -1] occurrence of CRS_ADDNODE=<value> in the file
  CRS_ADDNODE=`$AWK -F"=" '{if ($1=="CRS_ADDNODE") print $2}' $CRSCONFIG_ADDPARAMS | tail -1`
  # If value for CRS_ADDNODE is found
  if [ "$CRS_ADDNODE" = "true" ]; then
    # set ADDNODE to true
    ADDNODE=true
  fi
fi

# if addnode then reset SW_ONLY and HA_CONFIG variables to false
if [ "$ADDNODE" = "true" ]; then
  SW_ONLY=false
  HA_CONFIG=false
fi

if [ `$UNAME` = "Linux" ]; then
   ISLINUX=true
fi


if [ "$SW_ONLY" = "true" ]; then
  $ECHO
  $ECHO "To configure Grid Infrastructure for a Stand-Alone Server run the following command as the root user:"
  $ECHO "$ROOTHASPL"
  $ECHO
  $ECHO
  $ECHO "To configure Grid Infrastructure for a Cluster execute the following command:"
  $ECHO "$CONFIGSH_CMD"
  $ECHO "This command launches the Grid Infrastructure Configuration Wizard. The wizard also supports silent operation, and the parameters can be passed through the response file that is available in the installation media."
  $ECHO
else
  if [ "$GI_WIZARD" = "true" ]; then
    $ECHO "Relinking oracle with rac_on option"
    $SU $ORACLE_OWNER -c "$ECHO \"rootconfig.sh: Relinking oracle with rac_on option\" ; $ORACLE_HOME/crs/config/relink_rac_on $ORACLE_HOME $MAKE" >> $ORACLE_HOME/install/make.log 2>&1
    EXITCODE=$?
    if [ $EXITCODE -ne 0 ]; then
      $ECHO "Relinking rac_on failed"
      exit $EXITCODE
    fi
  fi

  if [ "$ISLINUX" = "true" -a "$RAC9I_PRESENT" = "true" ]; then
      $CMDLLROOTSH_CMD
  fi

  if [ "$HA_CONFIG" = "true" ]; then
    ROOTSCRIPT=$ROOTHASPL
  else
    ROOTSCRIPT=$ROOTCRSPL
  fi

  #Passing the ROOTSCRIPT_ARGS constructed to rootscripts.
  $ROOTSCRIPT $ROOTSCRIPT_ARGS
  EXITCODE=$?
  if [ $EXITCODE -ne 0 ]; then
    $ECHO "$ROOTSCRIPT execution failed"
    exit $EXITCODE
  fi
fi
exit 0

rootcrs.pl 脚本的日志文件是/u01/app/11.2.0/grid/cfgtoollogs/crsconfig/rootcrs_node2.log .

在配置之前,先通过读取配置文件得到集群基本信息

017-10-12 13:01:10: The configuration parameter file /u01/app/11.2.0/grid/crs/install/crsconfig_params is valid
2017-10-12 13:01:10: ### Printing the configuration values from files:
2017-10-12 13:01:10:    /u01/app/11.2.0/grid/crs/install/crsconfig_params
2017-10-12 13:01:10:    /u01/app/11.2.0/grid/crs/install/s_crsconfig_defs
2017-10-12 13:01:10: ASM_AU_SIZE=1
2017-10-12 13:01:10: ASM_DISCOVERY_STRING=/dev/asm-*
2017-10-12 13:01:10: ASM_DISKS=/dev/asm-disk1
2017-10-12 13:01:10: ASM_DISK_GROUP=DATA

这些文件配置信息就是在OUI安装时写进去的。

配置文件读取完毕,获取文件目录权限,保存ACL信息:

2017-10-12 13:01:10: ### Printing of configuration values complete ###
2017-10-12 13:01:10: USER_IGNORED_PREREQ  is set to 1
2017-10-12 13:01:10: User ignored Prerequisites during installation
2017-10-12 13:01:10: saving current owner/permisssios of  parent dir of /u01/app/11.2.0

2017-10-12 13:01:10: saving parent dir ACLs in /u01/app/11.2.0/grid/crs/install/ParentDirPerm_node2.txt

2017-10-12 13:01:10: Getting file permissions for /u01/app/11.2.0

2017-10-12 13:01:10: Getting file permissions for /u01/app

2017-10-12 13:01:10: Getting file permissions for /u01

2017-10-12 13:01:10: writing /u01/app/11.2.0:grid:oinstall:0775 to /u01/app/11.2.0/grid/crs/install/ParentDirPerm_node2.txt
2017-10-12 13:01:10: writing /u01/app:grid:oinstall:0775 to /u01/app/11.2.0/grid/crs/install/ParentDirPerm_node2.txt
2017-10-12 13:01:10: writing /u01:grid:oinstall:0775 to /u01/app/11.2.0/grid/crs/install/ParentDirPerm_node2.txt
2017-10-12 13:01:10: Installing Trace File Analyzer

查看 ParentDirPerm_node2.txt ACL信息:

[root@node2 ~]# more /u01/app/11.2.0/grid/crs/install/ParentDirPerm_node2.txt
/u01/app/11.2.0:grid:oinstall:0775
/u01/app:grid:oinstall:0775
/u01:grid:oinstall:0775

创建TFA(oracle Trace File Analyzer)


>  
>  Using JAVA_HOME : /u01/app/11.2.0/grid/jdk/jre
>  
>  Running Auto Setup for TFA as user root...
>  
>  
>  The following installation requires temporary use of SSH.
>  If SSH is not configured already then we will remove SSH 
>  when complete.
>    
>  Installing TFA now...
>  
>  
>  TFA Will be Installed on node2...
>  
>  TFA will scan the following Directories
>  ++++++++++++++++++++++++++++++++++++++++++++
>  
>  .----------------------------------------------------.
>  |                        node2                       |
>  +-----------------------------------------+----------+
>  | Trace Directory                         | Resource |
>  +-----------------------------------------+----------+
>  | /u01/app/11.2.0/grid/OPatch/crs/log     | CRS      |
>  | /u01/app/11.2.0/grid/cfgtoollogs        | INSTALL  |
>  | /u01/app/11.2.0/grid/crs/log            | CRS      |
>  | /u01/app/11.2.0/grid/cv/log             | CRS      |
>  | /u01/app/11.2.0/grid/evm/admin/log      | CRS      |
>  | /u01/app/11.2.0/grid/evm/admin/logger   | CRS      |
>  | /u01/app/11.2.0/grid/evm/log            | CRS      |
>  | /u01/app/11.2.0/grid/install            | INSTALL  |
>  | /u01/app/11.2.0/grid/log                | CRS      |
>  | /u01/app/11.2.0/grid/log/               | CRS      |
>  | /u01/app/11.2.0/grid/network/log        | CRS      |
>  | /u01/app/11.2.0/grid/oc4j/j2ee/home/log | CRSOC4J  |
>  | /u01/app/11.2.0/grid/opmn/logs          | CRS      |
>  | /u01/app/11.2.0/grid/racg/log           | CRS      |
>  | /u01/app/11.2.0/grid/rdbms/log          | ASM      |
>  | /u01/app/11.2.0/grid/scheduler/log      | CRS      |
>  | /u01/app/11.2.0/grid/srvm/log           | CRS      |
>  | /u01/app/oraInventory/ContentsXML       | INSTALL  |
>  | /u01/app/oraInventory/logs              | INSTALL  |
>  '-----------------------------------------+----------'
>  
>  
>  Installing TFA on node2
>  HOST: node2  TFA_HOME: /u01/app/11.2.0/grid/tfa/node2/tfa_home
>  
>  .------------------------------------------------.
>  | Host  | Status of TFA | PID   | Port | Version |
>  +-------+---------------+-------+------+---------+
>  | node2 | RUNNING       | 21382 | 5000 | 2.5.1.5 |
>  | node1 | RUNNING       | 21110 | 5000 | 2.5.1.5 |
>  '-------+---------------+-------+------+---------'
>  
>  Summary of TFA Installation:
>  .---------------------------------------------------------------.
>  |                             node2                             |
>  +---------------------+-----------------------------------------+
>  | Parameter           | Value                                   |
>  +---------------------+-----------------------------------------+
>  | Install location    | /u01/app/11.2.0/grid/tfa/node2/tfa_home |
>  | Repository location | /u01/app/grid/tfa/repository            |
>  | Repository usage    | 0 MB out of 10240 MB                    |
>  '---------------------+-----------------------------------------'
>  
>  
>  TFA is successfully installed..
>  
>  Usage : /u01/app/11.2.0/grid/tfa/bin/tfactl <command> [options]
>  <command> =
>           print        Print requested details
>           purge        Delete collections from TFA repository
>           directory    Add or Remove or Modify directory in TFA
>           host         Add or Remove host in TFA
>           set          Turn ON/OFF or Modify various TFA features
>           diagcollect  Collect logs from across nodes in cluster 
>  
>  For help with a command: /u01/app/11.2.0/grid/tfa/bin/tfactl <command> -help
>  
>   
>End Command output

[root@node2 ~]# /u01/app/11.2.0/grid/tfa/bin/tfactl -help
Usage : /u01/app/11.2.0/grid/tfa/bin/tfactl <command> [options]
<command> =
         print        Print requested details
         purge        Delete collections from TFA repository
         directory    Add or Remove or Modify directory in TFA
         host         Add or Remove host in TFA
         set          Turn ON/OFF or Modify various TFA features
         diagcollect  Collect logs from across nodes in cluster 

For help with a command: /u01/app/11.2.0/grid/tfa/bin/tfactl <command> -help

创建checkpoint检查点文件:
从11.2.0.2 版本开始, root.sh 在运行时会产生一个检查点( Check point )文件,在每执行一个阶段的操作过程中,root.sh 都会把对应阶段的操作状态记录到检查点文件当中,以便在下一次运行root.sh 时能够清楚地了解上一次运行所处的阶段,以及对应阶段的状态,从而决定从哪里重新开始。这也是为什么Oracle 从11.2.0.2版本开始宣称,root.sh 脚本可以被重复运行的原因。这意味着用户再也不需要像之前版本那样,当
root.sh 脚本失败后需要将之前的配直彻底删除,才能重新运行root.sh,极大地节省了GI 的部署时间。

2017-10-12 13:01:41: checkpoint ROOTCRS_STACK does not exist
2017-10-12 13:01:41: Oracle clusterware configuration has started
2017-10-12 13:01:41: Running as user grid: /u01/app/11.2.0/grid/bin/cluutil -ckpt -oraclebase /u01/app/grid -writeckpt -name ROOTCRS_STACK -state START
2017-10-12 13:01:41: s_run_as_user2: Ru
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值