闲来有空,整理下VMware workstation上oracle 11 RAC的安装
环境:
VMware Workstation :9.0.0 build-812388
OS :Red Hat Enterprise Linux Server release 6.3 (Santiago)
Oracle :11203
配置环境如图所示
磁盘 45G 分别有两块网卡 内存2.5G Swap为内存的2倍
VMware virtual Ethernet adapter 1 192.168.10网段
VMware virtual Ethernet adapter 8 172.10.10 网段
详细信息如下图所示
1.IP规划
###eth0 public ip
192.168.10.10 rac1
192.168.10.20 rac2
###eth1 private ip
172.10.10.10 rac1-priv
172.10.10.20 rac2-priv
###virtual ip
192.168.10.110 rac1-vip
192.168.10.120 rac2-vip
###scan ip
192.168.10.100 rac-scan
/etc/hosts文件编辑,添加以下内容,如图所示
2.修改shm的大小
编辑 /etc/fstab 添加如下一行(根据主机内存进行修改,这里是3G)
shmfs /dev/shm tmpfs size=3g 0
3.关闭服务
两个节点均进行操作
[root@localhost~]# chkconfig iptables off
[root@localhost~]# chkconfig ip6tables off
[root@localhost ~]# chkconfig postfix off
如图所示
4.软件包安装检查
执行以下命令检查所需的包是否安装
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE}(%{ARCH})\n' binutils \
compat-libstdc++- \
compat-libstdc++- \
elfutils-libelf- \
elfutils-libelf-devel \
gcc \
gcc-c++ \
glibc \
glibc \
glibc-common \
glibc-devel \
glibc-devel \
glibc-headers \
ksh \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
numactl-devel \
sysstat
5.配置本地yum安装软件包
两个节点均进行操作
编辑/etc/yum.repos.d/local.repo,添加以下内容
[local]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0
mount /dev/sr0 /mnt/ 挂载光盘,安装所需的包
选择上一步检查未安装的包,使用yum安装
yum install binutils* compat-libstdc* elfutils-libelf* gcc*glibc* ksh* libaio* libgcc* libstdc* make* numactl-devel* sysstat* compat*elfutils* unix* libXp* -y
6.创建用户、组
两个节点均需要做
groupadd oinstall
groupadd dba
groupadd oper
groupadd asmadmin
groupadd asmdba
groupadd asmoper
useradd -g oinstall -Gdba,asmdba,asmadmin,asmoper grid
useradd -g oinstall -G dba,oper,asmdba oracle
echo -n oracle|passwd --stdin grid
echo -n oracle|passwd --stdin oracle
7.创建软件安装目录并赋予权限
目录规划:
Oracle Base 目录 :/oracle/db
Grid Base 目录:/oracle/grid
Grid Home 目录:/oracle/asm
创建目录
mkdir -p /oracle
mkdir -p /oracle/db
mkdir -p /oracle/grid
mkdir -p /oracle/asm
赋予权限
chown -R grid.dba /oracle
chown -R grid.dba /oracle/asm
chown -R grid.dba /oracle/grid
chown -R oracle.dba /oracle/db
chmod -R 775 /oracle
8.修改系统内核参数
8.1编辑/etc/sysctl.conf文件中加入下列参数
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 5368709120
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 运行使其生效
8.2设置Shell Limits(系统资源限制)
在/etc/security/limits.conf文件中加入下面行
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
8.3修改安全限制
编辑/etc/pam.d/login文件,添加下列行
session required pam_limits.so
8.4修改/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
# source /etc/profile 运行使其生效
9.修改用户环境变量
9.1Grid 用户
修改节点1环境变量
# su – grid
$ vi .bash_profile
export ORACLE_BASE=/oracle/grid
export ORACLE_HOME=/oracle/asm
export ORACLE_SID=+ASM1
exportPATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
exportPATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib
export CLASSPATH
$ source .bash_profile 使其生效
修改节点2环境变量
# su – grid
$ vi .bash_profile
export ORACLE_BASE=/oracle/grid
export ORACLE_HOME=/oracle/asm
export ORACLE_SID=+ASM2
exportPATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
exportPATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib
export CLASSPATH
$ source .bash_profile 使其生效
9.2Oracle 用户
修改节点1环境变量
# su - oracle
$ vi .bash_profile
export ORACLE_BASE=/oracle/db
exportORACLE_HOME=$ORACLE_BASE/product/11.2
export ORACLE_SID=racdb1
exportPATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
exportPATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib
export CLASSPATH
$ source .bash_profile 使其生效
修改节点2环境变量
# su - oracle
$ vi .bash_profile
export ORACLE_BASE=/oracle/db
exportORACLE_HOME=$ORACLE_BASE/product/11.2
export ORACLE_SID=racdb2
exportPATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
exportPATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib
export CLASSPATH
$ source .bash_profile 使其生效
10配置互信
10.1Grid用户互信配置
节点1
[root@rac1 ~]# su – grid
[grid@rac1 ~]$ ssh-keygen -t rsa
[grid@rac1 ~]$ ssh-keygen -t dsa
节点2
[root@rac2 ~]# su – grid
[grid@rac2 ~]$ ssh-keygen -t rsa
[grid@rac1 ~]$ ssh-keygen -t dsa
节点1
[grid@rac1 ~]$ cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys
[grid@rac1 ~]$ sshgrid@rac2 cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys
节点2
[grid@rac2 ~]$ cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys
[grid@rac2 ~]$ ssh grid@rac1 cat ~/.ssh/*.pub >>~/.ssh/authorized_keys
检验 在节点1节点2同时执行以下操作
$ssh rac1 date
$ssh rac1-priv date
$ssh rac2 date
$ssh rac2-priv date
10.2oracle用户互信配置
节点1
[root@rac1 ~]# su - oracle
[oracle@rac1 ~]$ ssh-keygen -t rsa
[oracle@rac1 ~]$ ssh-keygen -t dsa
节点2
[root@rac2 ~]# su - oracle
[oracle@rac2 ~]$ ssh-keygen -t rsa
[oracle@rac2 ~]$ ssh-keygen -t dsa
节点1
[oracle@rac1 ~]$ cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys
[oracle@rac1 ~]$ ssh oracle@rac2 cat ~/.ssh/*.pub >>~/.ssh/authorized_keys
节点2
[oracle@rac2 ~]$ cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys
[oracle@rac2 ~]$ ssh oracle@rac1 cat ~/.ssh/*.pub >>~/.ssh/authorized_keys
检验 在节点1节点2同时执行以下操作
$ssh rac1 date
$ssh rac1-priv date
$ssh rac2 date
$ssh rac2-priv date
11.创建共享磁盘
本次使用的是VMware,使用以下操作方法创建共享磁盘
D:\>cd D:\soft\VMware
D:\soft\VMware>
D:\soft\VMware>vmware-vdiskmanager.exe -c -s 2g -a lsilogic -t 2E:\vm\sharedisk
\ocr_vote.vmdk
D:\soft\VMware>vmware-vdiskmanager.exe -c -s 5g -a lsilogic -t 2E:\vm\sharedisk
\oradata.vmdk
关闭两台虚拟机
编辑虚拟机配置文件,添加刚刚创建的共享磁盘信息,修改.vmx的文件,添加以下内容 两个文件都要添加
###add by mjt
#shared disks configure
disk.locking = "FALSE"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize ="0"
diskLib.dataCacheMinReadAheadSize ="0"
diskLib.maxUnsyncedWrites = "0"
scsi1.present = "TRUE"
scsi1.virtualDev = "lsilogic"
scsil.sharedBus = "VIRTUAL"
scsi1:0.present = "TRUE"
scsi1:0.mode ="independent-persistent"
scsi1:0.fileName ="E:\vm\sharedisk\ocr_vote.vmdk"
scsi1:0.deviceType = "disk"
scsi1:0.redo = ""
scsi1:1.present = "TRUE"
scsi1:1.mode ="independent-persistent"
scsi1:1.fileName ="E:\vm\sharedisk\oradata.vmdk"
scsi1:1.deviceType = "disk"
scsi1:1.redo = ""
保存之后打开虚拟机看见的是下列状态
确保两台机器都均是这种状态 打开虚拟机进行磁盘的格式化等操作
查看两个节点中服务器识别状态
[root@rac1 ~]# fdisk /dev/sdb
[root@rac1 ~]# fdisk /dev/sdc
[root@rac1 ~]# fdisk -l /dev/sdb
[root@rac1 ~]# fdisk -l /dev/sdc
[root@rac1 ~]# partprobe
节点2
[root@rac2 ~]# fdisk -l /dev/sdb
[root@rac2 ~]# fdisk -l /dev/sdc
两个节点均要操作
映射到裸设备
修改/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"
KERNEL=="raw*",OWNER="grid",GROUP="dba",MODE="660"
两个节点均要操作
[root@rac1 ~]# partprobe
[root@rac1 ~]# start_udev
[root@rac1 ~]# ls -l /dev/raw/
软件安装部分
12.介质上传
p10404530_112030_Linux-x86-64_1of7.zip
p10404530_112030_Linux-x86-64_2of7.zip
p10404530_112030_Linux-x86-64_3of7.zip
[root@rac1 ~]# mkdir /soft
[root@rac1 ~]# chown -R grid.dba /soft/
使用grid用户上传
cluster安装
[grid@rac1 soft]$ cd grid/
$ unzip p10404530_112030_Linux-x86-64_3of7.zip
[root@rac1 ~]# cd /soft/grid/rpm
[root@rac1 rpm]# rpm -ivh cvuqdisk-1.0.9-1.rpm
[root@rac1 rpm]# scp cvuqdisk-1.0.9-1.rpm rac2:/tmp
[root@rac2 ~]# rpm -ivh /tmp/cvuqdisk-1.0.9-1.rpm
[grid@rac1 grid]$ ./runInstaller
12.1跳过软件更新
选择Install and Configure GridInfrastructure for a Cluster,点击“Next”
选择Advanced Installation,点击“Next”
添加简体中文,Simplified Chinese,点击“Next”
添加节点2的信息,名字和虚拟ip都是在hosts中配置的
此处就不需要再配置ssh互信了,之前已经做过配置,如果前面没有配置,此处可以进行配置,10G之前没有此选项
12.7配置网络接口
查看是否正常
可能会提示密码强度不够,点击yes即可,next
选择dba组,出现提示,忽略即可
查看是否是环境变量中设置的路径
不影响安装,点击next
12.17总体信息检查
检查相关配置信息是否正确
使用root用户执行以下两个脚本
节点1
[root@rac1 ~]#/oracle/oraInventory/orainstRoot.sh
Changing permissions of/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions forworld.
Changing groupname of /oracle/oraInventoryto oinstall.
The execution of the script is complete.
节点2
[root@rac2 ~]#/oracle/oraInventory/orainstRoot.sh
Changing permissions of/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions forworld.
Changing groupname of /oracle/oraInventoryto oinstall.
The execution of the script is complete.
节点1
[root@rac1 ~]# /oracle/asm/root.sh
Performing root user operation for Oracle11g
The following environment variables are setas:
ORACLE_OWNER= grid
ORACLE_HOME= /oracle/asm
Enter the full pathname of the local bindirectory: [/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/oratabfile as needed by
Database Configuration Assistant when adatabase is created
Finished running generic part of rootscript.
Now product-specific root actions will beperformed.
Using configuration parameter file:/oracle/asm/crs/install/crsconfig_params
Creating trace directory
User ignored Prerequisites duringinstallation
OLR initialization - successful
rootwallet
rootwallet cert
rootcert export
peerwallet
profile reader wallet
pawallet
peerwallet keys
pawallet keys
peercert request
pacert request
peercert
pacert
peerroot cert TP
profile reader root cert TP
paroot cert TP
peerpa cert TP
papeer cert TP
profile reader pa cert TP
profile reader peer cert TP
peeruser cert
pauser 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.cssdmonitor' on'rac1' succeeded
CRS-2676: Start of 'ora.gipcd' 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 asmcrs 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 disk60d9d4acbefa4f35bfcac5961d035393.
Successfully replaced voting disk group with+asmcrs.
CRS-4256: Updating the profile
CRS-4266: Voting file(s) successfullyreplaced
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1.ONLINE 60d9d4acbefa4f35bfcac5961d035393(/dev/raw/raw1) [ASMCRS]
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.ASMCRS.dg' on 'rac1'
CRS-2676: Start of 'ora.ASMCRS.dg' on 'rac1'succeeded
Configure Oracle GridInfrastructure for a Cluster ... succeeded
节点2
[root@rac2 ~]# /oracle/asm/root.sh
Performing root user operation for Oracle11g
The following environment variables are setas:
ORACLE_OWNER= grid
ORACLE_HOME= /oracle/asm
Enter the full pathname of the local bindirectory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copyingcoraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratabfile as needed by
Database Configuration Assistant when adatabase is created
Finished running generic part of rootscript.
Now product-specific root actions will beperformed.
Using configuration parameter file:/oracle/asm/crs/install/crsconfig_params
Creating trace directory
User ignored Prerequisites duringinstallation
OLR initialization - successful
Adding Clusterware entries to upstart
CRS-4402: The CSS daemon was started inexclusive mode but found an active CSS daemon on node rac1, number 1, and isterminating
An active cluster was found during exclusivestartup, restarting to join the cluster
Configure Oracle GridInfrastructure for a Cluster ... succeeded
遇见以下错误,是正常的,是因为在hosts文件中存在有scan ip,只要两个节点可以ping同scan的ip即可
13安装数据库软件
rdbms的安装
[oracle@rac1 ~]$ unzipp10404530_112030_Linux-x86-64_1of7.zip
[oracle@rac1 ~]$ unzipp10404530_112030_Linux-x86-64_2of7.zip
[oracle@rac1 ~]$ cd database/
[oracle@rac1 database]$ ./runInstaller
13.1取消技术支持
选择Oracle Real Application Clusters database installation
查看是否和oracle用户环境变量中配置的相同
均选择dba组
13.8执行配置脚本
使用root用户执行以下脚本
/oracle/db/product/11.2/root.sh
节点1
[root@rac1 ~]#/oracle/db/product/11.2/root.sh
Performing root user operation for Oracle11g
The following environment variables are setas:
ORACLE_OWNER= oracle
ORACLE_HOME= /oracle/db/product/11.2
Enter the full pathname of the local bindirectory: [/usr/local/bin]:
The contents of "dbhome" have notchanged. No need to overwrite.
The contents of "oraenv" have notchanged. No need to overwrite.
The contents of "coraenv" have notchanged. No need to overwrite.
Entries will be added to the /etc/oratabfile as needed by
Database Configuration Assistant when adatabase is created
Finished running generic part of rootscript.
Now product-specific root actions will beperformed.
Finished product-specific root actions.
[root@rac1 ~]#
节点2
[root@rac2 ~]#/oracle/db/product/11.2/root.sh
Performing root user operation for Oracle11g
The following environment variables are setas:
ORACLE_OWNER= oracle
ORACLE_HOME= /oracle/db/product/11.2
Enter the full pathname of the local bindirectory: [/usr/local/bin]:
The contents of "dbhome" have notchanged. No need to overwrite.
The contents of "oraenv" have notchanged. No need to overwrite.
The contents of "coraenv" have notchanged. No need to overwrite.
Entries will be added to the /etc/oratabfile as needed by
Database Configuration Assistant when adatabase is created
Finished running generic part of rootscript.
Now product-specific root actions will beperformed.
Finished product-specific root actions.
[root@rac2 ~]#
安装完成
14.1diskgroup创建
[root@rac1 ~]# su - grid
[grid@rac1 ~]$ asmca
选择“Disk Groups”选项,点击“Create”按钮创建ASM磁盘组,磁盘组名为DATADG1,完成后点击exit
14.2使用oracle用户创建数据库
[oracle@rac1 ~]$ dbca
可能会提示强度不够,忽略即可
本次根据内存2.5G进行配置
14.14完成安装
14.15检查集群状态
[grid@rac1 ~]$ crs_stat -t Name Type Target State Host ------------------------------------------------------------ ora.ASMCRS.dg ora....up.type ONLINE ONLINE rac1 ora.DATADG1.dg ora....up.type ONLINE ONLINE rac1 ora....ER.lsnr ora....er.type ONLINE ONLINE rac1 ora....N1.lsnr ora....er.type ONLINE ONLINE rac1 ora.asm ora.asm.type ONLINE ONLINE rac1 ora.cvu ora.cvu.type ONLINE ONLINE rac2 ora.gsd ora.gsd.type OFFLINE OFFLINE ora....network ora....rk.type ONLINE ONLINE rac1 ora.oc4j ora.oc4j.type ONLINE ONLINE rac2 ora.ons ora.ons.type ONLINE ONLINE rac1 ora....SM1.asm application ONLINE ONLINE rac1 ora....C1.lsnr application ONLINE ONLINE rac1 ora.rac1.gsd application OFFLINE OFFLINE ora.rac1.ons application ONLINE ONLINE rac1 ora.rac1.vip ora....t1.type ONLINE ONLINE rac1 ora....SM2.asm application ONLINE ONLINE rac2 ora....C2.lsnr application ONLINE ONLINE rac2 ora.rac2.gsd application OFFLINE OFFLINE ora.rac2.ons application ONLINE ONLINE rac2 ora.rac2.vip ora....t1.type ONLINE ONLINE rac2 ora.racdb.db ora....se.type ONLINE ONLINE rac1 ora.scan1.vip ora....ip.type ONLINE ONLINE rac1 [grid@rac1 ~]$
数据库连接
[oracle@rac1 ~]$ sqlplus system/oracle@racdb SQL*Plus: Release 11.2.0.3.0 Production on Sat Oct 10 18:17:30 2015 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> [oracle@rac2 ~]$ sqlplus system/oracle@racdb SQL*Plus: Release 11.2.0.3.0 Production on Sat Oct 10 18:17:43 2015 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL>
至此,所有的安装完成,后续的操作下次继续。。。