redhat6.7环境下oracle11gR2 RAC静默安装

(一)基础环境

虚拟机环境 :vmware workstation 12

操作系统    : redhat6.7 - 64bit

数据库版本 :11.2.0.4

(二)安装前的环境准备

(2.1)配置/etc/hosts文件,2个节点都要修改

[oracle@standbydb1 bin]$vim /etc/hosts
# 添加2个节点的IP信息
192.168.10.41    standbydb1
192.168.10.42    standbydb2
192.168.10.43    standbydb1-vip
192.168.10.44    standbydb2-vip
192.168.10.40    standbydb-scan

10.10.10.41       standbydb1-priv
10.10.10.42       standbydb2-priv

 

(2.2)操作系统参数修改,2个节点都要修改

(2.2.1)修改/etc/sysctl.conf

[root@standbydb1 ~]# vi /etc/sysctl.conf 
# 在末尾添加
 
kernel.msgmnb = 65536 
kernel.msgmax = 65536 
kernel.shmmax = 68719476736 
kernel.shmall = 4294967296 
fs.aio-max-nr = 1048576 
fs.file-max = 6815744 
kernel.shmall = 2097152 
kernel.shmmax = 1306910720 
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 
net.ipv4.tcp_wmem = 262144 262144 262144 
net.ipv4.tcp_rmem = 4194304 4194304 4194304

内核参数执行命令sysctl -p生效。

(2.2.2)修改/etc/security/limits.conf

[root@standbydb1 ~]# vi /etc/security/limits.conf 
# 在末尾添加
 
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

(2.2.3)修改/etc/security/limits.conf

[root@standbydb1 ~]# vi /etc/pam.d/login
# 在文件末尾添加 session required pam_limits.so

 

(2.3)配置共享存储
(2.3.1)分区、格式化磁盘,在一个节点上执行即可

# 在节点1上格式化,以/dev/sdb为例:

[root@standbydb1 ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 3824.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-3824, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-3824, default 3824): 
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

(2.3.2)在2个节点上添加裸设备,2个节点都要执行

[root@standbydb1 ~]# vi /etc/udev/rules.d/60-raw.rules
 # 在后面添加

ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc1", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd1", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sde1", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="sdf1", RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", KERNEL=="sdg1", RUN+="/bin/raw /dev/raw/raw6 %N"
ACTION=="add", KERNEL=="sdh1", RUN+="/bin/raw /dev/raw/raw7 %N"


KERNEL=="raw[1]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[2]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[3]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[4]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[5]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[6]", MODE="0660", OWNER="grid", GROUP="asmadmin"
KERNEL=="raw[7]", MODE="0660", OWNER="grid", GROUP="asmadmin"

启动裸设备,2个节点都执行

[root@standbydb1 ~]# start_udev

检查裸设备,2个节点都要查看,如果看不到设备信息,重启节点即可

[root@standbydb1 ~]# raw -qa
/dev/raw/raw1:    bound to major 8, minor 17
/dev/raw/raw2:    bound to major 8, minor 33
/dev/raw/raw3:    bound to major 8, minor 49
/dev/raw/raw4:    bound to major 8, minor 65
/dev/raw/raw5:    bound to major 8, minor 81
/dev/raw/raw6:    bound to major 8, minor 97
/dev/raw/raw7:    bound to major 8, minor 113

(2.4)安装依赖包,2个节点都执行

yum install -y binutils-*
yum install -y compat-libstdc++-*
yum install -y elfutils-libelf-*
yum install -y elfutils-libelf-*
yum install -y elfutils-libelf-devel-static-*
yum install -y gcc-*
yum install -y gcc-c++-*
yum install -y glibc-*
yum install -y glibc-common-*
yum install -y glibc-devel-*
yum install -y glibc-headers-*
yum install -y kernel-headers-*
yum install -y ksh-*
yum install -y libaio-*
yum install -y libaio-devel-*
yum install -y libgcc-*
yum install -y libgomp-*
yum install -y libstdc++-*
yum install -y libstdc++-devel-*
yum install -y make-*
yum install -y sysstat-*
yum install -y compat-libcap*

(2.5)创建oracle、grid用户相关

(2.5.1)创建用户、用户组、目录,2个节点都要执行

/usr/sbin/groupadd -g 1010 oinstall
/usr/sbin/groupadd -g 1020 asmadmin
/usr/sbin/groupadd -g 1021 asmdba
/usr/sbin/groupadd -g 1022 asmoper
/usr/sbin/groupadd -g 1031 dba
/usr/sbin/groupadd -g 1032 oper
useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid
useradd -u 1101 -g oinstall -G dba,asmdba,oper oracle
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/grid
mkdir /u01/app/oracle
chown -R grid:oinstall /u01
chown oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/

(2.5.2)配置grid的环境变量,2个节点都要执行

[grid@standbydb1 ~]$ vim .bash_profile 

#添加
export TMP=/tmp 
export TMPDIR=$TMP 
export ORACLE_SID=+ASM1   #如果是节点2,改为:+ASM2
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=/usr/sbin:$PATH 
export PATH=$ORACLE_HOME/bin:$PATH 
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib 
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib 
umask 022

(2.5.3)配置oracle的环境变量,2个节点都要执行

[oracle@standbydb1 ~]$ vim .bash_profile 

#添加
export TMP=/tmp 
export TMPDIR=$TMP 
export ORACLE_SID=standby1
export ORACLE_BASE=/u01/app/oracle 
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export TNS_ADMIN=$ORACLE_HOME/network/admin 
export PATH=/usr/sbin:$PATH 
export PATH=$ORACLE_HOME/bin:$PATH 
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib 
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib 
umask 022

(2.5.4)配置grid的节点互信,在一个节点用grid用户执行

./sshUserSetup.sh -hosts "primarydb1 primarydb2" -user grid -advanced

(2.5.5)配置oracle的节点互信,在一个节点用oracle用户执行

./sshUserSetup.sh -hosts "primarydb1 primarydb2" -user oracle -advanced

 (2.6)安装前的检查

 2个节点安装cvuqdisk包,进入grid安装包

[root@standbydb1 soft]# cd grid/
[root@standbydb1 grid]# ls
doc  install  response  rpm  runcluvfy.sh  runInstaller  sshsetup  stage  welcome.html
[root@standbydb1 grid]# cd rpm/
[root@standbydb1 rpm]# ls
cvuqdisk-1.0.7-1.rpm
[root@standbydb1 rpm]# rpm -ivh cvuqdisk-1.0.7-1.rpm
Preparing...                ########################################### [100%]
Using default group oinstall to install package
   1:cvuqdisk               ########################################### [100%]

执行grid安装检查

./runcluvfy.sh stage -pre crsinst -n standbydb1,standbydb2 -fixup -verbose

如果没有报错,即可执行安装操作。

 (三)安装

(3.1)安装grid

安装命令:

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

响应文件grid_install.rsp的内容为:

oracle.install.responseFileVersion=/oracle/install/rspfmt_crsinstall_response_schema_v11_2_0
ORACLE_HOSTNAME=standbydb1
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en
oracle.install.option=CRS_CONFIG
ORACLE_BASE=/u01/app/grid
ORACLE_HOME=/u01/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=standbydb-scan
oracle.install.crs.config.gpnp.scanPort=1521
oracle.install.crs.config.clusterName=standbydb-scan
oracle.install.crs.config.gpnp.configureGNS=false
oracle.install.crs.config.gpnp.gnsSubDomain=
oracle.install.crs.config.gpnp.gnsVIPAddress=
oracle.install.crs.config.autoConfigureClusterNodeVIP=false
oracle.install.crs.config.clusterNodes=standbydb1:standbydb1-vip,standbydb2:standbydb2-vip
oracle.install.crs.config.networkInterfaceList=eth0:192.168.10.0:1,eth1:10.10.10.0:2,eth2:192.168.0.0:3
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=Oracle123
oracle.install.asm.diskGroup.name=OCR
oracle.install.asm.diskGroup.redundancy=NORMAL
oracle.install.asm.diskGroup.AUSize=1
oracle.install.asm.diskGroup.disks=/dev/raw/raw1,/dev/raw/raw2,/dev/raw/raw3
oracle.install.asm.diskGroup.diskDiscoveryString=/dev/raw/*
oracle.install.asm.monitorPassword=Oracle123
oracle.install.crs.upgrade.clusterNodes=
oracle.install.asm.upgradeASM=false
oracle.installer.autoupdates.option=SKIP_UPDATES
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
View Code

 

额外工作:

(1)创建磁盘组

su - grid

sqlplus / as sysasm create diskgroup data external redundancy disk '/dev/raw/raw4','/dev/raw/raw5','/dev/raw/raw6' attribute 'compatible.rdbms'='11.2.0.0', 'compatible.asm'='11.2.0.0', 'au_size'='1M'; create diskgroup arch external redundancy disk '/dev/raw/raw7' attribute 'compatible.rdbms'='11.2.0.0', 'compatible.asm'='11.2.0.0', 'au_size'='1M';

启动所有节点上的磁盘组

(2)创建默认监听

su - grid

srvctl add listener
srvctl start listener

 

(3.2)安装数据库软件

安装命令:

./runInstaller -ignorePrereq -silent -force -responseFile /u01/mysoft/oracle/db_install_20190714.rsp

响应文件db_install_20190714.rsp的内容为:

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=standbydb1
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.CLUSTER_NODES=standbydb1,standbydb2
oracle.install.db.isRACOneInstall=false
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=
oracle.install.db.config.starterdb.memoryOption=false
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
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.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
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=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
View Code

 

(3.3)创建数据库

[oracle@standbydb1 bin]$ pwd
/u01/app/oracle/product/11.2.0/db_1/bin
[oracle@standbydb1 bin]$ ./dbca -silent -responseFile /u01/mysoft/oracle/database/response/dbca_20190714.rsp

 响应文件db_install_20190714.rsp的内容为:

[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "standby"
DB_UNIQUE_NAME = "standby"
SID = "standby"
NODELIST=standbydb1,standbydb2
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "Oracle123"
SYSTEMPASSWORD = "Oracle123"
DATAFILEDESTINATION = "+DATA"
STORAGETYPE=ASM
DISKGROUPNAME=DATA
CHARACTERSET = "ZHS16GBK"
NATIONALCHARACTERSET= "UTF8"
DB_BLOCK_SIZE=8192
TOTALMEMORY = "1024"
View Code

  (四)结果确认

查看集群资源

[grid@standbydb1 ~]$ crsctl status res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
               ONLINE  ONLINE       standbydb1                                   
               ONLINE  ONLINE       standbydb2                                   
ora.DATA.dg
               ONLINE  ONLINE       standbydb1                                   
               ONLINE  ONLINE       standbydb2                                   
ora.LISTENER.lsnr
               ONLINE  ONLINE       standbydb1                                   
               ONLINE  ONLINE       standbydb2                                   
ora.OCR.dg
               ONLINE  ONLINE       standbydb1                                   
               ONLINE  ONLINE       standbydb2                                   
ora.asm
               ONLINE  ONLINE       standbydb1               Started             
               ONLINE  ONLINE       standbydb2               Started             
ora.gsd
               OFFLINE OFFLINE      standbydb1                                   
               OFFLINE OFFLINE      standbydb2                                   
ora.net1.network
               ONLINE  ONLINE       standbydb1                                   
               ONLINE  ONLINE       standbydb2                                   
ora.ons
               ONLINE  ONLINE       standbydb1                                   
               ONLINE  ONLINE       standbydb2                                   
ora.registry.acfs
               ONLINE  ONLINE       standbydb1                                   
               ONLINE  ONLINE       standbydb2                                   
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       standbydb1                                   
ora.cvu
      1        ONLINE  ONLINE       standbydb1                                   
ora.oc4j
      1        ONLINE  ONLINE       standbydb1                                   
ora.scan1.vip
      1        ONLINE  ONLINE       standbydb1                                   
ora.standby.db
      1        ONLINE  ONLINE       standbydb1               Open                
      2        ONLINE  ONLINE       standbydb2               Open                
ora.standbydb1.vip
      1        ONLINE  ONLINE       standbydb1                                   
ora.standbydb2.vip
      1        ONLINE  ONLINE       standbydb2                                   
View Code

查看数据库状态

SQL> select name,open_mode from v$database;
NAME      OPEN_MODE
--------- --------------------
STANDBY   READ WRITE

SQL> select host_name,instance_name from gv$instance;
HOST_NAME             INSTANCE_NAME
-------------  -----------------
standbydb1         standby1
standbydb2         standby2

结束。

 

转载于:https://www.cnblogs.com/lijiaman/p/11185504.html

你可能感兴趣的:(数据库,操作系统,开发工具)