環境:oracle linux7.7,安裝系統時需雙網路卡,接心跳線。
節點一(rac1):
網路卡一:10.121.116.91
網路卡二:192.168.1.101
節點二(rac2):
網路卡一:10.121.116.92
網路卡二:192.168.1.103
關閉防火牆
systemctl stop firewalld
systemctl disable firewalld
1.掛載映象,配置本地yum(兩個節點都要操作):
mkdir /mnt/cdrom
mount /dev/sr0 /mnt/cdrom/
mv /etc/yum.repos.d /etc/yum.repos.d.bak
mkdir /etc/yum.repos.d
vi /etc/yum.repos.d/public-yum-ol7.repo
[CDROM]
name=isofile
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=0
gpgkey=file:///mnt/RPM-GPG-KEY-oracle
yum clean all
yum makecache
2.修改主機名:(11.2.0.4要求主機名小寫)
vim /etc/hostname rac1
3.修改hosts檔案
vim /etc/hosts 127.0.0.1 localhostlocalhost.localdomain localhost4 localhost4.localdomain4 ::1localhostlocalhost.localdomain localhost6 localhost6.localdomain6 #rac1 10.121.116.91 rac1 10.121.116.93 rac1-vip 192.168.1.101 rac1-priv #rac2 10.121.116.92 rac2 10.121.116.94 rac2-vip 192.168.1.103 rac2-priv #scan-cluster 10.121.116.95 scan-cluster
4.配置核心引數
vim /etc/sysctl.conf
fs.aio-max-nr = 1048576 fs.file-max = 6815744
kernel.shmall = 16777216 kernel.shmmax = 68719476735 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
sysctl -p
5.修改limits
grid soft nproc 2047 grid hard nproc 16384 grid soft nofile 1024 grid hard nofile 65536 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536
6.修改/etc/pam.d/login檔案
vim /etc/pam.d/login 加入如下內容: session required pam_limits.so
7.修改/etc/profile
vim /etc/profile
加入如下內容: if [ $USER = "oracle" ] || [ $USER = "grid" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else
ulimit -u 16384 -n 65536 fi umask 022 fi
8.禁用selinux
vim /etc/selinux/config 把SELINUX=enforcing改為SELINUX=disabled
9.新增組和使用者
groupadd -g 501 oinstall groupadd -g 502 dba groupadd -g 503 oper groupadd -g 504 asmadmin groupadd -g 505 asmoper groupadd -g 506 asmdba useradd -g oinstall -G dba,asmdba,oper oracle useradd -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid
passwd oracle passwd grid
10.建立目錄
mkdir -p /u01/app/oracle mkdir -p /u01/app/grid mkdir -p /u01/app/11.2.0/grid chown -R grid:oinstall /u01/app/grid chown -R grid:oinstall /u01/app/11.2.0 chown -R oracle:oinstall /u01/app/oracle chmod -R 775 /u01 mkdir -p /u01/app/oraInventory chown -R grid:oinstall /u01/app/oraInventory chmod -R 775 /u01/app/oraInventory
11.配置 grid 和 oracle 使用者的環境變數
vim /home/oracle/.bash_profile
export ORACLE_SID=rac1 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 export LD_LIBRARY_PATH=$ORACLE_HOME/lib export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS" export TMP=/tmp export TMPDIR=$TMP export PATH=$PATH:$ORACLE_HOME/bin
source /home/oracle/.bash_profile
vim /home/grid/.bash_profile export ORACLE_SID=+ASM1 export ORACLE_BASE=/u01/app/grid export ORACLE_HOME=/u01/app/11.2.0/grid export LD_LIBRARY_PATH=$ORACLE_HOME/lib export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS" export PATH=$ORACLE_HOME/bin:$PATH source /home/grid/.bash_profile
rac2上重複此操作。注意:另外一臺資料庫例項名須做相應修改:(rac2/+ASM2)
12.安裝依賴:
yum install gcc gcc-c++ glibc* glibc-devel* libgcc* libstdc++* libstdc++-devel* make sysstat -y yum install -y compat-libstdc* yum install -y unixODBC* yum install -y compat-libcap* yum install -y libcap* yum install libaio-devel yum install xdpyinfo yum install perl-Env yum install -y smartmontools yum install elfutils-libelf-devel yum install unzip
13.配置互相信任,grid/oracle使用者都需要
切換到oracle使用者: rac1: ssh-keygen -t rsa [這裡一路回車就可以了] cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys ssh rac2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys[輸入yes] ssh-copy-id oracle@rac2[將本地公鑰追加到authorized_keys上] ssh rac2 date 只要不再提示輸入密碼就成功了。 rac2: ssh-keygen -t rsa [這裡一路回車就可以了] cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys ssh rac1 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys[輸入yes] ssh-copy-id oracle@rac1 [將本地公鑰追加到authorized_keys上] ssh rac1 date 只要不再提示輸入密碼就成功了。 grid使用者重複此步驟,把oracle改為grid即可。
14.配置共享儲存,這裡用的是3par8400,已在3par管理軟體中劃好磁碟並對映到主機,只需格式化即可
fdisk -l fdisk /dev/sdc fdisk /dev/sdd fdisk /dev/sde fdisk /dev/sdf fdisk /dev/sdg fdisk /dev/sdh fdisk /dev/sdi fdisk /dev/sdj fdisk /dev/sdk fdisk /dev/sdl fdisk /dev/sdc表示要對/dev/sdc磁碟進行格式化,其中,輸入的命令分別表示: n表示新建1個分割槽; p表示分割槽型別選擇為primary partition 主分割槽; 1表示分割槽編號從1開始; 起始、終止柱面選擇預設值,即1和500; w表示將新建的分割槽資訊寫入硬碟分割槽表。
15.配置ASM磁碟(需要上傳並安裝如下三個依賴包):
rpm -ivh pdksh-5.2.14-37.el5.x86_64.rpm rpm -ivh oracleasm-support-2.1.8-1.el6.x86_64.rpm rpm -ivh oracleasmlib-2.0.4-1.el6.x86_64.rpm
執行如下命令
oracleasm configure -i命令進行配置時,使用者配置為grid,組為asmadmin,啟動ASM library driver驅動服務,並且將其配置為隨著作業系統的啟動而自動啟動。 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 配置完成後,記得執行 oracleasm init命令來載入oracleasm核心模組。
oracleasm init
Creating /dev/oracleasm mount point: /dev/oracleasm Loading module "oracleasm": oracleasm Configuring "oracleasm" to use device physical block size Mounting ASMlib driver filesystem: /dev/oracleasm
在rac1建立共享盤:
oracleasm createdisk OCR1 /dev/sdc1 oracleasm createdisk OCR2 /dev/sdd1 oracleasm createdisk OCR3 /dev/sde1 oracleasm createdisk FRA /dev/sdf1 oracleasm createdisk DATA1 /dev/sdg1 oracleasm createdisk DATA2 /dev/sdh1 oracleasm createdisk DATA3 /dev/sdi1 oracleasm createdisk DATA4 /dev/sdj1 oracleasm createdisk DATA5 /dev/sdk1 oracleasm createdisk DATA6 /dev/sdl1
在rac2掃描磁碟:
oracleasm scandisks Reloading disk partitions: done Cleaning any stale ASM disks... Scanning system for ASM disks... Instantiating disk "OCR1" Instantiating disk "OCR2" Instantiating disk "OCR3" Instantiating disk "FRA" Instantiating disk "DATA1" Instantiating disk "DATA2" Instantiating disk "DATA3" Instantiating disk "DATA4" Instantiating disk "DATA5" Instantiating disk "DATA6"
16.安裝grid
上傳並解壓安裝包
unzip p13390677_112040_Linux-x86-64_1of7.zip unzip p13390677_112040_Linux-x86-64_2of7.zip unzip p13390677_112040_Linux-x86-64_3of7.zip chown -R grid:oinstall /u01/app/grid/ chown -R oracle:oinstall /u01/app/database/
使用grid使用者進入到解壓目錄
cd /u01/app/grid/ 驗證: ./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -fixup -verbose
安裝Grid Infrastructure
1.安裝流程
只需要在一個節點上安裝即可,會自動複製到其他節點中,這裡在rac1中安裝。
進入圖形化介面,在grid使用者下進行安裝
安裝之前進入grid下rpm目錄安裝一個包(需在root使用者下):
cd /u01/app/grid/rpm/ rpm -ivh cvuqdisk-1.0.9-1.rpm
再到grid使用者/u01/app/grid/下執行./runInstaller
cd /u01/app/grid/ export DISPLAY=IP:0.0 ./runInstaller
跳過更新
選擇安裝叢集
選擇自定義安裝
選擇語言為English
定義叢集名字,SCAN Name 為hosts中定義的scan-cluster,取消GNS
介面只有第一個節點rac1,點選“Add”把第二個節點rac2加上
選擇網路卡
配置ASM例項需要為具有sysasm許可權的sys使用者,具有sysdba許可權的asmsnmp使用者設定密碼,這裡設定統一密碼。
yes即可
不選擇智慧管理。
檢查ASM例項許可權分組情況,預設既可。
選擇grid軟體安裝路徑和base目錄,預設既可。
選擇grid安裝清單目錄,預設既可。
環境檢測出現dervice checks for asm警告,我並不是透過udev配置asm,可忽略。resolv.conf錯誤,是因為沒有配置DNS,可以忽略。
安裝grid概要
提示需要root使用者依次執行指令碼orainstRoot.sh ,root.sh (一定要先在rac1執行完指令碼後,才能在其他節點執行)。
注意:RHEL 7 安裝oracle rac 11.2.0.4執行root.sh會報錯ohasd failed to start 報錯原因:因為RHEL 7使用systemd而不是initd執行程序和重啟程序,而root.sh透過傳統的initd執行ohasd程序。
解決方法:
在RHEL 7中ohasd需要被設定為一個服務,在執行指令碼root.sh之前。
以root使用者建立服務檔案
touch /usr/lib/systemd/system/ohas.service chmod 777 /usr/lib/systemd/system/ohas.service
將以下內容新增到新建立的ohas.service檔案中
vim /usr/lib/systemd/system/ohas.service [Unit] Description=Oracle High Availability Services After=syslog.target [Service] ExecStart=/etc/init.d/init.ohasd run >/dev/null 2>&1 Type=simple Restart=always [Install] WantedBy=multi-user.target
以root使用者執行下面的命令
systemctl daemon-reload systemctl enable ohas.service systemctl start ohas.service systemctl status ohas.service
ohas.service正常執行即可依次執行指令碼orainstRoot.sh ,root.sh
[root@rac1 rules.d]# /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@rac1 rules.d]# /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 User ignored Prerequisites during installation 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 upstart CRS-2672: Attempting to start 'ora.mdnsd' on 'rac1' CRS-2676: Start of 'ora.mdnsd' on 'rac1' succeeded CRS-2672: Attempting to start 'ora.gpnpd' on 'rac1' CRS-2676: Start of 'ora.gpnpd' on 'rac1' succeeded CRS-2672: Attempting to start 'ora.cssdmonitor' on 'rac1' CRS-2672: Attempting to start 'ora.gipcd' on 'rac1' CRS-2676: Start of 'ora.gipcd' on 'rac1' succeeded CRS-2676: Start of 'ora.cssdmonitor' on 'rac1' succeeded CRS-2672: Attempting to start 'ora.cssd' on 'rac1' CRS-2672: Attempting to start 'ora.diskmon' on 'rac1' CRS-2676: Start of 'ora.diskmon' on 'rac1' succeeded CRS-2676: Start of 'ora.cssd' on 'rac1' succeeded ASM created and started successfully. Disk Group DATA 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 75df39da21084f84bf866b66b29c3ce3. Successfully replaced voting disk group with +DATA. CRS-4256: Updating the profile CRS-4266: Voting file(s) successfully replaced ## STATE File Universal Id File Name Disk group -- ----- ----------------- --------- --------- 1. ONLINE 75df39da21084f84bf866b66b29c3ce3 (ORCL:VOL1) [DATA] Located 1 voting disk(s). CRS-2672: Attempting to start 'ora.asm' on 'rac1' CRS-2676: Start of 'ora.asm' on 'rac1' succeeded CRS-2672: Attempting to start 'ora.DATA.dg' on 'rac1' CRS-2676: Start of 'ora.DATA.dg' on 'rac1' succeeded Configure Oracle Grid Infrastructure for a Cluster ... succeeded 在rac2上執行: [root@rac2 rpm]# /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@rac2 rpm]# /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 User ignored Prerequisites during installation OLR initialization - successful Adding Clusterware entries to upstart CRS-4402: The CSS daemon was started in exclusive mode but found an active CSS daemon on node rac1, 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
完成指令碼後,點選OK,進行下一步。