代码改变世界

单机静默安装GI软件并创建ASM实例和ASM磁盘组

2015-12-02 14:41  AlfredZhao  阅读(...)  评论(... 编辑 收藏

环境:RHEL 6.4 + Oracle 11.2.0.4
需求:单机静默安装GI软件并创建ASM实例和ASM磁盘组,为后续迁移数据库文件到ASM做准备

1. 安装配置GI软件

1.1 创建grid用户和相关组,创建目录,确认ASM磁盘权限,配置环境变量

-- 创建grid用户和相关组
groupadd asmadmin
groupadd asmdba
groupadd asmoper
useradd -g oinstall -G dba,asmadmin,asmdba,asmoper grid
usermod -g oinstall -G dba,asmadmin,asmdba oracle
passwd grid
-- 创建目录
mkdir -p /u02/app/11.2.0/grid
mkdir -p /u02/app/grid
-- 赋予目录权限
chmod 775 /u02/app
chown -R grid:oinstall /u02/app/11.2.0
chown -R grid:oinstall /u02/app/grid
-- ASM磁盘
$ ls -lh /dev/mapper/ora_vg-lv_asm*
lrwxrwxrwx. 1 root root 7 Dec  1 13:13 /dev/mapper/ora_vg-lv_asm1 -> ../dm-2
lrwxrwxrwx. 1 root root 7 Dec  1 13:14 /dev/mapper/ora_vg-lv_asm2 -> ../dm-3
lrwxrwxrwx. 1 root root 7 Dec  1 13:14 /dev/mapper/ora_vg-lv_asm3 -> ../dm-4
lrwxrwxrwx. 1 root root 7 Dec  1 13:14 /dev/mapper/ora_vg-lv_asm4 -> ../dm-5
lrwxrwxrwx. 1 root root 7 Dec  1 13:14 /dev/mapper/ora_vg-lv_asm5 -> ../dm-6
lrwxrwxrwx. 1 root root 7 Dec  1 13:15 /dev/mapper/ora_vg-lv_asm6 -> ../dm-7
-- 赋权并将赋权操作添加到/etc/rc.local文件中
chown grid:asmadmin /dev/mapper/ora_vg-lv_asm*
-- grid环境变量
export ORACLE_BASE=/u02/app/grid
export ORACLE_HOME=/u02/app/11.2.0/grid
export ORACLE_SID=+ASM
export PATH=$ORACLE_HOME/bin:$PATH

注意:生产环境一般用udev绑定新盘,我这里由于是Citrix虚拟化实验环境,用每个lv模拟了一个磁盘。划lv盘过程可参考《Linux平台oracle 11g单实例 + ASM存储 安装部署 快速参考》相关内容。

1.2 解压安装包

# chmod 775 /u02/soft/
$ unzip /u02/media/p13390677_112040_Linux-x86-64_3of7.zip -d /u02/soft/

1.3 静默安装GI

$ cd /u02/soft/grid/response
$ cp grid_install.rsp grid_install.rsp.bak
$ sed -i 's/^#.*$//g' *.rsp
$ sed -i '/^$/d' *.rsp

$ more grid_install.rsp

oracle.install.responseFileVersion=/oracle/install/rspfmt_crsinstall_response_schema_v11_2_0
ORACLE_HOSTNAME=JY-DB01
INVENTORY_LOCATION=/u02/app/oraInventory
SELECTED_LANGUAGES=en
oracle.install.option=HA_CONFIG
ORACLE_BASE=/u02/app/grid
ORACLE_HOME=/u02/app/11.2.0/grid
oracle.install.asm.OSDBA=asmdba
oracle.install.asm.OSOPER=asmoper
oracle.install.asm.OSASM=asmadmin
oracle.install.crs.config.gpnp.scanName=
oracle.install.crs.config.gpnp.scanPort=
oracle.install.crs.config.clusterName=
oracle.install.crs.config.gpnp.configureGNS=false
oracle.install.crs.config.gpnp.gnsSubDomain=
oracle.install.crs.config.gpnp.gnsVIPAddress=
oracle.install.crs.config.autoConfigureClusterNodeVIP=
oracle.install.crs.config.clusterNodes=
oracle.install.crs.config.networkInterfaceList=
oracle.install.crs.config.storageOption=ASM_STORAGE
oracle.install.crs.config.sharedFileSystemStorage.diskDriveMapping=
oracle.install.crs.config.sharedFileSystemStorage.votingDiskLocations=
oracle.install.crs.config.sharedFileSystemStorage.votingDiskRedundancy=NORMAL
oracle.install.crs.config.sharedFileSystemStorage.ocrLocations=
oracle.install.crs.config.sharedFileSystemStorage.ocrRedundancy=NORMAL
oracle.install.crs.config.useIPMI=false
oracle.install.crs.config.ipmi.bmcUsername=
oracle.install.crs.config.ipmi.bmcPassword=
oracle.install.asm.SYSASMPassword=oracle
oracle.install.asm.diskGroup.name=data1
oracle.install.asm.diskGroup.redundancy=NORMAL
oracle.install.asm.diskGroup.AUSize=1
oracle.install.asm.diskGroup.disks=/dev/mapper/ora_vg-lv_asm1,/dev/mapper/ora_vg-lv_asm2
oracle.install.asm.diskGroup.diskDiscoveryString=/dev/mapper/ora*
oracle.install.asm.monitorPassword=oracle
oracle.install.crs.upgrade.clusterNodes=
oracle.install.asm.upgradeASM=false
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=

1.3.1 静默安装

./runInstaller -responseFile /u02/soft/grid/response/grid_install.rsp -silent -ignorePrereq -showProgress

过程如下:

Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 20827 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 4015 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-12-01_03-47-21PM. Please wait ...[grid@JY-DB01 grid]$ [WARNING] [INS-30011] The SYS password entered does not conform to the Oracle recommended standards.
   CAUSE: Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
   ACTION: Provide a password that conforms to the Oracle recommended standards.
[WARNING] [INS-30011] The ASMSNMP password entered does not conform to the Oracle recommended standards.
   CAUSE: Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
   ACTION: Provide a password that conforms to the Oracle recommended standards.
[WARNING] [INS-32018] The selected Oracle home is outside of Oracle base.
   CAUSE: The Oracle home selected was outside of Oracle base.
   ACTION: Oracle recommends installing Oracle software within the Oracle base directory. Adjust the Oracle home or Oracle base accordingly.
You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2015-12-01_03-47-21PM.log

Prepare in progress.
..................................................   9% Done.

Prepare successful.

Copy files in progress.
..................................................   14% Done.
..................................................   21% Done.
..................................................   26% Done.
..................................................   31% Done.
..................................................   36% Done.
..................................................   42% Done.
..................................................   50% Done.
..................................................   56% Done.
..................................................   61% Done.
..................................................   66% Done.
..................................................   71% Done.
........................................
Copy files successful.

Link binaries in progress.
..........
Link binaries successful.
..........
Setup files in progress.
..................................................   76% Done.
..................................................   89% Done.

Setup files successful.
The installation of Oracle Grid Infrastructure 11g was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2015-12-01_03-47-21PM.log' for more details.
..................................................   94% Done.

Execute Root Scripts in progress.

As a root user, execute the following script(s):
        1. /u02/app/11.2.0/grid/root.sh


..................................................   100% Done.

Execute Root Scripts successful.
As install user, execute the following script to complete the configuration.
        1. /u02/app/11.2.0/grid/cfgtoollogs/configToolAllCommands RESPONSE_FILE=<response_file>

        Note:
        1. This script must be run on the same host from where installer was run. 
        2. This script needs a small password properties file for configuration assistants that require passwords (refer to install guide documentation).


Successfully Setup Software.

按提示执行脚本

-- root用户执行root.sh
# /u02/app/11.2.0/grid/root.sh
Check /u02/app/11.2.0/grid/install/root_JY-DB01_2015-12-01_15-54-30.log for the output of root script
-- 启动资源
$ crsctl start resource -all
-- 检查has,css,evm都是online
crsctl check has
crsctl check css
crsctl check evm
-- 创建密码文件
$ cd $ORACLE_HOME/dbs
$ orapwd file=orapw+ASM password=oracle entries=10 ignorecase=y
-- grid用户执行配置 
$ /u02/app/11.2.0/grid/cfgtoollogs/configToolAllCommands RESPONSE_FILE=/u02/soft/grid/response/grid_install.rsp

注意:如果执行root.sh的脚本日志中遇到libcap.so.1找不到的错误可参考《Oracle 11g安装GI后,运行roothas.pl脚本报错libcap.so.1找不到》解决。

2. 创建ASM实例

-- ASM实例参数文件
INSTANCE_TYPE=ASM
DB_UNIQUE_NAME=+ASM
ASM_POWER_LIMIT=1
ASM_DISKSTRING=/dev/mapper/ora*
ASM_DISKGROUPS=data1
LARGE_POOL_SIZE=16M
-- 启动到nomount
SQL> startup nomount pfile='$ORACLE_HOME/dbs/init+ASM.ora'
ASM instance started

Total System Global Area 1135747072 bytes
Fixed Size                  2260728 bytes
Variable Size            1108320520 bytes
ASM Cache                  25165824 bytes

3. 创建ASM磁盘组DATA1

3.1 查询可用ASM磁盘

--查询v$asm_disk
set linesize 200
col path for a50
select GROUP_NUMBER, DISK_NUMBER, MOUNT_STATUS, NAME, FAILGROUP, CREATE_DATE, PATH from v$asm_disk;
--结果如下:
GROUP_NUMBER DISK_NUMBER MOUNT_S NAME                           FAILGROUP                      CREATE_DA PATH
------------ ----------- ------- ------------------------------ ------------------------------ --------- --------------------------------------------------
           0           0 CLOSED                                                                          /dev/mapper/ora_vg-lv_asm6
           0           1 CLOSED                                                                          /dev/mapper/ora_vg-lv_asm5
           0           5 CLOSED                                                                          /dev/mapper/ora_vg-lv_asm1
           0           3 CLOSED                                                                          /dev/mapper/ora_vg-lv_asm3
           0           4 CLOSED                                                                          /dev/mapper/ora_vg-lv_asm2
           0           2 CLOSED                                                                          /dev/mapper/ora_vg-lv_asm4

6 rows selected.
-- 查询v$asm_diskgroup
select GROUP_NUMBER, NAME, TYPE, TOTAL_MB, FREE_MB, USABLE_FILE_MB from v$asm_diskgroup;

3.2 创建磁盘组

创建ASM磁盘组data1,普通冗余,指定2个故障组。

create diskgroup data1 normal redundancy
failgroup fg1 disk '/dev/mapper/ora_vg-lv_asm1' name d1a
failgroup fg2 disk '/dev/mapper/ora_vg-lv_asm2' name d1b;

执行过程输出信息:

SQL> create diskgroup data1 normal redundancy
  2  failgroup fg1 disk '/dev/mapper/ora_vg-lv_asm1' name d1a
  3  failgroup fg2 disk '/dev/mapper/ora_vg-lv_asm2' name d1b;

Diskgroup created.

SQL> select GROUP_NUMBER, DISK_NUMBER, MOUNT_STATUS, NAME, FAILGROUP, CREATE_DATE, PATH from v$asm_disk;

GROUP_NUMBER DISK_NUMBER MOUNT_S NAME                           FAILGROUP                      CREATE_DA PATH
------------ ----------- ------- ------------------------------ ------------------------------ --------- --------------------------------------------------
           0           0 CLOSED                                                                          /dev/mapper/ora_vg-lv_asm6
           0           1 CLOSED                                                                          /dev/mapper/ora_vg-lv_asm5
           0           2 CLOSED                                                                          /dev/mapper/ora_vg-lv_asm4
           0           3 CLOSED                                                                          /dev/mapper/ora_vg-lv_asm3
           1           1 CACHED  D1B                            FG2                            02-DEC-15 /dev/mapper/ora_vg-lv_asm2
           1           0 CACHED  D1A                            FG1                            02-DEC-15 /dev/mapper/ora_vg-lv_asm1

6 rows selected.
SQL>  select GROUP_NUMBER, NAME, TYPE, TOTAL_MB, FREE_MB, USABLE_FILE_MB from v$asm_diskgroup;

GROUP_NUMBER NAME                           TYPE     TOTAL_MB    FREE_MB USABLE_FILE_MB
------------ ------------------------------ ------ ---------- ---------- --------------
           1 DATA1                          NORMAL      10240      10138           5069

3.3 注册磁盘组到crsctl中

3.3.1 添加asm服务

[grid@JY-DB01 ~]$ srvctl add asm
[grid@JY-DB01 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
               ONLINE  ONLINE       jy-db01                                      
ora.asm
               OFFLINE OFFLINE      jy-db01                                      
ora.ons
               OFFLINE OFFLINE      jy-db01                                      
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       jy-db01                                      
ora.diskmon
      1        OFFLINE OFFLINE                                                   
ora.evmd
      1        ONLINE  ONLINE       jy-db01  

3.3.2 创建spfile,重启ASM实例

SQL> create spfile from pfile;

File created.

SQL> shutdown immediate;
ASM diskgroups volume disabled
ASM diskgroups dismounted
ASM instance shutdown
SQL> startup
ASM instance started

Total System Global Area 1135747072 bytes
Fixed Size                  2260728 bytes
Variable Size            1108320520 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted
ASM diskgroups volume enabled
SQL> show parameter pfile    

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u02/app/11.2.0/grid/dbs/spfil
                                                 e+ASM.ora

3.3.3 查看资源,DATA1磁盘组已经自动注册

$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA1.dg
               ONLINE  ONLINE       jy-db01                                      
ora.LISTENER.lsnr
               ONLINE  ONLINE       jy-db01                                      
ora.asm
               ONLINE  ONLINE       jy-db01                  Started             
ora.ons
               OFFLINE OFFLINE      jy-db01                                      
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       jy-db01                                      
ora.diskmon
      1        OFFLINE OFFLINE                                                   
ora.evmd
      1        ONLINE  ONLINE       jy-db01