########12c rac 多出一个grid的base目录和需要准备一个40G的盘做GIMR磁盘,其他大致相同.
########从满脑子问号rac是什么开始搞,做之前先百度了解rac是什么,基本架构是怎么样的,大概就是下图这样子,详细点的自行百度~
########准备好oracle安装包,Oracle官网下载,包不要钱.
########p13390677_112040_Linux-x86-64_1of7/p13390677_112040_Linux-x86-64_2of7/p13390677_112040_Linux-x86-64_3of7
1.VMware环境:两台安装linux的虚拟机,本次我使用的red hat 6.8,每台两个网卡public/private。
搞几个共享磁盘出来
cmd切换到VMware安装目录下,执行创建共享磁盘.
vmware-vdiskmanager.exe -c -s 1G -a lsilogic -t 2 C:\share_disk\ocr01.vmdk
vmware-vdiskmanager.exe -c -s 1G -a lsilogic -t 2 C:\share_disk\ocr02.vmdk
vmware-vdiskmanager.exe -c -s 1G -a lsilogic -t 2 C:\share_disk\ocr03.vmdk
vmware-vdiskmanager.exe -c -s 5G -a lsilogic -t 2 C:\share_disk\data.vmdk
vmware-vdiskmanager.exe -c -s 5G -a lsilogic -t 2 C:\share_disk\backup.vmdk
改虚拟机的.vmx文件,文件末尾添加刚才创建的虚拟磁盘.
scsi1.present = "TRUE"
scsi1.virtualDev = "lsilogic"
scsi1.sharedBus = "virtual"
scsi1:1.present = "TRUE"
scsi1:1.mode = "independent-persistent"
scsi1:1.filename = "C:\share_disk\ocr01.vmdk"
scsi1:1.deviceType = "disk"
scsi1:2.present = "TRUE"
scsi1:2.mode = "independent-persistent"
scsi1:2.filename = "C:\share_disk\ocr02.vmdk"
scsi1:2.deviceType = "disk"
scsi1:3.present = "TRUE"
scsi1:3.mode = "independent-persistent"
scsi1:3.filename = "C:\share_disk\ocr03.vmdk"
scsi1:3.deviceType = "disk"
scsi1:4.present = "TRUE"
scsi1:4.mode = "independent-persistent"
scsi1:4.filename = "C:\share_disk\backup.vmdk"
scsi1:4.deviceType = "disk"
scsi1:5.present = "TRUE"
scsi1:5.mode = "independent-persistent"
scsi1:5.filename = "C:\share_disk\data.vmdk"
scsi1:5.deviceType = "disk"
disk.locking = "false"
disk.EnableUUID = "true"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.DataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"
2.开机检查两台主机都可以看到刚添加的共享盘,检查swap空间。
内存 | Swap |
1 - 2 GB | 内存的1.5倍 |
2-16GB | 和内存相等 |
>16GB | 16 GB |
3.操作系统配置
3.1关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
3.2关闭iptables
rhel6
service iptables stop
chkconfig ip6tables off
chkconfig iptables off
rhel7
systemctl stop firewalld.service
systemctl disable firewalld.service
firewall-cmd --state
3.3改IP地址,改hosts文件
cat >> /etc/hosts <<EOF
2.2.2.10 rac1
2.2.2.11 rac1-vip
2.2.2.20 rac2
2.2.2.21 rac2-vip
2.2.2.15 rac-scan
192.168.88.200 rac1-priv
192.168.88.201 rac2-priv
EOF
禁用ntp,oracle rac中会使用ctss来同步集群时间.
mv /etc/ntp.conf /etc/ntp.conf.bak
3.4内核参数
cat >> /etc/sysctl.conf <<EOF
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
fs.aio-max-nr = 1048576
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
EOF
sysctl -p
3.5Limits
cat >> /etc/security/limits.conf <<EOF
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
12C:
grid soft stack 10240
oracle soft stack 10240
3.6 pam
echo session required pam_limits.so >> /etc/pam.d/login
3.7 profile
cat >> /etc/profile <<EOF
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
EOF
3.8 新建用户及更改环境变量.
/usr/sbin/groupadd -g 501 oinstall
/usr/sbin/groupadd -g 502 dba
/usr/sbin/groupadd -g 504 asmadmin
/usr/sbin/groupadd -g 506 asmdba
/usr/sbin/groupadd -g 507 asmoper
/usr/sbin/useradd -u 501 -g oinstall -G asmadmin,asmdba,asmoper grid
/usr/sbin/useradd -u 502 -g oinstall -G dba,asmdba oracle
##passwd oracle
echo "oracle:oracle" | chpasswd
##passwd grid
echo "grid:grid" | chpasswd
##Oracle Inventory目录
mkdir -p /u01/app/oraInventory
chown -R grid:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory
##Grid Home目录
mkdir -p /u01/11.2.0/grid
chown -R grid:oinstall /u01/12.2.0/grid
chmod -R 775 /u01/11.2.0/grid
##Oracle Base目录
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oracle/cfgtoollogs
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
##Oracle Home目录
mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /u01/app/oracle/product/
chmod -R 775 /u01/app/oracle/product/
12C:grid $ORACLE_BASE
mkdir /u01/grid
chown -R grid:oinstall /u01/grid
chmod -R 775 /u01/grid
##oracle用户.bash_profile添加
vi /home/oracle/.bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_SID=jicheng1 ##rac2为jicheng2
export NLS_LANG=american_america.zhs16gbk
export PATH=.:$PATH:$ORACLE_HOME/bin:/ u01/11.2.0/grid/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
##grid用户.bash_profile添加
vi /home/grid/.bash_profile
export ORACLE_BASE=/u01/app/oracle
#12C export ORACLE_BASE=/u01/grid
export ORACLE_HOME=/u01/11.2.0/grid
export ORACLE_SID=+ASM1 ##rac2为ASM2
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
3.9 操作系统配置结束,reboot两台机器(改配置文件关selinux重启生效)
4.ASM盘,可以使用ASMlib和udev方式来绑定,本次使用udev来绑定ASM磁盘
取共享磁盘ssid,创建文件/etc/udev/rules.d/99-oracle.rules并写入,往rac2节点拷贝一份,同样启动start_udev
rhel6
for i in sdb sdc sdd sde sdf; do UUID=`/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$i` ; echo 'KERNEL=="sd*", BUS=="scsi", PROGRAM=="scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="'$UUID'", NAME="asm-'$i'", OWNER="grid", GROUP="asmadmin", MODE="0660"'; done >> /etc/udev/rules.d/99-oracle.rules ; cat /etc/udev/rules.d/99-oracle.rules
start_udev
ll /dev/asm*
scp /etc/udev/rules.d/99-oracle.rules 2.2.2.20:/etc/udev/rules.d/99-oracle.rules
rac2 :
start_udev
ll /dev/asm*
rhel7
for i in b c d e f
do
UUID=`/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`
echo 'KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="'$UUID'", SYMLINK+="asm-disk'$i'",OWNER="grid", GROUP="asmadmin",MODE="0660"'
done >> /etc/udev/rules.d/99-oracle.rules
/sbin/udevadm trigger --type=devices --action=change
udevadm control --reload-rules
5.上传文件,安装依赖包,图形界面安装grid,oracle数据库软件,DBCA建库。
5.1安装依赖包,配好yum装吧
yum install -y binutils compat-libstdc++-33 glibc ksh libaio libgcc libstdc++ make compat-libcap1 gcc gcc-c++ glibc-devel libaio-devel libstdc++-devel sysstat elfutils-libelf-devel
5.2图形界面grid用户运行 ./runInstaller
installation type 选高级.
添加rac2,配置双节点grid用户互信
注意选择路径,把刚才三个ocr磁盘选上
最后安装检查会报asm磁盘警告,检查两个节点都可以访问asm磁盘后直接忽略下一步.
dd if=/dev/zero f=/dev/asm-sda bs=1024 count=1
5.3安装完成运行root脚本,先在第一个节点上执行,然后其他节点顺序执行,不能同时执行
/u01/app/oraInventory/orainstRoot.sh
/u01/11.2.0/grid/root.sh
5.4验证集群
[root@rac1]# /oracle/11.2.0/grid/bin/crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.DATA.dg ora....up.type ONLINE ONLINE rac1
ora....N1.lsnr ora....er.type ONLINE ONLINE rac1
ora.asm ora.asm.type ONLINE ONLINE rac1
ora.cvu ora.cvu.type ONLINE ONLINE rac1
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE rac1
ora.oc4j ora.oc4j.type ONLINE ONLINE rac1
ora.ons ora.ons.type ONLINE ONLINE rac1
ora....SM1.asm application ONLINE ONLINE rac1
ora.rac1.gsd application OFFLINE OFFLINE
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip ora....t1.type ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora.rac2.gsd application OFFLINE OFFLINE
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip ora....t1.type ONLINE ONLINE rac2
ora....ry.acfs ora....fs.type ONLINE ONLINE rac1
ora.scan1.vip ora....ip.type ONLINE ONLINE rac1
5.5图形界面oracle用户运行 ./runInstaller
只安装数据库软件
添加rac2,设置oracle用户互信
5.6一路下一步到安装完成,同样执行root脚本
5.7DBCA建库,图形界面Oracle用户执行dbca
选rac数据库
自定义,定制
选中两个节点
使用ASM盘存储数据
后面配置就看需求了,测试环境可以都试一试.
结束。