一步一步在Linux上安装Oracle 11gR2 RAC (8–完结)

脚本附录

7.1 preusers.sh脚本

 

#!/bin/bash
#Purpose:Create 6 groups named 'oinstall','dba','asmadmin','asmdba','asmoper','oper', plus 2 users named 'oracle','grid'.
#Also setting the Environment
#variable for oracle user.
#variable for grid user.
#Usage:Log on as the superuser('root'),and then execute the command:#./1preusers.sh
#Author:Asher Huang

echo "Now create 6 groups named 'oinstall','dba','asmadmin','asmdba','asmoper','oper'"
echo "Plus 2 users named 'oracle','grid',Also setting the Environment"


groupadd -g 1000 oinstall 
groupadd -g 1200 asmadmin 
groupadd -g 1201 asmdba 
groupadd -g 1202 asmoper 
useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper -d /home/grid -s /bin/bash -c "grid Infrastructure Owner" grid 
echo "grid" | passwd --stdin grid

echo 'export PS1="`/bin/hostname -s`-> "'>> /home/grid/.bash_profile 
echo "export TMP=/tmp">> /home/grid/.bash_profile  
echo 'export TMPDIR=$TMP'>>/home/grid/.bash_profile 
echo "export ORACLE_SID=+ASM1">> /home/grid/.bash_profile 
echo "export ORACLE_BASE=/u01/app/grid">> /home/grid/.bash_profile
echo "export ORACLE_HOME=/u01/app/11.2.0/grid">> /home/grid/.bash_profile
echo "export ORACLE_TERM=xterm">> /home/grid/.bash_profile
echo "export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss'" >> /home/grid/.bash_profile
echo 'export TNS_ADMIN=$ORACLE_HOME/network/admin'  >> /home/grid/.bash_profile
echo 'export PATH=/usr/sbin:$PATH'>> /home/grid/.bash_profile
echo 'export PATH=$ORACLE_HOME/bin:$PATH'>> /home/grid/.bash_profile
echo 'export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib'>> /home/grid/.bash_profile
echo 'export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib'>> /home/grid/.bash_profile
echo "export EDITOR=vi" >> /home/grid/.bash_profile
echo "export LANG=en_US" >> /home/grid/.bash_profile
echo "export NLS_LANG=american_america.AL32UTF8" >> /home/grid/.bash_profile
echo "umask 022">> /home/grid/.bash_profile

groupadd -g 1300 dba 
groupadd -g 1301 oper 
useradd -u 1101 -g oinstall -G dba,oper,asmdba -d /home/oracle -s /bin/bash -c "Oracle Software Owner" oracle 
echo "oracle" | passwd --stdin oracle

echo 'export PS1="`/bin/hostname -s`-> "'>> /home/oracle/.bash_profile 
echo "export TMP=/tmp">> /home/oracle/.bash_profile  
echo 'export TMPDIR=$TMP'>>/home/oracle/.bash_profile 
echo "export ORACLE_HOSTNAME=node1.localdomain">> /home/oracle/.bash_profile 
echo "export ORACLE_SID=devdb1">> /home/oracle/.bash_profile 
echo "export ORACLE_BASE=/u01/app/oracle">> /home/oracle/.bash_profile
echo 'export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1'>> /home/oracle/.bash_profile
echo "export ORACLE_UNQNAME=devdb">> /home/oracle/.bash_profile
echo 'export TNS_ADMIN=$ORACLE_HOME/network/admin'  >> /home/oracle/.bash_profile
echo "export ORACLE_TERM=xterm">> /home/oracle/.bash_profile
echo 'export PATH=/usr/sbin:$PATH'>> /home/oracle/.bash_profile
echo 'export PATH=$ORACLE_HOME/bin:$PATH'>> /home/oracle/.bash_profile
echo 'export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib'>> /home/oracle/.bash_profile
echo 'export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib'>> /home/oracle/.bash_profile
echo "export EDITOR=vi" >> /home/oracle/.bash_profile
echo "export LANG=en_US" >> /home/oracle/.bash_profile
echo "export NLS_LANG=american_america.AL32UTF8" >> /home/oracle/.bash_profile
echo "export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss'" >> /home/oracle/.bash_profile
echo "umask 022">> /home/oracle/.bash_profile

echo "The Groups and users has been created"
echo "The Environment for grid,oracle also has been set successfully"

 

7.2 predir.sh脚本

 

#!/bin/bash
#Purpose:Create the necessary directory for oracle,grid users and change the authention to oracle,grid users.
#Usage:Log on as the superuser('root'),and then execute the command:#./2predir.sh
#Author:Asher Huang

echo "Now create the necessary directory for oracle,grid users and change the authention to oracle,grid users..."
mkdir -p /u01/app/grid 
mkdir -p /u01/app/11.2.0/grid 
mkdir -p /u01/app/oracle 
chown -R oracle:oinstall /u01
chown -R grid:oinstall /u01/app/grid 
chown -R grid:oinstall /u01/app/11.2.0
chmod -R 775 /u01
echo "The necessary directory for oracle,grid users and change the authention to oracle,grid users has been finished"

 

7.3 prelimits.sh脚本

#!/bin/bash
#Purpose:Change the /etc/security/limits.conf.
#Usage:Log on as the superuser('root'),and then execute the command:#./3prelimits.sh
#Author:Asher Huang

echo "Now modify the /etc/security/limits.conf,but backup it named /etc/security/limits.conf.bak before"
cp /etc/security/limits.conf /etc/security/limits.conf.bak
echo "oracle soft nproc 2047" >>/etc/security/limits.conf
echo "oracle hard nproc 16384" >>/etc/security/limits.conf
echo "oracle soft nofile 1024" >>/etc/security/limits.conf
echo "oracle hard nofile 65536" >>/etc/security/limits.conf
echo "grid soft nproc 2047" >>/etc/security/limits.conf
echo "grid hard nproc 16384" >>/etc/security/limits.conf
echo "grid soft nofile 1024" >>/etc/security/limits.conf
echo "grid hard nofile 65536" >>/etc/security/limits.conf
echo "Modifing the /etc/security/limits.conf has been succeed."

7.4 prelogin.sh脚本

#!/bin/bash
#Purpose:Modify the /etc/pam.d/login.
#Usage:Log on as the superuser('root'),and then execute the command:#./4prelimits.sh
#Author:Asher Huang

echo "Now modify the /etc/pam.d/login,but with a backup named /etc/pam.d/login.bak"
cp /etc/pam.d/login /etc/pam.d/login.bak

echo "session required /lib/security/pam_limits.so" >>/etc/pam.d/login
echo "session required pam_limits.so" >>/etc/pam.d/login

echo "Modifing the /etc/pam.d/login has been succeed."

7.5 preprofile.sh脚本

#!/bin/bash
#Purpose:Modify the /etc/profile.
#Usage:Log on as the superuser('root'),and then execute the command:#./5preprofile.sh
#Author:Asher Huang

echo "Now modify the  /etc/profile,but with a backup named  /etc/profile.bak"
cp /etc/profile /etc/profile.bak
echo 'if [ $USER = "oracle" ]||[ $USER = "grid" ]; then' >>  /etc/profile
echo 'if [ $SHELL = "/bin/ksh" ]; then' >> /etc/profile
echo 'ulimit -p 16384' >> /etc/profile
echo 'ulimit -n 65536' >> /etc/profile
echo 'else' >> /etc/profile
echo 'ulimit -u 16384 -n 65536' >> /etc/profile
echo 'fi' >> /etc/profile
echo 'fi' >> /etc/profile
echo "Modifing the /etc/profile has been succeed."

7.6 presysctl.sh脚本

#!/bin/bash
#Purpose:Modify the /etc/sysctl.conf.
#Usage:Log on as the superuser('root'),and then execute the command:#./6presysctl.sh
#Author:Asher Huang

echo "Now modify the /etc/sysctl.conf,but with a backup named /etc/sysctl.bak"
cp /etc/sysctl.conf /etc/sysctl.conf.bak

echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "kernel.shmall = 2097152" >> /etc/sysctl.conf
echo "kernel.shmmax = 1054472192" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.wmem_max = 1048586" >> /etc/sysctl.conf
echo "net.ipv4.tcp_wmem = 262144 262144 262144" >> /etc/sysctl.conf
echo "net.ipv4.tcp_rmem = 4194304 4194304 4194304" >> /etc/sysctl.conf

echo "Modifing the /etc/sysctl.conf has been succeed."
echo "Now make the changes take effect....."
sysctl -p

一步一步在Linux上安装Oracle 11gR2 RAC (7)

创建ASM磁盘组

   以grid用户创建ASM磁盘组,创建的ASM磁盘组为下一步创建数据库提供存储。

   

① grid用户登录图形界面,执行asmca命令来创建磁盘组:

 

② 进入ASMCA配置界面后,单击Create,创建新的磁盘组:

③ 输入磁盘组名 DATA,冗余策略选择External,磁盘选择ORCL:VOL3,单击OK

④ DATA磁盘组创建完成,单击OK

⑤ 继续创建磁盘组,磁盘组名FLASH,冗余策略选择External,磁盘选择ORCL:VOL4

⑥ 最后,完成DATAFLASH磁盘组的创建,Exit推出ASMCA图形配置界面:

至此,利用ASMCA创建好DATAFLASH磁盘组。且,可以看到连同之前创建的GRIDDG 3个磁盘组均已经被RAC双节点MOUNT

创建RAC数据库

接下来,使用DBCA来创建RAC数据库。

① 以oracle用户登录图形界面,执行dbca,进入DBCA的图形界面,选择第1项,创建RAC数据库:

 

② 选择创建数据库选项,Next

③ 选择创建通用数据库,Next

④ 配置类型选择Admin-Managed,输入数据库名devdb,选择双节点,Next

⑤ 选择默认,配置OEM、启用数据库自动维护任务,Next

⑥ 选择数据库用户使用同一口令,Next

 数据库存储选择ASM,使用OMF,数据区选择之前创建的DATA磁盘组,Next

⑧ 指定数据库闪回区,选择之前创建好的FLASH磁盘组,Next

⑨ 选择创建数据库自带Sample SchemaNext

 选择数据库字符集,AL32UTF8Next

 选择默认数据库存储信息,直接Next

⑫ 单击,Finish,开始创建数据库,Next

创建数据库可能持续时间稍长:

 完成创建数据库。

    至此,我们完成创建RAC数据库!!!

一步一步在Linux上安装Oracle 11gR2 RAC (6)

4安装Oracle 软件

   从此步骤开始,我们正式安装oracle软件:

① 以oracle用户登录图形界面,执行/home/oracle/database/runInstaller,进入OUI的图形安装界面:

      

② 进入OUI安装界面后,选择第3项,跳过软件更新,Next

③ 选择第2项,只安装oracle软件,Next

④ 选择第2项,安装oracle RAC,选择所有节点,Next

⑤ 语言选择默认,EnglishNext

⑥ 选择第1项,安装企业版软件,Next

 选择oracle软件的安装路径其中ORACLE_BASE,ORACLE_HOME均选择之前已经配置好的,可参照2.5节中的配置信息。Next

 

⑧ 选择oracle用户组,Next

⑨ 执行安装前的预检查,Next

 安装概要信息,Install

 根据提示以root用户分别在两个节点上执行脚本Next

   执行/u01/app/oracle/product/11.2.0/db_1/root.sh 脚本:

node1

[root@node1 ~]# /u01/app/oracle/product/11.2.0/db_1/root.sh 

Performing root user operation for Oracle 11g 

 

The following environment variables are set as:

    ORACLE_OWNER= oracle

    ORACLE_HOME=  /u01/app/oracle/product/11.2.0/db_1

 

Enter the full pathname of the local bin directory: [/usr/local/bin]: 

The contents of "dbhome" have not changed. No need to overwrite.

The contents of "oraenv" have not changed. No need to overwrite.

The contents of "coraenv" have not changed. No need to overwrite.

 

Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root script.

Now product-specific root actions will be performed.

Finished product-specific root actions.

[root@node1 ~]# 

node2

[root@node2 ~]# /u01/app/oracle/product/11.2.0/db_1/root.sh 

Performing root user operation for Oracle 11g 

 

The following environment variables are set as:

    ORACLE_OWNER= oracle

    ORACLE_HOME=  /u01/app/oracle/product/11.2.0/db_1

 

Enter the full pathname of the local bin directory: [/usr/local/bin]: 

The contents of "dbhome" have not changed. No need to overwrite.

The contents of "oraenv" have not changed. No need to overwrite.

The contents of "coraenv" have not changed. No need to overwrite.

 

Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root script.

Now product-specific root actions will be performed.

Finished product-specific root actions.

[root@node2 ~]# 

 最后,单击close,完成oracle软件在双节点上的安装。

 

至此,我们在RAC双节点上完成oracle软件的安装!!!  

一步一步在Linux上安装Oracle 11gR2 RAC (5)

安装Grid Infrastructure

从此步骤开始,我们正式安装Grid软件:

① 以grid用户登录图形界面,执行/home/grid/grid/runInstaller,进入OUI的图形安装界面:

 

② 进入OUI安装界面后,选择第3项,跳过软件更新,Next

③ 选择集群的Grid InfrastructureNext

④ 选择 advanced InstallationNext

⑤ 语言选择默认,EnglishNext

⑥ 去掉Configure GNS选项,按照之前2.1节中的表格输入Cluster Name:scan-cluster,SCAN Namescan-cluster.localdomainNext

 单击Add,添加第2个节点,Next

⑧ 确认网络接口,Next

⑨ 选择ASM,作为存储,Next

 

 输入ASM磁盘组名,这里命名为GRIDDG,冗余策略选择External外部,AU大小选择默认1MASM磁盘选择VOL1VOL2Next

 选择给ASMSYSASMSNMP用户配置为相同的口令,并输入口令,Next

 选择不使用IPMINext

 给ASM指定不同的组,Next

    

 选择GRID软件的安装路径,其中ORACLE_BASE,ORACLE_HOME均选择之前已经配置好的,可参照2.5节中的配置信息。这里需要注意GRID软件的ORACLE_HOME不能是ORACLE_BASE的子目录。

 选择默认的InventoryNext

⑯ 检查出现告警,提示在所有节点上缺失cvuqdisk-1.0.9-1软件包。

可以选择忽略,直接进入下一步安装。也可以从grid安装文件的rpm目录下获取该RPM包,然后进行安装。

node1

 

[root@node1 rpm]# pwd

/home/grid/grid/rpm

[root@node1 rpm]# ll

total 12

-rwxr-xr-x 1 root root 8551 Sep 22  2011 cvuqdisk-1.0.9-1.rpm

[root@node1 rpm]# rpm -ivh cvuqdisk-1.0.9-1.rpm 

Preparing…                ########################################### [100%]

Using default group oinstall to install package

   1:cvuqdisk               ########################################### [100%]

[root@node1 rpm]# 

node2

 

[root@node2 ~]# ll

total 96

-rw——- 1 root root  1371 Apr 20 14:48 anaconda-ks.cfg

drwxr-xr-x 2 root root  4096 Apr 26 11:20 asm_rpm

-rwxr-xr-x 1 root root  8551 Apr 27 09:27 cvuqdisk-1.0.9-1.rpm

-rw-r–r– 1 root root 51256 Apr 20 14:48 install.log

-rw-r–r– 1 root root  4077 Apr 20 14:48 install.log.syslog

drwxr-xr-x 2 root root  4096 Apr 24 10:45 shell

[root@node2 ~]# export CVUQDISK_GRP=oinstall

[root@node2 ~]# rpm -ivh cvuqdisk-1.0.9-1.rpm 

Preparing…                ########################################### [100%]

   1:cvuqdisk               ########################################### [100%]

[root@node2 ~]# 

在所有节点上安装完cvuqdisk-1.0.9-1软件后,重新执行预检查,不再有警告信息。

⑰ 进入安装GRID安装之前的概要信息,Install进行安装:

⑱ 根据提示以root用户分别在两个节点上执行脚本:

执行/u01/app/oraInventory/orainstRoot.sh脚本:

node1:

[root@node1 ~]# /u01/app/oraInventory/orainstRoot.sh 

Changing permissions of /u01/app/oraInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world.

 

Changing groupname of /u01/app/oraInventory to oinstall.

The execution of the script is complete.

[root@node1 ~]#

node2

[root@node2 ~]# /u01/app/oraInventory/orainstRoot.sh 

Changing permissions of /u01/app/oraInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world.

 

Changing groupname of /u01/app/oraInventory to oinstall.

The execution of the script is complete.

[root@node2 ~]# 

执行/u01/app/11.2.0/grid/root.sh脚本:

node1

[root@node1 ~]# /u01/app/11.2.0/grid/root

root.sh         rootupgrade.sh  

[root@node1 ~]# /u01/app/11.2.0/grid/root.sh 

Performing root user operation for Oracle 11g 

 

The following environment variables are set as:

    ORACLE_OWNER= grid

    ORACLE_HOME=  /u01/app/11.2.0/grid

 

Enter the full pathname of the local bin directory: [/usr/local/bin]: 

   Copying dbhome to /usr/local/bin …

   Copying oraenv to /usr/local/bin …

   Copying coraenv to /usr/local/bin …

 

 

Creating /etc/oratab file…

Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root script.

Now product-specific root actions will be performed.

Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params

Creating trace directory

OLR initialization – successful

  root wallet

  root wallet cert

  root cert export

  peer wallet

  profile reader wallet

  pa wallet

  peer wallet keys

  pa wallet keys

  peer cert request

  pa cert request

  peer cert

  pa cert

  peer root cert TP

  profile reader root cert TP

  pa root cert TP

  peer pa cert TP

  pa peer cert TP

  profile reader pa cert TP

  profile reader peer cert TP

  peer user cert

  pa user cert

Adding Clusterware entries to inittab

CRS-2672: Attempting to start 'ora.mdnsd' on 'node1'

CRS-2676: Start of 'ora.mdnsd' on 'node1' succeeded

CRS-2672: Attempting to start 'ora.gpnpd' on 'node1'

CRS-2676: Start of 'ora.gpnpd' on 'node1' succeeded

CRS-2672: Attempting to start 'ora.cssdmonitor' on 'node1'

CRS-2672: Attempting to start 'ora.gipcd' on 'node1'

CRS-2676: Start of 'ora.gipcd' on 'node1' succeeded

CRS-2676: Start of 'ora.cssdmonitor' on 'node1' succeeded

CRS-2672: Attempting to start 'ora.cssd' on 'node1'

CRS-2672: Attempting to start 'ora.diskmon' on 'node1'

CRS-2676: Start of 'ora.diskmon' on 'node1' succeeded

CRS-2676: Start of 'ora.cssd' on 'node1' succeeded

 

ASM created and started successfully.

 

Disk Group GRIDDG created successfully.

 

clscfg: -install mode specified

Successfully accumulated necessary OCR keys.

Creating OCR keys for user 'root', privgrp 'root'..

Operation successful.

CRS-4256: Updating the profile

Successful addition of voting disk 9516d145c0254f9ebf50064a6a916182.

Successfully replaced voting disk group with +GRIDDG.

CRS-4256: Updating the profile

CRS-4266: Voting file(s) successfully replaced

##  STATE    File Universal Id                File Name Disk group

—  —–    —————–                ——— ———

 1. ONLINE   9516d145c0254f9ebf50064a6a916182 (ORCL:VOL1) [GRIDDG]

Located 1 voting disk(s).

CRS-2672: Attempting to start 'ora.asm' on 'node1'

CRS-2676: Start of 'ora.asm' on 'node1' succeeded

CRS-2672: Attempting to start 'ora.GRIDDG.dg' on 'node1'

CRS-2676: Start of 'ora.GRIDDG.dg' on 'node1' succeeded

CRS-2672: Attempting to start 'ora.registry.acfs' on 'node1'

CRS-2676: Start of 'ora.registry.acfs' on 'node1' succeeded

Configure Oracle Grid Infrastructure for a Cluster … succeeded

[root@node1 ~]# 

node2

[root@node2 ~]# /u01/app/11.2.0/grid/root.sh 

Performing root user operation for Oracle 11g 

 

The following environment variables are set as:

    ORACLE_OWNER= grid

    ORACLE_HOME=  /u01/app/11.2.0/grid

 

Enter the full pathname of the local bin directory: [/usr/local/bin]: 

   Copying dbhome to /usr/local/bin …

   Copying oraenv to /usr/local/bin …

   Copying coraenv to /usr/local/bin …

 

 

Creating /etc/oratab file…

Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root script.

Now product-specific root actions will be performed.

Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params

Creating trace directory

OLR initialization – successful

Adding Clusterware entries to inittab

CRS-4402: The CSS daemon was started in exclusive mode but found an active CSS daemon on node node1, 

number 1, and is terminating

An active cluster was found during exclusive startup, restarting to join the cluster

Configure Oracle Grid Infrastructure for a Cluster … succeeded

[root@node2 ~]# 

此时,集群件相关的服务已经启动。当然,ASM实例也将在两个节点上启动。

[root@node1 ~]# su – grid

node1-> crs_stat -t

Name           Type           Target    State     Host        

————————————————————

ora.GRIDDG.dg  ora….up.type ONLINE    ONLINE    node1       

ora….N1.lsnr ora….er.type ONLINE    ONLINE    node1       

ora.asm        ora.asm.type   ONLINE    ONLINE    node1       

ora.cvu        ora.cvu.type   ONLINE    ONLINE    node1       

ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               

ora….network ora….rk.type ONLINE    ONLINE    node1       

ora….SM1.asm application    ONLINE    ONLINE    node1       

ora.node1.gsd  application    OFFLINE   OFFLINE               

ora.node1.ons  application    ONLINE    ONLINE    node1       

ora.node1.vip  ora….t1.type ONLINE    ONLINE    node1       

ora….SM2.asm application    ONLINE    ONLINE    node2       

ora.node2.gsd  application    OFFLINE   OFFLINE               

ora.node2.ons  application    ONLINE    ONLINE    node2       

ora.node2.vip  ora….t1.type ONLINE    ONLINE    node2       

ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    node1       

ora.ons        ora.ons.type   ONLINE    ONLINE    node1       

ora….ry.acfs ora….fs.type ONLINE    ONLINE    node1       

ora.scan1.vip  ora….ip.type ONLINE    ONLINE    node1       

node1-> 

⑲ 执行完上述脚本之后,单击OKNext,进入下一步。

 最后,单击close,完成GRID软件在双节点上的安装。

 

至此,GRID集群件安装成功!!!

一步一步在Linux上安装Oracle 11gR2 RAC (4)

2.1配置ASM磁盘

在上一步2.13节中,我们已经对RAC双节点已经配置好了共享磁盘,接下来需要将这些共享磁盘格式化、然后用asmlib将其配置为ASM磁盘,用于将来存放OCRVoting Disk和数据库用。

注意:只需在其中1个节点上格式化就可以,接下来我们选择在node1节点上格式化。

这里我们以asmlib软件来创建ASM磁盘,而不使用raw disk,而且从11gR2开始,OUI的图形界面已经不再支持raw disk

2.14.1 格式化共享磁盘

① 以root用户分别在两个节点上执行fdisk命令,查看现有硬盘分区信息:

node1

[root@node1 ~]# fdisk -l


Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2163    17374266   83  Linux

/dev/sda2            2164        2609     3582495   82  Linux swap / Solaris


Disk /dev/sdb: 524 MB, 524288000 bytes

64 heads, 32 sectors/track, 500 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes


Disk /dev/sdb doesn't contain a valid partition table


Disk /dev/sdc: 524 MB, 524288000 bytes

64 heads, 32 sectors/track, 500 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes


Disk /dev/sdc doesn't contain a valid partition table


Disk /dev/sdd: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


Disk /dev/sdd doesn't contain a valid partition table


Disk /dev/sde: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


Disk /dev/sde doesn't contain a valid partition table

[root@node1 ~]# 

node2

[root@node2 ~]# fdisk -l


Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2163    17374266   83  Linux

/dev/sda2            2164        2609     3582495   82  Linux swap / Solaris


Disk /dev/sdb: 524 MB, 524288000 bytes

64 heads, 32 sectors/track, 500 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes


Disk /dev/sdb doesn't contain a valid partition table


Disk /dev/sdc: 524 MB, 524288000 bytes

64 heads, 32 sectors/track, 500 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes


Disk /dev/sdc doesn't contain a valid partition table


Disk /dev/sdd: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


Disk /dev/sdd doesn't contain a valid partition table


Disk /dev/sde: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


Disk /dev/sde doesn't contain a valid partition table

[root@node2 ~]# 

从上,我们可以看到目前两个节点上的分区信息一致:其中/dev/sda是用于存放操作系统的,/dev/sdb/dev/sdc/dev/sdd/dev/sde4块盘都没有分区信息,这是我们在上一步2.13节中配置的4块共享磁盘。

② root用户在node1上格式化/dev/sdb/dev/sdc/dev/sdd/dev/sde4块盘

[root@node1 ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.


Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-500, default 1): 

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-500, default 500): 

Using default value 500


Command (m for help): w

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.

[root@node1 ~]# 

说明:fdisk /dev/sdb表示要对/dev/sdb磁盘进行格式化,其中,输入的命令分别表示:

n表示新建1个分区;

p表示分区类型选择为primary partition 主分区;

1表示分区编号从1开始;

起始、终止柱面选择默认值,即1500

w表示将新建的分区信息写入硬盘分区表。

 

③ 重复上述步骤②,以root用户在node1上分别格式化其余3块磁盘:

④ 格式化完毕之后,在node1node2节点上分别看到下述信息:

node1

[root@node1 ~]# fdisk -l


Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2163    17374266   83  Linux

/dev/sda2            2164        2609     3582495   82  Linux swap / Solaris


Disk /dev/sdb: 524 MB, 524288000 bytes

64 heads, 32 sectors/track, 500 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         500      511984   83  Linux


Disk /dev/sdc: 524 MB, 524288000 bytes

64 heads, 32 sectors/track, 500 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1         500      511984   83  Linux


Disk /dev/sdd: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sdd1               1         391     3140676   83  Linux


Disk /dev/sde: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sde1               1         391     3140676   83  Linux

[root@node1 ~]#  

node2

[root@node2 ~]# fdisk -l


Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2163    17374266   83  Linux

/dev/sda2            2164        2609     3582495   82  Linux swap / Solaris


Disk /dev/sdb: 524 MB, 524288000 bytes

64 heads, 32 sectors/track, 500 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         500      511984   83  Linux


Disk /dev/sdc: 524 MB, 524288000 bytes

64 heads, 32 sectors/track, 500 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1         500      511984   83  Linux


Disk /dev/sdd: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sdd1               1         391     3140676   83  Linux


Disk /dev/sde: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sde1               1         391     3140676   83  Linux

[root@node2 ~]#  

至此,格式化共享磁盘完毕。

    

2.14.2 在两个节点上安装ASM RPM软件包

在安装ASM软件包时,要注意选择的软件包要与操作系统平台、内核版本选择一致。ASM软件包可以到Oracle官网下载。

node1安装:

[root@node1 ~]# rpm -qa|grep asm

用上述命令,并未发现节点1上安装任何asm软件包。

[root@node1 ~]# cd asm_rpm/

[root@node1 asm_rpm]# ll

total 136

-rw-r–r– 1 root root 25977 Apr 26 11:19 oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm

-rw-r–r– 1 root root 14176 Apr 26 11:19 oracleasmlib-2.0.4-1.el5.x86_64.rpm

-rw-r–r– 1 root root 89027 Apr 26 11:19 oracleasm-support-2.1.3-1.el5.x86_64.rpm

[root@node1 asm_rpm]# rpm -ivh oracleasm-support-2.1.3-1.el5.x86_64.rpm 

warning: oracleasm-support-2.1.3-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159

Preparing…                ########################################### [100%]

   1:oracleasm-support      ########################################### [100%]

[root@node1 asm_rpm]# rpm -ivh oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm 

warning: oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159

Preparing…                ########################################### [100%]

   1:oracleasm-2.6.18-194.el########################################### [100%]

[root@node1 asm_rpm]# rpm -ivh oracleasmlib-2.0.4-1.el5.x86_64.rpm 

warning: oracleasmlib-2.0.4-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159

Preparing…                ########################################### [100%]

   1:oracleasmlib           ########################################### [100%]

[root@node1 asm_rpm]# rpm -qa|grep asm

oracleasm-2.6.18-194.el5-2.0.5-1.el5

oracleasm-support-2.1.3-1.el5

oracleasmlib-2.0.4-1.el5

[root@node1 asm_rpm]# 

node2 安装:

[root@node2 asm_rpm]# ll

total 136

-rw-r–r– 1 root root 25977 Apr 26 11:20 oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm

-rw-r–r– 1 root root 14176 Apr 26 11:20 oracleasmlib-2.0.4-1.el5.x86_64.rpm

-rw-r–r– 1 root root 89027 Apr 26 11:20 oracleasm-support-2.1.3-1.el5.x86_64.rpm

[root@node2 asm_rpm]# rpm -qa|grep asm

[root@node2 asm_rpm]# rpm -ivh oracleasm-support-2.1.3-1.el5.x86_64.rpm 

warning: oracleasm-support-2.1.3-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159

Preparing…                ########################################### [100%]

   1:oracleasm-support      ########################################### [100%]

[root@node2 asm_rpm]# rpm -ivh oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm 

warning: oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159

Preparing…                ########################################### [100%]

   1:oracleasm-2.6.18-194.el########################################### [100%]

[root@node2 asm_rpm]# rpm -ivh oracleasmlib-2.0.4-1.el5.x86_64.rpm 

warning: oracleasmlib-2.0.4-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159

Preparing…                ########################################### [100%]

   1:oracleasmlib           ########################################### [100%]

[root@node2 asm_rpm]# rpm -qa|grep asm

oracleasmlib-2.0.4-1.el5

oracleasm-support-2.1.3-1.el5

oracleasm-2.6.18-194.el5-2.0.5-1.el5

[root@node2 asm_rpm]# 

说明:安装上述3ASM RPM软件包时要先安装oracleasm-support-2.1.3-1.el5软件包,其次安装oracleasm-2.6.18-194.el5-2.0.5-1.el5软件包,最后安装oracleasmlib-2.0.4-1.el5软件包。

安装完毕后,执行 rpm -qa|grep asm确认是否安装成功。

2.14.3 配置ASM driver服务

node1上以root用户进行配置。在安装完上述步骤2.14.2节中的3ASM RPM软件包之后,可以通过执行/usr/sbin/oracleasm命令来进行配置,也可以通过执行/etc/init.d/oracleasm命令来进行配置,后者命令是Oracle 10g中进行ASM配置的命令,Oracle推荐执行前者命令,不过后者命令保留使用。

① 查看ASM服务状态:

[root@node1 ~]# /usr/sbin/oracleasm status

Checking if ASM is loaded: no

Checking if /dev/oracleasm is mounted: no

[root@node1 ~]# 

看到,默认情况下ASM服务并未开启。具体命令和相关参数可以直接执行下述命令来获取:

[root@node1 ~]# /usr/sbin/oracleasm -h

Usage: oracleasm [–exec-path=<exec_path>] <command> [ <args> ]

       oracleasm –exec-path

       oracleasm -h

       oracleasm -V


The basic oracleasm commands are:

    configure        Configure the Oracle Linux ASMLib driver

    init             Load and initialize the ASMLib driver

    exit             Stop the ASMLib driver

    scandisks        Scan the system for Oracle ASMLib disks

    status           Display the status of the Oracle ASMLib driver

    listdisks        List known Oracle ASMLib disks

    querydisk        Determine if a disk belongs to Oracle ASMlib

    createdisk       Allocate a device for Oracle ASMLib use

    deletedisk       Return a device to the operating system

    renamedisk       Change the label of an Oracle ASMlib disk

    update-driver    Download the latest ASMLib driver

[root@node1 ~]#

② 配置ASM服务:

[root@node1 ~]# /usr/sbin/oracleasm configure -i

Configuring the Oracle ASM library driver.


This will configure the on-boot properties of the Oracle ASM library

driver.  The following questions will determine whether the driver is

loaded on boot and what permissions it will have.  The current values

will be shown in brackets ('[]').  Hitting <ENTER> without typing an

answer will keep that current value.  Ctrl-C will abort.


Default user to own the driver interface []: grid

Default group to own the driver interface []: asmadmin

Start Oracle ASM library driver on boot (y/n) [n]: y

Scan for Oracle ASM disks on boot (y/n) [y]: y

Writing Oracle ASM library driver configuration: done

[root@node1 ~]# /usr/sbin/oracleasm status

Checking if ASM is loaded: no

Checking if /dev/oracleasm is mounted: no

[root@node1 ~]# /usr/sbin/oracleasm init

Loading module "oracleasm": oracleasm

Mounting ASMlib driver filesystem: /dev/oracleasm

[root@node1 ~]# /usr/sbin/oracleasm configure

ORACLEASM_ENABLED=true

ORACLEASM_UID=grid

ORACLEASM_GID=asmadmin

ORACLEASM_SCANBOOT=true

ORACLEASM_SCANORDER=""

ORACLEASM_SCANEXCLUDE=""

[root@node1 ~]# 

说明/usr/sbin/oracleasm configure -i命令进行配置时,用户配置为grid,组为asmadmin,启动ASM library driver驱动服务,并且将其配置为随着操作系统的启动而自动启动。

配置完成后,记得执行 /usr/sbin/oracleasm init命令来加载oracleasm内核模块。

③ 在node2上执行上述步骤②,完成ASM服务配置。

2.14.4 配置ASM磁盘

我们安装ASM RPM软件包,配置ASM 驱动服务的最终目的是要创建ASM磁盘,为将来安装grid软件、创建Oracle数据库提供存储。

说明:只需在一个节点上创建ASM磁盘即可!创建完之后,在其它节点上执行/usr/sbin/oracleasm scandisks之后,就可看到ASM磁盘。

接下来,开始创建ASM磁盘:

① 执行/usr/sbin/oracleasm createdisk来创建ASM磁盘

[root@node1 ~]# /usr/sbin/oracleasm listdisks

[root@node1 ~]# /usr/sbin/oracleasm createdisk -h

Usage: oracleasm-createdisk [-l <manager>] [-v] <label> <device>

[root@node1 ~]# /usr/sbin/oracleasm createdisk VOL1 /dev/sdb1

Writing disk header: done

Instantiating disk: done

[root@node1 ~]# /usr/sbin/oracleasm createdisk VOL2 /dev/sdc1

Writing disk header: done

Instantiating disk: done

[root@node1 ~]# /usr/sbin/oracleasm createdisk VOL3 /dev/sdd1

Writing disk header: done

Instantiating disk: done

[root@node1 ~]# /usr/sbin/oracleasm createdisk VOL4 /dev/sde1

Writing disk header: done

Instantiating disk: done

[root@node1 ~]# /usr/sbin/oracleasm listdisks

VOL1

VOL2

VOL3

VOL4

[root@node1 ~]# 

    从上看到,创建出来4ASM磁盘。此时,node2上还看不到刚创建的ASM磁盘。

② node2 执行/usr/sbin/oracleasm scandisks扫描磁盘

[root@node2 ~]# /usr/sbin/oracleasm listdisks

[root@node2 ~]# /usr/sbin/oracleasm scandisks

Reloading disk partitions: done

Cleaning any stale ASM disks…

Scanning system for ASM disks…

Instantiating disk "VOL1"

Instantiating disk "VOL2"

Instantiating disk "VOL3"

Instantiating disk "VOL4"

[root@node2 ~]# /usr/sbin/oracleasm listdisks

VOL1

VOL2

VOL3

VOL4

[root@node2 ~]# 

③ 如何确定ASM磁盘同物理磁盘之间的对应关系?

[root@node1 ~]# /usr/sbin/oracleasm querydisk /dev/sd*

Device "/dev/sda" is not marked as an ASM disk

Device "/dev/sda1" is not marked as an ASM disk

Device "/dev/sda2" is not marked as an ASM disk

Device "/dev/sdb" is not marked as an ASM disk

Device "/dev/sdb1" is marked an ASM disk with the label "VOL1"

Device "/dev/sdc" is not marked as an ASM disk

Device "/dev/sdc1" is marked an ASM disk with the label "VOL2"

Device "/dev/sdd" is not marked as an ASM disk

Device "/dev/sdd1" is marked an ASM disk with the label "VOL3"

Device "/dev/sde" is not marked as an ASM disk

Device "/dev/sde1" is marked an ASM disk with the label "VOL4"

[root@node1 ~]#

至此,ASM磁盘准备工作已经完成!

2.15 解压安装介质

在获取开篇1.2节中提到的安装介质如下:

[root@node1 ~]# ls -l

total 3401724

-rw——- 1 root root       1376 Apr 20 14:05 anaconda-ks.cfg

drwxr-xr-x 2 root root       4096 Apr 26 11:19 asm_rpm

-rw-r–r– 1 root root      51217 Apr 20 14:05 install.log

-rw-r–r– 1 root root       4077 Apr 20 14:05 install.log.syslog

-rw-r–r– 1 root root 1358454646 Apr 20 16:22 p10404530_112030_Linux-x86-64_1of7.zip

-rw-r–r– 1 root root 1142195302 Apr 20 16:29 p10404530_112030_Linux-x86-64_2of7.zip

-rw-r–r– 1 root root  979195792 Apr 20 17:07 p10404530_112030_Linux-x86-64_3of7.zip

drwxr-xr-x 2 root root       4096 Apr 24 10:17 shell

[root@node1 ~]# 

其中:

p10404530_112030_Linux-x86-64_1of7.zip

p10404530_112030_Linux-x86-64_2of7.zip

Oracle软件的安装介质。

p10404530_112030_Linux-x86-64_3of7.zipGRID软件的安装介质。

注意:这里的3个软件包均是来源于MetaLink网站,其版本均是目前Oracle 11g的最新版本,11.2.0.3.0。如果没有MetaLink账号的话,也可以从oracle官方网站免费获取11.2.0.1.0的版本软件来进行安装和配置。

我们通过下述命令来解压上述3个压缩软件包:

[root@node1 ~]# unzip p10404530_112030_Linux-x86-64_1of7.zip 

[root@node1 ~]# unzip p10404530_112030_Linux-x86-64_2of7.zip

[root@node1 ~]# unzip p10404530_112030_Linux-x86-64_3of7.zip  

解压之后,信息如下:

[root@node1 ~]# ls -l

total 3401724

-rw——- 1 root root       1376 Apr 20 14:05 anaconda-ks.cfg

drwxr-xr-x 2 root root       4096 Apr 26 11:19 asm_rpm

drwxr-xr-x 8 root root       4096 Sep 22  2011 database

drwxr-xr-x 8 root root       4096 Sep 22  2011 grid

-rw-r–r– 1 root root      51217 Apr 20 14:05 install.log

-rw-r–r– 1 root root       4077 Apr 20 14:05 install.log.syslog

-rw-r–r– 1 root root 1358454646 Apr 20 16:22 p10404530_112030_Linux-x86-64_1of7.zip

-rw-r–r– 1 root root 1142195302 Apr 20 16:29 p10404530_112030_Linux-x86-64_2of7.zip

-rw-r–r– 1 root root  979195792 Apr 20 17:07 p10404530_112030_Linux-x86-64_3of7.zip

drwxr-xr-x 2 root root       4096 Apr 24 10:17 shell

[root@node1 ~]# du -sh database/

2.5G    database/

[root@node1 ~]# du -sh grid/

1.1G    grid/

[root@node1 ~]# 

可以看到,数据库的安装文件2.5G大小,GRID软件的安装1.1GB

为便于将来安装软件,分别将其moveoracle用户和grid用户的家目录:

[root@node1 ~]# mv database/ /home/oracle/

[root@node1 ~]# mv grid/ /home/grid/

[root@node1 ~]# 

2.16 安装前预检查配置信息

在安装 GRID之前,建议先利用CVU(Cluster Verification Utility)检查 CRS的安装前环境。

① 使用 CVU 检查CRS的安装前环境:

[root@node1 ~]# su – grid

node1-> pwd

/home/grid

node1-> ls

Desktop  grid

node1-> cd grid/

node1-> ll

total 72

drwxr-xr-x  9 root root  4096 Sep 22  2011 doc

drwxr-xr-x  4 root root  4096 Sep 22  2011 install

-rwxr-xr-x  1 root root 28122 Sep 22  2011 readme.html

drwxr-xr-x  2 root root  4096 Sep 22  2011 response

drwxr-xr-x  2 root root  4096 Sep 22  2011 rpm

-rwxr-xr-x  1 root root  4878 Sep 22  2011 runcluvfy.sh

-rwxr-xr-x  1 root root  3227 Sep 22  2011 runInstaller

drwxr-xr-x  2 root root  4096 Sep 22  2011 sshsetup

drwxr-xr-x 14 root root  4096 Sep 22  2011 stage

-rwxr-xr-x  1 root root  4326 Sep  2  2011 welcome.html

node1-> ./runcluvfy.sh stage -pre crsinst -n node1,node2 -fixup -verbose


Performing pre-checks for cluster services setup 


Checking node reachability…


Check: Node reachability from node "node1"

  Destination Node                      Reachable?              

  ————————————  ————————

  node1                                 yes                     

  node2                                 yes                     

Result: Node reachability check passed from node "node1"



Checking user equivalence…


Check: User equivalence for user "grid"

  Node Name                             Status                  

  ————————————  ————————

  node2                                 passed                  

  node1                                 passed                  

Result: User equivalence check passed for user "grid"


Checking node connectivity…


Checking hosts config file…

  Node Name                             Status                  

  ————————————  ————————

  node2                                 passed                  

  node1                                 passed                  


Verification of the hosts config file successful



Interface information for node "node2"

 Name   IP Address      Subnet          Gateway         Def. Gateway    HW Address        MTU   

 —— ————— ————— ————— ————— —————– ——

 eth0   172.16.0.192    172.16.0.0      0.0.0.0         172.16.15.254   00:0C:29:00:42:89 1500  

 eth1   192.168.94.12   192.168.94.0    0.0.0.0         172.16.15.254   00:0C:29:00:42:93 1500  



Interface information for node "node1"

 Name   IP Address      Subnet          Gateway         Def. Gateway    HW Address        MTU   

 —— ————— ————— ————— ————— —————– ——

 eth0   172.16.0.191    172.16.0.0      0.0.0.0         172.16.15.254   00:0C:29:A2:AE:1F 1500  

 eth1   192.168.94.11   192.168.94.0    0.0.0.0         172.16.15.254   00:0C:29:A2:AE:29 1500  



Check: Node connectivity of subnet "172.16.0.0"

  Source                          Destination                     Connected?      

  ——————————  ——————————  —————-

  node2[172.16.0.192]             node1[172.16.0.191]             yes             

Result: Node connectivity passed for subnet "172.16.0.0" with node(s) node2,node1



Check: TCP connectivity of subnet "172.16.0.0"

  Source                          Destination                     Connected?      

  ——————————  ——————————  —————-

  node1:172.16.0.191              node2:172.16.0.192              passed          

Result: TCP connectivity check passed for subnet "172.16.0.0"



Check: Node connectivity of subnet "192.168.94.0"

  Source                          Destination                     Connected?      

  ——————————  ——————————  —————-

  node2[192.168.94.12]            node1[192.168.94.11]            yes             

Result: Node connectivity passed for subnet "192.168.94.0" with node(s) node2,node1



Check: TCP connectivity of subnet "192.168.94.0"

  Source                          Destination                     Connected?      

  ——————————  ——————————  —————-

  node1:192.168.94.11             node2:192.168.94.12             passed          

Result: TCP connectivity check passed for subnet "192.168.94.0"



Interfaces found on subnet "172.16.0.0" that are likely candidates for VIP are:

node2 eth0:172.16.0.192

node1 eth0:172.16.0.191


Interfaces found on subnet "192.168.94.0" that are likely candidates for a private interconnect are:

node2 eth1:192.168.94.12

node1 eth1:192.168.94.11

Checking subnet mask consistency…

Subnet mask consistency check passed for subnet "172.16.0.0".

Subnet mask consistency check passed for subnet "192.168.94.0".

Subnet mask consistency check passed.


Result: Node connectivity check passed


Checking multicast communication…


Checking subnet "172.16.0.0" for multicast communication with multicast group "230.0.1.0"…

Check of subnet "172.16.0.0" for multicast communication with multicast group "230.0.1.0" passed.


Checking subnet "192.168.94.0" for multicast communication with multicast group "230.0.1.0"…

Check of subnet "192.168.94.0" for multicast communication with multicast group "230.0.1.0" passed.


Check of multicast communication passed.


Checking ASMLib configuration.

  Node Name                             Status                  

  ————————————  ————————

  node2                                 passed                  

  node1                                 passed                  

Result: Check for ASMLib configuration passed.


Check: Total memory 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         1.9641GB (2059516.0KB)    1.5GB (1572864.0KB)       passed    

  node1         1.9641GB (2059516.0KB)    1.5GB (1572864.0KB)       passed    

Result: Total memory check passed


Check: Available memory 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         1.8744GB (1965456.0KB)    50MB (51200.0KB)          passed    

  node1         1.7501GB (1835088.0KB)    50MB (51200.0KB)          passed    

Result: Available memory check passed


Check: Swap space 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         3.4165GB (3582484.0KB)    2.9462GB (3089274.0KB)    passed    

  node1         3.4165GB (3582484.0KB)    2.9462GB (3089274.0KB)    passed    

Result: Swap space check passed


Check: Free disk space for "node2:/tmp" 

  Path              Node Name     Mount point   Available     Required      Status      

  —————-  ————  ————  ————  ————  ————

  /tmp              node2         /             13.0361GB     1GB           passed      

Result: Free disk space check passed for "node2:/tmp"


Check: Free disk space for "node1:/tmp" 

  Path              Node Name     Mount point   Available     Required      Status      

  —————-  ————  ————  ————  ————  ————

  /tmp              node1         /             5.874GB       1GB           passed      

Result: Free disk space check passed for "node1:/tmp"


Check: User existence for "grid" 

  Node Name     Status                    Comment                 

  ————  ————————  ————————

  node2         passed                    exists(1100)            

  node1         passed                    exists(1100)            


Checking for multiple users with UID value 1100

Result: Check for multiple users with UID value 1100 passed 

Result: User existence check passed for "grid"


Check: Group existence for "oinstall" 

  Node Name     Status                    Comment                 

  ————  ————————  ————————

  node2         passed                    exists                  

  node1         passed                    exists                  

Result: Group existence check passed for "oinstall"


Check: Group existence for "dba" 

  Node Name     Status                    Comment                 

  ————  ————————  ————————

  node2         passed                    exists                  

  node1         passed                    exists                  

Result: Group existence check passed for "dba"


Check: Membership of user "grid" in group "oinstall" [as Primary]

  Node Name         User Exists   Group Exists  User in Group  Primary       Status      

  —————-  ————  ————  ————  ————  ————

  node2             yes           yes           yes           yes           passed      

  node1             yes           yes           yes           yes           passed      

Result: Membership check for user "grid" in group "oinstall" [as Primary] passed


Check: Membership of user "grid" in group "dba" 

  Node Name         User Exists   Group Exists  User in Group  Status          

  —————-  ————  ————  ————  —————-

  node2             yes           yes           no            failed          

  node1             yes           yes           no            failed          

Result: Membership check for user "grid" in group "dba" failed


Check: Run level 

  Node Name     run level                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         5                         3,5                       passed    

  node1         5                         3,5                       passed    

Result: Run level check passed


Check: Hard limits for "maximum open file descriptors" 

  Node Name         Type          Available     Required      Status          

  —————-  ————  ————  ————  —————-

  node2             hard          65536         65536         passed          

  node1             hard          65536         65536         passed          

Result: Hard limits check passed for "maximum open file descriptors"


Check: Soft limits for "maximum open file descriptors" 

  Node Name         Type          Available     Required      Status          

  —————-  ————  ————  ————  —————-

  node2             soft          1024          1024          passed          

  node1             soft          1024          1024          passed          

Result: Soft limits check passed for "maximum open file descriptors"


Check: Hard limits for "maximum user processes" 

  Node Name         Type          Available     Required      Status          

  —————-  ————  ————  ————  —————-

  node2             hard          16384         16384         passed          

  node1             hard          16384         16384         passed          

Result: Hard limits check passed for "maximum user processes"


Check: Soft limits for "maximum user processes" 

  Node Name         Type          Available     Required      Status          

  —————-  ————  ————  ————  —————-

  node2             soft          2047          2047          passed          

  node1             soft          2047          2047          passed          

Result: Soft limits check passed for "maximum user processes"


Check: System architecture 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         x86_64                    x86_64                    passed    

  node1         x86_64                    x86_64                    passed    

Result: System architecture check passed


Check: Kernel version 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         2.6.18-194.el5            2.6.18                    passed    

  node1         2.6.18-194.el5            2.6.18                    passed    

Result: Kernel version check passed


Check: Kernel parameter for "semmsl" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             250           250           250           passed          

  node1             250           250           250           passed          

Result: Kernel parameter check passed for "semmsl"


Check: Kernel parameter for "semmns" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             32000         32000         32000         passed          

  node1             32000         32000         32000         passed          

Result: Kernel parameter check passed for "semmns"


Check: Kernel parameter for "semopm" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             100           100           100           passed          

  node1             100           100           100           passed          

Result: Kernel parameter check passed for "semopm"


Check: Kernel parameter for "semmni" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             128           128           128           passed          

  node1             128           128           128           passed          

Result: Kernel parameter check passed for "semmni"


Check: Kernel parameter for "shmmax" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             1054472192    1054472192    1054472192    passed          

  node1             1054472192    1054472192    1054472192    passed          

Result: Kernel parameter check passed for "shmmax"


Check: Kernel parameter for "shmmni" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             4096          4096          4096          passed          

  node1             4096          4096          4096          passed          

Result: Kernel parameter check passed for "shmmni"


Check: Kernel parameter for "shmall" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             2097152       2097152       2097152       passed          

  node1             2097152       2097152       2097152       passed          

Result: Kernel parameter check passed for "shmall"


Check: Kernel parameter for "file-max" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             6815744       6815744       6815744       passed          

  node1             6815744       6815744       6815744       passed          

Result: Kernel parameter check passed for "file-max"


Check: Kernel parameter for "ip_local_port_range" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             between 9000.0 & 65500.0  between 9000.0 & 65500.0  between 9000.0 & 65500.0  passed

  node1             between 9000.0 & 65500.0  between 9000.0 & 65500.0  between 9000.0 & 65500.0  passed

Result: Kernel parameter check passed for "ip_local_port_range"


Check: Kernel parameter for "rmem_default" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             262144        262144        262144        passed          

  node1             262144        262144        262144        passed          

Result: Kernel parameter check passed for "rmem_default"


Check: Kernel parameter for "rmem_max" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             4194304       4194304       4194304       passed          

  node1             4194304       4194304       4194304       passed          

Result: Kernel parameter check passed for "rmem_max"


Check: Kernel parameter for "wmem_default" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             262144        262144        262144        passed          

  node1             262144        262144        262144        passed          

Result: Kernel parameter check passed for "wmem_default"


Check: Kernel parameter for "wmem_max" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             1048586       1048586       1048576       passed          

  node1             1048586       1048586       1048576       passed          

Result: Kernel parameter check passed for "wmem_max"


Check: Kernel parameter for "aio-max-nr" 

  Node Name         Current       Configured    Required      Status        Comment     

  —————-  ————  ————  ————  ————  ————

  node2             1048576       1048576       1048576       passed          

  node1             1048576       1048576       1048576       passed          

Result: Kernel parameter check passed for "aio-max-nr"


Check: Package existence for "make" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         make-3.81-3.el5           make-3.81                 passed    

  node1         make-3.81-3.el5           make-3.81                 passed    

Result: Package existence check passed for "make"


Check: Package existence for "binutils" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         binutils-2.17.50.0.6-14.el5  binutils-2.17.50.0.6      passed    

  node1         binutils-2.17.50.0.6-14.el5  binutils-2.17.50.0.6      passed    

Result: Package existence check passed for "binutils"


Check: Package existence for "gcc(x86_64)" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         gcc(x86_64)-4.1.2-48.el5  gcc(x86_64)-4.1.2         passed    

  node1         gcc(x86_64)-4.1.2-48.el5  gcc(x86_64)-4.1.2         passed    

Result: Package existence check passed for "gcc(x86_64)"


Check: Package existence for "libaio(x86_64)" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         libaio(x86_64)-0.3.106-5  libaio(x86_64)-0.3.106    passed    

  node1         libaio(x86_64)-0.3.106-5  libaio(x86_64)-0.3.106    passed    

Result: Package existence check passed for "libaio(x86_64)"


Check: Package existence for "glibc(x86_64)" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         glibc(x86_64)-2.5-49      glibc(x86_64)-2.5-24      passed    

  node1         glibc(x86_64)-2.5-49      glibc(x86_64)-2.5-24      passed    

Result: Package existence check passed for "glibc(x86_64)"


Check: Package existence for "compat-libstdc++-33(x86_64)" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         compat-libstdc++-33(x86_64)-3.2.3-61  compat-libstdc++-33(x86_64)-3.2.3  passed    

  node1         compat-libstdc++-33(x86_64)-3.2.3-61  compat-libstdc++-33(x86_64)-3.2.3  passed    

Result: Package existence check passed for "compat-libstdc++-33(x86_64)"


Check: Package existence for "elfutils-libelf(x86_64)" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         elfutils-libelf(x86_64)-0.137-3.el5  elfutils-libelf(x86_64)-0.125  passed    

  node1         elfutils-libelf(x86_64)-0.137-3.el5  elfutils-libelf(x86_64)-0.125  passed    

Result: Package existence check passed for "elfutils-libelf(x86_64)"


Check: Package existence for "elfutils-libelf-devel" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         elfutils-libelf-devel-0.137-3.el5  elfutils-libelf-devel-0.125  passed    

  node1         elfutils-libelf-devel-0.137-3.el5  elfutils-libelf-devel-0.125  passed    

Result: Package existence check passed for "elfutils-libelf-devel"


Check: Package existence for "glibc-common" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         glibc-common-2.5-49       glibc-common-2.5          passed    

  node1         glibc-common-2.5-49       glibc-common-2.5          passed    

Result: Package existence check passed for "glibc-common"


Check: Package existence for "glibc-devel(x86_64)" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         glibc-devel(x86_64)-2.5-49  glibc-devel(x86_64)-2.5   passed    

  node1         glibc-devel(x86_64)-2.5-49  glibc-devel(x86_64)-2.5   passed    

Result: Package existence check passed for "glibc-devel(x86_64)"


Check: Package existence for "glibc-headers" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         glibc-headers-2.5-49      glibc-headers-2.5         passed    

  node1         glibc-headers-2.5-49      glibc-headers-2.5         passed    

Result: Package existence check passed for "glibc-headers"


Check: Package existence for "gcc-c++(x86_64)" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         gcc-c++(x86_64)-4.1.2-48.el5  gcc-c++(x86_64)-4.1.2     passed    

  node1         gcc-c++(x86_64)-4.1.2-48.el5  gcc-c++(x86_64)-4.1.2     passed    

Result: Package existence check passed for "gcc-c++(x86_64)"


Check: Package existence for "libaio-devel(x86_64)" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         libaio-devel(x86_64)-0.3.106-5  libaio-devel(x86_64)-0.3.106  passed    

  node1         libaio-devel(x86_64)-0.3.106-5  libaio-devel(x86_64)-0.3.106  passed    

Result: Package existence check passed for "libaio-devel(x86_64)"


Check: Package existence for "libgcc(x86_64)" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         libgcc(x86_64)-4.1.2-48.el5  libgcc(x86_64)-4.1.2      passed    

  node1         libgcc(x86_64)-4.1.2-48.el5  libgcc(x86_64)-4.1.2      passed    

Result: Package existence check passed for "libgcc(x86_64)"


Check: Package existence for "libstdc++(x86_64)" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         libstdc++(x86_64)-4.1.2-48.el5  libstdc++(x86_64)-4.1.2   passed    

  node1         libstdc++(x86_64)-4.1.2-48.el5  libstdc++(x86_64)-4.1.2   passed    

Result: Package existence check passed for "libstdc++(x86_64)"


Check: Package existence for "libstdc++-devel(x86_64)" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         libstdc++-devel(x86_64)-4.1.2-48.el5  libstdc++-devel(x86_64)-4.1.2  passed    

  node1         libstdc++-devel(x86_64)-4.1.2-48.el5  libstdc++-devel(x86_64)-4.1.2  passed    

Result: Package existence check passed for "libstdc++-devel(x86_64)"


Check: Package existence for "sysstat" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         sysstat-7.0.2-3.el5       sysstat-7.0.2             passed    

  node1         sysstat-7.0.2-3.el5       sysstat-7.0.2             passed    

Result: Package existence check passed for "sysstat"


Check: Package existence for "ksh" 

  Node Name     Available                 Required                  Status    

  ————  ————————  ————————  ———-

  node2         ksh-20100202-1.el5        ksh-20060214              passed    

  node1         ksh-20100202-1.el5        ksh-20060214              passed    

Result: Package existence check passed for "ksh"


Checking for multiple users with UID value 0

Result: Check for multiple users with UID value 0 passed 


Check: Current group ID 

Result: Current group ID check passed


Starting check for consistency of primary group of root user

  Node Name                             Status                  

  ————————————  ————————

  node2                                 passed                  

  node1                                 passed                  


Check for consistency of root user's primary group passed


Starting Clock synchronization checks using Network Time Protocol(NTP)…


NTP Configuration file check started…

Network Time Protocol(NTP) configuration file not found on any of the nodes. Oracle Cluster Time 

Synchronization Service(CTSS) can be used instead of NTP for time synchronization on the cluster nodes

No NTP Daemons or Services were found to be running


Result: Clock synchronization check using Network Time Protocol(NTP) passed


Checking Core file name pattern consistency…

Core file name pattern consistency check passed.


Checking to make sure user "grid" is not in "root" group

  Node Name     Status                    Comment                 

  ————  ————————  ————————

  node2         passed                    does not exist          

  node1         passed                    does not exist          

Result: User "grid" is not part of "root" group. Check passed


Check default user file creation mask

  Node Name     Available                 Required                  Comment   

  ————  ————————  ————————  ———-

  node2         0022                      0022                      passed    

  node1         0022                      0022                      passed    

Result: Default user file creation mask check passed

Checking consistency of file "/etc/resolv.conf" across nodes


Checking the file "/etc/resolv.conf" to make sure only one of domain and search entries is defined

File "/etc/resolv.conf" does not have both domain and search entries defined

Checking if domain entry in file "/etc/resolv.conf" is consistent across the nodes…

domain entry in file "/etc/resolv.conf" is consistent across nodes

Checking if search entry in file "/etc/resolv.conf" is consistent across the nodes…

search entry in file "/etc/resolv.conf" is consistent across nodes

Checking file "/etc/resolv.conf" to make sure that only one search entry is defined

All nodes have one search entry defined in file "/etc/resolv.conf"

Checking all nodes to make sure that search entry is "localdomain" as found on node "node2"

All nodes of the cluster have same value for 'search'

Checking DNS response time for an unreachable node

  Node Name                             Status                  

  ————————————  ————————

  node2                                 passed                  

  node1                                 passed                  

The DNS response time for an unreachable node is within acceptable limit on all nodes


File "/etc/resolv.conf" is consistent across nodes


Check: Time zone consistency 

Result: Time zone consistency check passed

Fixup information has been generated for following node(s):

node2,node1

Please run the following script on each node as "root" user to execute the fixups:

'/tmp/CVU_11.2.0.3.0_grid/runfixup.sh'


Pre-check for cluster services setup was unsuccessful on all the nodes. 

node1->

从上面的预检查结果中,可以看到不成功,其实错误的原因是grid用户不属于dba组!不过,Oracle自动给我们提供的修复的脚本,根据上述提示,分别以root用户在两个节点上执行/tmp/CVU_11.2.0.3.0_grid/runfixup.sh脚本来修复。

node1

[root@node1 ~]# id grid

uid=1100(grid) gid=1000(oinstall) groups=1000(oinstall),1200(asmadmin),1201(asmdba),1202(asmoper)

[root@node1 ~]# 

看到,grid的确不属于dba组。执行脚本,进行修复:

[root@node1 ~]# sh /tmp/CVU_11.2.0.3.0_grid/runfixup.sh 

Response file being used is :/tmp/CVU_11.2.0.3.0_grid/fixup.response

Enable file being used is :/tmp/CVU_11.2.0.3.0_grid/fixup.enable

Log file location: /tmp/CVU_11.2.0.3.0_grid/orarun.log

uid=1100(grid) gid=1000(oinstall) groups=1000(oinstall),1200(asmadmin),1201(asmdba),1202(asmoper)

[root@node1 ~]# id grid

uid=1100(grid) gid=1000(oinstall) groups=1000(oinstall),1200(asmadmin),1201(asmdba),1202(asmoper),1300(dba)

[root@node1 ~]# 

同样,在node2上执行上述脚本:

[root@node2 ~]# sh /tmp/CVU_11.2.0.3.0_grid/runfixup.sh 

Response file being used is :/tmp/CVU_11.2.0.3.0_grid/fixup.response

Enable file being used is :/tmp/CVU_11.2.0.3.0_grid/fixup.enable

Log file location: /tmp/CVU_11.2.0.3.0_grid/orarun.log

uid=1100(grid) gid=1000(oinstall) groups=1000(oinstall),1200(asmadmin),1201(asmdba),1202(asmoper)

[root@node2 ~]# id grid

uid=1100(grid) gid=1000(oinstall) groups=1000(oinstall),1200(asmadmin),1201(asmdba),1202(asmoper),1300(dba)

[root@node2 ~]# 

执行完修复脚本后,重新执行预检查:

node1-> ./runcluvfy.sh stage -pre crsinst -n node1,node2 -fixup -verbose

Checking the file "/etc/resolv.conf" to make sure only one of domain and search entries is defined

File "/etc/resolv.conf" does not have both domain and search entries defined

Checking if domain entry in file "/etc/resolv.conf" is consistent across the nodes…

domain entry in file "/etc/resolv.conf" is consistent across nodes

Checking if search entry in file "/etc/resolv.conf" is consistent across the nodes…

search entry in file "/etc/resolv.conf" is consistent across nodes

Checking file "/etc/resolv.conf" to make sure that only one search entry is defined

All nodes have one search entry defined in file "/etc/resolv.conf"

Checking all nodes to make sure that search entry is "localdomain" as found on node "node2"

All nodes of the cluster have same value for 'search'

Checking DNS response time for an unreachable node

  Node Name                             Status                  

  ————————————  ————————

  node2                                 passed                  

  node1                                 passed                  

The DNS response time for an unreachable node is within acceptable limit on all nodes


File "/etc/resolv.conf" is consistent across nodes


Check: Time zone consistency 

Result: Time zone consistency check passed


Pre-check for cluster services setup was successful

node1->

 

直到此步骤,我们的安装环境已经完全准备OK!!!

一步一步在Linux上安装Oracle 11gR2 RAC (3)

2.4 建用户、改口令、修改用户配置文件

配置11gR2 RAC需要安装Oracle Grid Infrastructure软件、Oracle数据库软件,其中Grid软件等同于Oracle 10gClusterware集群件。Oracle建议以不同的用户分别安装Grid Infrastructure软件、Oracle数据库软件,我们这里以grid用户安装Grid Infrastructureoracle用户安装Oracle数据库软件。并且gridoracle用户需要属于不同的用户组。在配置RAC时,还要求这两个用户在RAC的不同节点上uidgid要一致。用户、组的对应信息见下表:

Group Name

Group ID

Group Info

Oracle User(1100)

Grid User(1101)

oinstall

1000

Inventory Group

Y

Y

dba

1300

OSDBA Group

Y

oper

1301

OSOPER Group

Y

asmadmin

1200

OSASM 

Y

asmdba

1201

OSDBA for ASM

Y

Y

asmoper

1202

OSOPER for ASM 

Y

(Figure 2.4用户、组配置信息表)

我们可以通过执行下述shell脚本的1preusers.sh来完成用户、组的创建,脚本的具体内容可见本文档附录

[root@node1 shell]# pwd

/root/shell

[root@node1 shell]# ll

total 24

-rwxr–r– 1 root root 3544 Apr 24 09:40 1preusers.sh

-rwxr–r– 1 root root  678 Apr 24 09:40 2predir.sh

-rwxr–r– 1 root root  858 Apr 24 09:40 3prelimits.sh

-rwxr–r– 1 root root  465 Apr 24 09:40 4prelogin.sh

-rwxr–r– 1 root root  651 Apr 24 09:40 5preprofile.sh

-rwxr–r– 1 root root 1132 Apr 24 09:40 6presysctl.sh

[root@node1 shell]# ./1preusers.sh 

Now create 6 groups named ‘oinstall’,’dba’,’asmadmin’,’asmdba’,’asmoper’,’oper’

Plus 2 users named ‘oracle’,’grid’,Also setting the Environment

Changing password for user grid.

passwd: all authentication tokens updated successfully.

Changing password for user oracle.

passwd: all authentication tokens updated successfully.

The Groups and users has been created

The Environment for grid,oracle also has been set successfully

[root@node1 shell]# id grid

uid=1100(grid) gid=1000(oinstall) groups=1000(oinstall),1200(asmadmin),1201(asmdba),1202(asmoper)

[root@node1 shell]# id oracle

uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1201(asmdba),1300(dba),1301(oper)

[root@node1 shell]#    

说明:在节点node2上执行该脚本时,需要将grid用户环境变量ORACLE_SID修改为+ASM2oracle用户环境变量ORACLE_SID修改为devdb2,ORACLE_HOSTNAME环境变量修改为node2.localdomain

2.5 建路径、改权限

关于gridoracle用户的环境变量配置信息,见下述表格。

Environment Variable

Grid User

Oracle User

ORACLE_BASE

/u01/app/grid

/u01/app/oracle

ORACLE_HOME

/u01/app/11.2.0/grid

/u01/app/oracle/product/11.2.0/db_1

ORACLE_SID [node1]

+ASM1

devdb1

ORACLE_SID [node2]

+ASM2

devdb2

(Figure 2.5环境变量配置信息表)

通过执行上述2.4节中脚本2predir.sh来完成相关路径、权限的配置。脚本的具体内容可见本文档附录。

[root@node1 shell]# pwd

/root/shell

[root@node1 shell]# ./2predir.sh 

Now create the necessary directory for oracle,grid users and change the authention to oracle,grid users…

The necessary directory for oracle,grid users and change the authention to oracle,grid users has been 

finished

[root@node1 shell]# cd /u01/app/

[root@node1 app]# ll

total 12

drwxrwxr-x 3 grid   oinstall 4096 Apr 24 10:06 11.2.0

drwxrwxr-x 2 grid   oinstall 4096 Apr 24 10:06 grid

drwxrwxr-x 2 oracle oinstall 4096 Apr 24 10:06 oracle

[root@node1 app]# 

2.6 修改/etc/security/limits.conf,配置oraclegrid用户的shell限制

   通过执行上述2.4节中脚本3prelimits.sh完成。脚本的具体内容可见本文档附录。

[root@node1 shell]# pwd

/root/shell

[root@node1 shell]# ./3prelimits.sh 

Now modify the /etc/security/limits.conf,but backup it named /etc/security/limits.conf.bak before

Modifing the /etc/security/limits.conf has been succeed.

[root@node1 shell]# 

2.7 修改/etc/pam.d/login配置文件

   通过执行上述2.4节中脚本4prelogin.sh完成。脚本的具体内容可见本文档附录。

[root@node1 shell]# pwd

/root/shell

[root@node1 shell]# ./4prelogin.sh 

Now modify the /etc/pam.d/login,but with a backup named /etc/pam.d/login.bak

Modifing the /etc/pam.d/login has been succeed.

[root@node1 shell]#

2.8 修改/etc/profile文件

   通过执行上述2.4节中脚本5preprofile.sh完成。脚本的具体内容可见本文档附录。

[root@node1 shell]# pwd

/root/shell

[root@node1 shell]# ./5preprofile.sh 

Now modify the  /etc/profile,but with a backup named  /etc/profile.bak

Modifing the /etc/profile has been succeed.

[root@node1 shell]# 

2.9修改内核配置文件

   通过执行上述2.4节中脚本6presysctl.sh完成。脚本的具体内容可见本文档附录。

[root@node1 shell]# pwd

/root/shell

[root@node1 shell]# ./6presysctl.sh 

Now modify the /etc/sysctl.conf,but with a backup named /etc/sysctl.bak

Modifing the /etc/sysctl.conf has been succeed.

Now make the changes take effect…..

net.ipv4.ip_forward = 0

net.ipv4.conf.default.rp_filter = 1

net.ipv4.conf.default.accept_source_route = 0

kernel.sysrq = 0

kernel.core_uses_pid = 1

net.ipv4.tcp_syncookies = 1

kernel.msgmnb = 65536

kernel.msgmax = 65536

kernel.shmmax = 68719476736

kernel.shmall = 4294967296

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

kernel.shmmax = 536870912

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048586

net.ipv4.tcp_wmem = 262144 262144 262144

net.ipv4.tcp_rmem = 4194304 4194304 4194304

[root@node1 shell]# 

2.10 停止ntp服务,11gR2新增的检查项

[root@node1 ~]# service ntpd status

ntpd is stopped

[root@node1 ~]# chkconfig ntpd off

[root@node1 ~]# cat /etc/ntp

ntp/      ntp.conf  

[root@node1 ~]# cp /etc/ntp.conf /etc/ntp.conf.bak

[root@node1 ~]# rm -rf /etc/ntp.conf

[root@node1 ~]

2.11 节点2准备工作

    我们已经在node1完成基本准备配置工作,在node2上重复上述2.22.10节中准备工作,以完成节点2的准备工作。

    说明:2.3节配置SCAN IP已在节点2上完成,可忽略。2.4节中需要修改对应的环境变量。

2.12 配置oraclegrid 用户SSH对等性

   虽然在安装软件的过程中,oracle会自动配置SSH对等性,建议在安装软件之前手工配置。

   配置oracle用户对等性:

   node1:

[root@node1 ~]# su – oracle

node1-> env | grep ORA

ORACLE_UNQNAME=devdb

ORACLE_SID=devdb1

ORACLE_BASE=/u01/app/oracle

ORACLE_HOSTNAME=node1.localdomain

ORACLE_TERM=xterm

ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

node1-> pwd

/home/oracle

node1-> mkdir ~/.ssh

node1-> chmod 700 ~/.ssh

node1-> ls -al

total 44

drwx—— 4 oracle oinstall 4096 Apr 24 10:47 .

drwxr-xr-x 4 root   root     4096 Apr 24 09:41 ..

-rw——- 1 oracle oinstall    5 Apr 24 10:43 .bash_history

-rw-r–r– 1 oracle oinstall   33 Apr 24 09:41 .bash_logout

-rw-r–r– 1 oracle oinstall  823 Apr 24 09:41 .bash_profile

-rw-r–r– 1 oracle oinstall  124 Apr 24 09:41 .bashrc

-rw-r–r– 1 oracle oinstall  515 Apr 24 09:41 .emacs

drwxr-xr-x 4 oracle oinstall 4096 Apr 24 09:41 .mozilla

drwx—— 2 oracle oinstall 4096 Apr 24 10:47 .ssh

-rw-r–r– 1 oracle oinstall  658 Apr 24 09:41 .zshrc

node1-> ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_rsa): 

Enter passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved in /home/oracle/.ssh/id_rsa.

Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.

The key fingerprint is:

4a:bd:22:4c:cc:6a:33:ae:5a:de:7d:7c:8b:77:9e:81 oracle@node1.localdomain

node1-> ssh-keygen -t dsa 

Generating public/private dsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_dsa): 

Enter passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved in /home/oracle/.ssh/id_dsa.

Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.

The key fingerprint is:

8b:50:73:41:03:ad:1c:59:25:aa:40:1c:c9:5e:03:99 oracle@node1.localdomain

node1-> 

node2:

[root@node2 ~]# su – oracle

node2-> env|grep ORA

ORACLE_UNQNAME=devdb

ORACLE_SID=devdb2

ORACLE_BASE=/u01/app/oracle

ORACLE_HOSTNAME=node2.localdomain

ORACLE_TERM=xterm

ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

node2-> pwd

/home/oracle

node2-> ls -al

total 40

drwx—— 3 oracle oinstall 4096 Apr 24 10:45 .

drwxr-xr-x 4 root   root     4096 Apr 24 10:44 ..

-rw——- 1 oracle oinstall   10 Apr 24 10:49 .bash_history

-rw-r–r– 1 oracle oinstall   33 Apr 24 10:44 .bash_logout

-rw-r–r– 1 oracle oinstall  823 Apr 24 10:44 .bash_profile

-rw-r–r– 1 oracle oinstall  124 Apr 24 10:44 .bashrc

-rw-r–r– 1 oracle oinstall  515 Apr 24 10:44 .emacs

drwxr-xr-x 4 oracle oinstall 4096 Apr 24 10:44 .mozilla

-rw-r–r– 1 oracle oinstall  658 Apr 24 10:44 .zshrc

node2-> mkdir ~/.ssh

node2-> chmod 770 ~/.ssh/

node2-> ls -al

total 44

drwx—— 4 oracle oinstall 4096 Apr 24 10:49 .

drwxr-xr-x 4 root   root     4096 Apr 24 10:44 ..

-rw——- 1 oracle oinstall   10 Apr 24 10:49 .bash_history

-rw-r–r– 1 oracle oinstall   33 Apr 24 10:44 .bash_logout

-rw-r–r– 1 oracle oinstall  823 Apr 24 10:44 .bash_profile

-rw-r–r– 1 oracle oinstall  124 Apr 24 10:44 .bashrc

-rw-r–r– 1 oracle oinstall  515 Apr 24 10:44 .emacs

drwxr-xr-x 4 oracle oinstall 4096 Apr 24 10:44 .mozilla

drwxrwx— 2 oracle oinstall 4096 Apr 24 10:49 .ssh

-rw-r–r– 1 oracle oinstall  658 Apr 24 10:44 .zshrc

node2-> ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_rsa): 

Enter passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved in /home/oracle/.ssh/id_rsa.

Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.

The key fingerprint is:

a0:64:81:a6:12:b2:18:4e:01:c3:bd:9d:f6:bb:55:b0 oracle@node2.localdomain

node2-> ssh-keygen -t dsa

Generating public/private dsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_dsa): 

Enter passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved in /home/oracle/.ssh/id_dsa.

Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.

The key fingerprint is:

85:56:69:73:74:a3:ef:5b:88:d7:6d:ef:90:03:b6:72 oracle@node2.localdomain

node2-> 

【补充说明:在网友的细心发现下,在node2上配置SSH对等性时,权限需要改成700而不是770!

大大,发现个问题
node2的:
chmod 770 ~/.ssh 需改成
chmod 700 ~/.ssh 么。
770的话node2 一直要口令啊。】

 

返回节点1

node1-> id

uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1201(asmdba),1300(dba),1301(oper)

node1-> pwd

/home/oracle

node1-> cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys

node1-> cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys 

node1-> ssh node2 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys 

The authenticity of host ‘node2 (172.16.0.192)’ can’t be established.

RSA key fingerprint is a7:6b:2c:2d:fb:c3:ff:33:af:92:cd:7b:99:3b:cf:3a.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘node2,172.16.0.192’ (RSA) to the list of known hosts.

oracle@node2’s password: 

node1-> ssh node2 cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys 

oracle@node2’s password: 

node1-> scp ~/.ssh/authorized_keys node2:~/.ssh/authorized_keys 

oracle@node2’s password: 

authorized_keys       

100% 2040     2.0KB/s   00:00  

node1-> 

验证oracle SSH对等性:

node1node2两个节点上分别执行下述命令,第一次执行时需要口令验证:

node1-> id

uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1201(asmdba),1300(dba),1301(oper)

node1-> ssh node1 date

The authenticity of host ‘node1 (172.16.0.191)’ can’t be established.

RSA key fingerprint is 16:c2:67:cd:73:dd:b7:8b:f4:07:ef:e0:fb:36:34:3e.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘node1,172.16.0.191’ (RSA) to the list of known hosts.

Tue Apr 24 11:28:15 CST 2012

node1-> ssh node2 date

Tue Apr 24 11:28:18 CST 2012

node1-> ssh node1-priv date

The authenticity of host ‘node1-priv (192.168.94.11)’ can’t be established.

RSA key fingerprint is 16:c2:67:cd:73:dd:b7:8b:f4:07:ef:e0:fb:36:34:3e.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘node1-priv,192.168.94.11’ (RSA) to the list of known hosts.

Tue Apr 24 11:28:25 CST 2012

node1-> ssh node2-priv date

The authenticity of host ‘node2-priv (192.168.94.12)’ can’t be established.

RSA key fingerprint is a7:6b:2c:2d:fb:c3:ff:33:af:92:cd:7b:99:3b:cf:3a.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘node2-priv,192.168.94.12’ (RSA) to the list of known hosts.

Tue Apr 24 11:28:30 CST 2012

node1-> ssh node1.localdomain date

The authenticity of host ‘node1.localdomain (172.16.0.191)’ can’t be established.

RSA key fingerprint is 16:c2:67:cd:73:dd:b7:8b:f4:07:ef:e0:fb:36:34:3e.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘node1.localdomain’ (RSA) to the list of known hosts.

Tue Apr 24 11:28:39 CST 2012

node1-> ssh node2.localdomain date

The authenticity of host ‘node2.localdomain (172.16.0.192)’ can’t be established.

RSA key fingerprint is a7:6b:2c:2d:fb:c3:ff:33:af:92:cd:7b:99:3b:cf:3a.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘node2.localdomain’ (RSA) to the list of known hosts.

Tue Apr 24 11:28:46 CST 2012

node1-> ssh node2-priv.localdomain date

The authenticity of host ‘node2-priv.localdomain (192.168.94.12)’ can’t be established.

RSA key fingerprint is a7:6b:2c:2d:fb:c3:ff:33:af:92:cd:7b:99:3b:cf:3a.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘node2-priv.localdomain’ (RSA) to the list of known hosts.

Tue Apr 24 11:28:52 CST 2012

node1-> ssh node1-priv.localdomain date

The authenticity of host ‘node1-priv.localdomain (192.168.94.11)’ can’t be established.

RSA key fingerprint is 16:c2:67:cd:73:dd:b7:8b:f4:07:ef:e0:fb:36:34:3e.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘node1-priv.localdomain’ (RSA) to the list of known hosts.

Tue Apr 24 11:28:59 CST 2012

第二次执行时不再提示输入口令,并且可以成功执行命令,则表示oracle用户SSH对等性配置成功

node1

node1-> ssh node1 date

Tue Apr 24 11:29:02 CST 2012

node1-> ssh node2 date

Tue Apr 24 11:29:07 CST 2012

node1-> ssh node1-priv date

Tue Apr 24 11:29:13 CST 2012

node1-> ssh node2-priv date

Tue Apr 24 11:29:18 CST 2012

node1-> ssh node2-priv.localdomain date

Tue Apr 24 11:29:27 CST 2012

node1-> ssh node1-priv.localdomain date

Tue Apr 24 11:29:33 CST 2012

node1-> 

node2

node2-> id

uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1201(asmdba),1300(dba),1301(oper)

node2-> pwd

/home/oracle

node2-> ssh node1 date

Tue Apr 24 11:32:06 CST 2012

node2-> ssh node2 date

Tue Apr 24 11:32:09 CST 2012

node2-> ssh node1-priv date

Tue Apr 24 11:32:14 CST 2012

node2-> ssh node2-priv date

Tue Apr 24 11:32:17 CST 2012

node2-> ssh node1.localdomain date

Tue Apr 24 11:32:26 CST 2012

node2-> ssh node2.localdomain date

Tue Apr 24 11:32:29 CST 2012

node2-> ssh node1-priv.localdomain date

Tue Apr 24 11:32:39 CST 2012

node2-> ssh node2-priv.localdomain date

Tue Apr 24 11:32:43 CST 2012

node2->

至此,Oracle用户SSH对等性配置完成!重复上述步骤,以grid用户配置其对等性。

2.13 配置共享磁盘

在任意节点上先创建共享磁盘,然后在另外的节点上选择添加已有磁盘。这里选择先在node2节点机器上创建共享磁盘,然后在node1上添加。共创建4块硬盘,其中2500M的硬盘,将来用于配置GRIDDG磁盘组,专门存放OCRVoting Disk13G的磁盘,用于配置DATA磁盘组,存放数据库;13G的磁盘,用于配置FLASH磁盘组,用于闪回区;

node2上创建共享硬盘详细步骤:

① 先关闭节点2 11gnode2,然后选择11gnode2,右键选择编辑设置,Edit settings

② 在编辑虚拟机对话框下,选择添加,Add,选择硬盘,Next

③ 选择创建新硬盘,Next

④ 磁盘大小选择500M,选中支持集群属性,指定磁盘的存放位置,Next

⑤ 驱动器设备选择SCSI 1:0,模式选择独立,Next

⑥ 弹出对话框中,Finish

 虚拟机属性中,选择刚才新添加的SCSI controller 1驱动器,配置其为Physical模式,用于支持共享,因为这块新添加的硬盘将来要被node1node2两个节点访问:

⑧ 重复执行上述③⑥步骤,添加第二块500M硬盘,将其驱动器设备选择SCSI 1:1

⑨ 如法炮制,添加另外两块3G硬盘,驱动器设备分别选择SCSI 2:0SCSI 2:1,同样需要配置新添加的SCSI controller 2驱动器模式为Physical模式,用于支持共享。最后,添加完4块共享硬盘的node2配置信息如下:

node1上添加已有共享硬盘详细步骤:

① 先关闭节点1 11gnode1,然后选择11gnode1,右键选择编辑设置,Edit settings,操作界面同node2上创建共享硬盘步骤①:

② 在编辑虚拟机对话框下,选择添加,Add,选择硬盘,Next,操作界面同node2上创建共享硬盘步骤②:

③ 选择已有虚拟硬盘,Next

④ 选择指定的存储设备,注意要选择在node2节点中创建的第1块硬盘:

⑤ 驱动器设备选择SCSI 1:0,模式选择独立,Next,操作界面同node2上创建共享硬盘步骤⑤:

⑥ 同样选择新添加的SCSI controller 1驱动器,配置其为Physical模式,用于支持共享,操作界面同node2上创建共享硬盘步骤7

 如法炮制,添加剩余的3块硬盘,注意,驱动器编号要依次选择SCSI 1:1SCSI 2:0SCSI 2:1。同时要将新添加的SCSI controller 2驱动器模式为Physical模式,用于支持共享。最后,添加完4块共享硬盘的node1配置信息如下:

至此,完成在两个节点上对共享硬盘的添加配置。

Oracle OCP考试1z0-007系列4:学会使用分组函数

继上篇文章,Oracle OCP考试1z0-007系列3:学会使用单行函数后,本篇是系列4,学会使用分组函数。 本篇是1z0-007课程的第四章,主要内容:

     1  了解在SQL语句中可以使用的分组函数;

     2  学会在SELECT语句中使用GROUP BY从句;

     3  学会使用HAVING从句来过滤数据。

本篇内容相对比较难,具体文档和讲义如下:

解决一则row cache lock引起的性能故障

     收到紧急邮件:说某客户生产系统在今天早上9:30左右,生产环境整个系统操作响应很慢,查询一票单子可能要耗时半分钟,有时候登录界面也卡住很久才响应

       这是一套10.2.0.5.0的双节点RAC数据库,平时系统运行较为正常,现在突然变慢。好了,对于我这个优化菜鸟来讲,还是从AWR报告入手。下面给出分析步骤和解决办法:

1   从报告头中看到,在数据库出现性能问题的一个小时内,DB Time达到240分钟,(DB Time)/Elapsed=3.93,说明数据库应该是存在问题的。

  Snap Id Snap Time Sessions Cursors/Session
Begin Snap: 10638 05-6月 -12 09:00:00 54 5.8
End Snap: 10639 05-6月 -12 10:01:03 102 5.8
Elapsed:   61.04 (mins)    
DB Time:   240.11 (mins)    

2   从报告的Load Profile节,看到用户的每秒调用高达680次,说明肯定存在问题了。

Load Profile

  Per Second Per Transaction
Redo size: 12,939.46 6,115.60
Logical reads: 67,323.18 31,819.06
Block changes: 53.22 25.15
Physical reads: 1.02 0.48
Physical writes: 4.72 2.23
User calls: 679.70 321.25
Parses: 90.49 42.77
Hard parses: 0.35 0.16
Sorts: 1.94 0.92
Logons: 0.08 0.04
Executes: 316.75 149.71
Transactions: 2.12  

3   继续分析报告,从Top 5中看到排在第一的等待事件是row cache lock,并且该等待事件的平均等待达到2128ms。 

ROW CACHE LOCK等待事件是一个共享池相关的等待事件,是由于对于字典缓冲的访问造成的。通常直接的解决办可以通过调大共享池来解决,但是,并非在所有场景下都凑效。

 

Top 5 Timed Events

Event Waits Time(s) Avg Wait(ms) % Total Call Time Wait Class
row cache lock 2,736 5,822 2,128 40.4 Concurrency
CPU time   4,305   29.9  
gc cr block busy 2,293 2,633 1,148 18.3 Cluster
gc buffer busy 1,569 1,096 698 7.6 Cluster
enq: TX – row lock contention 2,029 998 492 6.9 Application

 

4    继续分析,发现基于时间的统计信息中,加载序列sequence的耗时排在了第二位。

Time Model Statistics

  • Total time in database user-calls (DB Time): 14406.5s
  • Statistics including the word "background" measure background process time, and so do not contribute to the DB time statistic
  • Ordered by % or DB time desc, Statistic name

 

Statistic Name Time (s) % of DB Time
sql execute elapsed time 14,188.01 98.48
sequence load elapsed time 6,900.83 47.90
DB CPU 4,304.59 29.88
PL/SQL execution elapsed time 20.64 0.14
parse time elapsed 10.25 0.07
hard parse elapsed time 6.00 0.04
PL/SQL compilation elapsed time 1.17 0.01
hard parse (sharing criteria) elapsed time 1.07 0.01
repeated bind elapsed time 0.80 0.01
hard parse (bind mismatch) elapsed time 0.64 0.00
connection management call elapsed time 0.31 0.00
failed parse elapsed time 0.00 0.00
DB time 14,406.50  
background elapsed time 2,115.75  
background cpu time 20.52  

5     看到最耗时的竟然是一条再简单不过的SQL语句,SELECT SEQ_NEWID.NEXTVAL FROM DUAL,取序列的值,竟然会如此的耗时?

SQL ordered by Elapsed Time

  • Resources reported for PL/SQL code includes the resources used by all SQL statements called by the code.
  • % Total DB Time is the Elapsed Time of the SQL statement divided into the Total Database Time multiplied by 100
  • Total DB Time (s): 14,406
  • Captured SQL account for 223.8% of Total

 

Elapsed Time (s) CPU Time (s) Executions Elap per Exec (s) % Total DB Time SQL Id SQL Module SQL Text
6,910 0 281 24.59 47.96 1gd7ancd2px8m FC.EdiService.Import.exe SELECT SEQ_NEWID.NEXTVAL FROM …

6    再看字典缓冲区的统计信息:取序列值一共287次,就失败了43.9%,看来的确是取序列值的地方出现问题,也就解释了为什么上一步骤中的分许出的那条SQL会如此耗时,因为差不多有一半的情况下都没有取到序列的值。

Dictionary Cache Stats

  • "Pct Misses" should be very low (< 2% in most cases)
  • "Final Usage" is the number of cache entries being used

 

Cache Get Requests Pct Miss Scan Reqs Pct Miss Mod Reqs Final Usage
dc_awr_control 65 1.54 0   1 1
dc_database_links 304 0.00 0   0 1
dc_global_oids 155 0.00 0   0 24
dc_histogram_data 74,704 0.25 0   0 5,612
dc_histogram_defs 71,400 0.26 0   0 4,945
dc_object_ids 29,398 0.01 0   0 1,136
dc_objects 3,912 0.23 0   0 860
dc_profiles 150 0.00 0   0 1
dc_rollback_segments 17,789 0.10 0   0 56
dc_segments 8,927 0.06 0   4 896
dc_sequences 287 43.90 0   279 3
dc_tablespace_quotas 2 50.00 0   0 2
dc_tablespaces 8,954 0.00 0   0 25
dc_usernames 1,082 0.00 0   0 8
dc_users 13,991 0.00 0   0 31
outstanding_alerts 326 77.91 0   23 54

7   到此,解决问题的基本思路已经出来了,通过将序列缓存到内存中,基本可以解决问题。通过查看生产系统上的该序列的信息,发现创建序列的语句如下:

-- Create sequence 
create sequence SEQ_NEWID
minvalue 1000
maxvalue 9999
start with 1000
increment by 1
nocache;

8   调整序列,使之cache到内存中,alter sequence SEQ_NEWID cache 3000;

9   附带,刚在生产系统上把序列cache到内存,另一同事就把RAC数据库给重启了,据他判断说是存储系统出了问题。可是,怎么会是存储出了问题呢?如果,能重现这次的性能问题该多好啊,只是没有如果!

      在处理这个问题的时候,参照了老白的文章:白鳝说WAIT EVENT之ROW CACHE LOCK

Oracle OCP考试1z0-007系列3:学会使用单行函数

        继上篇文章,Oracle OCP考试1z0-007系列2:学会使用WHERE和ORDER BY从句后,本篇是系列3,学会使用单行函数。 本篇是1z0-007课程的第三章,主要内容:

     1 了解在SQL语句中可以使用的函数分类;

     2  学会在SELECT语句中使用日期、字符、数值函数;

     3 了解Oracle中的转换函数。

本篇内容比较重要,具体文档和讲义如下: