Oracle12.2.0.1RAC在linux6上部署(一)

系统环境:
VMware Workstation14.5 +linux 6.8(64位)+Oracle 11.2.0.4.0 
两个节点test12c1(节点1)和test12c2(节点2)

vi /etc/hosts
10.0.100.21 test12c1
10.0.100.22 test12c2
10.0.100.31 test12c1-vip
10.0.100.32 test12c2-vip
10.0.100.20 test-scan
1.1.1.1 test12c1-priv
1.1.1.2 test12c2-priv

节点1:
hostname:test12c1  ip:10.0.100.21   scanip:10.0.100.20  dbname=test   instance_name=test1

节点2:
hostname:test12c2  ip:10.0.100.22   scanip:10.0.100.20   dbname=test   instance_name=test2

0、安装前检查与需知:

1、每个节点至少8G的内存,检查时间、时区,几个节点的网卡名要一样。
2、临时空间/tmp至少1G
3、GI至少需要12 G的空间,Oracle建议分配100 GB来为补丁提供更多空间。
Oracle数据库企业版至少需要9 GB。OCR空间至少要39G(extend)。
4、需要的rpm见
https://docs.oracle.com/en/database/oracle/oracle-database/12.2/cwlin/operating-system-requirements-for-x86-64-linux-platforms.html#GUID-3F647617-7FF5-4EE4-BBA8-9A5E3EEC888F
5、关闭Transparent HugePages
https://docs.oracle.com/en/database/oracle/oracle-database/12.2/cwlin/disabling-transparent-hugepages.html#GUID-02E9147D-D565-4AF8-B12A-8E6E9F74BEEA
在Red Hat Enterprise Linux 6,Red Hat Enterprise Linux 7,SUSE 11,Oracle Linux 6和Oracle Linux 7中默认启用Transparent HugePages内存,而早期版本的Oracle Linux使用Unbreakable Enterprise Kernel 2(UEK2)内核。Transparent HugePages会在运行时导致内存分配延迟。为避免性能问题,Oracle建议您在所有Oracle数据库服务器上禁用透明超大页面。Oracle建议您改用标准的HugePages来提高性能。
6、16G以上大内存开启HugePages

以下为在笔记本的虚拟机上安装,资源有限。

1、安装rpm包(2个节点都要配置)

配置yum源
mount  /dev/cdrom /mnt

vi /etc/yum.repos.d/ol.repo
[local-source]
name=ol
baseurl=file:///mnt/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

安装rpm

yum install xterm bc* binutils* compat-l* e2fsprog*  glibc-2.*  glibc-de*  ksh* libgcc-4*  libstdc+*  libaio-0* libaio-d* libXtst-* libX11-1*  libXau-1* libxcb-1* libXi-1.*  make-3.8* net-tool* nfs-util* sysstat-* smartmontools* gcc-c++* xorg-x11-xauth

具体见官方文档:

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/cwlin/operating-system-requirements-for-x86-64-linux-platforms.html#GUID-3F647617-7FF5-4EE4-BBA8-9A5E3EEC888F
包含
bc
binutils-2.20.51.0.2-5.36.el6 (x86_64)
compat-libcap1-1.10-1 (x86_64)
compat-libstdc++-33-3.2.3-69.el6 (x86_64)
compat-libstdc++-33-3.2.3-69.el6 (i686)
e2fsprogs-1.41.12-14.el6 (x86_64)
e2fsprogs-libs-1.41.12-14.el6 (x86_64)
glibc-2.12-1.7.el6 (i686)
glibc-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6 (i686)
ksh
libgcc-4.4.4-13.el6 (i686)
libgcc-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6 (i686)
libstdc++-devel-4.4.4-13.el6 (x86_64)
libstdc++-devel-4.4.4-13.el6 (i686)
libaio-0.3.107-10.el6 (x86_64)
libaio-0.3.107-10.el6 (i686)
libaio-devel-0.3.107-10.el6 (x86_64)
libaio-devel-0.3.107-10.el6 (i686)
libXtst-1.0.99.2 (x86_64)
libXtst-1.0.99.2 (i686)
libX11-1.5.0-4.el6 (i686)
libX11-1.5.0-4.el6 (x86_64)
libXau-1.0.6-4.el6 (i686)
libXau-1.0.6-4.el6 (x86_64)
libxcb-1.8.1-1.el6 (i686)
libxcb-1.8.1-1.el6 (x86_64)
libXi-1.3 (x86_64)
libXi-1.3 (i686)
make-3.81-19.el6
net-tools-1.60-110.el6_2.x86_64 (for Oracle RAC and Oracle Clusterware)
nfs-utils-1.2.3-15.0.1 (for Oracle ACFS)
sysstat-9.0.4-11.el6 (x86_64)
smartmontools-5.43-1.el6.x86_64

2、创建用户、目录(2个节点都要配置)

groupadd -g 1005 oinstall
groupadd -g 1001 dba
groupadd -g 1002 asmadmin
groupadd -g 1003 asmdba
groupadd -g 1004 asmoper
useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
useradd -u 1101 -g oinstall -G dba,asmdba,asmadmin,asmoper oracle

mkdir -p /u01/12.2.0/grid 
mkdir -p /u01/app/grid
chown -R grid:oinstall /u01/12.2.0/grid
chown -R grid:oinstall /u01/app/grid  
chmod -R 775 /u01/12.2.0/grid  

mkdir -p /u01/app/oracle 
mkdir /u01/app/oracle/cfgtoollogs  
chown -R oracle:oinstall /u01/app/oracle 
chmod -R 775 /u01/app/oracle  

mkdir -p /u01/app/oracle/product/12.2.0/db_1 
chown -R oracle:oinstall /u01/app/oracle/product/12.2.0/db_1 
chmod -R 775 /u01/app/oracle/product/12.2.0/db_1 

mkdir -p /u01/app/oraInventory
chown -R grid:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory

3、创建共享磁盘(2个节点都要配置)

虚拟机创建共享盘:
vmware-vdiskmanager.exe -c -s 39Gb -a lsilogic -t 2 "E:\Virtual Machines\sharedisk\ocr.vmdk"
vmware-vdiskmanager.exe -c -s 15Gb -a lsilogic -t 2 "E:\Virtual Machines\sharedisk\data.vmdk"
vmware-vdiskmanager.exe -c -s 5Gb -a lsilogic -t 2 "E:\Virtual Machines\sharedisk\arch.vmdk"
分别打开两台虚拟机目录中的vmx文件,在最后一行添加:

scsi1.present = "TRUE"
scsi1.virtualDev = "lsilogic"
scsi1.sharedBus = "virtual"

scsi1:1.present = "TRUE"
scsi1:1.mode = "independent-persistent"
scsi1:1.filename = "E:\Virtual Machines\sharedisk\ocr.vmdk"

scsi1:2.present = "TRUE"
scsi1:2.mode = "independent-persistent"
scsi1:2.filename = "E:\Virtual Machines\sharedisk\data.vmdk"

scsi1:3.present = "TRUE"
scsi1:3.mode = "independent-persistent"
scsi1:3.filename = "E:\Virtual Machines\sharedisk\arch.vmdk"

disk.locking = "false"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.DataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"

4、操作系统配置修改(2个节点都要配置)

4.1配置主机信息

vi /etc/hosts

10.0.100.21 test12c1
10.0.100.22 test12c2

10.0.100.31 test12c1-vip
10.0.100.32 test12c2-vip

10.0.100.20 test-scan

1.1.1.1 test12c1-priv
1.1.1.2 test12c2-priv

4.2配置系统参数

修改内核参数
vi /etc/sysctl.conf

# for oracle
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 1364702 #物理内存/4k,See Note: 301830.1 for more information.
kernel.shmmax = 2794909696 #物理内存*0.6 (or higher at customer's discretion - see Note:567506.1)
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
kernel.panic_on_oops = 1
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
vm.swappiness=10
运行以下命令生效:
sysctl -p

加载pam_limits.so模块
vi /etc/pam.d/login
session required pam_limits.so

修改用户参数
vi /etc/profile
if [ $USER = "oracle" ] || [ $USER = "grid" ] ; then
    if [ $SHELL = "/bin/ksh" ]; then
       ulimit -u 16384
       ulimit -n 65536
    else
       ulimit -u 16384 -n 65536
    fi
fi

vi /etc/security/limits.conf
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
grid soft nproc 2047
grid hard nproc 16384

oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle soft nproc 2047
oracle hard nproc 16384
root soft nproc 2047

* soft memlock 157286400  #90% RAM FOR HUGEPAGES 单位是k
* hard memlock 157286400  #90% RAM FOR HUGEPAGES 单位是k

4.3关闭防火墙

vi /etc/selinux/config
SELINUX=disabled
需要重启。

service iptables stop
chkconfig iptables off

4.4关闭NTP

service ntpd stop
chkconfig ntpd off
rm -rf /etc/ntpd.conf 
rm -rf /var/run/ntpd.pid

4.5配置ssh互信

ssh生成公钥/私钥 (oracle、grid用户)
ssh-keygen -t rsa -P ''
输入内容直接按回车
cd ~/.ssh
cat id_rsa.pub
将2个节点id_rsa.pub的内容,复制出来写入到2个节点的authorized_keys文件中
cd ~/.ssh
vi authorized_keys
在2个节点分别测试ssh联通性(oracle、grid用户都要)
ssh 10.0.100.21
提示输入yes
exit
ssh 10.0.200.22
提示输入yes
exit

4.6 oracle、grid用户环境变量配置

Grid用户环境变量:
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=+ASM1  # RAC1
#export ORACLE_SID=+ASM2  # RAC2
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/12.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

oracle用户环境变量:

export TMP=/tmp 
export TMPDIR=$TMP 
export ORACLE_SID=test1 #节点2改为test2
export ORACLE_BASE=/u01/app/oracle 
export ORACLE_HOME=$ORACLE_BASE/product/12.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

4.7配置zeroconf

vi /etc/sysconfig/network
NOZEROCONF=yes

4.8取消透明大页(Transparent HugePages)

vi /etc/grub.conf 
添加到文件中的内核引导行中,例如:
kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/vg_test12c1-lv_root rd_NO_LUKS rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_LVM_LV=vg_test12c1/lv_swap rd_LVM_LV=vg_test12c1/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet transparent_hugepage=never

重启OS后确认是否生效
[root@test12c1 ~]# cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
always madvise [never]

4.9设置Disk I/O Scheduler deadline

vi /etc/udev/rules.d/60-oracle-schedulers.rules
添加如下内容
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"
运行生效
udevadm control --reload-rules

Related Posts