CentOS 7.2安装Oracle 12c RAC
CentOS 7.2安装Oracle 12c RAC
一、基础结构:
二、存储规划:
1、GRID集群组件磁盘组
+dggrid: 1个,由三个10G磁盘组成normal
2、数据库安装磁盘组
+dgsystem:用于数据库基本表空间,控制文件,参数文件等
+dgrecovery:用于归档与闪回日志空间
+dgdata:用户数据库业务表空间
三、IP规划:
oraclenode1:
publicip : bond0 :192.168.10.103
vip:192.168.10.105
privateip :bond2 :192.168.14.3
oraclenode2:
publicip : bond0 :192.168.10.104
vip:192.168.10.106
privateip :bond2 :192.168.14.4
scanip :192.168.10.107
四、软件版本:
操作系统:CentOS 7.2
数据库:ORACLE12c R1
集群管理软件:ORACLEGRID 12.0.1.2
五、系统环境配置:
注意:如下配置除非特别说明,否则两个节点都需要操作
1、安装软件依赖
yum -y install binutilscompat-libcap1 compat-libstdc++-33 compat-libstdc++-33.i686 gcc gcc-c++ glibc glibc.i686 glibc-develglibc-devel.i686 ksh libgcc libgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel libstdc++-devel.i686 libaiolibaio.i686 libaio-devel libaio-devel.i686 libXext libXext.i686 libXtst libXtst.i686 libX11libX11.i686 libXau libXau.i686 libxcb libxcb.i686 libXi libXi.i686 make sysstat unixODBCunixODBC-devel readline libtermcap-devel pdksh
2、修改host文件
#在两台主机修改host文件,添加如下内容:
vim /etc/hosts
#public ip bond0
192.168.10.103 oraclenode1
192.168.10.104 oraclenode2
#private ip bond2
192.168.14.3 oraclenode1pri
192.168.14.4 oraclenode2pri
#vip ip
192.168.10.105 oraclenode1vip
192.168.10.106 oraclenode2vip
#scan ip
192.168.10.107 oraclenodescan
3、关闭selinux和配置防火墙
setenforce 0
firewall-cmd --set-defaults-zone=trusted
4、添加组与用户
#在两个节点增加用户与组:
groupadd -g 60001 oinstall
groupadd -g 60002 dba
groupadd -g 60003 oper
groupadd -g 60004 backupdba
groupadd -g 60005 dgdba
groupadd -g 60006 kmdba
groupadd -g 60007 asmdba
groupadd -g 60008 asmoper
groupadd -g 60009 asmadmin
useradd -u 61001 -g oinstall -G asmadmin,asmdba,dba,asmoper grid
useradd -u 61002 -g oinstall -G dba,backupdba,dgdba,kmdba,asmadmin,oper,asmdba oracle
echo "grid" | passwd --stdin grid
echo "oracle" | passwd --stdin oracle
5、添加目录
mkdir -p /data/oracle/app/grid
mkdir -p /data/oracle/app/12.1.0.2/grid
chown -R grid:oinstall /data/oracle
mkdir -p /data/oracle/app/oraInventory
chown -R grid:oinstall /data/oracle/app/oraInventory
mkdir -p /data/oracle/app/oracle
chown -R oracle:oinstall /data/oracle/app/oracle
chmod -R 775 /data/oracle
6、修改操作系统参数
vim/etc/security/limits.conf
#ORACLE SETTING
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
vim/etc/security/limits.d/20-nproc.conf
# Change this
* soft nproc 1024
# To this
* - nproc 16384
vim/etc/pam.d/login
#ORACLE SETTING
session required pam_limits.so
MEMTOTAL=$(free -b | sed -n '2p' | awk '{print $2}')
SHMMAX=$(expr $MEMTOTAL \*4 / 5)
SHMMNI=4096
SHMALL=$(expr $MEMTOTAL /\( 4 \* 1024 \))
cp /etc/sysctl.conf /etc/sysctl.conf.bak
cat >> /etc/sysctl.conf << EOF
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmax = $SHMMAX
kernel.shmall = $SHMALL
kernel.shmmni = $SHMMNI
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 = 1048576
kernel.panic_on_oops = 1
EOF
# kernel.shmmax大于共享内存区,小于物理内存
# kernel.shmall物理内存/4K
让配置生效:
sysctl –p
#使用centos 7.2 安装grid时,需要修改这个参数,不然会报错
vim /etc/systemd/logind.conf
RemoveIPC=no
systemctldaemon-reload
systemctlrestart systemcd-logind
7、配置用户环境变量
su - grid
#grid用户的环境变量如下:
vim~/.bash_profile
PS1="[`whoami`@`hostname`:"'$PWD]$'
export PS1
umask 022
export TMP=/tmp
exportLANG=en_US
export TMPDIR=$TMP
exportORACLE_HOSTNAME=oraclenode1
ORACLE_SID=+ASM1;export ORACLE_SID
ORACLE_TERM=xterm;export ORACLE_TERM
ORACLE_BASE=/data/oracle/app/grid;export ORACLE_BASE
ORACLE_HOME=/data/oracle/app/12.1.0.2/grid;export ORACLE_HOME
NLS_DATE_FORMAT="yyyy-mm-ddHH24:MI:SS"; export NLS_DATE_FORMAT
PATH=.:$PATH:$HOME/bin:$ORACLE_HOME/bin;export PATH
THREADS_FLAG=native;export THREADS_FLAG
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
su - oracle
#oracle用户的环境变量如下:
vim ~/.bash_profile
PS1="[`whoami`@`hostname`:"'$PWD]$'
export PS1
export TMP=/tmp
exportLANG=en_US
exportTMPDIR=$TMP
export ORACLE_HOSTNAME=oraclenode1
exportORACLE_UNQNAME=orcldb
ORACLE_BASE=/data/oracle/app/oracle;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.1.0.2/db_1;export ORACLE_HOME
ORACLE_SID=orcldb1;export ORACLE_SID
ORACLE_TERM=xterm;export ORACLE_TERM
NLS_DATE_FORMAT="yyyy-mm-ddHH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;exportNLS_LANG
PATH=.:$PATH:$HOME/bin:$ORACLE_BASE/product/12.1.0.2/db_1/bin:$ORACLE_HOME/bin;export PATH
THREADS_FLAG=native;export THREADS_FLAG
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
#节点二:
su - grid
#grid的环境变量
vim ~./bash_profile
PS1="[`whoami`@`hostname`:"'$PWD]$'
export PS1
umask 022
export TMP=/tmp
exportLANG=en_US
exportTMPDIR=$TMP
exportORACLE_HOSTNAME=oraclenode2
ORACLE_SID=+ASM2;export ORACLE_SID
ORACLE_TERM=xterm;export ORACLE_TERM
ORACLE_BASE=/data/oracle/app/grid;export ORACLE_BASE
ORACLE_HOME=/data/oracle/app/12.1.0.2/grid;export ORACLE_HOME
NLS_DATE_FORMAT="yyyy-mm-ddHH24:MI:SS"; export NLS_DATE_FORMAT
PATH=.:$PATH:$HOME/bin:$ORACLE_HOME/bin;export PATH
THREADS_FLAG=native;export THREADS_FLAG
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
su - oracle
vim~/.bash_profile
PS1="[`whoami`@`hostname`:"'$PWD]$'
export PS1
export TMP=/tmp
exportLANG=en_US
exportTMPDIR=$TMP
exportORACLE_HOSTNAME=oraclenode2
exportORACLE_UNQNAME=orcldb
ORACLE_BASE=/data/oracle/app/oracle;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.1.0.2/db_1;export ORACLE_HOME
ORACLE_SID=orcldb2;export ORACLE_SID
ORACLE_TERM=xterm;export ORACLE_TERM
NLS_DATE_FORMAT="yyyy-mm-ddHH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;exportNLS_LANG
PATH=.:$PATH:$HOME/bin:$ORACLE_BASE/product/12.1.0.2/db_1/bin:$ORACLE_HOME/bin;export PATH
THREADS_FLAG=native;export THREADS_FLAG
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、配置ssh无密登录(两节点)
su - grid
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub [email]grid@192.168.10.103[/email]
ssh-copy-id -i ~/.ssh/id_rsa.pub [email]grid@192.168.10.104[/email]
su - oracle
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub [email]oracle@192.168.10.103[/email]
ssh-copy-id -i ~/.ssh/id_rsa.pub [email]oracle@192.168.10.104[/email]
9、配置共享存储
存储划分以卷:
grid01 10G
grid02 10G
grid03 10G
system 300G
recovery 800G
data 4T
配置多路径wwid和别名:
前提:服务器已经连接到存储,并识别到LUN
a、配置/etc/multipath.conf文件
defaults {
polling_interval 10
path_selector "round-robin0"
path_grouping_policy multibus
prio alua
path_checker readsector0
rr_min_io 100
max_fds 8192
rr_weight priorities
failback immediate
no_path_retry fail
user_friendly_names yes
find_multipaths yes
}
blacklist {
devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
devnode "^sd[a]"
}
b、执行如下命令
modprobe dm-multipath
multipath -F
multipath dm-multipath
multipath dm-round-robin
执行完成上述命令之后,会在/etc/multipath目录下生成一个bindings这的一个文件,包含了存储的uuid和别名
mpatha 36000d310036222000000000000000003
mpathb 36000d310036222000000000000000004
mpathc 36000d310036222000000000000000008
mpathd 36000d310036222000000000000000007
mpathe 36000d310036222000000000000000006
mpathf 36000d310036222000000000000000005
mpathg 36000d310036222000000000000000009
c、修改别名方便识别
multipaths {
multipath {
wwid 36000d310036222000000000000000004
alias dgdata
path_grouping_policy multibus
}
multipath {
wwid 36000d310036222000000000000000005
alias dggrid1
path_grouping_policy multibus
}
multipath {
wwid 36000d310036222000000000000000006
alias dggrid2
path_grouping_policy multibus
}
multipath {
wwid 36000d310036222000000000000000009
alias dgrecovery
path_grouping_policy multibus
}
multipath {
wwid 36000d310036222000000000000000007
alias dggrid3
path_grouping_policy multibus
}
multipath {
wwid 36000d310036222000000000000000008
alias dgsystem
path_grouping_policy multibus
}
}
重启服务生效
systemctl reload multipath
d、修改udev权限
vim /etc/udev/rules/12-mulitpath-privs.rules
ENV{DM_NAME}=="dg*",OWNER:="grid",GROUP:="asmadmin",MODE:="660"
重启服务器生效,并检查重启后权限、别名是否正常
解压安装包
unzip linuxamd64_12102_grid_1of2.zip
unzip linuxamd64_12102_grid_2of2.zip
cd /soft/grid/rpm
export CVUQDISK_GRP=oinstall
rpm -ivh cvuqdisk-1.0.9-1.rpm
su - grid
./runcluvfy.shstage -pre crsinst -n Oraclenode1,oraclenode2 -fixup -verbose
./runcluvfy.sh stage-post hwos -n oraclenode1,oraclenode2 -verbose
#检查不通过的配置
11、安装grid
#远程调用图形界面安装vnc
./runInstaller
图形化界面安装,按照前面规划填写相关配置,值得注意的是硬盘位置需要修改:使用多路径修改为/dev/mapper/dg*
grid安装完成,使用crs_stat -t查看集群状态,使用ocrcheck、crsctl query css votedisk查看ocr磁盘状态
12、创建asm磁盘组
su - grid
asmca
#按照自己的规划,添加相应的磁盘组,并和存储卷关联
数据库软件的安装和实例创建,可以参考 http://www.linuxidc.com/Linux/2017-05/143564.htm 上的内容,集群的配置和单实例步骤基本上是一致的。