通过文件系统(NFS)搭建RAC

一、环境信息

1、服务器:Centos 6.9 x64
2、网卡:2个弹性网卡,3个havip
3、磁盘:软件放本地,Database和CRS、voting disk放NAS
4、共享文件系统(NFS):申请创建2个NAS文件系统

二、配置NAS

1、根据文档购买配置NAS

地址:
https://help.aliyun.com/document_detail/27526.html?spm=a2c4g.11186623.6.556.27c97442QMoIVR

①创建文件系统
②添加挂载点

2、挂载文件系统

a、安装NFS客户端

sudo yum install nfs-utils
cat /proc/sys/sunrpc/tcp_slot_table_entries  //查看

b、挂载NFS文件系统

① 创建挂载目录:
mkdir /oradata
mkdir /crs
② 挂载:
sudo mount -t nfs -o rw,bg,hard,vers=3,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 142504bf3e-rci86.cn-beijing.nas.aliyuncs.com:/ /crs --这里我是直接编辑fstab文件,之后mount -a挂载

注:
用NAS 4版本安装时报错:
Additional Information:
rac1:Mount options did not meet the requirements [Expected = >"rw,hard,rsize>=32768,wsize>=32768,proto=tcp|tcp,vers=3|nfsvers=3|nfsv3|v3,timeo>=600,acregmin=0&acregmax=0&acdirmin=0&acdirmax=0|actimeo=0" ; Found = "rw,relatime,vers=4,rsize=1048576,wsize=1048576,namlen=255,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,hard,noresvport,p> roto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.3.43,minorversion=0,local_lock=none,addr=192.168.3.45"]
The problem occurred on nodes:
rac2,rac1 Summary of the failed nodes rac2 rac1

③ 卸载:
umount /crs

c、挂载NAS文件系统时需要注意的一个地方

如果NAS直接挂载到根目录下是无法对这个挂载目录更改属主的,挂载目录下的子目录可以修改,这样在执行root.sh的时候就会报错:
[root@rac1 ~]# /u01/app/grid_home/root.sh
Performing root user operation for Oracle 11g 

The following environment variables are set as:
    ORACLE_OWNER= grid
    ORACLE_HOME=  /u01/app/grid_home

Enter the full pathname of the local bin directory: [/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/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.
Using configuration parameter file: /u01/app/grid_home/crs/install/crsconfig_params
Creating trace directory
User ignored Prerequisites during installation
Installing Trace File Analyzer
Can't change ownership of /crs: Operation not permitted
Filesystem of /crs/ocr is not supported
Root is not able to perform superuser operations on this filesystem
Check export options on NAS filer
/u01/app/grid_home/perl/bin/perl -I/u

需要对NAS操作:

①cd /crs    //此时NAS挂载到了/crs目录
②mkdir crs
   chown grid:oinstall crs
③重新配置配置fstab
147644b13d-rck75.cn-beijing.nas.aliyuncs.com:/crs /crs  nfs rw,bg,hard,nointr,nolock,vers=3,rsize=1048576,wsize=1048576,tcp,noac,hard,timeo=600,actimeo=0,retrans=2,_netdev,noresvport 0 0

d、linux自动挂载

配置/etc/fstab

142504bf3e-gam92.cn-beijing.nas.aliyuncs.com:/ /data  nfs rw,hard,vers=3,rsize=1048576,wsize=1048576,hard,timeo=600,actimeo=0,retrans=2,_netdev,noresvport 0 0   --这个不能修改挂载目录属主

147644b13d-rck75.cn-beijing.nas.aliyuncs.com:/crs /data  nfs rw,bg,hard,nointr,nolock,vers=3,rsize=1048576,wsize=1048576,tcp,noac,hard,timeo=600,actimeo=0,retrans=2,_netdev,noresvport 0 0
128a54b70b-coi12.cn-beijing.nas.aliyuncs.com:/data /oradata  nfs rw,bg,hard,nointr,nolock,vers=3,rsize=1048576,wsize=1048576,tcp,noac,hard,timeo=600,actimeo=0,retrans=2,_netdev,noresvport 0 0   --数据盘挂载需要加nolock参数

e、修改权限和属主

chown grid:oinstall -R /crs
chown oracle:oinstall -R /data
chmod 775 /crs
chmod 775 /data

三、安装数据库

1、下载安装包

2、创建用户

groupadd -g 500 oinstall
groupadd -g 501 asmadmin
groupadd -g 502 asmdba
groupadd -g 503 asmoper
groupadd -g 504 dba
groupadd -g 505 oper
useradd -g oinstall -G asmadmin,asmdba,asmoper,dba -u 500 grid
useradd -g oinstall -G asmdba,dba,oper -u 501 oracle
passwd oracle
passwd grid

3、创建目录

mkdir -p /u01/app/oracle/product/11.2.0/db_1
mkdir -p /u01/app/grid_base
mkdir -p /u01/app/grid_home
chmod -R 775 /u01
chown -R oracle:oinstall /u01
chown -R grid:oinstall /u01/app/grid_base
chown -R grid:oinstall /u01/app/grid_home

4、修改hosts文件

192.168.3.50 rac1
192.168.3.51 rac2
192.168.3.12 rac1-vip
192.168.3.13 rac2-vip
192.168.3.219 rac1-priv
192.168.3.220 rac2-priv
192.168.3.14 rac-scan

5、配置对等性

/software/grid/sshsetup/sshUserSetup.sh -user grid -hosts "rac1 rac2" - noPromptPassphrase -confirm -advanced

/software/database/sshsetup/sshUserSetup.sh -user oracle -hosts "rac1 rac2" - noPromptPassphrase -confirm -advanced

6、配置环境变量

#Grid
Vi .bash_profile
umask 022
ORACLE_BASE=/u01/app/grid_base
ORACLE_HOME=/u01/app/grid_home
ORACLE_SID=NFS1  //第二个节点NFS2
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
#Oracle
umask 022
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
ORACLE_SID=rac1
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:/usr/lib
#export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export TNS_ADMIN=$ORACLE_HOME/network/admin

#export NLS_LANG="simplified chinese"_china.al32utf8
#export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
#export NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SSXFF'
#export NLS_TIMESTAMP_TZ_FORMAT='YYYY-MM-DD HH24:MI:SSXFF TZR'
#alias sqlplus='rlwrap sqlplus'
#alias rman='rlwrap rman'

7、修改资源限制等信息

vi /etc/sysctl.conf

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4153692159
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


vi /etc/security/limits.conf
oracle           soft    nofile          4096
oracle           hard   nofile          65536
oracle           soft    nproc          2047
oracle           hard   nproc          16384
oracle           soft   stack          10240
grid           soft    nofile          4096
grid            hard   nofile          65536
grid            soft    nproc          2047
grid            hard   nproc          16384
grid            soft   stack          10240
*           soft   memlock         18874368
*           hard   memlock          18874368

8、安装依赖包

rpm -q 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 libXp make numactl-devel sysstat unixODBC unixODBC-devel compat-libcap1.x86_64 libcap.x86_64|grep not

yum install compat-libstdc++-33 elfutils-libelf-devel gcc-c++ ksh libaio-devel libstdc++-devel libXp numactl-devel unixODBC unixODBC-devel compat-libcap1 -y

9、开始安装Grid软件

    这里我用图形化界面安装的,下面列出guoch过程中的几个截图:
通过文件系统(NFS)搭建RAC
通过文件系统(NFS)搭建RAC
通过文件系统(NFS)搭建RAC
通过文件系统(NFS)搭建RAC

10、安装Oracle软件

    oracle软件正常安装

11、创建Database

dbca -silent -createDatabase -templateName New_Database.dbt -gdbname rac -sid rac -sysPassword sys -systemPassword system -datafileDestination '/oradata' -RECOVERYAREADESTINATION '/oradata/flash_recovery_area' -storageType FS -responseFile NO_VALUE -characterset ZHS16GBK -sampleSchema true -automaticMemoryManagement true -nodeinfo rac1,rac2

安装过程中报错:

[root@rac1 ~]# cat /u01/app/oracle/cfgtoollogs/dbca/rac/rac.log
Creating and starting Oracle instance
DBCA_PROGRESS : 1%
ORA-01501: CREATE DATABASE failed
ORA-00200: control file could not be created
ORA-00202: control file: '/oradata/rac/control01.ctl'
ORA-27086: unable to lock file - already in use

ORA-01501: CREATE DATABASE failed
ORA-00200: control file could not be created
ORA-00202: control file: '/oradata/rac/control01.ctl'
ORA-27086: unable to lock file - already in use

DBCA_PROGRESS : 100%


在挂载nfs文件系统时添加nolock参数

dbca创建完需要修改参数:

alter system set cluster_interconnects = '192.168.3.219' scope=spfile sid='rac1' ;
alter system set cluster_interconnects = '192.168.3.220' scope=spfile sid='rac2' ;

四、其他一些信息

1、简单对数据进行压测

        swingbench安装在节点1上,对节点2进行压测,当并发达到170-200时,节点2数据库TPS能达到90-100,CPU接近100%,再多TPS不会增加,并且服务器配置限制,swingbench软件并发连接上不去

2、数据库安装完一些现象

①Grid和ASM实例只在节点二上存在,节点一上没有,如果ASM实例不启动的话,数据库只能在一个节点上启动
②节点二ASM实例不启动,节点一Database可以单独启动,此时节点一服务器只有一个oracle实例,grid和asm实例不存在
③刚开始在ECS安装的时候配置了组播,后发现关闭组播对数据库运行没有影响,用NFS搭建RAC应该是不用配置组播的

最后

上面罗列了一些数据库搭建完发现的问题和现象,能力有限,目前对一些现象还不是很清楚,仍需继续学习,如有问题,欢迎一起讨论 ^_^

上一篇:oracle监听配置介绍


下一篇:OSSFS将OSS bucket 挂载到本地文件系统及注意事项