首页 > 代码库 > RAC安装概要

RAC安装概要

 

RAC安装概要

 

GRID版本: 11.2.0.0.0

Oracle版本: 11.2.0.1

OS: RHEL5.8 x86_64 (2.6.18-308.el5)

 

#!/bin/bash# 设置当前要配置的节点, 1为node101机器, 2为node102机SID=1#SID=2# ============================================# 环境# ============================================# ---------------------------------------# |  节点   | 主机名称  |     IP地址      |# |---------|----------|----------------|# |         | rac1-pub | 192.168.80.101 |# | node101 | rac1-vip | 192.168.80.111 |# |         | rac1     | 10.0.0.101     |# |---------|----------|----------------|# |         | rac2-pub | 192.168.80.102 |# | node102 | rac2-vip | 192.168.80.112 |# |         | rac2     | 10.0.0.102     |# |---------|----------|----------------|# | node101 | scan-ip  | 192.168.80.121 |# ---------------------------------------# 以上节点为虚拟机, 本地机器IP为192.168.1.175, 且对node101和node102配置了对应的DNS# ============================================# 准备# ============================================节点内存1600Myum groupinstall "X Window System" -yyum install nfs-utils.x86_64 -yservice portmap startyum install rsync -ymkdir /mnt/{grid,database}mount /dev/cdrom /media/cdrommount -t nfs dns:/media/disk1/grid /mnt/gridmount -t nfs dns:/media/disk1/database /mnt/database/# ============================================# 删除# ============================================#rm -rf /etc/oracle/ /etc/oraInst.loc /etc/oratab#cd /usr/local/bin/#rm -f coraenv dbhome oraenv#rm -f /etc/init.d/init.ohasd#rm -f /etc/init.d/ohasd#rm -f /etc/inittab.crs#rm -f /etc/inittab.no_crs#sed -i -r /init.ohasd/d /etc/inittab# ============================================# 用户和组# ============================================groupadd -g 1000 oinstallgroupadd -g 1200 asmadmingroupadd -g 1201 asmdbagroupadd -g 1202 asmopergroupadd -g 1300 dbagroupadd -g 1301 operuseradd -u 1000 -g oinstall -G dba,asmadmin,asmdba,asmoper grid -c "Grid Infrastructure Owner"echo 123456|passwd --stdin griduseradd -u 1001 -g oinstall -G dba,oper,asmdba -c "Oracle Software Owner" oracleecho 123456|passwd --stdin oracle# ============================================# 环境变量# ============================================cat >> /home/grid/.bash_profile <<EOFexport ORACLE_BASE=/u01/app/gridexport ORACLE_HOME=/u01/app/11.2.0/gridexport ORACLE_SID=+ASM$SIDexport PATH=\$ORACLE_HOME/bin:\$PATHEOFcat >> /home/oracle/.bash_profile <<EOFexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1export ORACLE_SID=rac$SIDexport PATH=\$ORACLE_HOME/bin:\$PATHEOF# ============================================# network# ============================================sed -s -e s/eth0/eth0:0/ -e s/192.168.80.10$SID/10.0.0.10$SID/ /etc/sysconfig/network-scripts/ifcfg-eth0 > /etc/sysconfig/network-scripts/ifcfg-eth0:0service network restartip addr list | grep inet# ============================================# hostname# ============================================sed -i -r s/(HOSTNAME=).*/\1rac$SID/ /etc/sysconfig/networkhostname rac$SID# ============================================# hosts# ============================================[ "$(hostname)" = "rac1" ] && {cat >> /etc/hosts <<EOF192.168.80.101 rac1-pub.linux.com rac1-pub192.168.80.111 rac1-vip.linux.com rac1-vip10.0.0.101     rac1.linux.com rac1192.168.80.102 rac2-pub.linux.com rac2-pub192.168.80.112 rac2-vip.linux.com rac2-vip10.0.0.102     rac2.linux.com rac2EOF}[ "$(hostname)" = "rac1" ] && {cat >> /etc/hosts << EOF192.168.80.121 scan-ip.linux.com scan-ipEOF}#rsync -avR /etc/hosts node102:/# ============================================# 节点互信# ============================================for u in root grid oracle; dosu $u -c "ssh-keygen -t rsa"su $u -c "ssh-keygen -t dsa"donefor u in root grid oracle; doeval "rsync -av $u@node102:~$u/.ssh/id_rsa.pub ~$u/.ssh/id_rsa.pub.tmp"eval "rsync -av $u@node102:~$u/.ssh/id_dsa.pub ~$u/.ssh/id_dsa.pub.tmp"eval "cat ~$u/.ssh/id_rsa.pub ~$u/.ssh/id_dsa.pub ~$u/.ssh/id_rsa.pub.tmp ~$u/.ssh/id_dsa.pub.tmp > ~$u/.ssh/authorized_keys"# 虚拟机与本地机器的互信, 方便登录配置eval "cat >> ~$u/.ssh/authorized_keys <<EOFssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA+lexExdw90eqWl6zpLIejL76xIx6LFCBM65tDyL4Pu3IxHoyzKhtD5jK6C3mXIjFCI7YLseDvdVMOkVb8KtPMqsYkiLtQHb2uwNy94XpIzAl0BSDfxWM5/icXr+dnCupDNHMZjcFI6kUU4wZNhzI4Xt+/cFv7+U7Qj6Ij1WJUJGZcxc8F4iVb4n9Ldeukkvc+UQ5j8iMrIykz9aqF31toFgBDMq5ORyKATKRShsU2BKFSkubaEYxOeaNfPFLi2Ycq703yTTCVFRlJkDdZs5J3++uOAcH9mVoeWmYZH4ooN0VE6ILTb0Y8LJOzOSYoYx6nyTG13Ulx0BmOry7rt7ygw== root@dns.linux.comEOF"eval "rsync -av ~$u/.ssh/authorized_keys $u@node102:~/.ssh"eval rm -f ~$u/.ssh/id_rsa.pub.tmp ~$u/.ssh/id_dsa.pub.tmpdonefor u in grid oracle; dosu grid -c for h in rac1 rac1-pub node101 rac2 rac2-pub node102; do echo -ne "$h\t"; ssh $h "date +%F\ %T"; donedone#su grid -c "for h in rac1-priv rac1-priv.linux.com rac1-pub rac1-pub.linux.com node101 rac2-priv rac2-priv.linux.com rac2-pub rac2-pub.linux.com node102; do echo -ne \"\$h\t\"; ssh \$h \"date +%F\\\ %T\"; done"# ============================================# iscsi设备与裸设备# ============================================iscsiadm -m discovery -t sendtargets -p 192.168.1.175:3260iscsiadm -m node -T iqn.2014-11.com.linux:Storage1.target1 -l#iscsiadm -m node -T iqn.2014-11.com.linux:Storage1.target1 -ufdisk /dev/sda # 划分两个4G大小的分区(sda1, sda2)# ============================================# udev配置# ============================================cat >> /etc/udev/rules.d/60-raw.rules <<EOFACTION=="add", KERNEL=="sda1", RUN+="/bin/raw /dev/raw/raw1 %N"ACTION=="add", KERNEL=="sda2", RUN+="/bin/raw /dev/raw/raw2 %N"KERNEL=="raw[0-9]*", OWNER="grid", GROUP="oinstall", MODE="0660"EOFudevtrigger#rsync -avR  /etc/udev/rules.d/60-raw.rules node102:/# ============================================# ntpd# ============================================sed -i -r s/-u/-x -u/ /etc/sysconfig/ntpdservice ntpd startchkconfig ntpd on# rsync -avR /etc/sysconfig/ntpd node102:/# ============================================# 安装目录权限# ============================================# gridmkdir /u01chown -R grid:oinstall /u01/# oraclemkdir -p /u01/app/oraclechown -R oracle:oinstall /u01/app/oracle# ============================================# 依赖# ============================================yum install libaio.i386 libaio.x86_64 libaio-devel.i386 libaio-devel.x86_64 sysstat.x86_64 unixODBC.i386 unixODBC.x86_64 unixODBC-devel.i386 unixODBC-devel.x86_64 ksh.x86_64 smartmontools.x86_64 -y# ============================================# 验证 grid环境# ============================================su - gridcd /mnt/grid/./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -fixup -verbose# ============================================# 安装 grid# ============================================./runInstaller# ============================================# 安装 oracle 数据库软件# ============================================su - oraclecd /mnt/database./runInstaller# ============================================# dbca创建数据库# ============================================su - oracledbca

 

RAC安装概要