本篇内容主要讲解“Oracle RAC+DG环境搭建的方法是什么”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Oracle RAC+DG环境搭建的方法是什么”吧!

分两个脚本 env.sh 和rpm.sh

env.sh 整体脚本如下,修改相关数据库实例名后,在四台主机上直接执行:

#!/bin/bash##Purpose:1.settheEnvironmentandOSparameter#2.create6groups(oinstall,dba,oper,asmadmin,asmdba,asmoper)and2user(oracle,grid)#3.createthenecessarydirectory##Usage:Itwouldbecalledbymain.shoryoucanexecuteitalonelyandSeparatelyintwonodes.#Logonasthesuperuser('root'),andthenexecutethisscript##Notice:#2.youcanedittheconfigfirtly.Itwillberunintwonodes,soyoumustmodify#ORACLE_SIDandORACLE_SID_GRID##Author:yunxiaochong####################################################################################################################config#######################################################Defineparameter,Sameasthefollowingdirectory.(refertostep2)##########################################################################################################################oracle#ORACLE_SID="DEVDB1"#ORACLE_BASE="/u01/app/oracle"#ORACLE_HOME="${ORACLE_BASE}/product/11.2/db_1"#ORACLE_HOSTNAME=`hostname`#ORACLE_UNQNAME='DEVDB'#ORACLE_BASE_HEAD=/`echo$ORACLE_BASE|cut-d\/-f2`#/u01#APP=$ORACLE_BASE_HEAD/`echo$ORACLE_BASE|cut-d\/-f3`#/u01/app###grid#ORACLE_SID_GRID="+ASM1"#ORACLE_BASE_GRID="/u01/app/grid"#ORACLE_HOME_GRID="/u01/app/11.2/grid"#######################################################################################################HOSTNAME##IPTABLES#serviceiptablesstop>/dev/null#chkconfigiptablesoff>/dev/null#configDNS#vim/etc/resolv.conf#searchlocaldomain#nameserver10.28.254.19#chkconfigiptablesoff#vm/etc/hosts##SELinux#setenforce0#vim/etc/selinux/config#SELINUX=disabled#ntpd#servicentpdstatus#chkconfigntpdoff###########################################################################################stepsinfomation###################################################################################################echo"*************************************************************************"echo"**step0:cleanuserandgroupanddeletedirectory**"echo"**step1:create6groupsand2users**"echo"**step2:createnecessarydirectoryfororacleandgrid**"echo"**step3:SettheEnvironment~/.bash_profile**"echo"**step4:modifythe/etc/security/limits.conf.**"echo"**step5:modifythe/etc/pam.d/login.**"echo"**step6:modifythe/etc/profile.**"echo"**step7:modifythe/etc/sysctl.confandmakethechangestakeeffect**"echo"*************************************************************************"#step0:checkOS(cpuandmem)##################################clearlogrm-rf./log&>/dev/null#########################################################################################step0:cleanuserandgroupanddeletedirectory###############################################################################################cleanusersforuserinoraclegriddoid$user&>/dev/nullif[$?-eq0];thenuserdel-r$userecho"step0_1::deletedexisted$user">>./logfidone##cleangroupsforgroupindbaoinstalloperasmadminasmdbaasmoperdoegrep"^$group"/etc/group&>/dev/nullif[$?-eq0];thengroupdel$groupecho"step0_2::deletedexisted$group">>./logfidone##cleandirectoriesrm-rf$ORACLE_BASErm-rf$ORACLE_BASE_GRIDrm-rf$ORACLE_HOME_GRIDecho"Successfulfinished...step0:cleanedusers,groupsanddirectories"|tee-a./log################################################################################################step1:creategroupsandusers#########################################################################################################creategroupsgroupadd-g1100oinstallgroup_oinstall=$?groupadd-g1101dbagroup_dba=$?groupadd-g1102opergroup_oper=$?#----------------------------------#groupadd-g1200asmadmingroup_asmadmin=$?groupadd-g1201asmdbagroup_asmdba=$?groupadd-g1202asmopergroup_asmoper=$?#createusersuseradd-m-u1100-goinstall-Gdba,oper,asmdba-d/home/oracle-s/bin/bash-c"OracleSoftwareOwner"oracleuser_oracle=$?echo"oracle"|passwd--stdinoracle>/dev/nulluser_oracle_p=$?#----------------------------------------------------------------------#useradd-m-u1200-goinstall-Gasmadmin,asmdba,asmoper-d/home/grid-s/bin/bash-c"GridInfrastructureOwner"griduser_grid=$?echo"grid"|passwd--stdingrid>/dev/nulluser_grid_P=$?if[$group_oinstall==0-a$group_asmadmin==0-a$group_asmdba==0-a$group_asmoper==0\-a$user_grid==0-a$user_grid_P==0-a$group_dba==0-a$group_oper==0\-a$user_oracle==0-a$user_oracle_p==0];thenecho"step1_1::createdgroupsandusers">>./logelseecho"creategroupsandusersfailed"exit1fiecho"Successfulfinished...step1:createdusersandgroups"|tee-a./log#################################################################################################step2:createdirectory##########################################################################################################step2:createdirectoryif[!-d$ORACLE_BASE_GRID-a!-d$ORACLE_HOME_GRID];thenmkdir-p$ORACLE_BASE_GRIDmkdir-p$ORACLE_HOME_GRIDchown-Rgrid:oinstall$ORACLE_BASE_HEADecho"step2_1::directoryforgridfinished">>./logelseecho"step2_1::directoryforgridcreatefailed">>./logexit2fiif[!-d$ORACLE_BASE];thenmkdir-p$ORACLE_BASEchownoracle:oinstall$ORACLE_BASEchmod-R775$ORACLE_BASE_HEADecho"step2_2::directoryfororaclefinished">>./logelseecho"step2_2::directoryfororacleisalreadyOK">>./logexit2fiecho"Successfulfinished...step2:Thenecessarydirectoryhasbeenfinished"|tee-a./log#################################################################################################step3:SettheEnvironment~/.bash_profile###########################################################################################################oracle.bash_profilesed-i'/TMP/d'/home/oracle/.bash_profileecho"exportTMP=/tmp">>/home/oracle/.bash_profilesed-i'/TMPDIR/d'/home/oracle/.bash_profileecho'exportTMPDIR=$TMP'>>/home/oracle/.bash_profilesed-i'/ORACLE_HOSTNAME/d'/home/oracle/.bash_profileecho"exportORACLE_HOSTNAME=${ORACLE_HOSTNAME}">>/home/oracle/.bash_profilesed-i'/ORACLE_SID/d'/home/oracle/.bash_profileecho"exportORACLE_SID=${ORACLE_SID}">>/home/oracle/.bash_profilesed-i'/PS1/d'/home/oracle/.bash_profileecho'exportPS1="[\u@${ORACLE_SID}@\h:\W]"'>>/home/oracle/.bash_profilesed-i'/ORACLE_BASE/d'/home/oracle/.bash_profileecho"exportORACLE_BASE=${ORACLE_BASE}">>/home/oracle/.bash_profilesed-i'/ORACLE_HOME/d'/home/oracle/.bash_profileecho"exportORACLE_HOME=${ORACLE_HOME}">>/home/oracle/.bash_profilesed-i'/ORACLE_UNQNAME/d'/home/oracle/.bash_profileecho"exportORACLE_UNQNAME=${ORACLE_UNQNAME}">>/home/oracle/.bash_profilesed-i'/TNS_ADMIN/d'/home/oracle/.bash_profileecho"exportTNS_ADMIN=${ORACLE_HOME}/network/admin">>/home/oracle/.bash_profilesed-i'/ORACLE_TERM/d'/home/oracle/.bash_profileecho"exportORACLE_TERM=xterm">>/home/oracle/.bash_profilesed-i'/PATH/d'/home/oracle/.bash_profile#echo"exportPATH=/usr/sbin:$PATH">>/home/oracle/.bash_profileecho"exportPATH=${ORACLE_HOME}/bin:$PATH">>/home/oracle/.bash_profilesed-i'/LD_LIBRARY_PATH/d'/home/oracle/.bash_profileecho"exportLD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib">>/home/oracle/.bash_profilesed-i'/CLASSPATH/d'/home/oracle/.bash_profileecho"exportCLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib">>/home/oracle/.bash_profilesed-i'/EDITOR/d'/home/oracle/.bash_profileecho"exportEDITOR=vim">>/home/oracle/.bash_profilesed-i'/LANG=en_US/d'/home/oracle/.bash_profileecho"export">>/home/oracle/.bash_profilesed-i'/NLS/d'/home/oracle/.bash_profileecho"exportNLS_LANG=american_america.AL32UTF8">>/home/oracle/.bash_profileecho"exportNLS_DATE_FORMAT='yyyy/mm/ddhh34:mi:ss'">>/home/oracle/.bash_profilesed-i'/umask/d'/home/oracle/.bash_profileecho"umask022">>/home/oracle/.bash_profileecho"modifythe/home/oracle/.bash_profilehadbeensucceed.">>./log##grid.bash_profilesed-i'/TMP/d'/home/grid/.bash_profileecho"exportTMP=/tmp">>/home/grid/.bash_profilesed-i'/TMPDIR/d'/home/grid/.bash_profileecho"exportTMPDIR=$TMP">>/home/grid/.bash_profilesed-i'/ORACLE_SID/d'/home/grid/.bash_profileecho"exportORACLE_SID=$ORACLE_SID_GRID">>/home/grid/.bash_profilesed-i'/PS1/d'/home/oracle/.bash_profileecho'exportPS1="[\u@${ORACLE_SID}@\h:\W]"'>>/home/oracle/.bash_profilesed-i'/ORACLE_BASE/d'/home/grid/.bash_profileecho"exportORACLE_BASE=$ORACLE_BASE_GRID">>/home/grid/.bash_profilesed-i'/ORACLE_HOME/d'/home/grid/.bash_profileecho"exportORACLE_HOME=$ORACLE_HOME_GRID">>/home/grid/.bash_profilesed-i'/ORACLE_TERM/d'/home/grid/.bash_profileecho"exportORACLE_TERM=xterm">>/home/grid/.bash_profilesed-i'/NLS/d'/home/grid/.bash_profileecho"exportNLS_DATE_FORMAT='yyyy/mm/ddhh34:mi:ss'">>/home/grid/.bash_profileecho"exportTNS_ADMIN=$ORACLE_HOME_GRID/network/admin">>/home/grid/.bash_profilesed-i'/PATH/d'/home/grid/.bash_profileecho"exportPATH=$ORACLE_HOME_GRID/bin:$PATH">>/home/grid/.bash_profileecho"exportLD_LIBRARY_PATH=$ORACLE_HOME_GRID/lib:/lib:/usr/lib">>/home/grid/.bash_profilesed-i'/CLASSPATH/d'/home/grid/.bash_profileecho"exportCLASSPATH=$ORACLE_HOME_GRID/JRE:$ORACLE_HOME_GRID/jlib:$ORACLE_HOME_GRID/rdbms/jlib">>/home/grid/.bash_profilesed-i'/EDITOR/d'/home/grid/.bash_profileecho"exportEDITOR=vim">>/home/grid/.bash_profilesed-i'/LANG/d'/home/grid/.bash_profileecho"export">>/home/grid/.bash_profileecho"exportNLS_LANG=american_america.AL32UTF8">>/home/grid/.bash_profilesed-i'/umask/d'/home/grid/.bash_profileecho"umask022">>/home/grid/.bash_profileecho"modifythe/home/grid/.bash_profilehadbeensucceed.">>./logecho"Successfulfinished...step3:TheEnvironment(~/.bash_profile)hasbeensetsuccessfully"|tee-a./log#####################################################################################################################step4:modifythe/etc/security/limits.conf#############################################################################################################################backupfirstly\cp/etc/security/limits.conf/etc/security/limits.conf.baksed-i'/oracle/d'/etc/security/limits.confsed-i'/grid/d'/etc/security/limits.confecho"oraclesoftnproc2047">>/etc/security/limits.confecho"oraclehardnproc16384">>/etc/security/limits.confecho"oraclesoftnofile1024">>/etc/security/limits.confecho"oraclehardnofile65536">>/etc/security/limits.confecho"gridsoftnproc2047">>/etc/security/limits.confecho"gridhardnproc16384">>/etc/security/limits.confecho"gridsoftnofile1024">>/etc/security/limits.confecho"gridhardnofile65536">>/etc/security/limits.confecho"Successfulfinished...step4:Modifiedthe/etc/security/limits.confhasbeensucceed."|tee-a./log######################################################################################################################step5:modifythe/etc/pam.d/login######################################################################################################################################step5:#backupfirstly\cp/etc/pam.d/login/etc/pam.d/login.baksed-i'/pam_limits.so/d'/etc/pam.d/loginecho"sessionrequired/lib/security/pam_limits.so">>/etc/pam.d/loginecho"sessionrequiredpam_limits.so">>/etc/pam.d/loginecho"Successfulfinished...step5:Modifiedthe/etc/pam.d/loginhasbeensucceed."|tee-a./log######################################################################################################################step6:modifythe/etc/profile######################################################################################################################################backupfirstly\cp/etc/profile/etc/profile.bakrown=`grep-n"oracle"/etc/profile|head-1|cut-d:-f1`if[$rown];thensed-i''"$rown"',$d'/etc/profilefiecho'if[$USER="oracle"]||[$USER="grid"];then'>>/etc/profileecho'if[$SHELL="/bin/ksh"];then'>>/etc/profileecho'ulimit-p16384'>>/etc/profileecho'ulimit-n65536'>>/etc/profileecho'else'>>/etc/profileecho'ulimit-u16384-n65536'>>/etc/profileecho'fi'>>/etc/profileecho'fi'>>/etc/profileecho"Successfulfinished...step6:Modifiedthe/etc/profilehasbeensucceed."|tee-a./log######################################################################################################################step7:modifythe/etc/sysctl.confandmakethechangestakeeffect################################################################################################################backupfirstly\cp/etc/sysctl.conf/etc/sysctl.conf.bakrown=`grep-n"fs.aio-max-nr"/etc/sysctl.conf|head-1|cut-d:-f1`if[$rown];thensed-i''"$rown"',$d'/etc/sysctl.conffiecho"fs.aio-max-nr=1048576">>/etc/sysctl.confecho"fs.file-max=6815744">>/etc/sysctl.confecho"kernel.shmall=2097152">>/etc/sysctl.confecho"kernel.shmmax=8363284480">>/etc/sysctl.confecho"kernel.shmmni=4096">>/etc/sysctl.confecho"kernel.sem=25032000100128">>/etc/sysctl.confecho"net.ipv4.ip_local_port_range=900065500">>/etc/sysctl.confecho"net.core.rmem_default=262144">>/etc/sysctl.confecho"net.core.rmem_max=4194304">>/etc/sysctl.confecho"net.core.wmem_default=262144">>/etc/sysctl.confecho"net.core.wmem_max=1048586">>/etc/sysctl.confecho"net.ipv4.tcp_wmem=262144262144262144">>/etc/sysctl.confecho"net.ipv4.tcp_rmem=419430441943044194304">>/etc/sysctl.confsysctl-p&>/dev/nullecho"Successfulfinished...step6:Modifiedthe/etc/sysctl.confhasbeensucceed."|tee-a./log

rpm.sh 脚本如下,同样在四个主机上执行:

#!/bin/bash#/usr/bin/yuminstallbinutils-y-q/usr/bin/yuminstallcompat-libstdc++*-y-q/usr/bin/yuminstallcompat-libcap1*-y-q/usr/bin/yuminstallgcc-y-q/usr/bin/yuminstallglibc-y-q/usr/bin/yuminstallglibc-devel-y-q/usr/bin/yuminstallksh-y-q/usr/bin/yuminstalllibaio-y-q/usr/bin/yuminstalllibaio-devel-y-q/usr/bin/yuminstalllibgcc-y-q/usr/bin/yuminstalllibstdc++-y-q/usr/bin/yuminstalllibstdc++-devel-y-q/usr/bin/yuminstalllibXext-y-q/usr/bin/yuminstalllibXtst-y-q/usr/bin/yuminstalllibX11-y-q/usr/bin/yuminstalllibXau-y-q/usr/bin/yuminstalllibXi-y-q/usr/bin/yuminstallmake-y-q/usr/bin/yuminstallsysstat-y-q

执行结果如下:

到此,相信大家对“Oracle RAC+DG环境搭建的方法是什么”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!