1. 程式人生 > 其它 >ORACLE+RAC原理與實踐系列:1 RAC安裝

ORACLE+RAC原理與實踐系列:1 RAC安裝

技術標籤:DataBases資料庫

需求與環境

安裝部署ORACLE 19c RAC環境。55.34.4.153、55.34.4.154;兩臺vmware主機分別配置兩個網絡卡申請5個同網段的IP(公網IP),兩臺vmware主機配置三塊共享盤(OCRDG、DATADG、FRADG);

前期準備

建立grid使用者(雙節點)

useradd grid

groupadd oinstall

groupadd dba

groupadd oper

groupadd asmadmin

groupadd asmoper

groupadd asmdba

groupadd racdba

usermod -g oinstall -G dba,oper,asmadmin,asmoper,asmdba,racdba grid

uid=1779(grid) gid=1778(oinstall) groups=1778(oinstall),1779(dba),1780(oper),504(asmadmin),505(asmoper),506(asmdba),1784(racdba)

雙節點配置grid/root兩個使用者的互信,包括到自身節點的互信和到對方節點的互信

建立安裝目錄(雙節點)

mkdir gridhome
mkdir gridbase
mkdir gridInventory
chown grid:oinstall grid*

共享盤持久繫結

#!/bin/bash

for i in c d e f
do
echo $i
echo "KERNEL==\"sd?\",SUBSYSTEM==\"block\", PROGRAM==\"/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/\$name\",RESULT==\"`/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`\", SYMLINK+=\"asm-disk$i\",OWNER=\"grid\", GROUP=\"asmadmin\",MODE=\"0660\"" >>/etc/udev/rules.d/99-oracle-asmdevices.rules

done

/sbin/udevadm trigger --type=devices --action=change
ls -l /dev/asm*

exit 0

共享盤格式化

dd if=/dev/zero of=/dev/sdc bs=512K count=1

dd if=/dev/zero of=/dev/sdd bs=512K count=1

dd if=/dev/zero of=/dev/sde bs=512K count=1

網路配置

#########################################RAC begin

#pubilc ip

55.34.4.153 ora19node1

55.34.4.154 ora19node2

#private ip

192.168.124.5 ora19node1-priv

192.168.124.6 ora19node2-priv

#vitrual ip

55.34.4.157 ora19node1-vip

55.34.4.158 ora19node2-vip

#scan ip

55.34.4.159 ora19nodescan

##############################RAC END################################

/etc/hosts配置(雙節點)

包括public IP 、公網 VIP、scan IP 和 私網 IP;

ifconfig ens224 192.168.124.5 up

ifconfig ens224 192.168.124.6 up

ip address delete 192.168.124.5 dev ens224

雙節點的私網網絡卡分別上線

正式安裝(GI)

  • 解grid home
  • 許可權修改
chown -R grid:oinstall /data/gridhome/
  • 用grid使用者校驗

./runcluvfy.sh stage -post hwos -n ora19node1,ora19node2 -verbose

檢查硬體和OS

./runcluvfy.sh stage -pre crsinst -n ora19node1,ora19node2 -fixup -verbose

檢查crs安裝

說明:若失敗,會有自動修復指令碼出現,用root使用者在兩個節點下執行即可(請參考runclufy.sh的執行結果)。本人vmware 主機就有幾個依賴包沒安裝,如表格。

/tmp/CVU_19.0.0.0.0_grid/runfixup.sh

libaio-devel-0.3.109

yum install libaio-devel

nfs-utils-1.2.3-15

compat-libstdc++-33-3.2.3

  • 修改shm大小(修改/etc/fstab)

#for rac

tmpfs /dev/shm tmpfs defaults,size=8G 0 0

mount -o remount /dev/shm

注意: 上面幾個步驟都是本人通過runcluvfy.sh 指令碼檢查出來的,讀者在實踐過程中,用此指令碼多執行幾次,逐一解決問題即可。

建立安裝響應檔案

vim grid_install.rsp

此相應檔案在grid_home 有模板,讀者請仔細研讀模板(如GI安裝型別、各種使用者配置等),再填寫各個引數。

[[email protected] ~]<20200902 08:37:39>$ cat grid19_install_new.rsp

oracle.install.responseFileVersion=/oracle/install/rspfmt_crsinstall_response_schema_v19.0.0

####A

INVENTORY_LOCATION=/data/gridInventory

oracle.install.option=CRS_CONFIG

ORACLE_BASE=/data/grid19base

####B

oracle.install.asm.OSDBA=asmdba

oracle.install.asm.OSOPER=asmoper

oracle.install.asm.OSASM=asmadmin

####C

oracle.install.crs.config.scanType=LOCAL_SCAN

oracle.install.crs.config.SCANClientDataFile=

oracle.install.crs.config.gpnp.scanName=sgpbnkkfscan

oracle.install.crs.config.gpnp.scanPort=1530

####D

oracle.install.crs.config.ClusterConfiguration=STANDALONE

oracle.install.crs.config.configureAsExtendedCluster=false

oracle.install.crs.config.memberClusterManifestFile=

oracle.install.crs.config.clusterName=sgpbnkkfclus

oracle.install.crs.config.gpnp.configureGNS=false

oracle.install.crs.config.autoConfigureClusterNodeVIP=false

oracle.install.crs.config.gpnp.gnsOption=

oracle.install.crs.config.gpnp.gnsClientDataFile=

oracle.install.crs.config.gpnp.gnsSubDomain=

oracle.install.crs.config.gpnp.gnsVIPAddress=

oracle.install.crs.config.sites=

oracle.install.crs.config.clusterNodes=sgpbnk01kf:sgpbnk01kf-vip,sgpbnk02kf:sgpbnk02kf-vip

oracle.install.crs.config.networkInterfaceList=eth0:55.14.64.0:1,ens256:192.168.124.0:5

oracle.install.crs.configureGIMR=

oracle.install.asm.configureGIMRDataDG=false

####E

oracle.install.crs.config.storageOption=CLIENT_ASM_STORAGE

oracle.install.crs.config.sharedFileSystemStorage.votingDiskLocations=/dev/asm-diskf

oracle.install.crs.config.sharedFileSystemStorage.ocrLocations=/dev/asm-diskf

####F

oracle.install.crs.config.useIPMI=false

oracle.install.crs.config.ipmi.bmcUsername=

oracle.install.crs.config.ipmi.bmcPassword=

####G

oracle.install.asm.SYSASMPassword=Password12345A

oracle.install.asm.diskGroup.name=OCRDG

oracle.install.asm.diskGroup.redundancy=EXTERNAL

oracle.install.asm.diskGroup.AUSize=4

oracle.install.asm.diskGroup.FailureGroups=

oracle.install.asm.diskGroup.disksWithFailureGroupNames=

oracle.install.asm.diskGroup.disks=/dev/asm-diskf

oracle.install.asm.diskGroup.quorumFailureGroupNames=

oracle.install.asm.diskGroup.diskDiscoveryString=/dev/asm-disk*

oracle.install.asm.monitorPassword=Password12345A

oracle.install.asm.gimrDG.name=OCRDG

oracle.install.asm.gimrDG.redundancy=

oracle.install.asm.gimrDG.AUSize=4

oracle.install.asm.gimrDG.FailureGroups=

oracle.install.asm.gimrDG.disksWithFailureGroupNames=

oracle.install.asm.gimrDG.disks=/dev/asm-diskf

oracle.install.asm.gimrDG.quorumFailureGroupNames=

oracle.install.asm.configureAFD=

oracle.install.crs.configureRHPS=

##END

./gridSetup.sh -silent -ignorePrereq -responseFile /home/grid/grid_install.rsp

靜默安裝

[[email protected] gridhome]<20200902 08:45:30>$ ./gridSetup.sh -silent -ignorePrereq -responseFile /home/grid/grid_install.rsp

Launching Oracle Grid Infrastructure Setup Wizard...

[WARNING] [INS-13013] Target environment does not meet some mandatory requirements.

CAUSE: Some of the mandatory prerequisites are not met. See logs for details. /tmp/GridSetupActions2020-09-02_08-45-59AM/gridSetupActions2020-09-02_08-45-59AM.log

ACTION: Identify the list of failed prerequisite checks from the log: /tmp/GridSetupActions2020-09-02_08-45-59AM/gridSetupActions2020-09-02_08-45-59AM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.

The response file for this session can be found at:

/u01/gridhome/install/response/grid_2020-09-02_08-45-59AM.rsp

You can find the log of this install session at:

/tmp/GridSetupActions2020-09-02_08-45-59AM/gridSetupActions2020-09-02_08-45-59AM.log

As a root user, execute the following script(s):

1. /u01/gridInventory/orainstRoot.sh

2. /u01/gridhome/root.sh

Execute /u01/gridInventory/orainstRoot.sh on the following nodes:

[sgpbnk01kf, sgpbnk02kf]

Execute /u01/gridhome/root.sh on the following nodes:

[sgpbnk01kf, sgpbnk02kf]

Run the script on the local node first. After successful completion, you can start the script in parallel on all other nodes.

Successfully Setup Software with warning(s).

As install user, execute the following command to complete the configuration.

/u01/gridhome/gridSetup.sh -executeConfigTools -responseFile /home/grid/grid19_install_new.rsp [-silent]

一次性成功安裝。

雙節點依次執行root指令碼,注意要依次執行:現在一個節點執行,並觀察日誌,確保成功再在第二個節點執行

sh /data/gridInventory/orainstRoot.sh
sh /data/gridhome/root.sh

[[email protected] ~]<20200902 08:51:57># sh /u01/gridInventory/orainstRoot.sh

Changing permissions of /u01/gridInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world.

Changing groupname of /u01/gridInventory to oinstall.

The execution of the script is complete.

[[email protected] ~]<20200902 08:53:01># sh /u01/gridhome/root.sh

Check /u01/gridhome/install/root_sgpbnk01kf_2020-09-02_08-53-03-790273956.log for the output of root script

  1. GI安裝後的自動化配置
./gridSetup.sh -silent -executeConfigTools -responseFile /home/grid/grid_install.rsp

GI檢查

按照上面的流程,GI安裝完畢,可以執行相關命令檢查GI的狀態。

crsctl status resource -t

檢視資源狀態,按表格顯示-t

srvctl status scan

檢視scan的狀態

crsctl status resourcegroup -t

檢視資源組狀態

crsctl status type

檢視型別狀態(不懂)

crsctl status serverpool

檢視服務池狀態

crsctl status server

檢視服務狀態

crsctl check crs

檢查叢集同步服務

crsctl check ctss

檢查叢集時間同步(Cluster Time Synchronization Service)

crsctl get cpu equivalency

獲取CPU 資訊

crsctl get node role status -all

獲取節點角色

Olsnodes

檢視節點數

crsctl query css votedisk

查詢vote盤

srvctl status asm

檢視ASM狀態

crsctl check cluster

檢視叢集狀態

正式安裝(DB)

使用者

uid=1778(oracle) gid=1778(oinstall) groups=1778(oinstall),1779(dba),1780(oper),504(asmadmin),506(asmdba),1781(backupdba),1782(dgdba),1783(kmdba),1784(racdba)

useradd oracle

groupadd dba

groupadd oper

groupadd asmadmin

groupadd asmdba

groupadd backupdba

groupadd dgdba

groupadd kmdba

groupadd racdba

usermod -g oinstall -G dba,oper,asmadmin,asmdba,backupdba,dgdba,kmdba,racdba oracle

配置oracle 使用者 互信

磁碟規劃

節點1

節點2

/u01/dbhome

/u01/dbhome

/u01/dbbase

/u01/dbbase

/u01/dbInventory

/u01/dbInventory

DB安裝檢查

DB安裝檢查(grid_home目錄)

./runcluvfy.sh stage -pre dbinst -n "ora19node1,ora19node2" -verbose

編寫響應檔案

[[email protected] ~]<20200902 09:44:13>$ cat db19c_install.rsp

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0

oracle.install.option=INSTALL_DB_SWONLY

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION=/u01/dbInventory

ORACLE_HOME=/u01/dbhome

ORACLE_BASE=/u01/dbbase

oracle.install.db.InstallEdition=EE

oracle.install.db.OSDBA_GROUP=dba

oracle.install.db.OSOPER_GROUP=oper

oracle.install.db.OSBACKUPDBA_GROUP=backupdba

oracle.install.db.OSDGDBA_GROUP=dgdba

oracle.install.db.OSKMDBA_GROUP=kmdba

oracle.install.db.OSRACDBA_GROUP=racdba

oracle.install.db.rootconfig.executeRootScript=true

oracle.install.db.rootconfig.configMethod=ROOT

oracle.install.db.rootconfig.sudoPath=

oracle.install.db.rootconfig.sudoUserName=

oracle.install.db.CLUSTER_NODES=sgpbnk01kf,sgpbnk02kf

oracle.install.db.config.starterdb.type=

oracle.install.db.config.starterdb.globalDBName=

oracle.install.db.config.starterdb.SID=

oracle.install.db.ConfigureAsContainerDB=

oracle.install.db.config.PDBName=

oracle.install.db.config.starterdb.characterSet=

oracle.install.db.config.starterdb.memoryOption=

oracle.install.db.config.starterdb.memoryLimit=

oracle.install.db.config.starterdb.installExampleSchemas=

oracle.install.db.config.starterdb.password.ALL=

oracle.install.db.config.starterdb.password.SYS=

oracle.install.db.config.starterdb.password.SYSTEM=

oracle.install.db.config.starterdb.password.DBSNMP=

oracle.install.db.config.starterdb.password.PDBADMIN=

oracle.install.db.config.starterdb.managementOption=

oracle.install.db.config.starterdb.omsHost=

oracle.install.db.config.starterdb.omsPort=

oracle.install.db.config.starterdb.emAdminUser=

oracle.install.db.config.starterdb.emAdminPassword=

oracle.install.db.config.starterdb.enableRecovery=

oracle.install.db.config.starterdb.storageType=

oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=

oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=

oracle.install.db.config.asm.diskGroup=

oracle.install.db.config.asm.ASMSNMPPassword=

[[email protected] dbhome]<20210125 15:52:14>$ ./runInstaller -silent -ignorePrereqFailure -waitForCompletion -responseFile /home/oracle/dbinstall.rsp

Launching Oracle Database Setup Wizard...

Enter password for 'root' user:

[WARNING] [INS-13013] Target environment does not meet some mandatory requirements.

CAUSE: Some of the mandatory prerequisites are not met. See logs for details. /data/gridInventory/logs/InstallActions2021-01-25_03-52-17PM/installActions2021-01-25_03-52-17PM.log

ACTION: Identify the list of failed prerequisite checks from the log: /data/gridInventory/logs/InstallActions2021-01-25_03-52-17PM/installActions2021-01-25_03-52-17PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.

The response file for this session can be found at:

/data/dbhome/install/response/db_2021-01-25_03-52-17PM.rsp

You can find the log of this install session at:

/data/gridInventory/logs/InstallActions2021-01-25_03-52-17PM/installActions2021-01-25_03-52-17PM.log

RAC建庫

oracle使用者檢查

dbca -silent -executePrereqs -databaseConfigType RAC -nodelist ora19node1,ora19node2

檢查並建立磁碟組

select GROUP_NUMBER,name,path from v$asm_disk;
select NAME,COMPATIBILITY,DATABASE_COMPATIBILITY from v$asm_diskgroup;
ALTER DISKGROUPOCRDG SET ATTRIBUTE 'compatible.asm' = '19.0';
ALTER DISKGROUPOCRDG SET ATTRIBUTE 'compatible.rdbms' = '19.0';


CREATE DISKGROUP FRADG EXTERNAL redundancy DISK '/dev/asm-diskd' ATTRIBUTE 'compatible.asm' = '19.0', 'compatible.rdbms'='19.0','compatible.advm' = '19.0';
CREATE DISKGROUP DATADG EXTERNAL redundancy DISK '/dev/asm-diske' ATTRIBUTE 'compatible.asm' = '19.0', 'compatible.rdbms'='19.0','compatible.advm' = '19.0';
alter diskgroup FRADG mount;
alter diskgroup DATADG mount;

建立RAC響應檔案

[[email protected] ~]<20200902 15:15:30>$ cat dbca_rac.rsp

responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v19.0.0

gdbName=ORA19RAC

sid=ORA19RAC

databaseConfigType=RAC

RACOneNodeServiceName=

policyManaged=

createServerPool=

serverPoolName=

cardinality=

force=

pqPoolName=

pqCardinality=

createAsContainerDatabase=TRUE

numberOfPDBs=0

pdbName=

useLocalUndoForPDBs=TRUE

pdbAdminPassword=zzhzj321zg*A

nodelist=sgpbnk01kf,sgpbnk02kf

templateName=General_Purpose.dbc

sysPassword=zzhzj321zg*A

systemPassword=zzhzj321zg*A

oracleHomeUserPassword=zzhzj321zg*A

emConfiguration=

emExpressPort=5500

runCVUChecks=

dbsnmpPassword=

omsHost=

omsPort=

emUser=

emPassword=

dvConfiguration=

dvUserName=

dvUserPassword=

dvAccountManagerName=

dvAccountManagerPassword=

olsConfiguration=

datafileJarLocation=

datafileDestination=+DATADG

recoveryAreaDestination=+FRADG

storageType=ASM

diskGroupName=DATADG

asmsnmpPassword=zzhzj321zg*A

recoveryGroupName=FRADG

characterSet=

nationalCharacterSet=

registerWithDirService=

dirServiceUserName=

dirServicePassword=

walletPassword=

listeners=

variablesFile=

variables=

initParams=

sampleSchema=FALSE

memoryPercentage=

databaseType=

automaticMemoryManagement=

totalMemory=

靜默建庫

dbca -silent -ignorePrereqFailure -createDatabase -responseFile /home/oracle/dbca.rsp

[[email protected] ~]<20210125 17:16:13>$ dbca -silent -ignorePrereqFailure -createDatabase -responseFile /home/oracle/dbca.rsp

Prepare for db operation

8% complete

Copying database files

33% complete

Creating and starting Oracle instance

34% complete

35% complete

39% complete

44% complete

47% complete

50% complete

Creating cluster database views

52% complete

67% complete

Completing Database Creation

71% complete

73% complete

75% complete

Executing Post Configuration Actions

100% complete

Database creation complete. For details check the logfiles at:

/data/dbbase/cfgtoollogs/dbca/ORA19RAC.

Database Information:

Global Database Name:ORA19RAC

System Identifier(SID) Prefix:ORA19RAC

Look at the log file "/data/dbbase/cfgtoollogs/dbca/ORA19RAC/ORA19RAC.log" for further details.

總結

儘管按照上面的操作:GI---> DB--->DBCA建庫一整套流程最終操作成功。但是筆者在此要提醒讀者:

1. ORACLE RAC 涉及到知識點非常豐富,實驗前建議閱讀關於RAC 的架構和原理的文獻;

2. 儘管看著筆者操作順利,但中間其實有一些小小的錯誤,被筆者忽略了,請讀者認真思索每一個步驟;

3. 由於筆者安裝過太多次,文獻總結不完善,本文中的相關目錄的設計可能有些錯誤,請讀者自行規劃、修正;總體磁碟規劃為:

GI : gridbase、gridhome、gridInventory

DB : dbbase、dbhome、dbInventory

4. 附圖幾張:

GI安裝

root指令碼執行

檢視磁碟組: