srvctl:Oracle_11g_RAC_install安装脚本

 2021-07-15 13:16    77  

安装步骤srvctl:1.安装Linux操作系统

srvctl:Oracle_11g_RAC_install安装脚本

2.配置环境

3.安装GRID

4.安装数据库软件

5.创建实例

一srvctl、 環境准備。

規則系統、網絡、共享存儲srvctl。

安裝好系統并把ISO上傳至/media目錄。

1.1 在兩個節點中安装Oracle RAC所需要的软件包(01check_app.sh)Chkconfig NetworkManager off

Service NetworkManager stop

# 准备ISO REPO环境。

mkdir /mnt/iso

mount -o loop /media/OracleLinux-R5-U8-Server-x86_64-dvd.iso /mnt/iso

cd /mnt/iso/Packages

rpm -ivh *python-deltarpm* --force --nodeps

rpm -ivh createrepo-0.9.9-22.el6.noarch.rpm --force --nodeps

cd /mnt

createrepo .

# 添加ISO源

cat >> /etc/yum.repos.d/iso.repo <<EOF

[IS0]

name=ISO

baseurl=file:///mnt

gpgcheck=0

enabled=1

EOF

# 完成依赖安装。

yum install libXp* binutils* compat-libstdc++-* elfutils-libelf* gcc* glibc* libaio* libgcc* libstdc++* sysstat* unixODBC* *oracleasm* *multipath* ksh-* compat-libcap1-*

1.2 網絡配制(示例)。網卡綁定。

配置ip

# 重啟網絡或系統。

service network restart

OR

reboot

# 修改/etc/hosts 文件

127.0.0.1 localhost.localdomain localhost

# Public Network(eth0或bond0)

10.41.84.16 rac01

10.41.84.17 rac02

# Private Interconnect(eth1或bond1)

192.168.2.10 rac01-priv

192.168.2.11 rac02-priv

# Private Virtual IP

10.41.84.22 rac01-vip

10.41.84.23 rac02-vip

# Single Client Access Name (SCAN)

192.168.2.21 rac-cluster-scan

1.3 系統參數和用戶添加,在兩個節點中都運行。# 使用自帶的NTP服務

#sed -i 's/OPTIONS="-u/OPTIONS="-x -u/' /etc/sysconfig/ntpd

#service ntpd restart

# 在集群的两个 Oracle RAC 节点上针对 grid 和 oracle 用户执行以下用户、组和目录配置并设置 shell 限制的任务

groupadd -g 1000 oinstall

groupadd -g 1200 asmadmin

groupadd -g 1201 asmdba

groupadd -g 1202 asmoper

useradd -m -u 1100 -g oinstall -G asmadmin,asmdba,asmoper -d /home/grid -s /bin/bash grid

id grid

# 然后运行passwd grid为其设置密码。

passwd grid

# 为grid 用户帐户创建登录脚本

cat > /home/grid/.bash_profile <<"EOF"

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

alias ls="ls -F"

ORACLE_SID=+ASM1; export ORACLE_SID

JAVA_HOME=/usr/local/java; export JAVA_HOME

ORACLE_BASE=/u01/app/grid; export ORACLE_BASE

ORACLE_HOME=/u01/app/11.2.0/grid; export ORACLE_HOME

ORACLE_PATH=/u01/app/oracle/common/oracle/sql;

export ORACLE_PATH

ORACLE_TERM=xterm; export ORACLE_TERM

NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT

TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN

ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11

PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin

PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin

PATH=${PATH}:/u01/app/common/oracle/bin

export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib

export LD_LIBRARY_PATH

CLASSPATH=$ORACLE_HOME/JRE

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib

export CLASSPATH

THREADS_FLAG=native; export THREADS_FLAG

export TEMP=/tmp

export TMPDIR=/tmp

#NLS_LANG=SIMPLIFIED CHINESE_CHINA.UTF8

#NLS_LANG="SIMPLIFIED CHINESE".ZHS16GBK

#NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

umask 022

EOF

# 为 Oracle 数据库软件创建组和用户

groupadd -g 1300 dba

groupadd -g 1301 oper

useradd -m -u 1101 -g oinstall -G dba,oper,asmdba -d /home/oracle -s /bin/bash oracle

id oracle

# 然后运行passwd oracle为其设置密码。

passwd oracle

# 为 oracle 用户帐户创建登录脚本

cat > /home/oracle/.bash_profile <<"EOF"

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

alias ls="ls -F"

ORACLE_SID=orcl01; export ORACLE_SID

ORACLE_UNQNAME=orcl; export ORACLE_UNQNAME

JAVA_HOME=/usr/local/java; export JAVA_HOME

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE

ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1

export ORACLE_HOME

ORACLE_PATH=/u01/app/common/oracle/sql

export ORACLE_PATH

ORACLE_TERM=xterm; export ORACLE_TERM

NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"

export NLS_DATE_FORMAT

TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN

ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11

PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin

PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin

PATH=${PATH}:/u01/app/common/oracle/bin

export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib

export LD_LIBRARY_PATH

CLASSPATH=$ORACLE_HOME/JRE

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib

export CLASSPATH

THREADS_FLAG=native; export THREADS_FLAG

export TEMP=/tmp

export TMPDIR=/tmp

NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

umask 022

EOF

# 创建 Oracle 基本目录路径

mkdir -p /u01/app/grid

mkdir -p /u01/app/11.2.0/grid

chown -R grid:oinstall /u01

mkdir -p /u01/app/oracle

chown oracle:oinstall /u01/app/oracle

chmod -R 775 /u01

# 为 Oracle 软件安装用户设置资源限制

cat >> /etc/security/limits.conf <<EOF

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

EOF

cat >> /etc/pam.d/login <<EOF

session required pam_limits.so

EOF

cat >> /etc/profile << "EOF"

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

EOF

# 配制内核参数。

cat >> /etc/sysctl.conf <<EOF

kernel.shmmax = 4294967295

kernel.shmall = 2097152

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

fs.file-max = 6815744

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=1048576

fs.aio-max-nr=1048576

EOF

# 加載參數并驗証SElinux。

# vi /etc/sysconfig/selinux

# SELINUX=disabled

sysctl -p

getenforce ## 結果一定要為disable,不然SSH互通性會失敗!!!除非你配制好SELINUX

1.4 配制SSH和檢查系統配制。11g R2 版中的 OUI 界面包含了一个新的特性,该特性可以在 Oracle 软件的实际安装阶段为执行该安装的用户帐户自动配置 SSH。

如果失敗則使用如下方式手動添加。

# 用oracle用戶分別登錄執行:

# Note: Whenever prompted for a passphrase leave it empty and press return.

mkdir ~/.ssh

chmod 700 ~/.ssh

/usr/bin/ssh-keygen -t rsa

# oracle登錄其中一個節點執行:

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

ssh rac02 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

scp ~/.ssh/authorized_keys rac02:/home/oracle/.ssh/

測試結果:

ssh rac01 date

ssh rac02 date

# 安装 Oracle 软件之前运行集群验证实用程序CVU (runcluvfy.sh)

# oracle用戶登錄。

/tmp/grid/runcluvfy.sh stage -pre crsinst -fixup -n rac01,rac02 -verbose > /tmp/result.txt

# 查看 CVU 报告。 应该只发现如下的唯一一个错误:

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

Node Name User Exists Group Exists User in Group Comment

---------------- ------------ ------------ ------------ ----------------

racnode2 yes yes no failed

racnode1 yes yes no failed

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

# CVU 不能正确识別11gR2中的grid帳戶。

1.5 配制ASMLib及共享存儲Muiltpath(開始手動)。

# multipath 多路徑的配制

# SHOW HBA WWN

cat /sys/class/fc_host/host1

cat /sys/class/scsi_host/host1/device/fc_host:host1/port_name

scsi_id -g -u -s /block/sda

scsi_id -g -u /dev/sda

1) 安裝好multipath軟件,編輯/etc/multipath.conf文件

首先注釋掉第一段,就是啟用multipath.

然後把defaults修改成如下參數:

defaults {

user_friendly_names yes

udev_dir /dev

path_grouping_policy multibus

path_checker readsector0

failback immediate

no_path_retry fail

}

device {

vendor "HP"

product "HSV210"

path_grouping_policy group_by_prio

getuid_callout "/sbin/scsi_id -g -u -s /block/%n"

path_checker tur

path_selector "round-robin 0"

prio_callout "/sbin/mpath_prio_alua /dev/%n"

rr_weight uniform

rr_min_io 100

failback immediate

# hardware_handler "0"

no_path_retry 18

}

}

多路径捆绑如下:

blacklist {

devnode "^sda"

}

defaults {

user_friendly_names yes

path_grouping_policy multibus

failback immediate

no_path_retry fail

}

multipaths{

multipath{

wwid 3694049c100d5741c8752431a00000001

alias data

path_grouping_policy failover

}

multipath{

wwid 3694049c100d5741c87520adb00000000

alias FRA

path_grouping_policy failover

}

multipath{

wwid 3694049c100d5741c875ae4b400000003

alias VOTE

path_grouping_policy failover

}

multipath{

wwid 3694049c100d5741c875aed9200000004

alias VOTE1

path_grouping_policy failover

}

更多詳情可以通過man multipath和man multipath.conf查看。

2) 啟動multipath服務

service multipathd start

3) 運行 multipath -ll

mpath1 (360a9800050344862464a63425a456273) dm-2 NETAPP,LUN

[size=600G][features=0][hwhandler=0][rw]

\_ round-robin 0 [prio=4][active]

\_ 3:0:1:5 sdc 8:32 [active][ready]

\_ round-robin 0 [prio=1][enabled]

\_ 3:0:0:5 sdb 8:16 [active][ready]

就可以發現映射過來的mpath1.

ls -l /dev/mpath/mpath1 或 fdisk -l

查看相關信息.

4) 然後你就可以用fdisk為它分區了.(如果你想加入LVM,可以先pvcreate /dev/mpath/mpath1)

# 安装和配制ASM

rpm -Uvh oracleasm*

/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

# To avoid ASM issue with Multipath devices on Linux ORA-15186

# **** asm and multipath need special settings in /etc/sysconfig/oracleasm ****

# for device mapper drives, scan dm at first #

# ORACLEASM_SCANORDER=dm

# ignore sd drives, because we have multipath, to avoid missconfigurations #

# ORACLEASM_SCANEXCLUDE=sd

sed -i 's/ORACLEASM_SCANORDER="/ORACLEASM_SCANORDER="dm/' /etc/sysconfig/oracleasm

sed -i 's/ORACLEASM_SCANEXCLUDE="/ORACLEASM_SCANEXCLUDE="sd/' /etc/sysconfig/oracleasm

/usr/sbin/oracleasm init

/etc/init.d/oracleasm stop; sleep 2

/etc/init.d/oracleasm start

# 安裝多路徑軟件并創建5個大小為300M的Voting disk.(選擇extent時只產生1個OCR磁盤)

# Basic rules: You cannot create more than 1 (one) OCR or SPFILE in same Diskgroup.

# The COMPATIBLE.ASM disk group compatibility attribute must be set to 11.2 or greater to store OCR or voting disk data in a disk group.

# So I recommend always create two small DISKGROUP:

+VOTE – Storing Voting files and OCR mirror

+CRS – Storing OCR and ASM Spfile.

# /u01/app/11.2.0/grid/bin/ocrconfig -add +VOTE

# CRS01 and CRS02 will be used to diskgroup CRS

# VOTE01,VOTE02 and VOTE03 will be used to diskgroup VOTE

D

# 2個DATA盤和2個FRA(Oracle fast recovery area)盤。

# /t_fast_recovery_area.htm

# 注: 11g R2中已經去掉RAW磁盤的默認支持,默認改用ASM磁盤。

# root用戶運行以下命令。

multipath -ll

# 示例(根據實際路徑定義)

/usr/sbin/oracleasm createdisk CRSVOL1 /dev/mapper/mpath0

/usr/sbin/oracleasm createdisk CRSVOL2 /dev/mapper/mpath1

/usr/sbin/oracleasm createdisk CRSVOL3 /dev/mapper/mpath2

. . .

/usr/sbin/oracleasm createdisk DATAVOL1 /dev/mapper/mpath5

/usr/sbin/oracleasm createdisk DATAVOL2 /dev/mapper/mpath6

/usr/sbin/oracleasm createdisk FRAVOL1 /dev/mapper/mpath7

/usr/sbin/oracleasm createdisk FRAVOL2 /dev/mapper/mpath8

# 在其中一個節點中運行:

# 掃描

/usr/sbin/oracleasm scandisks

# 列出

/usr/sbin/oracleasm listdisks

二, 安裝grid套件和Oracle database11g。

2.2.1 安裝grid

# 為了避免 "ADVM/ACFS is not supported" 的問題。

# In fact ASMFS is not needed for for ASM

# 所以在安裝前運行如下命令。

echo "redhat-release-5Server-5" > /tmp/.linux_release

/usr/bin/chattr +i /tmp/.linux_release

su - grid

cd grid

export LC_ALL=en_US

./runInstaller

1) 选择 Install and Configure Grid Infrastructure for a Cluster

2) 选择 Advanced Installation

3) 添加Simplied Chinese語言支持。

4) 配制Scan

5) 添加節點并配制互通性。

click the [SSH Connectivity] button. Enter the "OS Password" for the grid user and click the [Setup] button. This will start the "SSH Connectivity" configuration process:

After the SSH configuration process successfully completes, acknowledge the dialog box.

Finish off this screen by clicking the [Test] button to verify passwordless SSH connectivity.

6) 驗証接口配制

7) Select " Automatic Storage Management (ASM)".

8) 創建CRS group 3個voting disk. Redundancy 選擇Normal

9) 配制密碼,使用同一個。。。

10) Do not use Intelligent Platform Management Interface (IPMI)。

11) 下一步

12) 下一步

13) 下一步

14) 開始安裝,完成之前按提示在兩個節點中運行兩個腳本。( 提示插件/助手錯誤可以忽略,因為并沒有使用DNS。)

# 驗証安裝

# 檢查CRS狀態

crsctl check crs

# 檢查節點

olsnodes -n

# 驗証ASM在各節點的運行狀態。

srvctl status asm -a

# Check Oracle Cluster Registry (OCR) and voting disks

ocrcheck

crsctl query css votedisk

# 在开始创建集群化数据库之前,还应确保现已安装的所有服务(Oracle TNS 监听器、Oracle Clusterware 进程等)正在运行。

# crs_stat -t -v 已经被抨击,不推荐在11gR2及以上使用,因为可能导致OCR错误,已经替换为 crsctl控制。

crsctl status resource -t

[grid@PYRAC1 ~]$ crsctl status resource -t

--------------------------------------------------------------------------------

NAME TARGET STATE SERVER STATE_DETAILS

--------------------------------------------------------------------------------

Local Resources

--------------------------------------------------------------------------------

ora.LISTENER.lsnr

ONLINE ONLINE pyrac1

ONLINE ONLINE pyrac2

ora.OCR.dg

ONLINE ONLINE pyrac1

ONLINE ONLINE pyrac2

ora.asm

ONLINE ONLINE pyrac1 Started

ONLINE ONLINE pyrac2 Started

ora.gsd

OFFLINE OFFLINE pyrac1

OFFLINE OFFLINE pyrac2

ora.net1.network

ONLINE ONLINE pyrac1

ONLINE ONLINE pyrac2

ora.ons

ONLINE ONLINE pyrac1

ONLINE ONLINE pyrac2

--------------------------------------------------------------------------------

Cluster Resources

--------------------------------------------------------------------------------

ora.LISTENER_SCAN1.lsnr

1 ONLINE ONLINE pyrac2

ora.cvu

1 ONLINE ONLINE pyrac2

ora.oc4j

1 ONLINE ONLINE pyrac2

ora.pyrac1.vip

1 ONLINE ONLINE pyrac1

ora.pyrac2.vip

1 ONLINE ONLINE pyrac2

ora.scan1.vip

1 ONLINE ONLINE pyrac2

2.2 使用 ASMCA 创建其他 ASM 磁盘组

[grid@rac01 ~] asmca &

1) From the "Disk Groups" tab, click the [Create] button.

2)

DATA

The "Create Disk Group" shows two of the ASMLib volumes DATAVOL1 and DATAVOL2 and two for FRA.

When creating the "Data" ASM disk group, specify "DATA" for the "Disk Group Name"

In the "Redundancy" section, choose "External (none)"

Check box "ORCL:DATAVOL1" and "ORCL:DATAVOL2" in the "Select Member Disks" section

After verifying all values in this dialog are correct, click the [OK] button.

NEXT FRA

When creating the "FRA" ASM disk group, specify "FRA" for the "Disk Group Name"

In the "Redundancy" section, choose "External (none)"

Check box "ORCL:FRAVOL1" and "ORCL:FRAVOL2" in the "Select Member Disks" section

After verifying all values in this dialog are correct, click the [OK] button.

3) After creating the ASM disk groups, you will be returned to the initial dialog. Click the [Exit] button.

2.2.3 為群集安裝oracle數據庫軟件。

# 以oracle用戶登錄

cd /home/oracle/database

[oracle@rac01 database]$ ./runInstaller

第2步選擇Install database software only

第5步時 Database Edition 選擇 Enterprise Edition。

第7步在Operating System Groups中:

Database Administrator (OSDBA) Group: dba

Database Operator (OSOPER) Group: oper

最後在完成之前執行腳本。

2.2.4 用dbca創建群集數據庫。

# 以oracle用戶登錄。

[oracle@rac01 ~]$ dbca&

第8步時選擇 Sample Schemas

第9步的時候選擇合適的内存、Sizing、編碼設置。

### Sessions = (1.5*processes)+22

第11步時選擇 Generate Database Creation Scripts

完成後,就具備完善的RAC環境。

三,驗証oracle RAC

crsctl check cluster -all

su - grid -c "crsctl status resource -w \"TYPE co 'ora'\" -t"

# 會顯示如下行

ora.orcl.db

1 ONLINE ONLINE rac01 Open

2 ONLINE ONLINE rac02 Open

# Verify Oracle Grid Infrastructure and Database Configuration

srvctl stop database -d orcl

sleep 1

srvctl start database -d orcl

sleep 1

srvctl status database -d orcl

sleep 1

# Single Oracle Instance - (Status of Specific Instance)

srvctl stop instance -d orcl -i orcl01

sleep 1

srvctl start instance -d orcl -i orcl01

# 檢查數據庫狀態

srvctl config database -d orcl -a

# 檢查監聽狀態

srvctl status listener -l LISTENER

lsnrctl service listener_scan

# OR

lsnrctl status

# 驗証時間同步

cluvfy comp clocksync -verbose

# 集群中正在運行的實例。

SELECT * FROM gv$instance;

# 所有數據庫文件及其所在的 ASM 磁盤組。

select name from v$datafile

union

select member from v$logfile

union

select name from v$controlfile

union

select name from v$tempfile;

# 啟動和停止cluster

#

# 用root帳戶登錄

# 停止本地

[root@rac01 ~] /u01/app/11.2.0/grid/bin/crsctl stop cluster

# 停止所有節點

[root@rac01 ~] /u01/app/11.2.0/grid/bin/crsctl stop cluster -all

# 啟動所有

/u01/app/11.2.0/grid/bin/crsctl start cluster -all

# 啟動部分

/u01/app/11.2.0/grid/bin/crsctl start cluster -n rac01 rac02

# 停止實例

srvctl stop database -d orcl

# 啟動實例

srvctl start database -d orcl

# 檢查監聽狀態

srvctl status listener -l LISTENER

lsnrctl service listener_scan

测试:

Crsctl check cluster –all 检查集群状态

Crsctl status resource –t 检查数据库、asm、监听、状态

本文标签:脚本安装

原文链接:https://www.xgfox.com/jsyd/929.html

本文版权:如无特别标注,本站文章均为原创。