分类: LINUX
2017-03-29 23:47:12
一. 介绍
1.1 11gR2 Grid架构的新概念
【SCAN】
SCAN(single client access name)是所有客户端连接到集群的地址。SCAN名字是在DNS(domain name service)或GNS(grid name service)中注册到三个IP地址的域名,当从集群中添加或者移除节点时,不再需要修改客户端。客户端也可是使用EZCONNECT和SCAN名字访问集群。
SCAN必须和集群中所有节点的VIP地址在相同的子网内,在你企业网络中,SCAN域名必须是唯一的。
【GNS】
在过去,主机名,VIP名字和地址是在DNS或hosts文件中定义的,GNS可以使用DHCP进行简单的安装配置。要使用GNS,DHCP必须配置在集群所在的子域。
【OCR和Voting在ASM存储中】
在10g中,OCR和Voting需要配置在裸设备上,11gR2架构中,OCR和Voting磁盘配置在ASM磁盘组中,是11gR2的新特性。当然,如果从11gR1升级到11gR2,OCR和Voting还可以继续使用裸设备(也可以使用命令行方式使用裸设备,不推荐)。
【无密码自动SSH连接(等效性)】
11gR2中,你可以在OUI中配置SSH等效性,而不用手动进行配置。
【IPMI(Intelligent
Platform Management Interface智能平台管理接口)】
IPMI提供了一套计算机硬件和固件通用的接口,管理员可以使用它监控系统健康和管理系统。
在Oracle Database
11gR2中,集群可以使用IPMI提供故障隔离,实现系统的完整性。IPMI详细信息,请参阅相关文档。
【时间同步】
Oracle集群部署需要所有节点时间同步,以前要实现该功能,需要配置操作系统的 NTP (network time protocol)服务。在11.2中,当无法访问NTP服务时,oracle提供了一种CTS(Cluster
Time Synchronization)服务,可以实现节点间时间同步(需保证节点NTP服务关闭,及无配置文件存在,该服务才会在自动启动)。
【Clusterware和ASM共享Oracle Home】
Clusterware和ASM共享的目录被成为Grid Infratructure目录
【Hangchecktimer和oprocd被替换】
Oracle Clusterware使用cluster synchronization service守护进程代理和监控提供更准确的hangs识别,取代hangchecktimer和oprocd进程,以避免错误的终止。
【Rebootless
Restart】
11gR2中,Fencing机制做了改变。Oracle clusterware的目标是无需重启节点实现节点驱逐。CSSD发现失败后启动正常关闭机制。此后OHASD将尝试重启stack。仅当清理失败时,才会重新启动以进行强制清理
【HAIP】
11gR2中,新HAIP(冗余互联)是可用的,多接口选择支持负载均衡和容错。
1.2 系统需要(节点一、节点二配置均相同)
硬件需要
1) 至少1.5G物理内存
2) 至少1GB临时空间可用/tmp
3) 至少4.5GB可用的磁盘空间安装Grid Infrastructure家目录
4) 至少4GB可用的磁盘空间安装Oracle Database家目录
5) 每个OCR和VOTING磁盘至少300MB空间
6) 至少2GB共享磁盘空间:包含所以数据文件,控制文件,日志文件,Spfile等
7) 每个节点至少两个网络接口
8) 所有节点public,private接口名字必须相同,如一个节点public使用eth0,则另外一个节点的public接口也必须使用eth0
9) Public接口必须支持TCP/IP,Private接口必须支持UDP
10) 每个节点一个public IP,一个virtual IP(VIP),一个private IP,一个或三个SCAN地址
1.3 需要的RPM包
binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
compat-libstdc++-33-3.2.3 (32 bit)
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
gcc-4.1.2
gcc-c++-4.1.2
glibc-2.5-24
glibc-2.5-24 (32 bit)
glibc-common-2.5
glibc-devel-2.5
glibc-devel-2.5 (32 bit)
glibc-headers-2.5
ksh-20060214
libaio-0.3.106
libaio-0.3.106 (32 bit)
libaio-devel-0.3.106
libaio-devel-0.3.106 (32 bit)
libgcc-4.1.2
libgcc-4.1.2 (32 bit)
libstdc++-4.1.2
libstdc++-4.1.2 (32 bit)
libstdc++-devel 4.1.2
make-3.81
sysstat-7.0.2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--注释
可以使用以下脚本验证是否安装了所需的软件(注意空格)
rpm -q --qf
'%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils \compat-libstdc++-33
\elfutils-libelf
\elfutils-libelf-devel
\gcc \gcc-c++ \glibc \glibc-common \glibc-devel \glibc-headers \ksh \libaio \libaio-devel \libgcc \libstdc++ \libstdc++-devel
\make \sysstat \
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1.4 本地yum源的搭建
1.创建yum源的目录 mkdir -R /web/yum
2.拷贝IOS文件到/web/yum目录下
cp -R /media/RHEL_6.5\ x86_64\ Disc\ 1/* /web/yum/
或者直接挂载:mount -o loop Red\ Hat\ Enterprise\ 6.5\ x86_64.iso /web/yum
3.创建yum的配置文件
[root@oranode1 yum]# cd /etc/yum.repos.d/
[root@oranode1 yum.repos.d]# ll
total 4
-rw-r--r--. 1 root root 529 Oct 30 2013 rhel-source.repo
[root@oranode1 yum.repos.d]# mv rhel-source.repo rhel-source.repo.bak
[root@oranode1 yum.repos.d]# vi rhel6.repo
[rhel6]
name=rhel6
baseurl=file:///web/yum
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@oranode1 yum.repos.d]# sed -i
"s#remote = url + '/' + relative#remote = '/web/yum' + '/' +
relative#g" /usr/lib/python2.6/site-packages/yum/yumRepo.py
4.导入RPM的签名信息
[root@ oranode1 yum.repos.d]# rpm --import
/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
1.5 所需软件
p10404530_112040_Linux-x86-64_1of7.zip
p10404530_112040_Linux-x86-64_2of7.zip
p10404530_112040_Linux-x86-64_3of7.zip
前两个为11.2.0.4的数据库软件,第三个为11.2.0.4的grid软件,也就是clusterware软件
二. Oracle
Rac集群节点准备
|
节点1 |
节点2 |
主机名 |
oranode1 |
oranode2 |
网卡eth0(public) |
10.211.55.40 |
10.211.55.42 |
网卡eth1(priv) |
192.168.1.111 |
192.168.1.112 |
Vip |
10.211.55.41 |
10.211.55.43 |
SCAN-IP |
10.211.55.202 |
注意:Public网卡的网段和Priv的网段不能在同一个网段,否则,安装期间无法跳过下一步。
/etc/hosts下文件配置,以Node1为例:
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
10.211.55.40 node1
10.211.55.42 node2
192.168.1.111 node1-priv
192.168.1.112 node2-priv
10.211.55.41 node1-vip
10.211.55.43 node2-vip
10.211.55.202 rac-cluster rac-cluster-scan
[root@oranode1 ~]# groupadd asmadmin
[root@oranode1 ~]# groupadd asmdba
[root@oranode1 ~]# groupadd asmoper
[root@oranode1 ~]# groupadd oinstall
[root@oranode1 ~]# groupadd dba
[root@oranode1 ~]# groupadd oper
[root@oranode1 ~]# useradd -g oinstall -G asmadmin,asmdba,asmoper grid
[root@oranode1 ~]# useradd -g oinstall -G dba,asmdba oracle
[root@oranode1 ~]# passwd oracle
[root@oranode1 ~]# passwd grid
[root@oranode1 ~]# mkdir /u01/app
[root@oranode1 ~]# chown -R grid.oinstall /u01
[root@oranode1 ~]# mkdir /u01/app/oracle
[root@oranode1 ~]# chown -R oracle.oinstall /u01/app/oracle
# vim /etc/ntp.conf
注释配置文件中以下默认开启的两行
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
打开配置文件中以下配置,并根据具体情况进行修改
restrict 10.211.55.0 mask 255.255.255.0 nomodify notrap
#service ntpd restart
#ntpq -p --查看刚刚的配置信息
--节点2上配置
# vim /etc/ntp.conf
注释配置文件中以下默认开启的两行
server 10.211.55.40 prefer ---具体根据实际IP
#service ntpd restart
#service ntpd
restart
2.4 配置内核参数
#
/etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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 --使刚刚配置的内核参数立即生效
# /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
#
/etc/pam.d/login
session required
pam_limits.so
2.5 禁用IPTABLES和SELINUX
#
/etc/selinux/config
SELINUX=disabled"
# chkconfig iptables off
# chkconfig
ip6tables off
文件类别 |
本地文件系统 |
Raw |
ASM |
Clusterware |
$CRS_HOME |
|
|
ORC & VoteDisk |
|
/dev/raw/raw1,raw2 |
|
Database software |
$ORACLE_HOME |
|
|
Spfile |
|
|
+DATA |
Datafile,controlfile |
|
|
+DATA |
Redolog,archived Log |
|
|
+DATA |
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xfccfd0e6.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-3916, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-3916, default 3916): +1G
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (133-3916, default 133): +1G
Value out of range.
First cylinder (133-3916, default 133):
Using default value 133
Last cylinder, +cylinders or +size{K,M,G} (133-3916, default 3916): +1G
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (265-3916, default 265):
Using default value 265
Last cylinder, +cylinders or +size{K,M,G} (265-3916, default 3916):
Using default value 3916
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@oranode1 ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ae4be
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 1938 15360000 83 Linux
/dev/sda3 1938 2461 4194304 82 Linux swap / Solaris
/dev/sda4 2461 5222 22182912 5 Extended
/dev/sda5 2461 5222 22181888 83 Linux
Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfccfd0e6
Device Boot Start End Blocks Id System
/dev/sdb1 1 132 1060258+ 83 Linux
/dev/sdb2 133 264 1060290 83 Linux
/dev/sdb3 265 3916
29334690 83 Linux
#节点二上使用df -h 命令查看的结果应该一致
本次使用udev的方式绑定划分的磁盘使用裸设备,并赋予权限,供OCR,VOTEDISK,ASM使用(Asmlib的方式本次不做说明,如有需要请查看官方文档)
[root@oranode1 ~]# vim /etc/udev/rules.d/60-raw.rules
ACTION=="add",KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add",KERNEL=="sdb2", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add",KERNEL=="sdb3", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add",KERNEL=="raw[1-3]",OWNER="grid",GROUP="asmadmin",MODE="660"
#节点一
[root@oranode1 ~]# start_udev
Starting udev: [ OK ]
[root@oranode1 ~]# ll /dev/raw/raw*
crw-rw---- 1 grid asmadmin 162, 1 May 6 14:23 /dev/raw/raw1
crw-rw---- 1 grid asmadmin 162, 2 May 6 14:23 /dev/raw/raw2
crw-rw---- 1 grid asmadmin 162, 3 May 6 14:23 /dev/raw/raw3
crw-rw---- 1 root disk 162, 0 May 6 14:23 /dev/raw/rawctl
#节点二
[root@oranode2 ~]# start_udev
Starting udev: [ OK ]
[root@oranode2 ~]# ll /dev/raw/raw*
crw-rw---- 1 grid asmadmin 162, 1 May 6 14:23 /dev/raw/raw1
crw-rw---- 1 grid asmadmin 162, 2 May 6 14:23 /dev/raw/raw2
crw-rw---- 1 grid asmadmin 162, 3 May 6 14:23 /dev/raw/raw3
crw-rw---- 1
root disk 162, 0 May 6 14:23 /dev/raw/rawctl
3.2 使用yum的方式补全rpm包
#节点一
[root@oranode1 yum]# yum install -y binutils compat-libstdc++ compat-libstdc++ elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat
#节点二
[root@oranode2 ~]# yum install -y binutils compat-libstdc++ compat-libstdc++ elfutils-libelf
elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers
ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat
3.3 配置使用Xmanager远程连接rhel 6进行图形化安装
#节点一,节点二同时处理
[root@oranode2 ~]# vim /etc/gdm/custom.conf
# GDM configuration storage
[daemon]
[security]
AllowRemoteRoot=true
[xdmcp]
Port=177
Enable=1
[greeter]
[chooser]
[debug]
[root@oranode2 ~]# init 3
[root@oranode2 ~]# init 5
四、开始安装Oracle
grid
3.1设置环境变量
#注意节点二上的ORACLE_SID设置,成员节点二上的ORACLE_SID=+ASM2
export ORACLE_SID=+ASM1
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export PATH
3.2开始图形化安装
[root@oranode1 ~]# xhost +
[root@oranode1 ~]# su - grid
[grid@oranode1 ~]$ cd grid/
[grid@oranode1 clusterware]$ ./runInstaller
#注意,一定是要在grid用户下安装集群软件
[root@oranode1 grid]# rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm
warning: pdksh-5.2.14-37.el5_8.1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID e8562897: NOKEY
error: Failed dependencies:
pdksh conflicts
with ksh-20120801-10.el6.x86_64
#卸载安装的ksh-20120801-10.el6.x86_64 rpm包
[root@oranode2 home]# rpm -e ksh-20120801-10.el6.x86_64
#Yum安装pdksh-5.2.14
[root@oranode2 home]# yum --nogpgcheck localinstall pdksh-5.2.14-37.el5_8.1.x86_64.rpm
#再次Check Again之后pdksh已经成功。
#关于NTP服务的检查
[root@oranode1 rpm]# service ntpd stop
Shutting down ntpd: [ OK ]
[root@oranode1
rpm]# mv /etc/ntp.conf /etc/ntp.conf.bak
#生产环境不建议此操作,尽量保证采用时间同步设备进行时间同步
#确认没有问题后,点击Ignore
All进行下一步安装
[root@oranode1 ~]# /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@oranode1 ~]# /u01/app/11.2.0/grid/root.sh
…..略
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 4bdcdb2f95554f56bf62ad029508ac7b (/dev/raw/raw1) [CLUSTER_DISK]
Located 1 voting disk(s).
CRS-2672: Attempting to start 'ora.asm' on 'oranode1'
CRS-2676: Start of 'ora.asm' on 'oranode1' succeeded
CRS-2672: Attempting to start 'ora.CLUSTER_DISK.dg' on 'oranode1'
CRS-2676: Start of 'ora.CLUSTER_DISK.dg' on 'oranode1' succeeded
Configure Oracle Grid Infrastructure for a Cluster ... succeeded
#执行完成后,安装程序会监听配置、ASMCA配置以及CVU的配置。CVU的配置验证可能会失败,可以忽略。
#在11gR2中,gsd服务已经废弃,保留的原因因向前兼容,可以忽略GSD的状态。
[grid@oranode1 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....DISK.dg ora....up.type ONLINE ONLINE oranode1
ora....ER.lsnr ora....er.type ONLINE ONLINE oranode1
ora....N1.lsnr ora....er.type ONLINE ONLINE oranode1
ora.asm ora.asm.type ONLINE ONLINE oranode1
ora.cvu ora.cvu.type ONLINE ONLINE oranode1
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE oranode1
ora.oc4j ora.oc4j.type ONLINE ONLINE oranode1
ora.ons ora.ons.type ONLINE ONLINE oranode1
ora....SM1.asm application ONLINE ONLINE oranode1
ora....E1.lsnr application ONLINE ONLINE oranode1
ora....de1.gsd application OFFLINE OFFLINE
ora....de1.ons application ONLINE ONLINE oranode1
ora....de1.vip ora....t1.type ONLINE ONLINE oranode1
ora....SM2.asm application ONLINE ONLINE oranode2
ora....E2.lsnr application ONLINE ONLINE oranode2
ora....de2.gsd application OFFLINE OFFLINE
ora....de2.ons application ONLINE ONLINE oranode2
ora....de2.vip ora....t1.type ONLINE ONLINE oranode2
ora....ry.acfs ora....fs.type ONLINE ONLINE oranode1
ora.scan1.vip ora....ip.type ONLINE ONLINE
oranode1
五、Oracle
Database软件安装
5.1设置Oracle用户环境变量
export PATH
export ORACLE_SID=orcl1
export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1/
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export PATH
#注意成员节点二上的ORACLE_SID的配置,成员节点二的ORACLE_SID=orcl2
5.2 开始图形化安装数据库软件
[root@oranode1 ~]# su – oracle
[oracle@oranode1 ~]$ cd database/
[oracle@oranode1
database]$ ./runInstaller
[root@oranode1 ~]# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
Performing root user operation for Oracle 11g
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The contents of "dbhome" have not changed. No need to overwrite.
The contents of "oraenv" have not changed. No need to overwrite.
The contents of "coraenv" have not changed. No need to overwrite.
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.
Finished
product-specific root actions.
#注意执行顺序,两个成员节点均要执行。
#执行完成点击OK。退出图形化安装程序,数据库软件安装成功。
[root@oranode1 ~]# su – grid
[grid@oranode1
~]$ asmca
[oracle@oranode1
~]$ dbca
[grid@oranode2 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....DISK.dg ora....up.type ONLINE ONLINE oranode1
ora.DATA.dg ora....up.type ONLINE ONLINE oranode1
ora....ER.lsnr ora....er.type ONLINE ONLINE oranode1
ora....N1.lsnr ora....er.type ONLINE ONLINE oranode1
ora.asm ora.asm.type ONLINE ONLINE oranode1
ora.cvu ora.cvu.type ONLINE ONLINE oranode2
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE oranode1
ora.oc4j ora.oc4j.type ONLINE ONLINE oranode2
ora.ons ora.ons.type ONLINE ONLINE oranode1
ora....SM1.asm application ONLINE ONLINE oranode1
ora....E1.lsnr application ONLINE ONLINE oranode1
ora....de1.gsd application OFFLINE OFFLINE
ora....de1.ons application ONLINE ONLINE oranode1
ora....de1.vip ora....t1.type ONLINE ONLINE oranode1
ora....SM2.asm application ONLINE ONLINE oranode2
ora....E2.lsnr application ONLINE ONLINE oranode2
ora....de2.gsd application OFFLINE OFFLINE
ora....de2.ons application ONLINE ONLINE oranode2
ora....de2.vip ora....t1.type ONLINE ONLINE oranode2
ora.orcl.db ora....se.type ONLINE ONLINE oranode1
ora....ry.acfs ora....fs.type ONLINE ONLINE oranode1
ora.scan1.vip ora....ip.type ONLINE ONLINE
oranode1
验证
[root@oranode2 ~]# su - oracle
sql^H[oracle@oranode2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Mon May 9 10:38:36 2016
Copyright (c)
1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and
Real Application Testing options
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE