现在的位置: 首页 > 数据库 > 正文

oracleRAC搭建步骤

2019年10月15日 数据库 ⁄ 共 4446字 ⁄ 字号 暂无评论

oracle rac安装环境准备:

创建用户和组:(1)
groupadd oinstall
groupadd dba
groupadd oper
groupadd asmadmin
groupadd asmdba
groupadd asmoper
useradd -g oinstall -G dba,asmdba,asmadmin,asmoper grid
useradd -g oinstall -G dba,oper,asmdba,asmadmin oracle

创建目录:
mkdir -p /u01/app/oracle
mkdir -p /u01/app/grid
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1
chown -R grid:oinstall /u01/app/grid
chown -R grid:oinstall /u01/app/11.2.0
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01
mkdir -p /u01/app/oraInventory
chown -R grid:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory

oracle用户环境变量:
umask 022
export ORACLE_SID=zhengyi
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export TMP=/tmp
export TMPDIR=$TMP
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export EDITOR=vi
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORACLE_PATH=.:$ORACLE_BASE/dba_scripts/sql:$ORACLE_HOME/rdbms/admin
export SQLPATH=$ORACLE_HOME/sqlplus/admin
#export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK" --AL32UTF8?SELECT userenv('LANGUAGE') db_NLS_LANG FROM DUAL;
export NLS_LANG="AMERICAN_CHINA.ZHS16GBK"

grid用户环境变量:
umask 022
export ORACLE_SID=+ASM1
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export PATH=$ORACLE_HOME/bin:$PATH

root用户环境变量:

export ORACLE_HOME=/u01/app/12.1.0/grid
export PATH=$PATH:$ORACLE_HOME/bin

安装依赖包
yum install glibc glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh compat-libcap1 compat-libstdc++ elfutils-libelf-devel gcc-c++

修改内核参数:版本1:
vi /etc/sysctl.conf
# for oracle
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1054472192
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

使修改参数立即生效:
/sbin/sysctl -p

修改OS用户grid和oracle资源限制:
cp /etc/security/limits.conf /etc/security/limits.conf.`date +%Y%m%d`

echo "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 " >> /etc/security/limits.conf

修改/etc/profile文件:
vi /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

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

tmpfs /dev/shm tmpfs defaults,size=2G 0 0

利用udev工具绑定裸设备:
vi /etc/udev/rules.d/90-oracle-..

KERNEL=="sdb1", NAME="asmdisk_ocr", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sdc1", NAME="asmdisk_data", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sdd1", NAME="asmdisk_fra", OWNER="grid", GROUP="asmadmin", MODE="0660"

备注:linux7查询磁盘UUID:
/usr/lib/udev/scsi_id -u grid -g asadmin -d /dev/sdb

本地yum仓库搭建:
[rhel-media]
name=Red Hat Enterprise Linux 6.5
baseurl=file:///mnt
enabled=1
gpgcheck=1

静默安装gird命令:./runInstaller -silent -responseFile /u01/soft/grid/grid_install.rsp -ignoreSysPrereqs -ignorePrereq

添加裸设备脚本:
vim genasmdisk.sh
#!/bin/bash
cat /dev/null > /etc/udev/rules.d/99-oracle-asmdevices.rules
for i in b c d e f;
do
echo "KERNEL==\"sd?1\", SUBSYSTEM==\"block\", PROGRAM==\"/usr/lib/udev/scsi_id -g -u -d /dev/\$name\", RESULT==\"`/usr/lib/udev/scsi_id -g -u -d /dev/sd${i}1`\", SYMLINK+=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\"" >> /etc/udev/rules.d/99-oracle-asmdevices.rules
done

互信脚本命令:
./sshUserSetup.sh -user grid -hosts "rac1 rac2" -advanced -noPromptPassphrase

./sshUserSetup.sh -user oracle -hosts "rac1 rac2" -advanced -noPromptPassphrase

安装数据库软件命令:./runInstaller -ignorePrereq -silent -force -responseFile /u01/soft/oracle/db_install.rsp

创建数据库实例命令:dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName orcl -sid orcl -sysPassword zhengyi -systemPassword zhengyi -storageType ASM -diskGroupName OCR -nationalCharacterSet "AL16UTF16" -characterSet "AL32UTF8" -nodeinfo rac1,rac2 -sampleSchema false -asmSysPassword zhengyi

注意:1.网卡信息中不能出现vip和scan的IP地址(安装之前不能ping通这些地址)
2.公网和私网的网卡名必须一致
3.修改完 /etc/sysconfig/network-scripts/ifcfg***后 要重启系统,系统会自动生成 /etc/udev/rules.d/70-persistent-net.rules。
4.公网和私网不能在同一个网段
5.获取磁盘UUID:/sbin/scsi_id -g -u /dev/sd$i
6.oracle.install.asm.diskGroup.name(ASM磁盘组名称不可缺少),否则会报错

ASM磁盘冗余方式:
High:需要三块磁盘
Normal:需要两块磁盘
External(None):不冗余,需要一块磁盘

给我留言

留言无头像?