單機靜默安裝GI軟件並建立ASM實例和ASM磁盤組

環境:RHEL 6.4 + Oracle 11.2.0.4
需求:單機靜默安裝GI軟件並建立ASM實例和ASM磁盤組,爲後續遷移數據庫文件到ASM作準備css

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存儲 安裝部署 快速參考》相關內容。html

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.rspgit

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.

按提示執行腳本session

-- 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找不到》解決。oracle

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個故障組。app

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;

執行過程輸出信息:ide

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
相關文章
相關標籤/搜索